Example #1
0
function draw_header($map, $img, $width, $height)
{
    /*
     * Draw the black bar at the top of the screen
     */
    $layer = ms_newLayerObj($map);
    $layer->set("status", MS_ON);
    $layer->set("type", MS_LAYER_POLYGON);
    $layer->set("transform", MS_OFF);
    $wkt = "POLYGON((0 0, 0 {$height}, {$width} {$height}, {$width} 0, 0 0))";
    $layer->addFeature(ms_shapeObjFromWkt($wkt));
    $layerc0 = ms_newClassObj($layer);
    $layerc0s0 = ms_newStyleObj($layerc0);
    $layerc0s0->color->setRGB(0, 0, 0);
    $layer->draw($img);
}
Example #2
0
function mktitle($map, $imgObj, $titlet, $subtitle = "", $width = 640)
{
    $height = $subtitle == "" ? 36 : 53;
    $layer = ms_newLayerObj($map);
    $layer->set("status", MS_ON);
    $layer->set("type", MS_LAYER_POLYGON);
    $layer->set("transform", MS_OFF);
    $wkt = "POLYGON((0 0, 0 {$height}, {$width} {$height}, {$width} 0, 0 0))";
    $layer->addFeature(ms_shapeObjFromWkt($wkt));
    $layerc0 = ms_newClassObj($layer);
    $layerc0s0 = ms_newStyleObj($layerc0);
    $layerc0s0->color->setRGB(0, 0, 0);
    $layer->draw($imgObj);
    $tlayer = $map->getLayerByName("iem_headerbar_title");
    $point = ms_newpointobj();
    $point->setXY(82, 22);
    $point->draw($map, $tlayer, $imgObj, 0, $titlet);
    if ($subtitle != "") {
        $point = ms_newpointobj();
        $point->setXY(82, 39);
        $point->draw($map, $tlayer, $imgObj, 1, $subtitle);
    }
}
Example #3
0
 function insereFeature($marca, $tipo, $xy, $texto, $position, $partials, $offsetx, $offsety, $minfeaturesize, $mindistance, $force, $shadowcolor, $shadowsizex, $shadowsizey, $outlinecolor, $cor, $sombray, $sombrax, $sombra, $fundo, $angulo, $tamanho, $fonte, $wrap, $wkt = false, $nomeTema = "")
 {
     //verifica se ja existe um layer criado anteriormente com o mesmo nome e apaga se existir
     if ($tipo == "limpaponto") {
         if ($this->layer) {
             $this->layer->set("status", MS_DELETE);
             $this->layer->set("name", "pindelete");
             $tipo = "POINT";
         }
     }
     if (!$this->layer) {
         $pinlayer = criaLayer($this->mapa, MS_LAYER_LINE, MS_DEFAULT, "Ins", $metaClasse = "SIM");
         $c = $pinlayer->getclass(0);
         $c->set("name", "");
         $e = $c->getstyle(0);
         $e->set("size", 1);
         $e->set("symbol", "ponto");
         $core = $e->color;
         $core->setrgb(255, 0, 0);
         if (!isset($cor)) {
             $cor = "255 0 0";
         }
         switch ($tipo) {
             case "GRAFICOPIZZA":
                 if (!isset($tamanho)) {
                     $tamanho = 5;
                 }
                 $e->set("size", $tamanho);
                 $pinlayer->setmetadata("tema", "Pontos inseridos");
                 $pinlayer->set("type", MS_LAYER_POINT);
                 break;
             case "POINT":
                 if (!isset($marca) || $marca == "") {
                     $marca = "marca";
                 }
                 if (!isset($tamanho)) {
                     $tamanho = 5;
                 }
                 $e->set("size", $tamanho);
                 $e->set("symbolname", $marca);
                 corE($e, $cor, "color");
                 $pinlayer->setmetadata("tema", "Pontos inseridos");
                 $pinlayer->set("type", MS_LAYER_POINT);
                 break;
             case "LINE":
                 if (!isset($marca) || $marca == "") {
                     $marca = "linha";
                 }
                 if (!isset($tamanho)) {
                     $tamanho = 2;
                 }
                 $e->set("size", $tamanho);
                 $e->set("symbol", $marca);
                 if (isset($cor) && $cor != "") {
                     corE($e, $cor, "color");
                 }
                 if (isset($texto) && $texto != "") {
                     $pinlayer->setmetadata("TEMA", $texto);
                 } else {
                     $pinlayer->setmetadata("tema", "Linhas inseridas");
                 }
                 $pinlayer->set("type", MS_LAYER_LINE);
                 break;
             case "POLYGON":
                 if (!isset($marca)) {
                     $marca = "p9";
                 }
                 if (!isset($tamanho)) {
                     $tamanho = 5;
                 }
                 $e->set("size", $tamanho);
                 $e->set("symbol", $marca);
                 $pinlayer->setmetadata("tema", "Poligonos inseridos");
                 $pinlayer->set("type", MS_LAYER_POLYGON);
                 $pinlayer->set("opacity", "50");
                 break;
             case "ANNOTATION":
                 //$c->set("status",MS_DELETE);
                 $pinlayer->setmetadata("TEMA", $texto);
                 $pinlayer->setmetadata("tiles", "nao");
                 $pinlayer->set("type", MS_LAYER_POINT);
                 $pinlayer->set("opacity", "100");
                 break;
         }
     }
     switch ($tipo) {
         case "ANNOTATION":
             $shp = ms_newshapeobj(MS_SHAPE_POINT);
             break;
         case "POINT":
             $shp = ms_newshapeobj(MS_SHAPE_POINT);
             break;
         case "LINE":
             $shp = ms_newshapeobj(MS_SHAPE_LINE);
             break;
         case "POLYGON":
             $shp = ms_newshapeobj(MS_SHAPE_POLYGON);
             break;
     }
     if ($wkt == false) {
         $apt = explode(" ", $xy);
         $lin = ms_newlineobj();
         for ($i = 0; $i < count($apt); $i = $i + 2) {
             $lin->addxy($apt[$i], $apt[$i + 1]);
         }
         $shp->add($lin);
     } else {
         $shp = ms_shapeObjFromWkt($xy);
     }
     if ($texto != "") {
         $texto = str_replace("*", "&", $texto);
         $texto = str_replace("|", ";", $texto);
         $shp->set("text", $texto);
         //caso nao seja do tipo annotation
         if ($pinlayer->numclasses == 1) {
             $novac = $pinlayer->getclass(0);
         } else {
             $novac = ms_newclassobj($pinlayer);
         }
         $this->adicionaLabel($novac, $wrap, $fonte, $tamanho, $angulo, $fundo, $sombra, $cor, $outlinecolor, $shadowcolor, $shadowsizex, $shadowsizey, $force, $mindistance, $minfeaturesize, $offsetx, $offsety, $partials, $position, "");
     }
     $pinlayer->addfeature($shp);
     if ($nomeTema != "") {
         $pinlayer->setmetadata("tema", $nomeTema);
     }
     //verifica a projecao
     $c = $shp->getCentroid();
     $c = $c->x;
     if ($c > -181 && $c < 181) {
         $pinlayer->setprojection(pegaProjecaoDefault("proj4"));
     } else {
         $pinlayer->setprojection($this->mapa->getProjection());
     }
     return "ok";
 }
