コード例 #1
0
ファイル: classe_mapa.php プロジェクト: edmarmoretti/i3geo
 function adicionaTemaSHP($arq)
 {
     if (file_exists($arq)) {
         $arq = str_replace(".shp", "", $arq);
         $arq = str_replace(".", "", $arq) . ".shp";
         $s = ms_newShapefileObj($arq, -1);
         /*
          if($this->v == 6)
          {$shape = $s->getshape(new resultObj(0));}
         else
         {$shape = $s->getshape(0);}
         */
         $shape = $s->getshape(0);
         $t = $shape->type;
         $tipo = MS_LAYER_POLYGON;
         if ($t == 0) {
             $tipo = MS_LAYER_POINT;
         }
         if ($t == 1) {
             $tipo = MS_LAYER_LINE;
         }
         $layer = criaLayer($this->mapa, $tipo, MS_DEFAULT, basename($arq), "SIM");
         $layer->set("data", $arq);
         //verifica se existe o arquivo PRJ
         if (file_exists(str_replace(".shp", "", $arq) . ".prj")) {
             $layer->setprojection("AUTO");
         }
         $layer->set("name", basename($arq));
         $layer->setmetadata("DOWNLOAD", "nao");
         $layer->setmetadata("TEMALOCAL", "NAO");
         $layer->setmetadata("nomeoriginal", basename($arq));
     }
     return "ok";
 }
