Commit 30ddded8c627dcf2216dcc37a31459d273f20c35

Authored by Edmar Moretti
1 parent 7c88dae9

Inclusão de novo preview de mapas no editor de mapfiles

admin/php/editortexto.php
... ... @@ -24,7 +24,7 @@ body {
24 24 margin-left: 10px;
25 25 font-size: 14px;
26 26 margin: auto;
27   - width: 1100px;
  27 + width: 1150px;
28 28 }
29 29 .CodeMirror {
30 30 height:500px;
... ... @@ -32,7 +32,7 @@ body {
32 32 width: 500px;
33 33 }
34 34 #selectComboMapfile {
35   - width:520px;
  35 + width:570px;
36 36 text-overflow: ellipsis;
37 37 font-size: 14px;
38 38 }
... ... @@ -142,14 +142,15 @@ Alt-left - Início da linha<br>
142 142  
143 143 </fieldset>
144 144  
145   - <fieldset style="position: relative; float: left; width:520px;margin: 5px;padding:10px;left:10px;">
  145 + <fieldset style="position: relative; float: left; width:580px;margin: 5px;padding:10px;left:10px;">
146 146 <legend>Mapfile em edi&ccedil;&atilde;o</legend>
147 147 <div id=filtroDeLetras ></div>
148 148 <div id="comboMapfiles" >Aguarde...</div>
149 149 <?php
  150 + //TODO O preview nao e mostrado quando o servico WMS e bloqueado
150 151 $mapfile = str_replace("\\","/",$mapfile);
151 152  
152   - echo "<iframe id='mapaPreview' src='../../mashups/openlayers.php?nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=450&fundo=".$mapfile."&temas=".$mapfile."' cols=100 rows=20 style='position:relative;top:2px;overflow:hidden;width:525px;height:500px;border:1px solid gray;'>";
  153 + echo "<iframe id='mapaPreview' src='../../mashups/openlayers.php?servidor=../admin/php/preview.php&fundo=&nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=550&altura=400&temas=".$mapfile."' style='position:relative;top:2px;overflow:hidden;width:100%;height:450px;border:0px solid gray;'>";
