Commit 5dea5c643d74186cb13f532e23741800e208ec77
1 parent
6278a4ea
Exists in
master
and in
7 other branches
Adaptação da ferramenta de geração WMS e WMC para bootstrap e correção de erros …
…na geração dos serviços. Uso da session php para obter o arquivo mapfile ao invés de parâmetro enviado via url
Showing
65 changed files
with
1588 additions
and
111 deletions
Show diff stats
admin/admin.db
No preview for this file type
classesphp/classe_mapa.php
@@ -1684,7 +1684,7 @@ class Mapa | @@ -1684,7 +1684,7 @@ class Mapa | ||
1684 | */ | 1684 | */ |
1685 | function converteWS($locaplic,$h) | 1685 | function converteWS($locaplic,$h) |
1686 | { | 1686 | { |
1687 | - $nomeurl = "/ogc.php?tema=".$this->arquivo; | 1687 | + $nomeurl = "/ogc.php?sid=".$this->arquivo; |
1688 | return($nomeurl); | 1688 | return($nomeurl); |
1689 | } | 1689 | } |
1690 | /* | 1690 | /* |
@@ -1704,33 +1704,27 @@ class Mapa | @@ -1704,33 +1704,27 @@ class Mapa | ||
1704 | 1704 | ||
1705 | Endereço do WMC | 1705 | Endereço do WMC |
1706 | */ | 1706 | */ |
1707 | - function converteWMC($locmapserv,$h) | 1707 | + function converteWMC($locmapserv,$urli3geo) |
1708 | { | 1708 | { |
1709 | - $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
1710 | - $protocolo = $protocolo[0]; | ||
1711 | - $protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
1712 | - $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
1713 | - $urli3geo = str_replace("/classesphp/mapa_controle.php","",$protocolo.$_SERVER["PHP_SELF"]); | 1709 | + $r = nomeRandomico(5); |
1710 | + $nomews = str_replace(".map",$r."wmc.map",$this->arquivo); | ||
1714 | 1711 | ||
1715 | - $nomews = str_replace(".map","wmc.map",$this->arquivo); | ||
1716 | $nomeurl = $locmapserv."?map=".$nomews; | 1712 | $nomeurl = $locmapserv."?map=".$nomews; |
1717 | $nomeogc = $urli3geo."/ogc.php?tema=".$nomews; | 1713 | $nomeogc = $urli3geo."/ogc.php?tema=".$nomews; |
1718 | $w = $this->mapa->web; | 1714 | $w = $this->mapa->web; |
1719 | $w->set("template",""); | 1715 | $w->set("template",""); |
1720 | // adiciona os parametros no nivel do mapa | 1716 | // adiciona os parametros no nivel do mapa |
1721 | $this->mapa->setmetadata("wms_title","i3Geo"); | 1717 | $this->mapa->setmetadata("wms_title","i3Geo"); |
1722 | - $this->mapa->setmetadata("wms_onlineresource","http://".$h.$nomeurl); | 1718 | + $this->mapa->setmetadata("wms_onlineresource","http://".$nomeurl); |
1723 | $projecao = pegaProjecaoDefault("epsg"); | 1719 | $projecao = pegaProjecaoDefault("epsg"); |
1724 | $this->mapa->setmetadata("wms_srs","EPSG:".$projecao); | 1720 | $this->mapa->setmetadata("wms_srs","EPSG:".$projecao); |
1725 | $this->mapa->setmetadata("wms_getcontext_enabled","1"); | 1721 | $this->mapa->setmetadata("wms_getcontext_enabled","1"); |
1726 | - foreach ($this->layers as $layer) | ||
1727 | - { | 1722 | + foreach ($this->layers as $layer){ |
1728 | if($layer->connectiontype != 7 && $layer->connectiontype != 9){ | 1723 | if($layer->connectiontype != 7 && $layer->connectiontype != 9){ |
1729 | $n = pegaNome($layer); | 1724 | $n = pegaNome($layer); |
1730 | $layer->setmetadata("wms_title",$n); | 1725 | $layer->setmetadata("wms_title",$n); |
1731 | $codigo = $layer->getmetadata("nomeoriginal"); | 1726 | $codigo = $layer->getmetadata("nomeoriginal"); |
1732 | - if($codigo == "") | ||
1733 | - { | 1727 | + if($codigo == ""){ |
1734 | $codigo = $layer->name; | 1728 | $codigo = $layer->name; |
1735 | } | 1729 | } |
1736 | $layer->setmetadata("wms_server_version","1.0.0"); | 1730 | $layer->setmetadata("wms_server_version","1.0.0"); |
@@ -1742,14 +1736,14 @@ class Mapa | @@ -1742,14 +1736,14 @@ class Mapa | ||
1742 | $layer->setmetadata("wms_format","image/png"); | 1736 | $layer->setmetadata("wms_format","image/png"); |
1743 | $layer->setmetadata("wms_formatlist","image/gif,image/png,image/png; mode=24bit,image/jpeg,image/wbmp,image/tiff"); | 1737 | $layer->setmetadata("wms_formatlist","image/gif,image/png,image/png; mode=24bit,image/jpeg,image/wbmp,image/tiff"); |
1744 | $layer->set("dump",MS_TRUE); | 1738 | $layer->set("dump",MS_TRUE); |
1745 | - $layer->set("status","ON"); | 1739 | + $layer->set("status",MS_DEFAULT); |
1746 | $layer->set("template","none.htm"); | 1740 | $layer->set("template","none.htm"); |
1747 | $c = $layer->getclass(0); | 1741 | $c = $layer->getclass(0); |
1748 | if ($c->name == "") | 1742 | if ($c->name == "") |
1749 | { | 1743 | { |
1750 | $c->name = " "; | 1744 | $c->name = " "; |
1751 | } | 1745 | } |
1752 | - if($layer->connectiontype != "WS_WMS" && $layer->getmetadata("permiteogc") == "" && $layer->getmetadata("TEMALOCAL") == ""){ | 1746 | + if($layer->connectiontype != "WS_WMS" && strtolower($layer->getmetadata("permiteogc")) != "nao" && $layer->getmetadata("TEMALOCAL") == ""){ |
1753 | if(ms_GetVersionInt() > 50201) | 1747 | if(ms_GetVersionInt() > 50201) |
1754 | { | 1748 | { |
1755 | $layer->setconnectiontype(MS_WMS); | 1749 | $layer->setconnectiontype(MS_WMS); |
ferramentas/convertews/dependencias.php
@@ -17,17 +17,6 @@ header("Content-type: text/javascript"); | @@ -17,17 +17,6 @@ header("Content-type: text/javascript"); | ||
17 | include("index.js"); | 17 | include("index.js"); |
18 | include("dicionario.js"); | 18 | include("dicionario.js"); |
19 | echo "\n"; | 19 | echo "\n"; |
20 | -/** | ||
21 | - * Inclui o template mustache do HTML usado para criar o conteudo da janela | ||
22 | - */ | ||
23 | -echo 'i3GEOF.converteMapaWS.MUSTACHE = "'; | ||
24 | -$texto = file_get_contents("template_mst.html"); | ||
25 | -$texto = str_replace("\n", "", $texto); | ||
26 | -$texto = str_replace("\r", "", $texto); | ||
27 | -$texto = str_replace("\t", "", $texto); | ||
28 | -$texto = str_replace('"', "'", $texto); | ||
29 | -echo $texto; | ||
30 | -echo '";'; | ||
31 | if(extension_loaded('zlib')){ | 20 | if(extension_loaded('zlib')){ |
32 | ob_end_flush(); | 21 | ob_end_flush(); |
33 | } | 22 | } |
ferramentas/convertews/dicionario.js
1 | //+$trad(1,i3GEOF.converteMapaWS.dicionario)+ | 1 | //+$trad(1,i3GEOF.converteMapaWS.dicionario)+ |
2 | i3GEOF.converteMapaWS.dicionario = { | 2 | i3GEOF.converteMapaWS.dicionario = { |
3 | 'ajudaDesktop' : [ { | 3 | 'ajudaDesktop' : [ { |
4 | - pt : "Você pode utilizar o endereço em softwares de geoprocessamento instalados em seu computador, como por exemplo, o", | 4 | + pt : "Você pode utilizar o endereço em softwares de geoprocessamento instalados em seu computador, como por exemplo, o gvSIG ou QGIS", |
5 | en : "", | 5 | en : "", |
6 | es : "Usted puede utilizar la dirección en el software de geoprocesamiento instalado en su ordenador, como por ejemplo: el" | 6 | es : "Usted puede utilizar la dirección en el software de geoprocesamiento instalado en su ordenador, como por ejemplo: el" |
7 | } ], | 7 | } ], |
ferramentas/convertews/exec.php
@@ -17,9 +17,13 @@ Converte o mapa atual em um wms e wmc. | @@ -17,9 +17,13 @@ Converte o mapa atual em um wms e wmc. | ||
17 | case "CONVERTEWMSWMC": | 17 | case "CONVERTEWMSWMC": |
18 | include_once(dirname(__FILE__)."/../../classesphp/classe_mapa.php"); | 18 | include_once(dirname(__FILE__)."/../../classesphp/classe_mapa.php"); |
19 | $m = new Mapa($map_file); | 19 | $m = new Mapa($map_file); |
20 | - if(!isset($_GET["h"])){$_GET["h"] = "";} | ||
21 | - $wms = $m->converteWS($locmapserv,$_GET["h"]); | ||
22 | - $wmc = $m->converteWMC($locmapserv,$_GET["h"]); | 20 | + $wms = "/ferramentas/convertews/ogc.php?sid=".$g_sid; |
21 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
22 | + $protocolo = $protocolo[0]; | ||
23 | + $protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
24 | + $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
25 | + $urli3geo = str_replace("/ferramentas/convertews/exec.php","",$protocolo.$_SERVER["PHP_SELF"]); | ||
26 | + $wmc = $m->converteWMC($locmapserv,$urli3geo); | ||
23 | $retorno = array("wms"=>$wms,"wmc"=>$wmc); | 27 | $retorno = array("wms"=>$wms,"wmc"=>$wmc); |
24 | break; | 28 | break; |
25 | } | 29 | } |
ferramentas/convertews/index.js
@@ -60,33 +60,16 @@ i3GEOF.converteMapaWS = { | @@ -60,33 +60,16 @@ i3GEOF.converteMapaWS = { | ||
60 | /** | 60 | /** |
61 | * Susbtitutos para o template | 61 | * Susbtitutos para o template |
62 | */ | 62 | */ |
63 | - mustacheHash : function() { | 63 | + mustacheHash : function(enderecowms,enderecowmc) { |
64 | var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.converteMapaWS.dicionario); | 64 | var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.converteMapaWS.dicionario); |
65 | dicionario["nomewms"] = enderecowms; | 65 | dicionario["nomewms"] = enderecowms; |
66 | dicionario["nomewmc"] = enderecowmc; | 66 | dicionario["nomewmc"] = enderecowmc; |
67 | - dicionario["divid"] = $i(divid).innerHTML; | 67 | + dicionario["bbox"] = i3GEO.parametros.mapexten.split(" ").join(","); |
68 | + dicionario["w"] = i3GEO.parametros.w; | ||
69 | + dicionario["h"] = i3GEO.parametros.h; | ||
68 | return dicionario; | 70 | return dicionario; |
69 | }, | 71 | }, |
70 | /* | 72 | /* |
71 | - Function: iniciaDicionario | ||
72 | - | ||
73 | - Carrega o dicionário e chama a função que inicia a ferramenta | ||
74 | - | ||
75 | - O Javascript é carregado com o id i3GEOF.nomedaferramenta.dicionario_script | ||
76 | - */ | ||
77 | - iniciaDicionario: function(){ | ||
78 | - if(typeof(i3GEOF.converteMapaWS.dicionario) === 'undefined'){ | ||
79 | - i3GEO.util.scriptTag( | ||
80 | - i3GEO.configura.locaplic+"/ferramentas/convertews/dicionario.js", | ||
81 | - "i3GEOF.converteMapaWS.iniciaJanelaFlutuante()", | ||
82 | - "i3GEOF.converteMapaWS.dicionario_script" | ||
83 | - ); | ||
84 | - } | ||
85 | - else{ | ||
86 | - i3GEOF.converteMapaWS.iniciaJanelaFlutuante(); | ||
87 | - } | ||
88 | - }, | ||
89 | - /* | ||
90 | Function: html | 73 | Function: html |
91 | 74 | ||
92 | Gera o código html para apresentação das opções da ferramenta | 75 | Gera o código html para apresentação das opções da ferramenta |
@@ -96,19 +79,31 @@ i3GEOF.converteMapaWS = { | @@ -96,19 +79,31 @@ i3GEOF.converteMapaWS = { | ||
96 | divid {String} - id do div que receberá o conteudo HTML da ferramenta | 79 | divid {String} - id do div que receberá o conteudo HTML da ferramenta |
97 | 80 | ||
98 | */ | 81 | */ |
99 | - html:function(divid,enderecowms,enderecowmc){ | ||
100 | - try{ | ||
101 | - var ins = '<div style=margin-left:5px; ><p class="paragrafo" >'+$trad('ajudaDesktop',i3GEOF.converteMapaWS.dicionario)+' <a href="http://www.gvsig.gva.es/" target=blank > gvSig</a>' + | ||
102 | - '<p class="paragrafo" >' + $trad('ajudaWms',i3GEOF.converteMapaWS.dicionario) + | ||
103 | - '<p class="paragrafo" >' + $trad('ajudaWmc',i3GEOF.converteMapaWS.dicionario) + '<a href=\"'+enderecowmc+'\" target=_blank >'+$trad('wmc',i3GEOF.converteMapaWS.dicionario)+'</a>' + | ||
104 | - '<p class="paragrafo" ><b>WMS: </b></p>' + | ||
105 | - '<p class="paragrafo" > <textarea cols="55" rows="3" style=cursor:pointer onclick="javascript:this.select()">' + | ||
106 | - enderecowms + '</textarea></p>' + | ||
107 | - '<p class="paragrafo" >' + | ||
108 | - '<a href="' + enderecowms + '&request=getcapabilities&version=1.1.0&service=wms" target=blank >'+$trad('testa',i3GEOF.converteMapaWS.dicionario)+'<br></div>'; | ||
109 | - $i(divid).innerHTML += ins; | ||
110 | - i3GEOF.converteMapaWS.aguarde.visibility = "hidden"; | ||
111 | - }catch(e){i3GEO.janela.tempoMsg(e);i3GEOF.converteMapaWS.aguarde.visibility = "hidden";} | 82 | + html:function(enderecowms,enderecowmc){ |
83 | + var ins = Mustache.render(i3GEOF.converteMapaWS.MUSTACHE, i3GEOF.converteMapaWS.mustacheHash(enderecowms,enderecowmc)); | ||
84 | + return ins; | ||
85 | + }, | ||
86 | + inicia: function(divid){ | ||
87 | + if(i3GEOF.converteMapaWS.MUSTACHE == ""){ | ||
88 | + $.get(i3GEO.configura.locaplic + "/ferramentas/convertews/template_mst.html", function(template) { | ||
89 | + i3GEOF.converteMapaWS.MUSTACHE = template; | ||
90 | + i3GEOF.converteMapaWS.inicia(divid); | ||
91 | + }); | ||
92 | + return; | ||
93 | + } | ||
94 | + var temp = function(retorno){ | ||
95 | + var enderecowms = $trad('erroWms',i3GEOF.converteMapaWS.dicionario), | ||
96 | + enderecowmc = $trad('erroWms',i3GEOF.converteMapaWS.dicionario); | ||
97 | + if (retorno.data != undefined){ | ||
98 | + enderecowms = i3GEO.configura.locaplic+retorno.data.wms+"&"; | ||
99 | + enderecowmc = window.location.protocol+"//"+window.location.host+retorno.data.wmc+"&"; | ||
100 | + } | ||
101 | + $i(divid).innerHTML = i3GEOF.converteMapaWS.html(enderecowms,enderecowmc); | ||
102 | + }; | ||
103 | + var p = i3GEO.configura.locaplic+"/ferramentas/convertews/exec.php?g_sid="+i3GEO.configura.sid+"&funcao=convertewmswmc"; | ||
104 | + var cp = new cpaint(); | ||
105 | + cp.set_response_type("JSON"); | ||
106 | + cp.call(p,"converteWMSWMC",temp); | ||
112 | }, | 107 | }, |
113 | /* | 108 | /* |
114 | Function: iniciaJanelaFlutuante | 109 | Function: iniciaJanelaFlutuante |
@@ -131,7 +126,7 @@ i3GEOF.converteMapaWS = { | @@ -131,7 +126,7 @@ i3GEOF.converteMapaWS = { | ||
131 | titulo = "<span class='i3GeoTituloJanelaBsNolink' >WMS</span></div>"; | 126 | titulo = "<span class='i3GeoTituloJanelaBsNolink' >WMS</span></div>"; |
132 | janela = i3GEO.janela.cria( | 127 | janela = i3GEO.janela.cria( |
133 | "440px", | 128 | "440px", |
134 | - "290px", | 129 | + "310px", |
135 | "", | 130 | "", |
136 | "", | 131 | "", |
137 | "", | 132 | "", |
@@ -150,20 +145,6 @@ i3GEOF.converteMapaWS = { | @@ -150,20 +145,6 @@ i3GEOF.converteMapaWS = { | ||
150 | "12" | 145 | "12" |
151 | ); | 146 | ); |
152 | divid = janela[2].id; | 147 | divid = janela[2].id; |
153 | - i3GEOF.converteMapaWS.aguarde = $i("i3GEOF.converteMapaWS_imagemCabecalho").style; | ||
154 | - i3GEOF.converteMapaWS.aguarde.visibility = "visible"; | ||
155 | - temp = function(retorno){ | ||
156 | - var enderecowms = $trad('erroWms',i3GEOF.converteMapaWS.dicionario), | ||
157 | - enderecowmc = $trad('erroWms',i3GEOF.converteMapaWS.dicionario); | ||
158 | - if (retorno.data != undefined){ | ||
159 | - enderecowms = i3GEO.configura.locaplic+retorno.data.wms+"&"; | ||
160 | - enderecowmc = window.location.protocol+"//"+window.location.host+retorno.data.wmc+"&"; | ||
161 | - } | ||
162 | - i3GEOF.converteMapaWS.html(divid,enderecowms,enderecowmc); | ||
163 | - }; | ||
164 | - p = i3GEO.configura.locaplic+"/ferramentas/convertews/exec.php?g_sid="+i3GEO.configura.sid+"&funcao=convertewmswmc&h="+window.location.host; | ||
165 | - cp = new cpaint(); | ||
166 | - cp.set_response_type("JSON"); | ||
167 | - cp.call(p,"converteWMSWMC",temp); | 148 | + i3GEOF.converteMapaWS.inicia(divid); |
168 | } | 149 | } |
169 | }; | 150 | }; |
170 | \ No newline at end of file | 151 | \ No newline at end of file |
@@ -0,0 +1,1527 @@ | @@ -0,0 +1,1527 @@ | ||
1 | +<?php | ||
2 | +include(dirname(__FILE__)."/../../classesphp/sani_request.php"); | ||
3 | +include_once (dirname(__FILE__)."/../../classesphp/carrega_ext.php"); | ||
4 | +include(dirname(__FILE__)."/../../ms_configura.php"); | ||
5 | +$_GET = array_merge($_GET,$_POST); | ||
6 | + | ||
7 | +session_name("i3GeoPHP"); | ||
8 | +session_id($_GET["sid"]); | ||
9 | +session_start(); | ||
10 | +$_GET["tema"] = $_SESSION["map_file"]; | ||
11 | + | ||
12 | +if(isset($_GET["BBOX"])){ | ||
13 | + $_GET["BBOX"] = str_replace(" ",",",$_GET["BBOX"]); | ||
14 | +} | ||
15 | + | ||
16 | +if(isset($_GET["tema"])){ | ||
17 | + $tema = $_GET["tema"]; | ||
18 | +} | ||
19 | +if(isset($_GET["TileMatrix"])){ | ||
20 | + $_GET["WIDTH"] = 256; | ||
21 | + $_GET["HEIGHT"] = 256; | ||
22 | + //calcula resolucoes | ||
23 | + $res = array(); | ||
24 | + $temp = 0.703125; | ||
25 | + for($i = 0; $i < 40; $i++){ | ||
26 | + $res[] = $temp; | ||
27 | + $temp = $temp / 2; | ||
28 | + } | ||
29 | + $_GET["tms"] = "/wmts/".$tema."/".$_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"]; | ||
30 | + $_GET["tms"] = str_replace(".png","",$_GET["tms"]).".png"; | ||
31 | + | ||
32 | + if($_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"] == "0/0/0" || $_GET["TileCol"] == -1 || $_GET["TileRow"]== -1){ | ||
33 | + return; | ||
34 | + } | ||
35 | + $_GET["BBOX"] = $lon1.",".$lat1.",".$lon2.",".$lat2; | ||
36 | + $_GET["SERVICE"] = "WMS"; | ||
37 | + $_GET["REQUEST"] = "getMap"; | ||
38 | + | ||
39 | +} | ||
40 | +set_time_limit(0); | ||
41 | +ini_set('memory_limit', '512M'); | ||
42 | +// | ||
43 | +//caso nenhum parametros tenha sido enviado | ||
44 | +// | ||
45 | +if(count($_GET) == 0){ | ||
46 | + $tipo="metadados"; | ||
47 | + $_GET["REQUEST"] = "getCapabilities"; | ||
48 | + $_GET["request"] = "getCapabilities"; | ||
49 | + $_GET["SERVICE"] = "WMS"; | ||
50 | +} | ||
51 | +// | ||
52 | +//compatibiliza chamadas fora do padrao | ||
53 | +// | ||
54 | +if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){ | ||
55 | + $_GET["OUTPUTFORMAT"] = $_GET["outputFormat"]; | ||
56 | +} | ||
57 | +if(isset($_GET["outputformat"]) && $_GET["outputformat"] != ""){ | ||
58 | + $_GET["OUTPUTFORMAT"] = $_GET["outputformat"]; | ||
59 | +} | ||
60 | +$cache = true; | ||
61 | + | ||
62 | +include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php"); | ||
63 | + | ||
64 | +if(isset($logExec) && $logExec["ogc"] == true){ | ||
65 | + i3GeoLog("prog: ogc url: ".implode("&",array_merge($_GET,$_POST)),$_SESSION["dir_tmp"]); | ||
66 | +} | ||
67 | +// | ||
68 | +//ajusta o default | ||
69 | +// | ||
70 | +if(!isset($_GET["ows_geomtype"]) || $_GET["ows_geomtype"] == ""){ | ||
71 | + $ows_geomtype = "none"; | ||
72 | +} | ||
73 | +else{ | ||
74 | + $ows_geomtype = $_GET["ows_geomtype"]; | ||
75 | +} | ||
76 | + | ||
77 | +// | ||
78 | +//imprime na tela a ajuda | ||
79 | +// | ||
80 | +if(isset($_GET["ajuda"])){ | ||
81 | + ogc_imprimeAjuda(); | ||
82 | + exit; | ||
83 | +} | ||
84 | +// | ||
85 | +//pega os enderecos para compor a url de chamada do gerador de web services | ||
86 | +// | ||
87 | +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
88 | +$protocolo = $protocolo[0]; | ||
89 | +$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
90 | +$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
91 | +$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); | ||
92 | + | ||
93 | +//ajusta o OUTPUTFORMAT | ||
94 | +$OUTPUTFORMAT = $_GET["OUTPUTFORMAT"]; | ||
95 | +if(strpos(strtolower($OUTPUTFORMAT),"kml") !== false){ | ||
96 | + $OUTPUTFORMAT = "kml"; | ||
97 | +} | ||
98 | +if(strpos(strtolower($OUTPUTFORMAT),"kmz") !== false){ | ||
99 | + $OUTPUTFORMAT = "kmz"; | ||
100 | +} | ||
101 | +// | ||
102 | +//para o caso da requisicao kmz | ||
103 | +//kmz nao funciona diretamente com mapserver | ||
104 | +// | ||
105 | +if(strtolower($OUTPUTFORMAT) == "kmz"){ | ||
106 | + $urln = "../../pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; | ||
107 | + header("Location:".$urln); | ||
108 | + exit; | ||
109 | +} | ||
110 | +if(strtolower($OUTPUTFORMAT) == "kml" && $ogrOutput == false){ | ||
111 | + $urln = "../../pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; | ||
112 | + header("Location:".$urln); | ||
113 | + exit; | ||
114 | +} | ||
115 | +if(strtolower($OUTPUTFORMAT) == "shape-zip" && $ogrOutput == false){ | ||
116 | + $retorno = downloadTema2("",$tema,$locaplic,$dir_tmp,$postgis_mapa); | ||
117 | + $zip = $retorno["shape-zip"]; | ||
118 | + if(file_exists($zip)){ | ||
119 | + ob_end_clean(); | ||
120 | + header('Content-type: application/zip'); | ||
121 | + header('Content-Disposition: attachment; filename='.basename($zip)); | ||
122 | + readfile($zip); | ||
123 | + } | ||
124 | + exit; | ||
125 | +} | ||
126 | +// | ||
127 | +//caso seja uma requisição WMS com format | ||
128 | +// | ||
129 | +$format = $_GET["format"]; | ||
130 | +if(strpos(strtolower($format),"kml") !== false){ | ||
131 | + $urln = "../..pacotes/kmlmapserver/kmlservice.php?request=kml&map=".$tema."&typename=".$tema; | ||
132 | + header("Location:".$urln); | ||
133 | + exit; | ||
134 | +} | ||
135 | +if(strpos(strtolower($format),"kmz") !== false){ | ||
136 | + $urln = "../../pacotes/kmlmapserver/kmlservice.php?request=kml&map=".$tema."&typename=".$tema; | ||
137 | + header("Location:".$urln); | ||
138 | + exit; | ||
139 | +} | ||
140 | +// | ||
141 | +//usa o epsg correto ao inves do apelido inventado pelo Google | ||
142 | +// | ||
143 | +if($_GET["SRS"] == "EPSG:900913" || $_GET["srs"] == "EPSG:900913"){ | ||
144 | + $_GET["SRS"] = "EPSG:3857"; | ||
145 | + $_GET["srs"] = "EPSG:3857"; | ||
146 | +} | ||
147 | +if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){ | ||
148 | + $_GET["srs"] = "EPSG:4326"; | ||
149 | + $_GET["SRS"] = "EPSG:4326"; | ||
150 | +} | ||
151 | + | ||
152 | +// | ||
153 | +//trata geojson da mesma forma que json | ||
154 | +// | ||
155 | +if(strtolower($OUTPUTFORMAT) == "geojson"){ | ||
156 | + $OUTPUTFORMAT = "json"; | ||
157 | +} | ||
158 | +// | ||
159 | +//para operar como o Geoserver, abre o openlayers | ||
160 | +// | ||
161 | +if(isset($format) && strtolower($format) == "application/openlayers"){ | ||
162 | + $urln = dirname($_SERVER["PHP_SELF"])."/mashups/openlayers.php?layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica,legenda"; | ||
163 | + //caso exista o openlayers3 | ||
164 | + if(file_exists(dirname(__FILE__)."/mashups/openlayers3.php")){ | ||
165 | + $urln = dirname($_SERVER["PHP_SELF"])."/mashups/openlayers3.php?layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica,legenda"; | ||
166 | + } | ||
167 | + if(!headers_sent()){ | ||
168 | + header("Location:".$urln); | ||
169 | + } | ||
170 | + else{ | ||
171 | + echo "<meta http-equiv='refresh' content='0;url=$urln'>"; | ||
172 | + } | ||
173 | +} | ||
174 | +// | ||
175 | +//pega a versao do Mapserver | ||
176 | +// | ||
177 | +//error_reporting(0); | ||
178 | +$versao = versao(); | ||
179 | +$versao = $versao["principal"]; | ||
180 | + | ||
181 | +$req = ms_newowsrequestobj(); | ||
182 | +$tipo = ""; | ||
183 | + | ||
184 | +$cache = false; | ||
185 | + | ||
186 | +// | ||
187 | +//inclui todos os parametros na requisicao e aproveita para verificar getcapabilities | ||
188 | +// | ||
189 | + | ||
190 | +$oMap = ms_newMapobj($tema); | ||
191 | +$c = $oMap->numlayers; | ||
192 | +$ls = array(); | ||
193 | +for ($i=0;$i < $c;++$i){ | ||
194 | + $l = $oMap->getlayer($i); | ||
195 | + if($l->status == MS_DEFAULT){ | ||
196 | + $ls[] = $l->name; | ||
197 | + } | ||
198 | +} | ||
199 | +$_GET["LAYERS"] = implode(",",$ls); | ||
200 | + | ||
201 | +foreach ($_GET as $k=>$v){ | ||
202 | + $req->setParameter(strtoupper($k), $v); | ||
203 | + if(strtolower($v) == "getcapabilities"){ | ||
204 | + $tipo = "metadados"; | ||
205 | + $cache = false; | ||
206 | + } | ||
207 | +} | ||
208 | +// | ||
209 | +//cria uma lista de epsgs para o getcapabilities | ||
210 | +// | ||
211 | +$req->setParameter("srsName",$req->getValueByName("SRS")); | ||
212 | +$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"; | ||
213 | +$VERSION = $_GET["VERSION"]; | ||
214 | +if(isset($_GET["version"]) && !isset($_GET["VERSION"])){ | ||
215 | + $VERSION = $_GET["version"]; | ||
216 | +} | ||
217 | +if(!isset($VERSION) || $VERSION == ""){ | ||
218 | + $req->setParameter("VeRsIoN","1.1.1"); | ||
219 | +} | ||
220 | + | ||
221 | +// | ||
222 | +//nome do mapfile que ficara em cache | ||
223 | +// | ||
224 | + | ||
225 | +$agora = intval(time() / 1000); | ||
226 | +//acrescenta ao nome a indicacao do tipo de TMS | ||
227 | +if(isset($_GET["tms"])){ | ||
228 | + $agora .= "tms"; | ||
229 | +} | ||
230 | +if(isset($_GET["Z"]) && isset($_GET["X"])){ | ||
231 | + $agora .= "google"; | ||
232 | +} | ||
233 | +// | ||
234 | +//se o outputformat for definido, evita o cahce de arquivo | ||
235 | +//o mesmo se existir filtro para o layer | ||
236 | +// | ||
237 | +if(isset($_GET["OUTPUTFORMAT"]) || !empty($_GET["map_layer_".$tema."_filter"])){ | ||
238 | + $_GET["DESLIGACACHE"] = "sim"; | ||
239 | +} | ||
240 | +if(isset($_GET["DESLIGACACHE"]) && $_GET["DESLIGACACHE"] == "sim"){ | ||
241 | + $agora = time(); | ||
242 | + $cache = false; | ||
243 | +} | ||
244 | +//remove o bbox do calculo do nome do mapfile | ||
245 | +$arrayget = $_GET; | ||
246 | +$arrayget["bbox"] = ""; | ||
247 | +$arrayget["BBOX"] = ""; | ||
248 | +$arrayget["Z"] = ""; | ||
249 | +$arrayget["X"] = ""; | ||
250 | +$arrayget["Y"] = ""; | ||
251 | +$arrayget["tms"] = ""; | ||
252 | +$arrayget["TileMatrix"] = ""; | ||
253 | +$arrayget["TileCol"] = ""; | ||
254 | +$arrayget["TileRow"] = ""; | ||
255 | + | ||
256 | +$nomeMapfileTmp = $dir_tmp."/ogc_".md5(implode("",$arrayget))."_".$agora.".map"; | ||
257 | + | ||
258 | +//essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao | ||
259 | +$cortePixels = 0; | ||
260 | +if(empty($ogcwsmap)){ | ||
261 | + $ogcwsmap = $_GET["ogcwsmap"]; | ||
262 | +} | ||
263 | +$oMap = ms_newMapobj($_SESSION["map_file"]); | ||
264 | +substituiConObj($oMap,$postgis_mapa); | ||
265 | + | ||
266 | + $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; | ||
267 | + $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; | ||
268 | + $or = $urli3geo."/ogc.php"; | ||
269 | + if((isset($tema)) && ($tema != "") && ($tipo=="metadados")){ | ||
270 | + $or = $or."?tema=".$tema."&"; | ||
271 | + } | ||
272 | + // | ||
273 | + //parametros no nível maior | ||
274 | + // | ||
275 | + $oMap->setmetadata("ows_onlineresource",$or); | ||
276 | + $oMap->setmetadata("wms_onlineresource",$or); | ||
277 | + $oMap->setmetadata("wms_title",$tituloInstituicao." - i3geo"); | ||
278 | + $oMap->setmetadata("wfs_title",$tituloInstituicao." - i3geo"); | ||
279 | + $oMap->setmetadata("wms_attribution_logourl_format","image/png"); | ||
280 | + $oMap->setmetadata("wms_attribution_logourl_height","56"); | ||
281 | + $oMap->setmetadata("wms_attribution_logourl_width","85"); | ||
282 | + $oMap->setmetadata("wms_attribution_logourl_href",$urli3geo."/imagens/i3geo.png"); | ||
283 | + $oMap->setmetadata("wms_attribution_onlineresource",$urli3geo); | ||
284 | + $oMap->setmetadata("wms_attribution_title",$tituloInstituicao); | ||
285 | + $oMap->setmetadata("ows_enable_request","*"); | ||
286 | + //parametro mandatario | ||
287 | + if($oMap->getmetadata("wms_srs") == ""){ | ||
288 | + $projecao = pegaProjecaoDefault("epsg"); | ||
289 | + $oMap->setmetadata("wms_srs","EPSG:".$projecao); | ||
290 | + } | ||
291 | + $e = $oMap->extent; | ||
292 | + $extensaoMap = ($e->minx)." ".($e->miny)." ".($e->maxx)." ".($e->maxy); | ||
293 | + //gera o mapa | ||
294 | + if ($tema != ""){ | ||
295 | + $listatema = explode(" ",str_replace(","," ",$tema)); | ||
296 | + //para o caso do tema ser um arquivo mapfile existente em uma pasta qualquer | ||
297 | + //$temai3geo = true indica que o layer será buscado na pasta i3geo/temas | ||
298 | + $temai3geo = true; | ||
299 | + if(file_exists($_GET["tema"]) && !isset($_GET["id_medida_variavel"])){ | ||
300 | + $nmap = ms_newMapobj($_GET["tema"]); | ||
301 | + $temai3geo = false; | ||
302 | + $nmap->setmetadata("ows_enable_request","*"); | ||
303 | + } | ||
304 | + //inclui o layer com a grade de coordenadas | ||
305 | + if((isset($_GET["grade"])) && (strtolower($_GET["grade"]) == "sim") && file_exists($locaplic."/temas/gridg.map")){ | ||
306 | + $listatema[] = "gridg"; | ||
307 | + } | ||
308 | + foreach ($listatema as $tx){ | ||
309 | + $extensao = ".map"; | ||
310 | + if($temai3geo == true && file_exists($locaplic."/temas/".$tx.".php")){ | ||
311 | + //$extensao = ".php"; | ||
312 | + } | ||
313 | + if($temai3geo == true && file_exists($locaplic."/temas/".$tx.".gvp")){ | ||
314 | + $extensao = ".gvp"; | ||
315 | + } | ||
316 | + if($extensao == ".map"){ | ||
317 | + //cria o mapfile com base no sistema de metadados estatisticos | ||
318 | + //verifica se o id_medida_variavel existe no mapfile e nao foi passado como um parametro | ||
319 | + if(!isset($_GET["id_medida_variavel"]) && $temai3geo == true){ | ||
320 | + $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); | ||
321 | + $l = $nmap->getlayer(0); | ||
322 | + $teste = $l->getmetadata("METAESTAT_ID_MEDIDA_VARIAVEL"); | ||
323 | + if($teste != "" && $l->data == ""){ | ||
324 | + $_GET["id_medida_variavel"] = $teste; | ||
325 | + } | ||
326 | + } | ||
327 | + | ||
328 | + if($temai3geo == true){ | ||
329 | + $nmap = ms_newMapobj($locaplic."/temas/".$tx.".map"); | ||
330 | + $nmap->setmetadata("ows_enable_request","*"); | ||
331 | + } | ||
332 | + if($temai3geo == false || empty($layers)){ | ||
333 | + $ts = $nmap->getalllayernames(); | ||
334 | + $nmap->setmetadata("ows_enable_request","*"); | ||
335 | + } | ||
336 | + else{ | ||
337 | + $ts = explode(",",str_replace(" ",",",$layers)); | ||
338 | + } | ||
339 | + foreach ($ts as $t){ | ||
340 | + $l = $nmap->getlayerbyname($t); | ||
341 | + if($l == ""){ | ||
342 | + $l = $nmap->getlayer(0); | ||
343 | + } | ||
344 | + //verifica se ja existe layer com mesmo nome | ||
345 | + if($oMap->getlayerbyname($l->name) == ""){ | ||
346 | + $permite = $l->getmetadata("permiteogc"); | ||
347 | + if(strtolower($permite) != "nao"){ | ||
348 | + //necessário pq o mapfile pode ter todos os layers como default | ||
349 | + if($temai3geo == false){ | ||
350 | + $l->set("status",MS_OFF); | ||
351 | + } | ||
352 | + else{ | ||
353 | + $l->set("status",MS_DEFAULT); | ||
354 | + } | ||
355 | + $l->setmetadata("ows_title",pegaNome($l)); | ||
356 | + $l->setmetadata("ows_srs",$listaepsg); | ||
357 | + $l->set("group",""); | ||
358 | + //timeout | ||
359 | + $tout = $l->getmetadata("wms_connectiontimeout"); | ||
360 | + if($tout == ""){ | ||
361 | + $l->setmetadata("wms_connectiontimeout",0); | ||
362 | + } | ||
363 | + //essa linha é necessária pq as vezes no mapfile não tem nenhum layer com o nome igual ao nome do mapfile | ||
364 | + if(count($ts)==1 && $temai3geo == true){ | ||
365 | + $l->set("name",$tx); | ||
366 | + } | ||
367 | + $l->setmetadata("gml_include_items","all"); | ||
368 | + $l->set("template","none.htm"); | ||
369 | + $l->set("dump",MS_TRUE); | ||
370 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
371 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
372 | + | ||
373 | + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
374 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
375 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
376 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
377 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
378 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
379 | + } | ||
380 | + if($l->type == MS_LAYER_RASTER && $l->numclasses > 0){ | ||
381 | + $c = $l->getclass(0); | ||
382 | + if($c->name == ""){ | ||
383 | + $c->name = " "; | ||
384 | + } | ||
385 | + } | ||
386 | + //inclui extensao geografica | ||
387 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
388 | + if($extensao == ""){ | ||
389 | + $extensao = $extensaoMap; | ||
390 | + } | ||
391 | + $l->setmetadata("wms_extent",$extensao); | ||
392 | + if (!empty($postgis_mapa)){ | ||
393 | + if ($l->connectiontype == MS_POSTGIS){ | ||
394 | + | ||
395 | + $lcon = $l->connection; | ||
396 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | ||
397 | + // | ||
398 | + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | ||
399 | + // | ||
400 | + if(($lcon == " ") || ($lcon == "")){ | ||
401 | + $l->set("connection",$postgis_mapa); | ||
402 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
403 | + } | ||
404 | + else{ | ||
405 | + $l->set("connection",$postgis_mapa[$lcon]); | ||
406 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | ||
407 | + } | ||
408 | + } | ||
409 | + } | ||
410 | + } | ||
411 | + | ||
412 | + autoClasses($l,$oMap); | ||
413 | + | ||
414 | + if($versao > 5){ | ||
415 | + $pr = $l->getProcessing(); | ||
416 | + if(!in_array("LABEL_NO_CLIP=True",$pr)){ | ||
417 | + $l->setprocessing("LABEL_NO_CLIP=True"); | ||
418 | + } | ||
419 | + if(!in_array("POLYLINE_NO_CLIP=True",$pr)){ | ||
420 | + $l->setprocessing("POLYLINE_NO_CLIP=True"); | ||
421 | + } | ||
422 | + } | ||
423 | + | ||
424 | + // | ||
425 | + //verifica se existem parametros de substituicao passados via url | ||
426 | + // | ||
427 | + $parametro = $_GET["map_layer_".$l->name."_filter"]; | ||
428 | + //echo $parametro;exit; | ||
429 | + if(!empty($parametro)){ | ||
430 | + $l->setfilter($parametro); | ||
431 | + $cache = false; | ||
432 | + } | ||
433 | + //muda o title se for vazio | ||
434 | + $nclass = $l->numclasses; | ||
435 | + for($i=0;$i<$nclass;$i++){ | ||
436 | + $classe = $l->getclass($i); | ||
437 | + if($classe->title == ""){ | ||
438 | + $classe->title = $classe->name; | ||
439 | + } | ||
440 | + } | ||
441 | + if($nclass == 1){ | ||
442 | + $classe = $l->getclass(0); | ||
443 | + if($classe->name == ""){ | ||
444 | + $classe->title = $l->getmetadata("tema"); | ||
445 | + $classe->set("name",$l->getmetadata("tema")); | ||
446 | + } | ||
447 | + } | ||
448 | + $layerAdicionado = ms_newLayerObj($oMap, $l); | ||
449 | + corrigeLayerGrid($l,$layerAdicionado); | ||
450 | + corrigeLayerGrid ( $layerAdicionado,$oMap ); | ||
451 | + } | ||
452 | + else{ | ||
453 | + //a camada nao pode ser usada como servico WMS, entao e enviada uma mensagem | ||
454 | + $l->set("data",""); | ||
455 | + $l->set("type",MS_POINT); | ||
456 | + $l->setmetadata("cache","nao"); | ||
457 | + //apaga as classes | ||
458 | + $nclass = $l->numclasses; | ||
459 | + for($i=0;$i<$nclass;$i++){ | ||
460 | + $classe = $l->getclass($i); | ||
461 | + $classe->set("status",MS_DELETE); | ||
462 | + } | ||
463 | + $l->updatefromstring(' | ||
464 | + LAYER | ||
465 | + SIZEUNITS PIXELS | ||
466 | + TRANSFORM FALSE | ||
467 | + CLASS | ||
468 | + LABEL | ||
469 | + SIZE 10 | ||
470 | + TYPE truetype | ||
471 | + FONT arial | ||
472 | + COLOR 255 0 0 | ||
473 | + POSITION cc | ||
474 | + FORCE true | ||
475 | + END | ||
476 | + END | ||
477 | + FEATURE POINTS 100 100 END | ||
478 | + TEXT "OGC denied" END | ||
479 | + FEATURE POINTS 100 120 END | ||
480 | + TEXT "' . $l->name . '" END | ||
481 | + END | ||
482 | + '); | ||
483 | + ms_newLayerObj($oMap, $l); | ||
484 | + } | ||
485 | + } | ||
486 | + } | ||
487 | + } | ||
488 | + | ||
489 | + } | ||
490 | + } | ||
491 | + else{ | ||
492 | + $intervalo = "0,5000"; | ||
493 | + $conta = 0; | ||
494 | + $int = explode(",",$intervalo); | ||
495 | + $codigosTema = array(); | ||
496 | + if(empty($_GET["perfil"])){ | ||
497 | + $perfil = ""; | ||
498 | + } | ||
499 | + include("../../classesphp/classe_menutemas.php"); | ||
500 | + $m = new Menutemas("",$perfil,$locaplic,$urli3geo); | ||
501 | + $menus = $m->pegaListaDeMenus(); | ||
502 | + foreach ($menus as $menu){ | ||
503 | + $grupos = $m->pegaListaDeGrupos($menu["idmenu"],$listasistemas="nao",$listasgrupos="sim"); | ||
504 | + //temas na raiz do menu | ||
505 | + $lts = $menu["temas"]; | ||
506 | + //var_dump($lts);exit; | ||
507 | + foreach($lts as $t){ | ||
508 | + if(strtolower($t["ogc_tema"]) != "nao"){ | ||
509 | + $codigosTema[$t["codigo_tema"]] = array("tema"=>$t["codigo_tema"],"fonte"=>$t["link_tema"]); | ||
510 | + } | ||
511 | + } | ||
512 | + foreach($grupos as $grupo){ | ||
513 | + $lts = $grupo["temasgrupo"]; | ||
514 | + //var_dump($lts); | ||
515 | + foreach($lts as $t){ | ||
516 | + if(strtolower($t["ogc"]) != "nao"){ | ||
517 | + $codigosTema[$t["tid"]] = array("tema"=>$t["tid"],"fonte"=>$t["link"]); | ||
518 | + } | ||
519 | + } | ||
520 | + if(strtolower($grupo["ogc"]) == "sim"){ | ||
521 | + foreach($grupo["subgrupos"] as $sgrupo){ | ||
522 | + if(strtolower($sgrupo["ogc"]) == "sim"){ | ||
523 | + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
524 | + foreach($lts as $t){ | ||
525 | + if(strtolower($t["ogc"]) == "sim"){ | ||
526 | + $codigosTema[$t["tid"]] = array("tema"=>$t["tid"],"fonte"=>$t["link"]); | ||
527 | + } | ||
528 | + } | ||
529 | + } | ||
530 | + } | ||
531 | + } | ||
532 | + } | ||
533 | + } | ||
534 | + //echo "<pre>".var_dump($codigosTema);exit; | ||
535 | + foreach($codigosTema as $c){ | ||
536 | + $codigoTema = $c["tema"]; | ||
537 | + if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | ||
538 | + if (@ms_newMapobj($locaplic."/temas/".$codigoTema.".map")){ | ||
539 | + $nmap = ms_newMapobj($locaplic."/temas/".$codigoTema.".map"); | ||
540 | + $nmap->setmetadata("ows_enable_request","*"); | ||
541 | + $ts = $nmap->getalllayernames(); | ||
542 | + foreach ($ts as $t){ | ||
543 | + if ($oMap->getlayerbyname($t) == ""){ | ||
544 | + $l = $nmap->getlayerbyname($t); | ||
545 | + $extensao = $l->getmetadata("EXTENSAO"); | ||
546 | + if($extensao == ""){ | ||
547 | + $extensao = $extensaoMap; | ||
548 | + } | ||
549 | + $l->setmetadata("wms_extent",$extensao); | ||
550 | + $l->setmetadata("ows_title",pegaNome($l)); | ||
551 | + $l->setmetadata("ows_srs",$listaepsg); | ||
552 | + $l->set("status",MS_OFF); | ||
553 | + $l->setmetadata("gml_include_items","all"); | ||
554 | + $l->set("dump",MS_TRUE); | ||
555 | + $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | ||
556 | + $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | ||
557 | + if($l->getmetadata("ows_metadataurl_href") == ""){ | ||
558 | + $l->setmetadata("ows_metadataurl_href",$c["fonte"]); | ||
559 | + $l->setmetadata("ows_metadataurl_type","TC211"); | ||
560 | + $l->setmetadata("ows_metadataurl_format","text/html"); | ||
561 | + } | ||
562 | + if(file_exists($locaplic."/temas/miniaturas/".$t.".map.mini.png")){ | ||
563 | + $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$t.".map.mini.png"; | ||
564 | + $l->setmetadata("wms_attribution_logourl_format","image/png"); | ||
565 | + $l->setmetadata("wms_attribution_logourl_height","50"); | ||
566 | + $l->setmetadata("wms_attribution_logourl_width","50"); | ||
567 | + $l->setmetadata("wms_attribution_logourl_href",$mini); | ||
568 | + } | ||
569 | + // | ||
570 | + //numero de pixels que serao considerados para corte da imagem no caso de cache ativo e tema de pontos | ||
571 | + // | ||
572 | + if ($l->getmetadata("cortepixels") != ""){ | ||
573 | + $cortePixels = $l->getmetadata("cortepixels"); | ||
574 | + } | ||
575 | + cloneInlineSymbol($l,$nmap,$oMap); | ||
576 | + ms_newLayerObj($oMap, $l); | ||
577 | + } | ||
578 | + } | ||
579 | + } | ||
580 | + else{ | ||
581 | + echo "Erro no arquivo ".$locaplic."/temas/".$codigoTema.".map <br>"; | ||
582 | + $error = ms_GetErrorObj(); | ||
583 | + while($error && $error->code != MS_NOERR){ | ||
584 | + //printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | ||
585 | + //$error = $error->next(); | ||
586 | + } | ||
587 | + } | ||
588 | + } | ||
589 | + } | ||
590 | + } | ||
591 | + // | ||
592 | + //a imagem do mapa recebera a legenda | ||
593 | + // | ||
594 | + if((isset($_GET["legenda"])) && (strtolower($_GET["legenda"]) == "sim")){ | ||
595 | + processaLegenda(); | ||
596 | + } | ||
597 | + // | ||
598 | + //a imagem do mapa recebera a barra de escala | ||
599 | + // | ||
600 | + if((isset($_GET["escala"])) && (strtolower($_GET["escala"]) == "sim")){ | ||
601 | + processaEscala(); | ||
602 | + } | ||
603 | + // | ||
604 | + //aplica os parametros sobre a grade de coordenadas | ||
605 | + // | ||
606 | + if((isset($_GET["grade"])) && (strtolower($_GET["grade"]) == "sim")){ | ||
607 | + processaGrade(); | ||
608 | + } | ||
609 | + $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); | ||
610 | + $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); | ||
611 | + //verifica se existem layers com plugin definido e processa conforme o tipo de plugin | ||
612 | + processaPluginI3geo(); | ||
613 | + // | ||
614 | + //caso seja download ou json ou csv | ||
615 | + // | ||
616 | + processaOutputformatMapfile(); | ||
617 | +if(ob_get_contents ()){ | ||
618 | + ob_end_clean(); | ||
619 | +} | ||
620 | +// | ||
621 | +//verifica se a requisicao e do tipo TMS. | ||
622 | +// | ||
623 | +// | ||
624 | +//calcula a extensao geografica com base no x,y,z em requisisoes TMS | ||
625 | +//quando for do tipo tms $_GET["tms"] contem os parametros do tile | ||
626 | +//essa rotina faz um exit ao final | ||
627 | +//o cache tms so fucniona se houver apenas uma camada no mapa | ||
628 | +//tms e usado basicamente por mashup ou openlayers | ||
629 | +// | ||
630 | +if(isset($_GET["tms"])){ | ||
631 | + if(!isset($_GET["TileMatrix"])){ | ||
632 | + $temp = explode("/",$_GET["tms"]); | ||
633 | + $z = $temp[2]; | ||
634 | + $x = $temp[3]; | ||
635 | + $y = str_replace(".png","",$temp[4]); | ||
636 | + $n = pow(2,$z+1); | ||
637 | + $lon1 = $x / $n * 360.0 - 180.0; | ||
638 | + $lon2 = ($x+1) / $n * 360.0 - 180.0; | ||
639 | + $n = pow(2,$z); | ||
640 | + $lat1 = $y / $n * 180.0 - 90.0; | ||
641 | + $lat2 = ($y+1) / $n * 180.0 - 90.0; | ||
642 | + } | ||
643 | + else{ | ||
644 | + $top_left_minx = -180; | ||
645 | + $top_left_maxy = 90; | ||
646 | + | ||
647 | + $x_size = $res[$_GET["TileMatrix"] - 1] * 256; | ||
648 | + $y_size = $x_size; | ||
649 | + | ||
650 | + $lon1 = $top_left_minx + ($_GET["TileCol"] * $x_size); | ||
651 | + $lat1 = $top_left_maxy - ($_GET["TileRow"] * $y_size) - $y_size; | ||
652 | + $lon2 = $top_left_minx + ($_GET["TileCol"] * $x_size) + $x_size; | ||
653 | + $lat2 = $top_left_maxy - ($_GET["TileRow"] * $y_size); | ||
654 | + } | ||
655 | + | ||
656 | + //essa funcao termina o processo se a imagem existir | ||
657 | + if($cache == true){ | ||
658 | + carregaCacheImagem($cachedir,$nomeMapfileTmp,$_GET["tms"]); | ||
659 | + } | ||
660 | + | ||
661 | + $layer0 = $oMap->getlayer(0); | ||
662 | + // | ||
663 | + //numero de pixels que serao considerados para corte da imagem no caso de cache ativo e tema de pontos | ||
664 | + // | ||
665 | + if ($layer0->getmetadata("cortepixels") != ""){ | ||
666 | + $cortePixels = $layer0->getmetadata("cortepixels"); | ||
667 | + } | ||
668 | + //se nao existir, salva a imagem | ||
669 | + //echo $lon1." ".$lat1." ".$lon2." ".$lat2;exit; | ||
670 | + $oMap->setsize(256,256); | ||
671 | + $oMap->setExtent($lon1,$lat1,$lon2,$lat2); | ||
672 | + | ||
673 | + $layer0->set("status",MS_DEFAULT); | ||
674 | + // | ||
675 | + //se o layer foi marcado para corte altera os parametros para ampliar o mapa | ||
676 | + //antes de gerar a imagem | ||
677 | + // | ||
678 | + if($cortePixels > 0){ | ||
679 | + //$oMap->prepareImage(); | ||
680 | + $escalaInicial = $oMap->scaledenom; | ||
681 | + $extensaoInicial = $oMap->extent; | ||
682 | + $wh = 256+($cortePixels*2); | ||
683 | + $oMap->setsize($wh,$wh); | ||
684 | + $ponto = new pointObj(); | ||
685 | + $ponto->setxy(($wh/2),($wh/2)); | ||
686 | + $oMap->zoomScale($escalaInicial, $ponto, $wh, $wh, $extensaoInicial); | ||
687 | + } | ||
688 | + | ||
689 | + $img = $oMap->draw(); | ||
690 | + | ||
691 | + if($img->imagepath == ""){ | ||
692 | + //tenta mais uma vez | ||
693 | + $img = $oMap->draw(); | ||
694 | + } | ||
695 | + if($img->imagepath == ""){ | ||
696 | + exit; | ||
697 | + } | ||
698 | + if($cache == true){ | ||
699 | + salvaCacheImagem($cachedir,$nomeMapfileTmp,$_GET["tms"]); | ||
700 | + } | ||
701 | + renderNocacheTms(); | ||
702 | +} | ||
703 | + | ||
704 | +// | ||
705 | +//verifica se a chamada do servico e do tipo TILE no padrao do Google | ||
706 | +// | ||
707 | +if(isset($_GET["Z"]) && isset($_GET["X"])){ | ||
708 | + $x = $_GET["X"]; | ||
709 | + $y = $_GET["Y"]; | ||
710 | + $z = $_GET["Z"]; | ||
711 | + $proj4 = pegaProjecaoDefault("proj4"); | ||
712 | + if(file_exists($tema)){ | ||
713 | + $layer0 = $oMap->getlayer(0); | ||
714 | + $layer0->set("status",MS_DEFAULT); | ||
715 | + $layer0->setProjection($proj4); | ||
716 | + } | ||
717 | + else{ | ||
718 | + //pode ter mais de um tema | ||
719 | + $lista = explode(" ",$tema); | ||
720 | + foreach($lista as $nomeLayer){ | ||
721 | + $layer0 = $oMap->getlayerbyname($nomeLayer); | ||
722 | + $layer0->set("status",MS_DEFAULT); | ||
723 | + $layer0->setProjection($proj4); | ||
724 | + } | ||
725 | + } | ||
726 | + // | ||
727 | + //numero de pixels que serao considerados para corte da imagem no caso de cache ativo e tema de pontos | ||
728 | + // | ||
729 | + if ($layer0->getmetadata("cortepixels") != ""){ | ||
730 | + $cortePixels = $layer0->getmetadata("cortepixels"); | ||
731 | + } | ||
732 | + | ||
733 | + if($cache == true){ | ||
734 | + carregaCacheImagem($cachedir,$nomeMapfileTmp,"/googlemaps/$layer0->name/$z/$x/$y"); | ||
735 | + } | ||
736 | + $n = pow(2,$z); | ||
737 | + $lon1 = $x / $n * 360.0 - 180.0; | ||
738 | + $lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); | ||
739 | + $x++; | ||
740 | + $y++; | ||
741 | + $lon2 = $x / $n * 360.0 - 180.0; | ||
742 | + $lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); | ||
743 | + $x--; | ||
744 | + $y--; | ||
745 | + | ||
746 | + $projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); | ||
747 | + $projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); | ||
748 | + | ||
749 | + $poPoint1 = ms_newpointobj(); | ||
750 | + $poPoint1->setXY($lon1, $lat1); | ||
751 | + $poPoint1->project($projInObj, $projOutObj); | ||
752 | + $poPoint2 = ms_newpointobj(); | ||
753 | + $poPoint2->setXY($lon2, $lat2); | ||
754 | + $poPoint2->project($projInObj, $projOutObj); | ||
755 | + $oMap->setsize(256,256); | ||
756 | + $oMap->setExtent($poPoint1->x,$poPoint1->y,$poPoint2->x,$poPoint2->y); | ||
757 | + | ||
758 | + $oMap->setProjection("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); | ||
759 | + | ||
760 | + // | ||
761 | + //se o layer foi marcado para corte altera os parametros para ampliar o mapa | ||
762 | + //antes de gerar a imagem | ||
763 | + // | ||
764 | + if($cortePixels > 0){ | ||
765 | + //$oMap->prepareImage(); | ||
766 | + $escalaInicial = $oMap->scaledenom; | ||
767 | + $extensaoInicial = $oMap->extent; | ||
768 | + $wh = 256+($cortePixels*2); | ||
769 | + $oMap->setsize($wh,$wh); | ||
770 | + $ponto = new pointObj(); | ||
771 | + $ponto->setxy(($wh/2),($wh/2)); | ||
772 | + $oMap->zoomScale($escalaInicial, $ponto, $wh, $wh, $extensaoInicial); | ||
773 | + } | ||
774 | + $img = $oMap->draw(); | ||
775 | + if($img->imagepath == ""){ | ||
776 | + exit; | ||
777 | + } | ||
778 | + if($cache == true){ | ||
779 | + salvaCacheImagem($cachedir,$nomeMapfileTmp,"/googlemaps/$layer0->name/$z/$x/$y"); | ||
780 | + } | ||
781 | + renderNocacheTms(); | ||
782 | +} | ||
783 | +if(strtolower($req->getValueByName("REQUEST")) == "getlegendgraphic"){ | ||
784 | + $legenda = $oMap->legend; | ||
785 | + $legenda->set("status",MS_ON); | ||
786 | + $numlayers = $oMap->numlayers; | ||
787 | + for ($i=0;$i < $numlayers;$i++){ | ||
788 | + $l = $oMap->getlayer($i); | ||
789 | + $l->set("status",MS_DEFAULT); | ||
790 | + if($req->getValueByName("LAYER") == ""){ | ||
791 | + $req->setParameter("LAYER",$l->name); | ||
792 | + } | ||
793 | + | ||
794 | + //muda o title se for vazio | ||
795 | + /* | ||
796 | + $nclass = $l->numclasses; | ||
797 | + for($i=0;$i<$nclass;$i++){ | ||
798 | + $classe = $l->getclass($i); | ||
799 | + if($classe->title == ""){ | ||
800 | + $classe->title = $classe->name; | ||
801 | + } | ||
802 | + } | ||
803 | + if($nclass == 1){ | ||
804 | + $classe = $l->getclass(0); | ||
805 | + if($classe->name == ""){ | ||
806 | + $classe->title = $l->getmetadata("tema"); | ||
807 | + $classe->set("name",$l->getmetadata("tema")); | ||
808 | + } | ||
809 | + } | ||
810 | + */ | ||
811 | + if($req->getValueByName("FORMAT") == ""){ | ||
812 | + $req->setParameter("FORMAT","image/png"); | ||
813 | + } | ||
814 | + $l->set("minscaledenom",0); | ||
815 | + $l->set("maxscaledenom",0); | ||
816 | + if($req->getValueByName("FORMAT") == "text/html"){ | ||
817 | + //remove offset de simbolos pontuais | ||
818 | + $nclass = $l->numclasses; | ||
819 | + for($cc = 0; $cc < $nclass; $cc++){ | ||
820 | + $classe = $l->getclass($cc); | ||
821 | + if($classe->numstyles > 0){ | ||
822 | + $estilo = $classe->getstyle(0); | ||
823 | + if($estilo->symbolname != "" && file_exists($estilo->symbolname)){ | ||
824 | + $estilo->set("offsetx",0); | ||
825 | + $estilo->set("offsety",0); | ||
826 | + } | ||
827 | + } | ||
828 | + } | ||
829 | + } | ||
830 | + } | ||
831 | + if($req->getValueByName("FORMAT") == "text/html"){ | ||
832 | + //define qual template utilizar | ||
833 | + if(empty($_GET["templateLegenda"])){ | ||
834 | + $legenda->set("template",$locaplic."/aplicmap/legendaOgc.html"); | ||
835 | + } else { | ||
836 | + $_GET["templateLegenda"] = str_replace(".htm","",$_GET["templateLegenda"]); | ||
837 | + $_GET["templateLegenda"] = str_replace(".","",$_GET["templateLegenda"]); | ||
838 | + if(file_exists($locaplic."/".$_GET["templateLegenda"].".htm")){ | ||
839 | + $legenda->set("template",$locaplic."/".$_GET["templateLegenda"].".htm"); | ||
840 | + } else { | ||
841 | + $legenda->set("template",$locaplic."/aplicmap/legendaOgc.html"); | ||
842 | + } | ||
843 | + } | ||
844 | + $tmparray["my_tag"] = "value_of_my_tag"; | ||
845 | + if($leg = @$oMap->processlegendtemplate($tmparray)){ | ||
846 | + if (function_exists("mb_convert_encoding")){ | ||
847 | + $leg = mb_convert_encoding($leg,"UTF-8","ISO-8859-1"); | ||
848 | + } | ||
849 | + echo $leg; | ||
850 | + exit; | ||
851 | + } | ||
852 | + } | ||
853 | +} | ||
854 | + | ||
855 | +if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){ | ||
856 | + $l = $oMap->getlayer(0); | ||
857 | + if($req->getValueByName("TYPENAME") == "" || $req->getValueByName("TYPENAME") == "undefined"){ | ||
858 | + $req->setParameter("TYPENAME",$l->name); | ||
859 | + } | ||
860 | + if($l->getProjection() == "" ){ | ||
861 | + $l->setProjection(pegaProjecaoDefault("proj4")); | ||
862 | + } | ||
863 | + if(strtolower($req->getValueByName("SRS")) == "epsg:900913"){ | ||
864 | + $req->setParameter("SRS","EPSG:3857"); | ||
865 | + } | ||
866 | +} | ||
867 | +if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo"){ | ||
868 | + $l = $oMap->getlayer(0); | ||
869 | + $req->setParameter("LAYERS",$l->name); | ||
870 | + $req->setParameter("QUERY_LAYERS",$l->name); | ||
871 | + if(strtolower($req->getValueByName("SRS")) == "epsg:900913"){ | ||
872 | + $req->setParameter("SRS","EPSG:3857"); | ||
873 | + $_GET["SRS"] = "EPSG:3857"; | ||
874 | + } | ||
875 | +} | ||
876 | +ms_ioinstallstdouttobuffer(); | ||
877 | +// | ||
878 | +//verifica parametro outputformat e ajusta a requisicao | ||
879 | +// | ||
880 | +if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){ | ||
881 | + $req->setParameter("format","image/png"); | ||
882 | +} | ||
883 | +if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "text/xml"){ | ||
884 | + $req->setParameter("info_format","application/vnd.ogc.gml"); | ||
885 | +} | ||
886 | +//json conforme cesium | ||
887 | +if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){ | ||
888 | + getfeatureinfoJson(); | ||
889 | + exit; | ||
890 | +} | ||
891 | +if(strtolower($request) == "getcapabilities"){ | ||
892 | + //header('Content-Disposition: attachment; filename=getcapabilities.xml'); | ||
893 | +} | ||
894 | +elseif(!isset($OUTPUTFORMAT)){ | ||
895 | + //$contenttype = ms_iostripstdoutbuffercontenttype(); | ||
896 | + header("Content-type: $contenttype"); | ||
897 | +} | ||
898 | +//$ogrOutput vem de ms_configura.php | ||
899 | + | ||
900 | +//precisa limpar o cabecalho | ||
901 | +if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){ | ||
902 | + $arq = $dir_tmp."/".$tema.".json"; | ||
903 | + if(isset($ogrOutput) && $ogrOutput == false){ | ||
904 | + exportaGeojson(); | ||
905 | + exit; | ||
906 | + } | ||
907 | + $oMap->owsdispatch($req); | ||
908 | + | ||
909 | + $contenttype = ms_iostripstdoutbuffercontenttype(); | ||
910 | + ms_iostripstdoutbuffercontentheaders(); | ||
911 | + //grava em disco | ||
912 | + $contents = ms_iogetstdoutbufferstring(); | ||
913 | + file_put_contents($arq,$contents); | ||
914 | + //envia para download | ||
915 | + | ||
916 | + header("Content-type: application/json; subtype=geojson"); | ||
917 | + | ||
918 | + ms_iogetStdoutBufferBytes(); | ||
919 | + ms_ioresethandlers(); | ||
920 | + | ||
921 | + exit; | ||
922 | +} | ||
923 | +if(strtolower($OUTPUTFORMAT) == "kml"){ | ||
924 | + $oMap->owsdispatch($req); | ||
925 | + $contenttype = ms_iostripstdoutbuffercontenttype(); | ||
926 | + ms_iostripstdoutbuffercontentheaders(); | ||
927 | + //grava em disco | ||
928 | + $arq = $dir_tmp."/".$tema.".kml"; | ||
929 | + $contents = ms_iogetstdoutbufferstring(); | ||
930 | + file_put_contents($arq,$contents); | ||
931 | + //envia para download | ||
932 | + header('Content-Disposition: attachment; filename='.$tema.'.kml'); | ||
933 | + ms_iogetStdoutBufferBytes(); | ||
934 | + ms_ioresethandlers(); | ||
935 | + exit; | ||
936 | +} | ||
937 | +//kmz nao funciona quando fornecido diretamente pelo mapserver | ||
938 | +if(strtolower($OUTPUTFORMAT) == "kmz"){ | ||
939 | + $oMap->owsdispatch($req); | ||
940 | + $contenttype = ms_iostripstdoutbuffercontenttype(); | ||
941 | + ms_iostripstdoutbuffercontentheaders(); | ||
942 | + //grava em disco | ||
943 | + $arq = $dir_tmp."/".$tema.".kmz"; | ||
944 | + $contents = ms_iogetstdoutbufferstring(); | ||
945 | + file_put_contents($arq,$contents); | ||
946 | + //envia para download | ||
947 | + header('Content-Disposition: attachment; filename='.$tema.'.kmz'); | ||
948 | + ms_iogetStdoutBufferBytes(); | ||
949 | + ms_ioresethandlers(); | ||
950 | + exit; | ||
951 | +} | ||
952 | +if(strtolower($OUTPUTFORMAT) == "shape-zip"){ | ||
953 | + $oMap->owsdispatch($req); | ||
954 | + $contenttype = ms_iostripstdoutbuffercontenttype(); | ||
955 | + //grava em disco | ||
956 | + $arq = $dir_tmp."/".$tema."_shapefile.zip"; | ||
957 | + $contents = ms_iogetstdoutbufferstring(); | ||
958 | + file_put_contents($arq,$contents); | ||
959 | + //envia para download | ||
960 | + header('Content-Disposition: attachment; filename='.$tema.'_shapefile.zip'); | ||
961 | + ms_iogetStdoutBufferBytes(); | ||
962 | + ms_ioresethandlers(); | ||
963 | + exit; | ||
964 | +} | ||
965 | +if(strtolower($OUTPUTFORMAT) == "csv"){ | ||
966 | + $arq = $dir_tmp."/".$tema.$ows_geomtype.".csv"; | ||
967 | + $fileName = $tema.$ows_geomtype.'.csv'; | ||
968 | + if(isset($ogrOutput) && $ogrOutput == false){ | ||
969 | + exportaCsv(); | ||
970 | + exit; | ||
971 | + } | ||
972 | + // | ||
973 | + $oMap->owsdispatch($req); | ||
974 | + $contenttype = ms_iostripstdoutbuffercontenttype(); | ||
975 | + ms_iostripstdoutbuffercontentheaders(); | ||
976 | + //grava em disco | ||
977 | + $contents = ms_iogetstdoutbufferstring(); | ||
978 | + file_put_contents($arq,$contents); | ||
979 | + //envia para download | ||
980 | + header('Content-Disposition: attachment; filename='.$fileName); | ||
981 | + header("Content-type: text/csv"); | ||
982 | + ms_iogetStdoutBufferBytes(); | ||
983 | + ms_ioresethandlers(); | ||
984 | + exit; | ||
985 | +} | ||
986 | +//echo $req->getValue(1);exit; | ||
987 | +ob_clean(); | ||
988 | +$oMap->owsdispatch($req); | ||
989 | +$contenttype = ms_iostripstdoutbuffercontenttype(); | ||
990 | +$buffer = ms_iogetStdoutBufferBytes(); | ||
991 | + | ||
992 | +ms_ioresethandlers(); | ||
993 | +// | ||
994 | +//funções | ||
995 | +// | ||
996 | +function ogc_pegaListaDeMenus(){ | ||
997 | + global $perfil,$locaplic,$urli3geo; | ||
998 | + if(!isset($perfil)){ | ||
999 | + $perfil = ""; | ||
1000 | + } | ||
1001 | + $m = new Menutemas("",$perfil,$locsistemas,$locaplic,"",$urli3geo); | ||
1002 | + foreach($m->pegaListaDeMenus() as $menu) | ||
1003 | + { | ||
1004 | + $menus[] = $urli3geo."/admin/xmlmenutemas.php?id_menu=".$menu["idmenu"]; | ||
1005 | + } | ||
1006 | + return $menus; | ||
1007 | +} | ||
1008 | +function ogc_imprimeAjuda(){ | ||
1009 | + echo "<pre><b>Construtor de web services do I3Geo.</b><br><br>"; | ||
1010 | + echo "Esse programa usa os arquivos mapfiles existentes em <br>"; | ||
1011 | + echo "i3geo/temas para gerar web services OGC.<br>"; | ||
1012 | + echo "Para escolher um tema, utilize:<br>"; | ||
1013 | + echo "ogc.php?lista=temas - para listar os temas disponíveis<br>"; | ||
1014 | + echo "Para usar esse web service voce pode usar o parametro &tema=,<br>"; | ||
1015 | + echo "ou seja,http://[host]/i3geo/ogc.php?tema=[codigo do tema]<br>"; | ||
1016 | + echo "no lugar do codigo pode ser especificado um arquivo mapfile qualquer. "; | ||
1017 | + echo "Nesse caso, deve ser digitado o caminho completo no servidor<br><br>"; | ||
1018 | + echo "Utilize o sistema de administracao do i3Geo para configurar quais os temas da pasta i3geo/temas podem ser utilizados.<br><br>"; | ||
1019 | + echo "Utilize o parametro restauramapa para indicar o ID de um mapa salvo no banco <br>"; | ||
1020 | + echo "de dados de administracao para utiliza-lo como um WMS"; | ||
1021 | +} | ||
1022 | +function ogc_imprimeListaDeTemas(){ | ||
1023 | +} | ||
1024 | +function ogc_imprimeListaDeTemasWfs(){ | ||
1025 | +} | ||
1026 | +function carregaCacheImagem($cachedir,$map,$tms){ | ||
1027 | + global $dir_tmp; | ||
1028 | + if($cachedir == ""){ | ||
1029 | + $nome = $dir_tmp."/cache".$tms; | ||
1030 | + } | ||
1031 | + else{ | ||
1032 | + $nome = $cachedir.$tms; | ||
1033 | + } | ||
1034 | + $nome = str_replace(".png","",$nome).".png"; | ||
1035 | + if(file_exists($nome)){ | ||
1036 | + ob_clean(); | ||
1037 | + //header('Content-Length: '.filesize($nome)); | ||
1038 | + header('Cache: '.$tms); | ||
1039 | + header('Content-Type: image/png'); | ||
1040 | + //header('Cache-Control: max-age=3600, must-revalidate'); | ||
1041 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | ||
1042 | + //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | ||
1043 | + //$etag = md5_file($nome); | ||
1044 | + //header('Etag: '.$etag); | ||
1045 | + readfile($nome); | ||
1046 | + exit; | ||
1047 | + } | ||
1048 | +} | ||
1049 | +function salvaCacheImagem($cachedir,$map,$tms){ | ||
1050 | + global $img,$dir_tmp,$cortePixels; | ||
1051 | + //por seguranca | ||
1052 | + if($cachedir == ""){ | ||
1053 | + $nome = $dir_tmp."/cache".$tms; | ||
1054 | + } | ||
1055 | + else{ | ||
1056 | + $nome = $cachedir.$tms; | ||
1057 | + } | ||
1058 | + $nome = str_replace(".png","",$nome).".png"; | ||
1059 | + if(!file_exists(dirname($nome))){ | ||
1060 | + @mkdir(dirname($nome),0744,true); | ||
1061 | + chmod(dirname($nome),0744); | ||
1062 | + } | ||
1063 | + $img->saveImage($nome); | ||
1064 | + //tenta mais uma vez | ||
1065 | + if(!file_exists($nome)){ | ||
1066 | + $img->saveImage($nome); | ||
1067 | + } | ||
1068 | + // | ||
1069 | + //corta a imagem gerada para voltar ao tamanho normal | ||
1070 | + // | ||
1071 | + if($cortePixels > 0){ | ||
1072 | + $img = imagecreatefrompng($nome); | ||
1073 | + $imgc = imagecreate(256,256); | ||
1074 | + | ||
1075 | + imagesavealpha($imgc, true); | ||
1076 | + // Fill the image with transparent color | ||
1077 | + $color = imagecolorallocatealpha($imgc,0x00,0x00,0x00,127); | ||
1078 | + imagefill($imgc, 0, 0, $color); | ||
1079 | + | ||
1080 | + imagecopy($imgc, $img, 0 , 0 , $cortePixels , $cortePixels , 256, 256); | ||
1081 | + imagepng($imgc,$nome); | ||
1082 | + } | ||
1083 | + chmod($nome,0744); | ||
1084 | + //header('Content-Length: '.filesize($nome)); | ||
1085 | + ob_clean(); | ||
1086 | + header('Content-Type: image/png'); | ||
1087 | + //header('Cache-Control: max-age=3600, must-revalidate'); | ||
1088 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | ||
1089 | + //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | ||
1090 | + readfile($nome); | ||
1091 | + exit; | ||
1092 | +} | ||
1093 | +function texto2iso($texto){ | ||
1094 | + if (function_exists("mb_convert_encoding")){ | ||
1095 | + if (mb_detect_encoding($texto,"UTF-8",true)){ | ||
1096 | + $texto = mb_convert_encoding($texto,"ISO-8859-1","UTF-8"); | ||
1097 | + } | ||
1098 | + } | ||
1099 | + return $texto; | ||
1100 | +} | ||
1101 | +function nomeRand($n=10) | ||
1102 | +{ | ||
1103 | + $nomes = ""; | ||
1104 | + $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
1105 | + $max = 51; | ||
1106 | + for($i=0; $i < $n; ++$i) | ||
1107 | + { | ||
1108 | + $nomes .= $a{mt_rand(0, $max)}; | ||
1109 | + } | ||
1110 | + return $nomes; | ||
1111 | +} | ||
1112 | +function renderNocacheTms(){ | ||
1113 | + global $img,$i3georendermode,$dir_tmp,$cortePixels; | ||
1114 | + if($i3georendermode == 1 && $cortePixels == 0){ | ||
1115 | + ob_clean(); | ||
1116 | + header('Content-Type: image/png'); | ||
1117 | + $img->saveImage(); | ||
1118 | + exit; | ||
1119 | + } | ||
1120 | + if($i3georendermode == 1 && $cortePixels > 0){ | ||
1121 | + $i3georendermode = 0; | ||
1122 | + } | ||
1123 | + $nomer = $dir_tmp."/temp".nomeRand().".png"; | ||
1124 | + $img->saveImage($nomer); | ||
1125 | + // | ||
1126 | + //corta a imagem gerada para voltar ao tamanho normal | ||
1127 | + // | ||
1128 | + if($cortePixels > 0){ | ||
1129 | + $img = imagecreatefrompng($nomer); | ||
1130 | + $imgc = imagecreate(256,256); | ||
1131 | + imagecopy( $imgc, $img, 0 , 0 , $cortePixels , $cortePixels , 256, 256 ); | ||
1132 | + imagepng($imgc,$nomer); | ||
1133 | + } | ||
1134 | + if($i3georendermode == 0 || !isset($i3georendermode)){ | ||
1135 | + ob_clean(); | ||
1136 | + //header('Content-Length: '.filesize($nomer)); | ||
1137 | + header('Content-Type: image/png'); | ||
1138 | + //header('Cache-Control: max-age=3600, must-revalidate'); | ||
1139 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | ||
1140 | + //header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); | ||
1141 | + readfile($nomer); | ||
1142 | + exit; | ||
1143 | + } | ||
1144 | + if($i3georendermode == 2){ | ||
1145 | + ob_clean(); | ||
1146 | + //header('Cache-Control: public, max-age=22222222'); | ||
1147 | + //header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT'); | ||
1148 | + header("X-Sendfile: $nomer"); | ||
1149 | + header("Content-type: image/png"); | ||
1150 | + exit; | ||
1151 | + } | ||
1152 | +} | ||
1153 | +function getfeatureinfoJson(){ | ||
1154 | + global $req, $oMap; | ||
1155 | + $req->setParameter("info_format","application/vnd.ogc.gml"); | ||
1156 | + $oMap->owsdispatch($req); | ||
1157 | + ms_iostripstdoutbuffercontentheaders(); | ||
1158 | + ob_clean(); | ||
1159 | + $r = ms_iogetstdoutbufferstring(); | ||
1160 | + //$r = converteenc($r); | ||
1161 | + $nome = $oMap->getlayer(0)->name; | ||
1162 | + $xml = simplexml_load_string($r); | ||
1163 | + | ||
1164 | + $json = json_encode($xml); | ||
1165 | + $r = json_decode($json,TRUE); | ||
1166 | + $propriedades = $r[$nome."_layer"]; | ||
1167 | + $propriedades = $propriedades[$nome."_feature"]; | ||
1168 | + $propriedades = converteenc(json_encode($propriedades)); | ||
1169 | + $propriedades = json_decode($propriedades); | ||
1170 | + $n = array(); | ||
1171 | + $n[] = array ( | ||
1172 | + "type" => "FeatureCollection", | ||
1173 | + "features" => array( | ||
1174 | + array( | ||
1175 | + "type"=>"Feature", | ||
1176 | + "id" => "", | ||
1177 | + "geometry" => array(), | ||
1178 | + "properties" => array( | ||
1179 | + $propriedades | ||
1180 | + ), | ||
1181 | + "geometry_name" => "" | ||
1182 | + ) | ||
1183 | + ) | ||
1184 | + ); | ||
1185 | + header("Content-type: application/json"); | ||
1186 | + $json = json_encode($n[0]); | ||
1187 | + //verifica a substituicao de alias | ||
1188 | + $itens = $oMap->getlayer(0)->getmetadata("ITENS"); // itens | ||
1189 | + $itensdesc = $oMap->getlayer(0)->getmetadata("ITENSDESC"); // descrição dos itens | ||
1190 | + $itens = explode(",",$itens); | ||
1191 | + $itensdesc = explode(",",converteenc($itensdesc)); | ||
1192 | + $n = count($itens); | ||
1193 | + for($i = 0; $i < $n; $i++){ | ||
1194 | + $json = str_ireplace($itens[$i],$itensdesc[$i],$json); | ||
1195 | + } | ||
1196 | + echo $json; | ||
1197 | +} | ||
1198 | +function processaOutputformatMapfile(){ | ||
1199 | + global $OUTPUTFORMAT, $oMap, $tema, $ows_geomtype; | ||
1200 | + if(strtolower($OUTPUTFORMAT) == "kml"){ | ||
1201 | + $l = $oMap->getlayer(0); | ||
1202 | + $n = $l->name; | ||
1203 | + $oMap->selectOutputFormat("kml"); | ||
1204 | + $oMap->outputformat->setOption("STORAGE", "filesystem"); | ||
1205 | + $oMap->outputformat->setOption("FILENAME", $tema.".kml"); | ||
1206 | + $l->setmetadata("wfs_getfeature_formatlist","kml"); | ||
1207 | + } | ||
1208 | + if(strtolower($OUTPUTFORMAT) == "shape-zip"){ | ||
1209 | + $l = $oMap->getlayer(0); | ||
1210 | + $n = $l->name; | ||
1211 | + $oMap->selectOutputFormat("shape-zip"); | ||
1212 | + $oMap->outputformat->setOption("STORAGE", "filesystem"); | ||
1213 | + $oMap->outputformat->setOption("FORM", "zip"); | ||
1214 | + $oMap->outputformat->setOption("FILENAME", $tema."_shapefile.zip"); | ||
1215 | + $l->setmetadata("wfs_getfeature_formatlist","shape-zip"); | ||
1216 | + } | ||
1217 | + if(strtolower($OUTPUTFORMAT) == "csv"){ | ||
1218 | + $l = $oMap->getlayer(0); | ||
1219 | + $n = $l->name."-csv"; | ||
1220 | + $oMap->selectOutputFormat("csv"); | ||
1221 | + $oMap->outputformat->setOption("STORAGE", "filesystem"); | ||
1222 | + $oMap->outputformat->setOption("FILENAME", $tema.$ows_geomtype.".csv"); | ||
1223 | + $oMap->outputformat->setOption("FORM", "simple"); | ||
1224 | + if(isset($ows_geomtype) && $ows_geomtype != ""){ | ||
1225 | + $oMap->outputformat->setOption("LCO:GEOMETRY", $ows_geomtype); | ||
1226 | + } | ||
1227 | + $l->setmetadata("wfs_getfeature_formatlist","csv"); | ||
1228 | + } | ||
1229 | + if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){ | ||
1230 | + $l = $oMap->getlayer(0); | ||
1231 | + $oMap->selectOutputFormat("geojson"); | ||
1232 | + $l->setmetadata("wfs_getfeature_formatlist","geojson"); | ||
1233 | + } | ||
1234 | +} | ||
1235 | +function carregaCacheArquivo(){ | ||
1236 | + global $dir_tmp, $tema, $OUTPUTFORMAT, $ows_geomtype; | ||
1237 | + if(strtolower($OUTPUTFORMAT) == "shape-zip"){ | ||
1238 | + $arq = $dir_tmp."/".$tema."_shapefile.zip"; | ||
1239 | + if(file_exists($arq)){ | ||
1240 | + header('Content-Disposition: attachment; filename='.$tema.'_shapefile.zip'); | ||
1241 | + readfile($arq); | ||
1242 | + exit; | ||
1243 | + } | ||
1244 | + } | ||
1245 | + if(strtolower($OUTPUTFORMAT) == "csv"){ | ||
1246 | + $arq = $dir_tmp."/".$tema.$ows_geomtype.".csv"; | ||
1247 | + if(file_exists($arq)){ | ||
1248 | + header('Content-Disposition: attachment; filename='.$tema.$ows_geomtype.'.csv'); | ||
1249 | + header("Content-type: text/csv"); | ||
1250 | + readfile($arq); | ||
1251 | + exit; | ||
1252 | + } | ||
1253 | + } | ||
1254 | + if(strtolower($OUTPUTFORMAT) == "kml"){ | ||
1255 | + $arq = $dir_tmp."/".$tema.".kml"; | ||
1256 | + if(file_exists($arq)){ | ||
1257 | + header('Content-Disposition: attachment; filename='.$tema.'.kml'); | ||
1258 | + header("Content-type: application/vnd.google-earth.kml+xml"); | ||
1259 | + readfile($arq); | ||
1260 | + exit; | ||
1261 | + } | ||
1262 | + } | ||
1263 | + if(strtolower($OUTPUTFORMAT) == "kmz"){ | ||
1264 | + $arq = $dir_tmp."/".$tema.".kmz"; | ||
1265 | + if(file_exists($arq)){ | ||
1266 | + header('Content-Disposition: attachment; filename='.$tema.'.kmz'); | ||
1267 | + header("Content-type: application/vnd.google-earth.kmz"); | ||
1268 | + readfile($arq); | ||
1269 | + exit; | ||
1270 | + } | ||
1271 | + } | ||
1272 | + if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){ | ||
1273 | + $arq = $dir_tmp."/".$tema.".json"; | ||
1274 | + if(file_exists($arq)){ | ||
1275 | + header("Content-type: application/json; subtype=geojson"); | ||
1276 | + readfile($arq); | ||
1277 | + exit; | ||
1278 | + } | ||
1279 | + } | ||
1280 | +} | ||
1281 | +function converteenc($texto){ | ||
1282 | + if (!mb_detect_encoding($texto,"UTF-8",true)){ | ||
1283 | + $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1"); | ||
1284 | + } | ||
1285 | + return $texto; | ||
1286 | +} | ||
1287 | +function processaPluginI3geo(){ | ||
1288 | + global $oMap, $locaplic; | ||
1289 | + $numlayers = $oMap->numlayers; | ||
1290 | + for ($i=0;$i < $numlayers;$i++){ | ||
1291 | + $l = $oMap->getlayer($i); | ||
1292 | + $c = $l->getmetadata("PLUGINI3GEO"); | ||
1293 | + if($c != ""){ | ||
1294 | + $cs = json_decode($c,true); | ||
1295 | + if($cs["plugin"] == "parametrossql"){ | ||
1296 | + $data = $l->data; | ||
1297 | + $cs = $cs["parametros"]; | ||
1298 | + $chaves = array(); | ||
1299 | + foreach($cs as $c){ | ||
1300 | + $chaves[] = $c["chave"]; | ||
1301 | + } | ||
1302 | + $chaves = implode(",",$chaves); | ||
1303 | + $filtro = $l->getFilterString(); | ||
1304 | + $chaves = str_ireplace(array(" and ", " or ", "select","from","where","update","delete","insert","--"),"",$chaves); | ||
1305 | + $chaves = explode(",",$chaves); | ||
1306 | + $n = count($chaves); | ||
1307 | + //a variavel $plugin vem da URL e contem os valores | ||
1308 | + //que devem ser substituidos | ||
1309 | + //se $plugin for vazio, usa o primeiro valor definido na configuracao do plugin | ||
1310 | + //A ordem dos valores deve ser exatamente a ordem das chaves | ||
1311 | + if(empty($plugin)){ | ||
1312 | + $plugin = array(); | ||
1313 | + foreach($cs as $c){ | ||
1314 | + if($c["chave"] != ""){ | ||
1315 | + //valores definidos no plugin como uma string | ||
1316 | + if($c["valores"] != ""){ | ||
1317 | + $temp = explode(",",$c["valores"]); | ||
1318 | + $plugin[] = $temp[0]; | ||
1319 | + } | ||
1320 | + elseif ($c["prog"] != ""){ | ||
1321 | + $plugin[] = execProg($c["prog"]); | ||
1322 | + } | ||
1323 | + } | ||
1324 | + } | ||
1325 | + $plugin = implode(",",$plugin); | ||
1326 | + } | ||
1327 | + $l->setmetadata("TEMA",$l->getmetadata("TEMA")." - ".$plugin); | ||
1328 | + $valores = str_ireplace(array(" and ", " or ", "select","from","where","update","delete","insert","--"),"",$plugin); | ||
1329 | + $valores = explode(",",strip_tags($valores)); | ||
1330 | + for($i = 0; $i < $n; $i++){ | ||
1331 | + if($chaves[$i] != ""){ | ||
1332 | + $v = (int) $valores[$i]; | ||
1333 | + $data = str_replace($chaves[$i],$v,$data); | ||
1334 | + if($filtro != ""){ | ||
1335 | + $filtro = str_replace($chaves[$i],$v,$filtro); | ||
1336 | + } | ||
1337 | + } | ||
1338 | + } | ||
1339 | + if($filtro != ""){ | ||
1340 | + $l->setfilter($filtro); | ||
1341 | + } | ||
1342 | + $l->set("data",$data); | ||
1343 | + } | ||
1344 | + } | ||
1345 | + } | ||
1346 | +} | ||
1347 | +function processaEscala(){ | ||
1348 | + global $oMap, $locaplic, $req; | ||
1349 | + $eb = $oMap->scalebar; | ||
1350 | + $eb->set("status",MS_EMBED); | ||
1351 | + if(!empty($_GET["escala_width"])){ | ||
1352 | + $eb->set("width",$_GET["escala_width"]); | ||
1353 | + } | ||
1354 | + if(!empty($_GET["escala_height"])){ | ||
1355 | + $eb->set("height",$_GET["escala_height"]); | ||
1356 | + } | ||
1357 | + //0 ou 1 | ||
1358 | + if(!empty($_GET["escala_style"])){ | ||
1359 | + $eb->set("style",$_GET["escala_style"]); | ||
1360 | + } | ||
1361 | + if(!empty($_GET["escala_intervals"])){ | ||
1362 | + $eb->set("intervals",$_GET["escala_intervals"]); | ||
1363 | + } | ||
1364 | + //MS_INCHES, MS_FEET, MS_MILES, MS_METERS, MS_KILOMETERS, MS_DD, MS_PIXELS, MS_NAUTICALMILES | ||
1365 | + if(!empty($_GET["escala_units"])){ | ||
1366 | + $eb->set("units",$_GET["escala_units"]); | ||
1367 | + } | ||
1368 | + if(!empty($_GET["escala_color"])){ | ||
1369 | + $_GET["escala_color"] = str_replace(","," ",$_GET["escala_color"]); | ||
1370 | + $ncor = explode(" ",$_GET["escala_color"]); | ||
1371 | + $cor = $eb->color; | ||
1372 | + $cor->setRGB($ncor[0],$ncor[1],$ncor[2]); | ||
1373 | + } | ||
1374 | + if(!empty($_GET["escala_backgroundcolor"])){ | ||
1375 | + $_GET["escala_backgroundcolor"] = str_replace(","," ",$_GET["escala_backgroundcolor"]); | ||
1376 | + $ncor = explode(" ",$_GET["escala_backgroundcolor"]); | ||
1377 | + $cor = $eb->backgroundcolor; | ||
1378 | + $cor->setRGB($ncor[0],$ncor[1],$ncor[2]); | ||
1379 | + } | ||
1380 | + if(!empty($_GET["escala_outlinecolor"])){ | ||
1381 | + $_GET["escala_outlinecolor"] = str_replace(","," ",$_GET["escala_outlinecolor"]); | ||
1382 | + $ncor = explode(" ",$_GET["escala_outlinecolor"]); | ||
1383 | + $cor = $eb->outlinecolor; | ||
1384 | + $cor->setRGB($ncor[0],$ncor[1],$ncor[2]); | ||
1385 | + } | ||
1386 | + //ul|uc|ur|ll|lc|lr | ||
1387 | + if(!empty($_GET["escala_position"])){ | ||
1388 | + if($_GET["escala_position"] == "ul") $eb->set("position",MS_UL); | ||
1389 | + if($_GET["escala_position"] == "uc") $eb->set("position",MS_UC); | ||
1390 | + if($_GET["escala_position"] == "ur") $eb->set("position",MS_UR); | ||
1391 | + if($_GET["escala_position"] == "ll") $eb->set("position",MS_LL); | ||
1392 | + if($_GET["escala_position"] == "lc") $eb->set("position",MS_LC); | ||
1393 | + if($_GET["escala_position"] == "lr") $eb->set("position",MS_LR); | ||
1394 | + } | ||
1395 | + //fonte e size so com truetype | ||
1396 | + if (!empty($_GET["escala_font"])){ | ||
1397 | + $label = $eb->label; | ||
1398 | + $label->updatefromstring("LABEL TYPE TRUETYPE END"); | ||
1399 | + $label->set("font",$_GET["escala_font"]); | ||
1400 | + } | ||
1401 | + if (!empty($_GET["escala_size"])){ | ||
1402 | + $label = $eb->label; | ||
1403 | + $label->updatefromstring("LABEL TYPE TRUETYPE END"); | ||
1404 | + if(empty($_GET["escala_size"])){ | ||
1405 | + $label->set("font","arial"); | ||
1406 | + } | ||
1407 | + $label->set("size",$_GET["escala_size"]); | ||
1408 | + } | ||
1409 | +} | ||
1410 | +function processaLegenda(){ | ||
1411 | + global $oMap, $locaplic, $req; | ||
1412 | + $leg = $oMap->legend; | ||
1413 | + $leg->set("status",MS_EMBED); | ||
1414 | + if(!empty($_GET["legenda_imagecolor"])){ | ||
1415 | + $_GET["legenda_imagecolor"] = str_replace(","," ",$_GET["legenda_imagecolor"]); | ||
1416 | + $ncor = explode(" ",$_GET["legenda_imagecolor"]); | ||
1417 | + $cor = $leg->imagecolor; | ||
1418 | + $cor->setRGB($ncor[0],$ncor[1],$ncor[2]); | ||
1419 | + $req->setParameter("TRANSPARENT",0); | ||
1420 | + } | ||
1421 | + if(!empty($_GET["legenda_keysizex"])){ | ||
1422 | + $leg->set("keysizex",$_GET["legenda_keysizex"]); | ||
1423 | + } | ||
1424 | + if(!empty($_GET["legenda_keysizey"])){ | ||
1425 | + $leg->set("keysizey",$_GET["legenda_keysizey"]); | ||
1426 | + } | ||
1427 | + if(!empty($_GET["legenda_keyspacingx"])){ | ||
1428 | + $leg->set("keyspacingx",$_GET["legenda_keyspacingx"]); | ||
1429 | + } | ||
1430 | + //ul|uc|ur|ll|lc|lr | ||
1431 | + if(!empty($_GET["legenda_position"])){ | ||
1432 | + if($_GET["legenda_position"] == "ul") $leg->set("position",MS_UL); | ||
1433 | + if($_GET["legenda_position"] == "uc") $leg->set("position",MS_UC); | ||
1434 | + if($_GET["legenda_position"] == "ur") $leg->set("position",MS_UR); | ||
1435 | + if($_GET["legenda_position"] == "ll") $leg->set("position",MS_LL); | ||
1436 | + if($_GET["legenda_position"] == "lc") $leg->set("position",MS_LC); | ||
1437 | + if($_GET["legenda_position"] == "lr") $leg->set("position",MS_LR); | ||
1438 | + } | ||
1439 | + if(!empty($_GET["legenda_keyspacingy"])){ | ||
1440 | + $leg->set("keyspacingy",$_GET["legenda_keyspacingy"]); | ||
1441 | + } | ||
1442 | + if(!empty($_GET["legenda_outlinecolor"])){ | ||
1443 | + $_GET["legenda_outlinecolor"] = str_replace(","," ",$_GET["legenda_outlinecolor"]); | ||
1444 | + $ncor = explode(" ",$_GET["legenda_outlinecolor"]); | ||
1445 | + $cor = $leg->outlinecolor; | ||
1446 | + $cor->setRGB($ncor[0],$ncor[1],$ncor[2]); | ||
1447 | + } | ||
1448 | + //fonte e size so com truetype | ||
1449 | + if (!empty($_GET["legenda_font"])){ | ||
1450 | + $label = $leg->label; | ||
1451 | + $label->updatefromstring("LABEL TYPE TRUETYPE END"); | ||
1452 | + $label->set("font",$_GET["legenda_font"]); | ||
1453 | + } | ||
1454 | + if (!empty($_GET["legenda_size"])){ | ||
1455 | + $label = $leg->label; | ||
1456 | + $label->updatefromstring("LABEL TYPE TRUETYPE END"); | ||
1457 | + if(empty($_GET["legenda_font"])){ | ||
1458 | + $label->set("font","arial"); | ||
1459 | + } | ||
1460 | + $label->set("size",$_GET["legenda_size"]); | ||
1461 | + } | ||
1462 | +} | ||
1463 | +function processaGrade(){ | ||
1464 | + global $oMap; | ||
1465 | + //veja o mapfile gridg.map em i3geo/temas | ||
1466 | + $layer = $oMap->getlayerbyname("gridg"); | ||
1467 | + if($layer != ""){ | ||
1468 | + if(!empty($_GET["grade_labelformat"])){ | ||
1469 | + $layer->grid->set("labelformat", $_GET["grade_labelformat"]); | ||
1470 | + } | ||
1471 | + if(!empty($_GET["grade_interval"])){ | ||
1472 | + $layer->grid->set("mininterval", $_GET["grade_interval"]); | ||
1473 | + $layer->grid->set("maxinterval", $_GET["grade_interval"]); | ||
1474 | + } | ||
1475 | + $classe = $layer->getclass(0); | ||
1476 | + $estilo = $classe->getstyle(0); | ||
1477 | + $label = $classe->getLabel(0); | ||
1478 | + if(!empty($_GET["grade_position"])){ | ||
1479 | + //("MS_AUTO"=>MS_AUTO,"MS_UL"=>MS_UL,"MS_LR"=>MS_LR,"MS_UR"=>MS_UR,"MS_LL"=>MS_LL, | ||
1480 | + //"MS_CR"=>MS_CR,"MS_CL"=>MS_CL,"MS_UC"=>MS_UC,"MS_LC"=>MS_LC,"MS_CC"=>MS_CC); | ||
1481 | + if($_GET["grade_position"] == "auto") $label->set("position",MS_AUTO); | ||
1482 | + if($_GET["grade_position"] == "cc") $label->set("position",MS_CC); | ||
1483 | + if($_GET["grade_position"] == "ul") $label->set("position",MS_UL); | ||
1484 | + if($_GET["grade_position"] == "uc") $label->set("position",MS_UC); | ||
1485 | + if($_GET["grade_position"] == "ur") $label->set("position",MS_UR); | ||
1486 | + if($_GET["grade_position"] == "ll") $label->set("position",MS_LL); | ||
1487 | + if($_GET["grade_position"] == "lc") $label->set("position",MS_LC); | ||
1488 | + if($_GET["grade_position"] == "lr") $label->set("position",MS_LR); | ||
1489 | + } | ||
1490 | + //fonte e size so com truetype | ||
1491 | + if (!empty($_GET["grade_font"])){ | ||
1492 | + $label->updatefromstring("LABEL TYPE TRUETYPE END"); | ||
1493 | + $label->set("font",$_GET["grade_font"]); | ||
1494 | + } | ||
1495 | + if (!empty($_GET["grade_size"])){ | ||
1496 | + $label->updatefromstring("LABEL TYPE TRUETYPE END"); | ||
1497 | + if(empty($_GET["grade_font"])){ | ||
1498 | + $label->set("font","arial"); | ||
1499 | + } | ||
1500 | + $label->set("size",$_GET["grade_size"]); | ||
1501 | + } | ||
1502 | + if(!empty($_GET["grade_color"])){ | ||
1503 | + $_GET["grade_color"] = str_replace(","," ",$_GET["grade_color"]); | ||
1504 | + $ncor = explode(" ",$_GET["grade_color"]); | ||
1505 | + $cor = $estilo->color; | ||
1506 | + $cor->setRGB($ncor[0],$ncor[1],$ncor[2]); | ||
1507 | + } | ||
1508 | + } | ||
1509 | + else { | ||
1510 | + echo "Layer gridg nao encontrado"; exit; | ||
1511 | + } | ||
1512 | +} | ||
1513 | +//utilizada para obter os dados default quando se utiliza o plugin parametrossql | ||
1514 | +function execProg($prog){ | ||
1515 | + //$retorno variavel deve ser retornada pelo programa $prog | ||
1516 | + //veja como exemplo i3geo/aplicmap/daods/listaano.php | ||
1517 | + global $urli3geo; | ||
1518 | + $handle = curl_init(); | ||
1519 | + curl_setopt( $handle, CURLOPT_URL, $urli3geo."/".$prog); | ||
1520 | + curl_setopt( $handle, CURLOPT_HEADER, false ); | ||
1521 | + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); | ||
1522 | + $str = curl_exec( $handle ); | ||
1523 | + curl_close( $handle ); | ||
1524 | + $retorno = json_decode($str,true); | ||
1525 | + return $retorno[0]["v"]; | ||
1526 | +} | ||
1527 | +?> |
ferramentas/convertews/template_mst.html
1 | -<div style='margin-left: 5px;'> | ||
2 | - <p class='paragrafo'> | ||
3 | - {{{ajudaDesktop}}} <a href='http://www.gvsig.gva.es/' target='blank'> | ||
4 | - gvSig</a> | ||
5 | - <p class='paragrafo'>{{{ajudaWms}}} | ||
6 | - <p class='paragrafo'> | ||
7 | - {{{ajudaWmc}}}<a href='\{{{nomewmc}}}\' target='_blank'>{{{wmc}}}</a> | ||
8 | - <p class='paragrafo'> | 1 | +<div class='container-fluid'> |
2 | + <h5>{{{ajudaDesktop}}}</h5> | ||
3 | + <h5>{{{ajudaWms}}}</h5> | ||
4 | + <h5>{{{ajudaWmc}}}</h5> | ||
5 | + <a href='{{{nomewmc}}}' target='_blank'>{{{wmc}}}</a> | ||
6 | + <h5> | ||
9 | <b>WMS: </b> | 7 | <b>WMS: </b> |
10 | - </p> | ||
11 | - <p class='paragrafo'> | ||
12 | - <textarea cols='55' rows='3' style='cursor: pointer' | ||
13 | - onclick='javascript:this.select()'> | ||
14 | - {{{nomewms}}} </textarea> | ||
15 | - </p> | ||
16 | - <p class='paragrafo'> | ||
17 | - <a | ||
18 | - href='{{{nomewms}}}&request=getcapabilities&version=1.1.0&service=wms' | ||
19 | - target=blank>{{{testa}}}</a><br> | 8 | + </h5> |
9 | + <a href='{{{nomewms}}}' target='_blank'>{{{nomewms}}}</a> | ||
10 | + <br> | ||
11 | + <a href='{{{nomewms}}}&request=getcapabilities&version=1.1.0&service=wms' target=blank>{{{testa}}} GetCapabilities</a> | ||
12 | + <br> | ||
13 | + <a href='{{{nomewms}}}&request=getmap&version=1.1.0&service=wms&WIDTH={{{w}}}&HEIGHT={{{h}}}&BBOX={{{bbox}}}' target=blank>{{{testa}}} getMap</a> | ||
14 | + | ||
20 | </div> | 15 | </div> |
21 | \ No newline at end of file | 16 | \ No newline at end of file |
js/listaDeFerramentas.js
@@ -18,10 +18,6 @@ i3GEO.listaDeFerramentas = { | @@ -18,10 +18,6 @@ i3GEO.listaDeFerramentas = { | ||
18 | descricao: $trad("descArquivos"), | 18 | descricao: $trad("descArquivos"), |
19 | id : "arquivos" | 19 | id : "arquivos" |
20 | }, | 20 | }, |
21 | - //{ | ||
22 | - // nome : $trad("d32"), | ||
23 | - // id : "interface" | ||
24 | - //}, | ||
25 | { | 21 | { |
26 | nome : $trad("operacoesMapaTema"), | 22 | nome : $trad("operacoesMapaTema"), |
27 | descricao: $trad("descOperacoesMapaTema"), | 23 | descricao: $trad("descOperacoesMapaTema"), |
js/mapa.js
@@ -733,11 +733,6 @@ i3GEO.mapa = | @@ -733,11 +733,6 @@ i3GEO.mapa = | ||
733 | * Abre a janela de dialogo da ferramenta convertews | 733 | * Abre a janela de dialogo da ferramenta convertews |
734 | */ | 734 | */ |
735 | convertews : function() { | 735 | convertews : function() { |
736 | - if (i3GEO.parametros.mapfile === "") { | ||
737 | - i3GEO.janela | ||
738 | - .tempoMsg("Essa opcao nao pode ser ativada. Consulte o administrador do sistema. Mapfile nao esta exposto."); | ||
739 | - return; | ||
740 | - } | ||
741 | i3GEO.util.dialogoFerramenta( | 736 | i3GEO.util.dialogoFerramenta( |
742 | "i3GEO.mapa.dialogo.convertews()", | 737 | "i3GEO.mapa.dialogo.convertews()", |
743 | "convertews", | 738 | "convertews", |
@@ -751,10 +746,6 @@ i3GEO.mapa = | @@ -751,10 +746,6 @@ i3GEO.mapa = | ||
751 | * Abre a janela de dialogo da ferramenta convertemapakml | 746 | * Abre a janela de dialogo da ferramenta convertemapakml |
752 | */ | 747 | */ |
753 | convertekml : function() { | 748 | convertekml : function() { |
754 | - if (i3GEO.parametros.mapfile === "") { | ||
755 | - alert("Essa opcao nao pode ser ativada. Consulte o administrador do sistema. Mapfile nao esta exposto."); | ||
756 | - return; | ||
757 | - } | ||
758 | i3GEO.util.dialogoFerramenta( | 749 | i3GEO.util.dialogoFerramenta( |
759 | "i3GEO.mapa.dialogo.convertekml()", | 750 | "i3GEO.mapa.dialogo.convertekml()", |
760 | "convertemapakml", | 751 | "convertemapakml", |
pacotes/yui290/build/container/container_compacto.js
100644 → 100755
pacotes/yui290/build/container/container_core_compacto.js
100644 → 100755
pacotes/yui290/build/utilities/utilities_compacto.js
100644 → 100755