コード例 #2
0
 $checkphp = fileContemString($dirmap . "/" . $nomePrefixo . ".dbf", "<?");
 if ($checkphp == true) {
     unlink($dirmap . "/" . $nomePrefixo . ".prj");
     unlink($dirmap . "/" . $nomePrefixo . ".shx");
     unlink($dirmap . "/" . $nomePrefixo . ".dbf");
     unlink($dirmap . "/" . $nomePrefixo . ".shp");
     exit;
 }
 $arqshp = $dir_tmp . "/" . $nomePrefixo . ".shp";
 //pega os parametros de conexao
 include "classe_metaestat.php";
 $m = new Metaestat();
 $conexao = $m->listaConexao($_POST["i3GEOuploadcodigoconexao"], true);
 //array(5) { ["codigo_estat_conexao"]=> string(1) "1" ["bancodedados"]=> string(8) "geosaude" ["host"]=> string(9) "localhost" ["porta"]=> string(4) "5432" ["usuario"]=> string(8) "postgres" }
 //pega as colunas do shapefile
 $shapefileObj = ms_newShapefileObj($arqshp, -1);
 $numshapes = $shapefileObj->numshapes;
 $mapObj = ms_newMapObjFromString("MAP END");
 $layer = ms_newLayerObj($mapObj);
 $layer->set("data", $arqshp);
 if (file_exists($dir_tmp . "/" . $nomePrefixo . ".prj")) {
     $layer->setprojection("AUTO");
 }
 $layer->open();
 $colunasTemp = $layer->getItems();
 $colunas = array();
 foreach ($colunasTemp as $c) {
     //abaixo gid e forcado a entrar
     if (!is_numeric($c) && strtolower($c) != "gid") {
         $colunas[] = $c;
     }
コード例 #3
0
ファイル: ms_criamapa.php プロジェクト: edmarmoretti/i3geo
function inserePoligonosUrl()
{
    global $tamanhosimbolo, $simbolo, $corsimbolo, $poligonos, $nometemapoligonos, $dir_tmp, $imgdir, $tmpfname, $locaplic;
    include_once "pacotes/phpxbase/api_conversion.php";
    if (!isset($nometemapoligonos)) {
        $nometemapoligonos = "Poligonos";
    }
    if ($nometemapoligonos == "") {
        $nometemapoligonos = "Poligonos";
    }
    //
    //cria o shape file
    //
    $tipol = MS_SHP_POLYGON;
    $nomeshp = $dir_tmp . "/" . $imgdir . "/poligonosins";
    // cria o dbf
    $def = array();
    $items = array("COORD");
    foreach ($items as $ni) {
        $def[] = array($ni, "C", "254");
    }
    if (!function_exists(dbase_create)) {
        xbase_create($nomeshp . ".dbf", $def);
    } else {
        dbase_create($nomeshp . ".dbf", $def);
    }
    $dbname = $nomeshp . ".dbf";
    $db = xbase_open($dbname, 2);
    $novoshpf = ms_newShapefileObj($nomeshp, $tipol);
    $linhas = explode(",", trim($poligonos));
    $pontosLinhas = array();
    //guarda os pontos de cada linha em arrays
    foreach ($linhas as $l) {
        $tempPTs = explode(" ", trim($l));
        $temp = array();
        foreach ($tempPTs as $p) {
            if (is_numeric($p)) {
                $temp[] = $p;
            }
        }
        $pontosLinhas[] = $temp;
    }
    foreach ($pontosLinhas as $ptsl) {
        $linhas = $ptsl;
        $shape = ms_newShapeObj($tipol);
        $linha = ms_newLineObj();
        $reg = array();
        $reg[] = "";
        for ($ci = 0; $ci < count($linhas); $ci = $ci + 2) {
            $linha->addXY($linhas[$ci], $linhas[$ci + 1]);
        }
        $shape->add($linha);
        $novoshpf->addShape($shape);
        xbase_add_record($db, $reg);
    }
    $novoshpf->free();
    xbase_close($db);
    //adiciona o layer
    $mapa = ms_newMapObj($tmpfname);
    $layer = ms_newLayerObj($mapa);
    $layer->set("name", "linhains");
    $layer->set("data", $nomeshp . ".shp");
    $layer->setmetadata("DOWNLOAD", "sim");
    $layer->setmetadata("temalocal", "sim");
    $layer->setmetadata("tema", $nometemapoligonos);
    $layer->setmetadata("classe", "sim");
    $layer->setmetadata("ATLAS", "nao");
    $layer->set("type", MS_LAYER_POLYGON);
    $layer->set("opacity", "50");
    $layer->set("status", MS_DEFAULT);
    $classe = ms_newClassObj($layer);
    $classe->set("name", " ");
    $estilo = ms_newStyleObj($classe);
    $cor = $estilo->color;
    if (!isset($corsimbolo)) {
        $corsimbolo = "255,0,0";
    }
    $corsimbolo = str_replace(" ", ",", $corsimbolo);
    $corsimbolo = explode(",", $corsimbolo);
    $cor->setRGB($corsimbolo[0], $corsimbolo[1], $corsimbolo[2]);
    $salvo = $mapa->save($tmpfname);
    erroCriacao();
}
コード例 #4
0
ファイル: classe_analise.php プロジェクト: edmarmoretti/i3geo
 function incmapageometrias($dir_tmp, $imgdir, $lista, $tipoLista = "stringArquivos")
 {
     $dir = $dir_tmp . "/" . $imgdir . "/";
     $tituloTema = " geometria";
     if ($tipoLista == "stringArquivos") {
         $lista = explode(",", $lista);
         $shapes = array();
         $valoresoriginais = array();
         foreach ($lista as $l) {
             $geos = $this->unserializeGeo($dir . $l);
             // pega todas as geometrias
             foreach ($geos["dados"] as $geo) {
                 // echo $geo["wkt"]."<br>";
                 $shapes[] = ms_shapeObjFromWkt(str_replace("'", "", $geo["wkt"]));
                 foreach ($geo["valores"] as $v) {
                     $valorestemp[] = $v["item"] . "=" . $v["valor"];
                 }
                 $valoresoriginais[] = implode(" ", $valorestemp);
             }
         }
     }
     if ($tipoLista == "arraywkt") {
         $shapes = array();
         $valoresoriginais = array();
         foreach ($lista as $l) {
             $shapes[] = ms_shapeObjFromWkt($l);
         }
     }
     if ($tipoLista == "marcadores") {
         $shapes = array();
         $valoresoriginais = array();
         foreach ($lista as $l) {
             $valoresoriginais[] = $l["nome"];
             $p = explode(" ", $l["ext"]);
             $l = "POLYGON ((" . $p[0] . " " . $p[1] . "," . $p[0] . " " . $p[3] . "," . $p[2] . " " . $p[3] . "," . $p[2] . " " . $p[1] . "," . $p[0] . " " . $p[1] . "))";
             $shapes[] = ms_shapeObjFromWkt($l);
         }
         $tituloTema = " marcadores";
     }
     // verifica o tipo
     if (count($shapes) == 0) {
         return "erro.";
     }
     $tiposhape = $shapes[0]->type;
     $tiposhapefile = MS_SHP_POLYGON;
     if ($tiposhape == 0) {
         $tiposhapefile = MS_SHP_MULTIPOINT;
     }
     if ($tiposhape == 1) {
         $tiposhapefile = MS_SHP_ARC;
     }
     // cria o shapefile
     if ($this->dbaseExiste == false) {
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
     }
     $diretorio = dirname($this->arquivo);
     $novonomelayer = nomeRandomico();
     $nomeshp = $diretorio . "/" . $novonomelayer;
     $l = criaLayer($this->mapa, $tiposhape, MS_DEFAULT, "Ins", "SIM");
     $novoshpf = ms_newShapefileObj($nomeshp, $tiposhapefile);
     $def[] = array("ID", "C", "250");
     if ($this->dbaseExiste == false) {
         $db = xbase_create($nomeshp . ".dbf", $def);
         xbase_close($db);
     } else {
         $db = dbase_create($nomeshp . ".dbf", $def);
         dbase_close($db);
     }
     // acrescenta os pontos no novo shapefile
     $dbname = $nomeshp . ".dbf";
     if ($this->dbaseExiste == false) {
         $db = xbase_open($dbname, 2);
     } else {
         $db = dbase_open($dbname, 2);
     }
     $conta = 0;
     foreach ($shapes as $s) {
         $reg = array();
         $reg[] = $valoresoriginais[$conta];
         if ($this->dbaseExiste == false) {
             xbase_add_record($db, $reg);
         } else {
             dbase_add_record($db, $reg);
         }
         $novoshpf->addshape($s);
         $conta = $conta + 1;
     }
     if ($this->dbaseExiste == false) {
         xbase_close($db);
     } else {
         dbase_close($db);
     }
     $l->set("opacity", 80);
     $l->setmetadata("tema", $novonomelayer . $tituloTema);
     $l->setmetadata("TEMALOCAL", "SIM");
     $l->setmetadata("DOWNLOAD", "sim");
     $l->set("data", $nomeshp);
     $l->set("name", $novonomelayer);
     $classe = $l->getclass(0);
     $estilo = $classe->getstyle(0);
     if ($tiposhape == 0) {
         $estilo->set("symbolname", "ponto");
         $estilo->set("size", 6);
     }
     $cor = $estilo->color;
     $cor->setrgb(255, 210, 0);
     $cor = $estilo->outlinecolor;
     $cor->setrgb(255, 0, 0);
     $this->salva();
     return $novonomelayer;
 }
コード例 #5
0
ファイル: funcoes_gerais.php プロジェクト: edmarmoretti/i3geo
function criaSHP($tema, $map_file, $locaplic, $dir_tmp, $nomeRand = TRUE, $prj = "", $projetaToMap = true, $shapesSel = false)
{
    include dirname(__FILE__) . "/../ms_configura.php";
    $versao = versao();
    $versao = $versao["principal"];
    //para manipular dbf
    if (file_exists($locaplic . "/pacotes/phpxbase/api_conversion.php")) {
        include_once $locaplic . "/pacotes/phpxbase/api_conversion.php";
    } else {
        include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
    }
    $map = @ms_newMapObj($map_file);
    $nameMapfile = $map->name;
    substituiConObj($map, $postgis_mapa);
    $layer = $map->getlayerbyname($tema);
    //e necessario abrir ou nao vai projetar
    $layer->open();
    $prjMapa = $map->getProjection();
    $prjTema = $layer->getProjection();
    if ($prjTema != "") {
        $projInObj = new projectionObj($prjTema);
        $projOutObj = new projectionObj($prjMapa);
    } else {
        $projInObj = "";
        $projOutObj = "";
        $projetaToMap = false;
    }
    $layer->set("template", "none.htm");
    $diretorio = dirname($dir_tmp);
    $tipol = MS_SHP_POINT;
    if ($layer->type == MS_LAYER_LINE) {
        $tipol = MS_SHP_ARC;
    }
    if ($layer->type == MS_LAYER_POLYGON) {
        $tipol = MS_SHP_POLYGON;
    }
    if ($nomeRand == true) {
        $novonomelayer = $tema . "_" . nomeRandomico(5);
    } else {
        $novonomelayer = $tema;
    }
    $novonomelayer = str_replace(".", "-", $novonomelayer);
    $nomeshp = $dir_tmp . "/" . $nameMapfile . "_" . $novonomelayer;
    if (file_exists($nomeshp . ".shp")) {
        return $nomeshp;
    }
    $novoshpf = ms_newShapefileObj($nomeshp, $tipol);
    //se for do tipo features
    $data = $layer->data;
    $resultadoFinal = true;
    if ($data == "") {
        $def[] = array("ID", "C", "50");
        $reg[] = 0;
        if (!function_exists("dbase_create")) {
            $db = xbase_create($nomeshp . ".dbf", $def);
            xbase_add_record($db, $reg);
            xbase_close($db);
        } else {
            $db = dbase_create($nomeshp . ".dbf", $def);
            dbase_add_record($db, $reg);
            dbase_close($db);
        }
        if ($versao >= 6) {
            $shape = $layer->getshape(new resultObj(0));
        } else {
            $s = $layer->getfeature(0, -1);
            $result = $layer->getResult(0);
            $shpi = $result->shapeindex;
            $shape = $layer->getfeature($shpi, -1);
        }
        $novoshpf = ms_newShapefileObj($nomeshp . ".shp", -2);
        $novoshpf->addShape($shape);
        $resultadoFinal = true;
    } else {
        if ($shapesSel == false) {
            $shapesSel = retornaShapesSelecionados($layer, $map_file, $map, false);
        }
        $items = pegaItens($layer);
        // cria o dbf
        $def = array();
        $cni = 0;
        foreach ($items as $ni) {
            $temp = strtoupper($ni);
            $temp = substr($temp, 0, 8) . $cni;
            //
            //nao tem como descobrir o tamanho e tipo do campo
            //
            $def[] = array($temp, "C", "254");
            $cni = $cni + 1;
        }
        if (!function_exists("dbase_create")) {
            $db = xbase_create($nomeshp . ".dbf", $def);
        } else {
            $db = dbase_create($nomeshp . ".dbf", $def);
        }
        $dbname = $nomeshp . ".dbf";
        $reg = array();
        $novoshpf = ms_newShapefileObj($nomeshp . ".shp", -2);
        $res_count = count($shapesSel);
        if ($res_count > 0) {
            for ($i = 0; $i < $res_count; ++$i) {
                $shape = $shapesSel[$i];
                if ($projetaToMap == true) {
                    $shape->project($projInObj, $projOutObj);
                }
                foreach ($items as $ni) {
                    $vreg = $shape->values[$ni];
                    if (strlen($vreg) > 255) {
                        $vreg = substr($vreg, 0, 255);
                    }
                    $reg[] = $vreg;
                }
                $novoshpf->addShape($shape);
                if (!function_exists("dbase_create")) {
                    xbase_add_record($db, $reg);
                } else {
                    dbase_add_record($db, $reg);
                }
                $reg = array();
            }
            if (!function_exists("dbase_create")) {
                xbase_close($db);
            } else {
                dbase_close($db);
            }
            //
            //verifica a quantidade de registros no final
            //
            if (function_exists("dbase_open")) {
                $db = dbase_open($nomeshp . ".dbf", 0);
            } else {
                $db = xbase_open($nomeshp . ".dbf", 0);
            }
            if (function_exists("dbase_numrecords")) {
                $record_numbers = dbase_numrecords($db);
            } else {
                $record_numbers = xbase_numrecords($db);
            }
            if (function_exists("dbase_close")) {
                dbase_close($db);
            } else {
                xbase_close($db);
            }
            if ($record_numbers != $res_count) {
                if (file_exists($nomeshp . ".dbf")) {
                    unlink($nomeshp . ".dbf");
                }
                if (file_exists($nomeshp . ".shp")) {
                    unlink($nomeshp . ".shp");
                }
                if (file_exists($nomeshp . ".shx")) {
                    unlink($nomeshp . ".shx");
                }
                if (file_exists($nomeshp . ".prj")) {
                    unlink($nomeshp . ".prj");
                }
                $resultadoFinal = false;
            }
        } else {
            $resultadoFinal = false;
        }
    }
    if ($resultadoFinal == false) {
        return false;
    } else {
        //gera o arquivo prj
        if ($prj != "") {
            gravaDados(array($prj), $nomeshp . ".prj");
        } elseif ($projetaToMap == false) {
            $nomePrjOriginal = str_replace(".shp", ".prj", $layer->data);
            $nomeDestino = $nomeshp . ".prj";
            if (file_exists($nomePrjOriginal) && !file_exists($nomeDestino)) {
                copy($nomePrjOriginal, $nomeDestino);
            }
        }
        return $nomeshp;
    }
}
コード例 #6
0
 /**
  * Converte um tipo de regiao em shapefile
  * @param codigo do tipo de regiao
  * @return nome do arquivo criado
  */
 function regiao2shp($codigo_tipo_regiao)
 {
     $regiao = $this->listaTipoRegiao($codigo_tipo_regiao);
     $dados = $this->obtemDadosTabelaDB($regiao["codigo_estat_conexao"], $regiao["esquemadb"], $regiao["tabela"], "sim");
     $tipol = $this->listaPropGeoRegiao($codigo_tipo_regiao);
     include_once dirname(__FILE__) . "/../../classesphp/classe_shp.php";
     $s = new SHP();
     //st_dimension returns 0 for POINT, 1 for LINESTRING, 2 for POLYGON
     //echo MS_SHP_POINT.", ".MS_SHP_ARC.", ".MS_SHP_POLYGON.", ".MS_SHP_MULTIPOINT;
     //1, 3, 5, 8
     $conv[0] = 1;
     $conv[1] = 3;
     $conv[2] = 5;
     //cria as colunas
     $cni = 0;
     foreach ($dados["colunas"] as $t) {
         $temp = strtoupper($t["field"]);
         if (strlen($temp) > 10) {
             $temp = substr($temp, 0, 8) . $cni++;
         }
         if ($t["type"] == "varchar" || $t["type"] == "char" || $t["type"] == "character varying" || $t["type"] == "character" || $t["type"] == "text") {
             $def[] = array($temp, "C", "254");
         } else {
             if ($t["lengthvar"] < 0) {
                 $t["lengthvar"] = 0;
             }
             $def[] = array($temp, "N", $t["length"], $t["lengthvar"]);
         }
     }
     $nomeshp = $this->dir_tmp . "/regiao{$codigo_tipo_regiao}" . "_" . $this->nomeRandomico();
     $dbaseExiste = false;
     if (function_exists("dbase_create")) {
         $dbaseExiste = true;
     }
     //para manipular dbf
     if ($dbaseExiste == false) {
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
         $db = xbase_create($nomeshp . ".dbf", $def);
     } else {
         $db = dbase_create($nomeshp . ".dbf", $def);
     }
     $dbname = $nomeshp . ".dbf";
     $reg = array();
     $novoshpf = ms_newShapefileObj($nomeshp . ".shp", $conv[$tipol["st_dimension"]]);
     $cols = $dados["colunas"];
     $nc = count($dados["colunas"]);
     foreach ($dados["linhas"] as $l) {
         $reg = array();
         for ($i = 0; $i < $nc; $i++) {
             if ($cols[$i]["type"] != "geometry" && $cols[$i]["type"] != "geography") {
                 $reg[] = $l[$i];
             } else {
                 $reg[] = 0;
                 if ($cols[$i]["field"] == $regiao["colunageo"]) {
                     $shape = ms_shapeObjFromWkt($l[$i]);
                 }
             }
         }
         $novoshpf->addShape($shape);
         if ($dbaseExiste == false) {
             xbase_add_record($db, $reg);
         } else {
             dbase_add_record($db, $reg);
         }
     }
     if ($this->dbaseExiste == false) {
         xbase_close($db);
     } else {
         dbase_close($db);
     }
     return $nomeshp;
 }
コード例 #7
0
ファイル: classe_shp.php プロジェクト: edmarmoretti/i3geo
 function shpPT2shp($locaplic, $para)
 {
     if (!$this->layer) {
         return "erro";
     }
     $this->layer->set("template", "none.htm");
     $diretorio = dirname($this->arquivo);
     $tipol = MS_SHP_ARC;
     $tipos = MS_SHAPE_LINE;
     if ($para == "poligono") {
         $tipol = MS_SHP_POLYGON;
         $tipos = MS_SHAPE_POLYGON;
     }
     $novonomelayer = nomeRandomico();
     $nomeshp = $diretorio . "/" . $novonomelayer;
     $items = pegaItens($this->layer);
     // cria o dbf
     $def = array();
     foreach ($items as $ni) {
         $temp = strtoupper($ni);
         $def[] = array($temp, "C", "254");
     }
     //para manipular dbf
     if ($this->dbaseExiste == false) {
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
         $db = xbase_create($nomeshp . ".dbf", $def);
     } else {
         $db = dbase_create($nomeshp . ".dbf", $def);
     }
     $dbname = $nomeshp . ".dbf";
     $reg = array();
     $novoshpf = ms_newShapefileObj($nomeshp . ".shp", $tipol);
     $this->layer->open();
     $prjMapa = $this->mapa->getProjection();
     $prjTema = $this->layer->getProjection();
     $ret = $this->mapa->extent;
     if ($prjTema != "" && $prjMapa != $prjTema) {
         $projOutObj = ms_newprojectionobj($prjTema);
         $projInObj = ms_newprojectionobj($prjMapa);
         $ret->project($projInObj, $projOutObj);
     }
     $this->layer->whichShapes($ret);
     $linha = ms_newLineObj();
     $pponto = "";
     $pontos = array();
     while ($shape = $this->layer->nextShape()) {
         $lin = $shape->line(0);
         $pt = $lin->point(0);
         if ($pponto == "") {
             $pponto = $pt;
         }
         if ($prjTema != "" && $prjMapa != $prjTema) {
             $pt->project($projInObj, $projOutObj);
         }
         $pontos[] = $pt->x;
         $pontos[] = $pt->y;
     }
     $pontos = implode(" ", $pontos);
     $pontos = xy2wkt($pontos);
     if ($para == "poligono") {
         $shape = ms_shapeObjFromWkt($pontos["poligono"]);
     } else {
         $shape = ms_shapeObjFromWkt($pontos["linha"]);
     }
     foreach ($items as $ni) {
         $reg[] = "-";
     }
     $novoshpf->addShape($shape);
     if ($this->dbaseExiste == false) {
         xbase_add_record($db, $reg);
         xbase_close($db);
     } else {
         dbase_add_record($db, $reg);
         dbase_close($db);
     }
     $this->layer->close();
     //cria o novo layer
     $layer = criaLayer($this->mapa, MS_LAYER_LINE, MS_DEFAULT, "", $metaClasse = "SIM");
     $layer->set("data", $nomeshp);
     $layer->setmetadata("tema", $novonomelayer . " (linear)");
     $layer->setmetadata("download", "sim");
     $layer->setmetadata("temalocal", "sim");
     $classe = $layer->getclass(0);
     $estilo = $classe->getstyle(0);
     $estilo->set("symbolname", "linha");
     if ($para == "poligono") {
         $layer->set("type", MS_LAYER_POLYGON);
         $layer->set("opacity", "50");
         $layer->setmetadata("tema", $novonomelayer . " (poligonal)");
     }
     return "ok";
 }
コード例 #8
0
ファイル: subirshapefile.php プロジェクト: edmarmoretti/i3geo
     unlink($dirmap . "/" . $nomePrefixo . ".shx");
     unlink($dirmap . "/" . $nomePrefixo . ".prj");
     exit;
 }
 echo "<p class='paragrafo' >Arquivo enviado.</p>";
 echo "<p class='paragrafo'></p>";
 if ($i3GEOuploadCriaMapfile == "on") {
     //verifica se o usuario marcou a opcao de cria mapfile
     //nesse caso o aplicativo de upload esta sendo executado de dentro do sistema de administracao, e o mapfile devera
     //ser criado e registrado no sistema
     $nome = $nomePrefixo;
     $codigo = $nomePrefixo;
     $it = $nomePrefixo;
     $en = $nomePrefixo;
     $es = $nomePrefixo;
     $sfileObj = ms_newShapefileObj($dirmap . "/" . $nomePrefixo . ".shp", -1);
     if (!isset($tipo) || $tipo == "") {
         $tipo = $sfileObj->type;
     }
     if ($tipo == 1) {
         $tipoLayer = "point";
     }
     if ($tipo == 3) {
         $tipoLayer = "line";
     }
     if ($tipo == 5) {
         $tipoLayer = "polygon";
     }
     $funcao = "CRIARNOVOMAP";
     $output = "retorno";
     $data = $dirmap . "/" . $nomePrefixo . ".shp";
コード例 #9
0
ファイル: upload.php プロジェクト: edmarmoretti/i3geo
     }
     xbase_close($db);
 } else {
     copy($dirmap . "/" . $ArquivoDest, $dirmap . "/" . $nome . ".dbf");
 }
 echo "<p class='paragrafo'>Arquivo enviado. Criando shape file... </p>";
 ob_flush();
 flush();
 sleep(1);
 $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POINT);
 $novoshpf->free();
 if (!file_exists($nomeshp)) {
     echo "<p class='paragrafo'>Erro ao criar arquivo shapefile</p>";
     paraAguarde();
 }
 $shapefileObj = ms_newShapefileObj($nomeshp, -2);
 if ($i3GEOuploaddbftipoarquivo != "dbf") {
     foreach ($csv->data as $d) {
         $poPoint = ms_newpointobj();
         $poPoint->setXY($d[$i3GEOuploaddbfnomex], $d[$i3GEOuploaddbfnomey]);
         $shapefileObj->addpoint($poPoint);
     }
 } else {
     require_once dirname(__FILE__) . "/../../pacotes/phpxbase/api_conversion.php";
     echo "<p class='paragrafo'>Lendo arquivo </p>";
     $dbf = xbase_open($dirmap . "/" . $nome . ".dbf");
     $records = xbase_numrecords($dbf);
     echo "<p class='paragrafo'>Numero de pontos: {$records}</p>";
     ob_flush();
     flush();
     sleep(1);
コード例 #10
0
ファイル: Save.php プロジェクト: alonso/fusion
function updatePtoDBFRecord($szFileName, $aszPointProperties, $nId = -1, $aPuntos)
{
    $dbfFile = dbase_open($szFileName . '.dbf', 2);
    // loop through the database and match the id
    $nCount = dbase_numrecords($dbfFile);
    //$nMaxID = 0;
    $nMaxID = $nCount + 1;
    $aszPointProperties[0] = $nMaxID;
    // add the record to the dbase file if the array is populated
    if (count($aszPointProperties) > 0) {
        $shpFile = ms_newShapefileObj(dirname(__FILE__) . '\\' . $szFileName, -2);
        $nPoints = count($aPuntos);
        if ($nPoints > 0) {
            $oShp = ms_newShapeObj(MS_SHP_POINT);
            $oPoint = ms_newLineObj();
            $oPoint->addXY($aPuntos[0], $aPuntos[1]);
            $oShp->add($oPoint);
            $oPoint->free();
            $shpFile->addShape($oShp);
            $oShp->free();
            dbase_add_record($dbfFile, array_values($aszPointProperties));
        }
    }
    $shpFile->free();
    // close the dbf
    dbase_close($dbfFile);
    // return success
    return true;
}