From 30ddded8c627dcf2216dcc37a31459d273f20c35 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Tue, 7 Apr 2015 20:07:41 +0000 Subject: [PATCH] Inclusão de novo preview de mapas no editor de mapfiles --- admin/php/editortexto.php | 9 +++++---- admin/php/preview.php | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ temas/_lbiomashp.map | 2 +- 3 files changed, 184 insertions(+), 5 deletions(-) create mode 100755 admin/php/preview.php diff --git a/admin/php/editortexto.php b/admin/php/editortexto.php index ea16e4b..6528446 100644 --- a/admin/php/editortexto.php +++ b/admin/php/editortexto.php @@ -24,7 +24,7 @@ body { margin-left: 10px; font-size: 14px; margin: auto; - width: 1100px; + width: 1150px; } .CodeMirror { height:500px; @@ -32,7 +32,7 @@ body { width: 500px; } #selectComboMapfile { - width:520px; + width:570px; text-overflow: ellipsis; font-size: 14px; } @@ -142,14 +142,15 @@ Alt-left - Início da linha
-
+
Mapfile em edição
Aguarde...
"; + echo ""; echo ""; diff --git a/admin/php/preview.php b/admin/php/preview.php new file mode 100755 index 0000000..44d70c2 --- /dev/null +++ b/admin/php/preview.php @@ -0,0 +1,178 @@ +$v){ + $req->setParameter(strtoupper($k), $v); + if(strtolower($k) == "layers" && empty($_GET["tema"])){ + $tema = $v; + } + if(strtolower($k) == "layer" && empty($_GET["tema"])){ + $tema = $v; + } +} +$req->setParameter("srsName",$req->getValueByName("SRS")); +$listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185"; +if(isset($version) && !isset($VERSION)){ + $VERSION = $version; +} +if(!isset($VERSION)){ + $req->setParameter("VeRsIoN","1.0.0"); +} +// +//compatibiliza chamadas fora do padrao +// +if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){ + $_GET["OUTPUTFORMAT"] = $_GET["outputFormat"]; +} +//essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao +$cortePixels = 0; + +if(empty($ogcwsmap)){ + $oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map"); +} +else{ + $oMap = ms_newMapobj($ogcwsmap); +} + +$proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; +$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; +$or = $proto.$server.$_SERVER['PHP_SELF']; +$or = $or."?tema=".$tema."&"; +$oMap->setmetadata("ows_onlineresource",$or); +$oMap->setmetadata("wms_onlineresource",$or); +$oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF'])); +$oMap->setmetadata("ows_enable_request","*"); +//parametro mandatario +if($oMap->getmetadata("wms_srs") == ""){ + $oMap->setmetadata("wms_srs","EPSG:4326"); +} +$e = $oMap->extent; +$extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); +//gera o mapa + +$nmap = ms_newMapobj($tema); + +$nmap->setmetadata("ows_enable_request","*"); +$l = $nmap->getlayer(0); + +//$l->setmetadata("ows_title",pegaNome($l)); +$l->setmetadata("ows_srs",$listaepsg); +$l->set("group",""); +$l->setmetadata("gml_include_items","all"); +$l->set("template","none.htm"); +$l->set("dump",MS_TRUE); +$l->setmetadata("WMS_INCLUDE_ITEMS","all"); +$l->setmetadata("WFS_INCLUDE_ITEMS","all"); +//inclui extensao geografica +$extensao = $l->getmetadata("EXTENSAO"); +if($extensao == ""){ + $extensao = $extensaoMap; +} +$l->setmetadata("wms_extent",$extensao); +if (!empty($postgis_mapa)){ + if ($l->connectiontype == MS_POSTGIS){ + $lcon = $l->connection; + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ + // + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição + // + if(($lcon == " ") || ($lcon == "")){ + $l->set("connection",$postgis_mapa); + $l->setmetadata("CONEXAOORIGINAL",$lcon); + } + else{ + $l->set("connection",$postgis_mapa[$lcon]); + $l->setmetadata("CONEXAOORIGINAL",$lcon); + } + } + } +} + +autoClasses($l,$oMap); +if($versao > 5){ + $pr = $l->getProcessing(); + if(!in_array("LABEL_NO_CLIP=True",$pr)){ + $l->setprocessing("LABEL_NO_CLIP=True"); + } + if(!in_array("POLYLINE_NO_CLIP=True",$pr)){ + $l->setprocessing("POLYLINE_NO_CLIP=True"); + } +} +$l->set("status",MS_DEFAULT); +ms_newLayerObj($oMap, $l); + +$oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); +$oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); + +if(ob_get_contents ()){ + ob_end_clean(); +} + + $l = $oMap->getlayer(0); + $req->setParameter("LAYERS",$l->name); + +ms_ioinstallstdouttobuffer(); +$req->setParameter("format","image/png"); +$oMap->owsdispatch($req); +$contenttype = ms_iostripstdoutbuffercontenttype(); +if(!isset($OUTPUTFORMAT)){ + header("Content-type: $contenttype"); +} + +$buffer = ms_iogetStdoutBufferBytes(); +ms_ioresethandlers(); + +function texto2iso($texto){ + if (function_exists("mb_convert_encoding")){ + if (mb_detect_encoding($texto,"UTF-8",true)){ + $texto = mb_convert_encoding($texto,"ISO-8859-1","UTF-8"); + } + } + return $texto; +} +function nomeRand($n=10) +{ + $nomes = ""; + $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $max = 51; + for($i=0; $i < $n; ++$i) + { + $nomes .= $a{mt_rand(0, $max)}; + } + return $nomes; +} + +?> diff --git a/temas/_lbiomashp.map b/temas/_lbiomashp.map index bcb0688..c2b3d13 100644 --- a/temas/_lbiomashp.map +++ b/temas/_lbiomashp.map @@ -14,7 +14,7 @@ MAP "download" "SIM" "itembuscarapida" "CD_LEGENDA" "ITENS" "CD_LEGENDA" - "permiteogc" "sim" + "permiteogc" "nao" "permitekml" "sim" "TEMA" "Biomas shapefile (acentuação)" "ESCALA" "1000000" -- libgit2 0.21.2