Example #4
0
function insereWKTUrl()
{
    global $tamanhosimbolo, $simbolo, $corsimbolo, $wkt, $nometemawkt, $dir_tmp, $imgdir, $tmpfname, $locaplic;
    include_once "pacotes/phpxbase/api_conversion.php";
    if (!isset($nometemapontos)) {
        $nometemapontos = "WKT";
    }
    if ($nometemapontos == "") {
        $nometemapontos = "WKT";
    }
    //
    //cria o shape file
    //
    $shape = ms_shapeObjFromWkt($wkt);
    $tipol = $shape->type;
    if ($tipol == 0) {
        $tipol = 3;
    }
    $nomeshp = $dir_tmp . "/" . $imgdir . "/wkts";
    // 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);
    if ($tipol == 1) {
        $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_ARC);
    }
    if ($tipol == 3) {
        $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_MULTIPOINT);
    }
    if ($tipol == 2) {
        $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON);
    }
    $reg[] = "";
    $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", "wktins");
    $layer->set("data", $nomeshp . ".shp");
    $layer->setmetadata("DOWNLOAD", "sim");
    $layer->setmetadata("temalocal", "sim");
    $layer->setmetadata("tema", $nometemawkt);
    $layer->setmetadata("classe", "sim");
    $layer->set("type", $shape->type);
    $layer->set("status", MS_DEFAULT);
    $classe = ms_newClassObj($layer);
    $classe->set("name", " ");
    $estilo = ms_newStyleObj($classe);
    if ($shape->type == 0) {
        if (!isset($simbolo)) {
            $estilo->set("symbolname", "ponto");
        }
        if (!isset($tamanhosimbolo)) {
            $estilo->set("size", 6);
        }
    }
    if ($shape->type == 1) {
        if (!isset($simbolo)) {
            $estilo->set("symbolname", "linha");
        }
        if (!isset($tamanhosimbolo)) {
            $estilo->set("size", 3);
        }
    }
    if ($shape->type == 2) {
        $layer->set("opacity", "50");
    }
    $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();
}
Example #5
0
}
/* selection is intersects only */
$variant = 'intersects';
/* a spatial filter in the form on a WKT geometry */
$spatialFilter = isset($_REQUEST['spatialfilter']) && $_REQUEST['spatialfilter'] != '' ? urldecode($_REQUEST['spatialfilter']) : false;
header('Content-type: application/json');
header('X-JSON: true');
if (!isset($mapName)) {
    die("{'error':'mapname not set'}");
}
if (isset($_SESSION['maps']) && isset($_SESSION['maps'][$mapName])) {
    $oMap = ms_newMapObj($_SESSION['maps'][$mapName]);
    /* add the spatial filter if provided.  It is expected to come as a
       WKT string, so we need to convert it to a shape */
    if ($spatialFilter !== false) {
        $oSpatialFilter = ms_shapeObjFromWkt($spatialFilter);
    }
    $aMapTips = array();
    $aURL = array();
    $aTipLabel = array();
    foreach ($aLayer as $key => $layer) {
        if (isLayerVisible($layer) === TRUE) {
            $oLayer = @$oMap->GetLayerByName($layer);
            // make sure the layer exists in the map.
            if (is_object($oLayer)) {
                $oLayer->set('tolerance', 0);
                if ($oLayer->type == MS_LAYER_RASTER || $oLayer->type == MS_LAYER_QUERY || $oLayer->type == MS_LAYER_CIRCLE || $oLayer->type == MS_LAYER_CHART) {
                    die("{'error':'maptips are only valid for vector layers'}");
                }
                if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
                    $oRes = $oLayer->getResult(0);
Example #6
0
function calculaAreaPixel($map_file, $celsize)
{
    $mapa = ms_newMapObj($map_file);
    $rect = $mapa->extent;
    $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs");
    $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=0,lon_0=" . $rect->minx . ",x_0=5000000,y_0=10000000");
    $y = $rect->maxy - ($rect->maxy - $rect->miny) / 2;
    $x = $rect->maxx - ($rect->maxx - $rect->minx) / 2;
    $shape = ms_newShapeObj(MS_SHAPE_POLYGON);
    $linha = ms_newLineObj();
    $linha->addXY($x, $y);
    $linha->addXY($x + $celsize, $y);
    $linha->addXY($x + $celsize, $y - $celsize);
    $linha->addXY($x, $y - $celsize);
    $linha->addXY($x, $y);
    $shape->add($linha);
    $shape->project($projInObj, $projOutObj);
    $s = $shape->towkt();
    $shape = ms_shapeObjFromWkt($s);
    $area = $shape->getArea();
    return $area;
}
Example #7
0
 function selecaoPorPoligono($tipo, $xs = "", $ys = "", $wkt = "", $buffer = 0)
 {
     if (!$this->layer) {
         return "erro";
     }
     $this->layer->set("tolerance", 0);
     if ($tipo == "novo") {
         $this->selecaoLimpa();
         $tipo = "adiciona";
     }
     if ($tipo == "limpa") {
         return $this->selecaoLimpa();
     }
     if ($tipo == "inverte") {
         return $this->selecaoInverte();
     }
     $tipoLayer = $this->layer->type;
     if (file_exists($this->qyfile)) {
         $this->mapa->loadquery($this->qyfile);
     }
     $indxlayer = $this->layer->index;
     $res_count = $this->layer->getNumresults();
     $shp_atual = array();
     if ($this->qyfileTema != "" && file_exists($this->qyfileTema)) {
         $shp_atual = $this->unserializeQ($this->qyfileTema);
     }
     $shpi = array();
     //transforma os pontos em shape
     if ($wkt != "") {
         $s = ms_shapeObjFromWkt($wkt);
     } else {
         $s = ms_newShapeObj(MS_SHAPE_POLYGON);
         $linha = ms_newLineObj();
         $xs = explode(",", $xs);
         $ys = explode(",", $ys);
         for ($i = 0; $i < count($xs); ++$i) {
             $linha->addxy($xs[$i], $ys[$i]);
         }
         $linha->addxy($xs[0], $ys[0]);
         $s->add($linha);
     }
     if ($buffer > 0) {
         $s = $this->bufferShape($s, $buffer);
     }
     $this->layer->querybyshape($s);
     $res_count = $this->layer->getNumresults();
     for ($i = 0; $i < $res_count; ++$i) {
         $result = $this->layer->getResult($i);
         $shpi[] = $result->shapeindex;
     }
     $this->layer->set("status", MS_DEFAULT);
     if ($tipo == "adiciona" && count($shpi) > 0) {
         return $this->selecaoAdiciona($shpi, $shp_atual);
     }
     if ($tipo == "retira" && count($shp_atual) > 0) {
         return $this->selecaoRetira($shpi, $shp_atual);
     }
     return "Nada selecionado.";
 }
Example #8
0
 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;
 }
Example #9
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;
 }
Example #10
0
 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";
 }
Example #11
0
function calculaarea($geo)
{
    global $postgis_con;
    $v = versao();
    if ($v["principal"] < 5 && $postgis_con == "") {
        return "erro. &Eacute; necess&aacute;ria uma vers&atilde;o maior que 5.0 do Mapserver.";
    }
    $g = $geo->towkt();
    $shape = ms_shapeObjFromWkt($g);
    $rect = $shape->bounds;
    $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs");
    $projOutObj = ms_newprojectionobj("proj=laea,lat_0=" . $rect->miny . ",lon_0=" . $rect->minx . ",x_0=500000,y_0=10000000,ellps=GRS67,units=m,no_defs");
    $shape->project($projInObj, $projOutObj);
    $s = $shape->towkt();
    $shape = ms_shapeObjFromWkt($s);
    $area = $shape->getArea();
    return $area / 10000;
}
Example #12
0
        }
        if ($shp->type == MS_SHAPE_POLYGON) {
            $tipo = "POLYGON";
        }
        $m->insereFeature($_GET["marca"], $_GET["tipo"], $_GET["xy"], $_GET["texto"], $_GET["position"], $_GET["partials"], $_GET["offsetx"], $_GET["offsety"], $_GET["minfeaturesize"], $_GET["mindistance"], $_GET["force"], $_GET["shadowcolor"], $_GET["shadowsizex"], $_GET["shadowsizey"], $_GET["outlinecolor"], $_GET["cor"], $_GET["sombray"], $_GET["sombrax"], $_GET["sombra"], $_GET["fundo"], $_GET["angulo"], $_GET["tamanho"], $_GET["fonte"], $_GET["wrap"], true, $_GET["nometema"]);
        $m->salva();
        redesenhaMapa();
        break;
    case "SHAPEFILE":
        include_once "../../classesphp/classe_analise.php";
        $m = new Analise($map_file, "");
        $nomeLayer = $m->aplicaFuncaoListaWKT(array($_GET["xy"]), "converteSHP", $dir_tmp, $imgdir);
        $l = $m->mapa->getlayerbyname($nomeLayer);
        $l->setmetadata("tema", $_GET["nometema"]);
        //verifica projecao
        $shp = ms_shapeObjFromWkt($_GET["xy"]);
        $c = $shp->getCentroid();
        $c = $c->x;
        if ($c > -181 && $c < 181) {
            $l->setprojection(pegaProjecaoDefault("proj4"));
        } else {
            $l->setprojection($m->mapa->getProjection());
        }
        $m->salva();
        redesenhaMapa();
        break;
}
if (isset($map_file) && isset($postgis_mapa) && $map_file != "") {
    restauraCon($map_file, $postgis_mapa);
}
cpjson($retorno);