153 154 echo "</iframe>";
154 155 echo "<input type=hidden name=tipo value=gravar />";
155 156  
... ...
admin/php/preview.php 0 → 100755
... ... @@ -0,0 +1,178 @@
  1 +<?php
  2 +/**
  3 +Esse programa e uma adaptacao do codigo i3geo/ogc.php
  4 +E utilizado no preview de camadas no editor de mapfiles
  5 +Evita bloqueios de OGC e nao faz cache
  6 + */
  7 +include(dirname(__FILE__)."/../../ms_configura.php");
  8 +include(dirname(__FILE__)."/../../classesphp/pega_variaveis.php");
  9 +include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php");
  10 +include(dirname(__FILE__)."/login.php");
  11 +if(verificaOperacaoSessao("admin/php/editortexto") == false){
  12 + echo "Vc nao pode realizar essa operacao.";exit;
  13 +}
  14 +//
  15 +//pega os endere&ccedil;os para compor a url de chamada do gerador de web services
  16 +//ogc.php
  17 +//
  18 +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']);
  19 +$protocolo = $protocolo[0];
  20 +$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'];
  21 +$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT'];
  22 +$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]);
  23 +//
  24 +//cria o web service
  25 +//
  26 +error_reporting(0);
  27 +$versao = versao();
  28 +$versao = $versao["principal"];
  29 +if($_GET["SRS"] == "EPSG:900913"){
  30 + $_GET["SRS"] = "EPSG:3857";
  31 +}
  32 +$req = ms_newowsrequestobj();
  33 +$_GET = array_merge($_GET,$_POST);
  34 +if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){
  35 + $_GET["srs"] = "EPSG:4326";
  36 +}
  37 +foreach ($_GET as $k=>$v){
  38 + $req->setParameter(strtoupper($k), $v);
  39 + if(strtolower($k) == "layers" && empty($_GET["tema"])){
  40 + $tema = $v;
  41 + }
  42 + if(strtolower($k) == "layer" && empty($_GET["tema"])){
  43 + $tema = $v;
  44 + }
  45 +}
  46 +$req->setParameter("srsName",$req->getValueByName("SRS"));
  47 +$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";
  48 +if(isset($version) && !isset($VERSION)){
  49 + $VERSION = $version;
  50 +}
  51 +if(!isset($VERSION)){
  52 + $req->setParameter("VeRsIoN","1.0.0");
  53 +}
  54 +//
  55 +//compatibiliza chamadas fora do padrao
  56 +//
  57 +if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){
  58 + $_GET["OUTPUTFORMAT"] = $_GET["outputFormat"];
  59 +}
  60 +//essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao
  61 +$cortePixels = 0;
  62 +
  63 +if(empty($ogcwsmap)){
  64 + $oMap = ms_newMapobj($locaplic."/aplicmap/ogcwsv".$versao.".map");
  65 +}
  66 +else{
  67 + $oMap = ms_newMapobj($ogcwsmap);
  68 +}
  69 +
  70 +$proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://";
  71 +$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
  72 +$or = $proto.$server.$_SERVER['PHP_SELF'];
  73 +$or = $or."?tema=".$tema."&";
  74 +$oMap->setmetadata("ows_onlineresource",$or);
  75 +$oMap->setmetadata("wms_onlineresource",$or);
  76 +$oMap->setmetadata("wms_attribution_onlineresource",$proto.$server.dirname($_SERVER['PHP_SELF']));
  77 +$oMap->setmetadata("ows_enable_request","*");
  78 +//parametro mandatario
  79 +if($oMap->getmetadata("wms_srs") == ""){
  80 + $oMap->setmetadata("wms_srs","EPSG:4326");
  81 +}
  82 +$e = $oMap->extent;
  83 +$extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy);
  84 +//gera o mapa
  85 +
  86 +$nmap = ms_newMapobj($tema);
  87 +
  88 +$nmap->setmetadata("ows_enable_request","*");
  89 +$l = $nmap->getlayer(0);
  90 +
  91 +//$l->setmetadata("ows_title",pegaNome($l));
  92 +$l->setmetadata("ows_srs",$listaepsg);
  93 +$l->set("group","");
  94 +$l->setmetadata("gml_include_items","all");
  95 +$l->set("template","none.htm");
  96 +$l->set("dump",MS_TRUE);
  97 +$l->setmetadata("WMS_INCLUDE_ITEMS","all");
  98 +$l->setmetadata("WFS_INCLUDE_ITEMS","all");
  99 +//inclui extensao geografica
  100 +$extensao = $l->getmetadata("EXTENSAO");
  101 +if($extensao == ""){
  102 + $extensao = $extensaoMap;
  103 +}
  104 +$l->setmetadata("wms_extent",$extensao);
  105 +if (!empty($postgis_mapa)){
  106 + if ($l->connectiontype == MS_POSTGIS){
  107 + $lcon = $l->connection;
  108 + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
  109 + //
  110 + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substitui&ccedil;&atilde;o
  111 + //
  112 + if(($lcon == " ") || ($lcon == "")){
  113 + $l->set("connection",$postgis_mapa);
  114 + $l->setmetadata("CONEXAOORIGINAL",$lcon);
  115 + }
  116 + else{
  117 + $l->set("connection",$postgis_mapa[$lcon]);
  118 + $l->setmetadata("CONEXAOORIGINAL",$lcon);
  119 + }
  120 + }
  121 + }
  122 +}
  123 +
  124 +autoClasses($l,$oMap);
  125 +if($versao > 5){
  126 + $pr = $l->getProcessing();
  127 + if(!in_array("LABEL_NO_CLIP=True",$pr)){
  128 + $l->setprocessing("LABEL_NO_CLIP=True");
  129 + }
  130 + if(!in_array("POLYLINE_NO_CLIP=True",$pr)){
  131 + $l->setprocessing("POLYLINE_NO_CLIP=True");
  132 + }
  133 +}
  134 +$l->set("status",MS_DEFAULT);
  135 +ms_newLayerObj($oMap, $l);
  136 +
  137 +$oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename));
  138 +$oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename));
  139 +
  140 +if(ob_get_contents ()){
  141 + ob_end_clean();
  142 +}
  143 +
  144 + $l = $oMap->getlayer(0);
  145 + $req->setParameter("LAYERS",$l->name);
  146 +
  147 +ms_ioinstallstdouttobuffer();
  148 +$req->setParameter("format","image/png");
  149 +$oMap->owsdispatch($req);
  150 +$contenttype = ms_iostripstdoutbuffercontenttype();
  151 +if(!isset($OUTPUTFORMAT)){
  152 + header("Content-type: $contenttype");
  153 +}
  154 +
  155 +$buffer = ms_iogetStdoutBufferBytes();
  156 +ms_ioresethandlers();
  157 +
  158 +function texto2iso($texto){
  159 + if (function_exists("mb_convert_encoding")){
  160 + if (mb_detect_encoding($texto,"UTF-8",true)){
  161 + $texto = mb_convert_encoding($texto,"ISO-8859-1","UTF-8");
  162 + }
  163 + }
  164 + return $texto;
  165 +}
  166 +function nomeRand($n=10)
  167 +{
  168 + $nomes = "";
  169 + $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ';
  170 + $max = 51;
  171 + for($i=0; $i < $n; ++$i)
  172 + {
  173 + $nomes .= $a{mt_rand(0, $max)};
  174 + }
  175 + return $nomes;
  176 +}
  177 +
  178 +?>
... ...
temas/_lbiomashp.map
... ... @@ -14,7 +14,7 @@ MAP
14 14 "download" "SIM"
15 15 "itembuscarapida" "CD_LEGENDA"
16 16 "ITENS" "CD_LEGENDA"
17   - "permiteogc" "sim"
  17 + "permiteogc" "nao"
18 18 "permitekml" "sim"
19 19 "TEMA" "Biomas shapefile (acentuação)"
20 20 "ESCALA" "1000000"
... ...