Commit 69e9763f777943b75011cb5c2e3a67b1569c8af7
1 parent
37bc2a44
Exists in
master
and in
7 other branches
--no commit message
Showing
1 changed file
with
176 additions
and
167 deletions
Show diff stats
ogc.php
@@ -89,39 +89,72 @@ if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){ | @@ -89,39 +89,72 @@ if(isset($_GET["outputFormat"]) && $_GET["outputFormat"] != ""){ | ||
89 | if(isset($_GET["outputformat"]) && $_GET["outputformat"] != ""){ | 89 | if(isset($_GET["outputformat"]) && $_GET["outputformat"] != ""){ |
90 | $_GET["OUTPUTFORMAT"] = $_GET["outputformat"]; | 90 | $_GET["OUTPUTFORMAT"] = $_GET["outputformat"]; |
91 | } | 91 | } |
92 | -if(strtolower($OUTPUTFORMAT) == "geojson"){ | ||
93 | - $OUTPUTFORMAT = "json"; | ||
94 | -} | ||
95 | $cache = true; | 92 | $cache = true; |
96 | require_once(dirname(__FILE__)."/classesphp/carrega_ext.php"); | 93 | require_once(dirname(__FILE__)."/classesphp/carrega_ext.php"); |
97 | include(dirname(__FILE__)."/ms_configura.php"); | 94 | include(dirname(__FILE__)."/ms_configura.php"); |
98 | include(dirname(__FILE__)."/classesphp/pega_variaveis.php"); | 95 | include(dirname(__FILE__)."/classesphp/pega_variaveis.php"); |
99 | include(dirname(__FILE__)."/classesphp/funcoes_gerais.php"); | 96 | include(dirname(__FILE__)."/classesphp/funcoes_gerais.php"); |
97 | +// | ||
98 | +//imprime na tela a ajuda | ||
99 | +// | ||
100 | +if(isset($ajuda)){ | ||
101 | + ogc_imprimeAjuda(); | ||
102 | + exit; | ||
103 | +} | ||
104 | +// | ||
105 | +//pega os enderecos para compor a url de chamada do gerador de web services | ||
106 | +// | ||
107 | +$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
108 | +$protocolo = $protocolo[0]; | ||
109 | +$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
110 | +$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
111 | +$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); | ||
112 | +// | ||
113 | +//imprime na tela a lista de temas disponiveis | ||
114 | +// | ||
115 | +if(isset($lista) && $lista == "temas"){ | ||
116 | + include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php"); | ||
117 | + ogc_imprimeListaDeTemas(); | ||
118 | + exit; | ||
119 | +} | ||
120 | +if(isset($lista) && $lista == "temaswfs"){ | ||
121 | + include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php"); | ||
122 | + ogc_imprimeListaDeTemasWfs(); | ||
123 | + exit; | ||
124 | +} | ||
125 | +// | ||
100 | //para o caso da requisicao kml | 126 | //para o caso da requisicao kml |
127 | +// | ||
101 | if(strtolower($OUTPUTFORMAT) == "kml" || strtolower($OUTPUTFORMAT) == "kmz"){ | 128 | if(strtolower($OUTPUTFORMAT) == "kml" || strtolower($OUTPUTFORMAT) == "kmz"){ |
102 | //http://localhost/i3geo/pacotes/kmlmapserver/kmlservice.php?request=kmz&map=_lbiomashp&typename=_lbiomashp | 129 | //http://localhost/i3geo/pacotes/kmlmapserver/kmlservice.php?request=kmz&map=_lbiomashp&typename=_lbiomashp |
103 | - if(!isset($tema) && isset($layers)){ | ||
104 | - $tema = $layers; | ||
105 | - } | ||
106 | - $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; | ||
107 | - header("Location:".$urln); | 130 | + if(!isset($tema) && isset($layers)){ |
131 | + $tema = $layers; | ||
132 | + } | ||
133 | + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; | ||
134 | + header("Location:".$urln); | ||
108 | exit; | 135 | exit; |
109 | } | 136 | } |
110 | - | ||
111 | -//define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos | 137 | +// |
138 | +//trata geojson da mesma forma que json | ||
139 | +// | ||
140 | +if(strtolower($OUTPUTFORMAT) == "geojson"){ | ||
141 | + $OUTPUTFORMAT = "json"; | ||
142 | +} | ||
143 | +// | ||
144 | +//define um nome para o mapfile caso a origem seja o sistema de metadados estatisticos | ||
145 | +// | ||
112 | if(isset($id_medida_variavel)){ | 146 | if(isset($id_medida_variavel)){ |
113 | $tema = "ogcmetaestat".$id_medida_variavel; | 147 | $tema = "ogcmetaestat".$id_medida_variavel; |
114 | $_GET["layers"] = $tema; | 148 | $_GET["layers"] = $tema; |
115 | $_GET["LAYERS"] = $tema; | 149 | $_GET["LAYERS"] = $tema; |
116 | } | 150 | } |
117 | -if(!isset($temas) && isset($tema)){ | ||
118 | - $temas = $tema; | 151 | +if(!isset($tema) && isset($temas)){ |
152 | + $tema = $temas; | ||
119 | } | 153 | } |
120 | if(isset($typeName)){ | 154 | if(isset($typeName)){ |
121 | $typename = $typeName; | 155 | $typename = $typeName; |
122 | } | 156 | } |
123 | -if(!isset($temas) && isset($typename)){ | ||
124 | - $temas = $typename; | 157 | +if(!isset($tema) && isset($typename)){ |
125 | $tema = $typename; | 158 | $tema = $typename; |
126 | } | 159 | } |
127 | // | 160 | // |
@@ -144,8 +177,8 @@ if(!empty($restauramapa)){ | @@ -144,8 +177,8 @@ if(!empty($restauramapa)){ | ||
144 | } | 177 | } |
145 | $m->save($xbase); | 178 | $m->save($xbase); |
146 | //$fundo = $xbase; | 179 | //$fundo = $xbase; |
147 | - $temas = $xbase; | ||
148 | - $_GET["tema"] = $temas; | 180 | + $tema = $xbase; |
181 | + $_GET["tema"] = $xbase; | ||
149 | $_GET["layers"] = ""; | 182 | $_GET["layers"] = ""; |
150 | $l = $m->getlayer(0); | 183 | $l = $m->getlayer(0); |
151 | $_GET["LAYERS"] = $l->name; | 184 | $_GET["LAYERS"] = $l->name; |
@@ -154,11 +187,10 @@ if(!empty($restauramapa)){ | @@ -154,11 +187,10 @@ if(!empty($restauramapa)){ | ||
154 | //para operar como o Geoserver | 187 | //para operar como o Geoserver |
155 | // | 188 | // |
156 | if(isset($format) && strtolower($format) == "application/openlayers"){ | 189 | if(isset($format) && strtolower($format) == "application/openlayers"){ |
157 | - //var_dump($_SERVER);exit; | ||
158 | if(!isset($layers)){ | 190 | if(!isset($layers)){ |
159 | - $layers = $temas; | 191 | + $layers = $tema; |
160 | } | 192 | } |
161 | - $urln = dirname($_SERVER["PHP_SELF"])."/mashups/openlayers.php?temas=".$layers."&layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica"; | 193 | + $urln = diogc_imprimeAjudarname($_SERVER["PHP_SELF"])."/mashups/openlayers.php?temas=".$layers."&layers=".$layers."&mapext=".$bbox."&botoes=pan,zoombox,zoomtot,identifica"; |
162 | //echo $urln;exit; | 194 | //echo $urln;exit; |
163 | if(!headers_sent()){ | 195 | if(!headers_sent()){ |
164 | header("Location:".$urln); | 196 | header("Location:".$urln); |
@@ -168,35 +200,6 @@ if(isset($format) && strtolower($format) == "application/openlayers"){ | @@ -168,35 +200,6 @@ if(isset($format) && strtolower($format) == "application/openlayers"){ | ||
168 | } | 200 | } |
169 | } | 201 | } |
170 | // | 202 | // |
171 | -//pega os endereços para compor a url de chamada do gerador de web services | ||
172 | -//ogc.php | ||
173 | -// | ||
174 | -$protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ||
175 | -$protocolo = $protocolo[0]; | ||
176 | -$protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; | ||
177 | -$protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; | ||
178 | -$urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); | ||
179 | -// | ||
180 | -//imprime na tela a ajuda | ||
181 | -// | ||
182 | -if(isset($ajuda)){ | ||
183 | - ogc_imprimeAjuda(); | ||
184 | - exit; | ||
185 | -} | ||
186 | -// | ||
187 | -//imprime na tela a lista de temas disponíveis | ||
188 | -// | ||
189 | -if(isset($lista) && $lista == "temas"){ | ||
190 | - include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php"); | ||
191 | - ogc_imprimeListaDeTemas(); | ||
192 | - exit; | ||
193 | -} | ||
194 | -if(isset($lista) && $lista == "temaswfs"){ | ||
195 | - include_once(dirname(__FILE__)."/classesphp/classe_menutemas.php"); | ||
196 | - ogc_imprimeListaDeTemasWfs(); | ||
197 | - exit; | ||
198 | -} | ||
199 | -// | ||
200 | //cria o web service | 203 | //cria o web service |
201 | // | 204 | // |
202 | error_reporting(0); | 205 | error_reporting(0); |
@@ -257,7 +260,9 @@ if(!isset($tema)){ | @@ -257,7 +260,9 @@ if(!isset($tema)){ | ||
257 | } | 260 | } |
258 | $tipo = "intervalo"; | 261 | $tipo = "intervalo"; |
259 | } | 262 | } |
263 | +// | ||
260 | //nome do mapfile que ficara em cache | 264 | //nome do mapfile que ficara em cache |
265 | +// | ||
261 | $agora = intval(time() / 1000); | 266 | $agora = intval(time() / 1000); |
262 | //acrescenta ao nome a indicacao do tipo de TMS | 267 | //acrescenta ao nome a indicacao do tipo de TMS |
263 | if(isset($_GET["tms"])){ | 268 | if(isset($_GET["tms"])){ |
@@ -266,7 +271,6 @@ if(isset($_GET["tms"])){ | @@ -266,7 +271,6 @@ if(isset($_GET["tms"])){ | ||
266 | if(isset($_GET["Z"]) && isset($_GET["X"])){ | 271 | if(isset($_GET["Z"]) && isset($_GET["X"])){ |
267 | $agora .= "google"; | 272 | $agora .= "google"; |
268 | } | 273 | } |
269 | - | ||
270 | // | 274 | // |
271 | //se o outputformat for definido, evita o cahce de arquivo | 275 | //se o outputformat for definido, evita o cahce de arquivo |
272 | //o mesmo se existir filtro para o layer | 276 | //o mesmo se existir filtro para o layer |
@@ -473,7 +477,7 @@ else{ | @@ -473,7 +477,7 @@ else{ | ||
473 | $oMap = $gm->addLayers($oMap,$gv,$dataView["layerNames"]); | 477 | $oMap = $gm->addLayers($oMap,$gv,$dataView["layerNames"]); |
474 | } | 478 | } |
475 | $numlayers = $oMap->numlayers; | 479 | $numlayers = $oMap->numlayers; |
476 | - $layers = array(); | 480 | + $lys = array(); |
477 | //$layers[] = "default"; | 481 | //$layers[] = "default"; |
478 | for ($i=0;$i < $numlayers;$i++){ | 482 | for ($i=0;$i < $numlayers;$i++){ |
479 | $l = $oMap->getlayer($i); | 483 | $l = $oMap->getlayer($i); |
@@ -484,7 +488,7 @@ else{ | @@ -484,7 +488,7 @@ else{ | ||
484 | $l->setmetadata("ows_srs",$listaepsg); | 488 | $l->setmetadata("ows_srs",$listaepsg); |
485 | $l->setmetadata("ows_title",$l->getmetadata("TEMA")); | 489 | $l->setmetadata("ows_title",$l->getmetadata("TEMA")); |
486 | $l->set("status",MS_OFF); | 490 | $l->set("status",MS_OFF); |
487 | - $layers[] = $l->name; | 491 | + $lys[] = $l->name; |
488 | if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ | 492 | if(file_exists($locaplic."/temas/miniaturas/".$tx.".map.mini.png")){ |
489 | $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; | 493 | $mini = $proto.$server.dirname($_SERVER['PHP_SELF'])."/temas/miniaturas/".$tx.".map.mini.png"; |
490 | $l->setmetadata("wms_attribution_logourl_format","image/png"); | 494 | $l->setmetadata("wms_attribution_logourl_format","image/png"); |
@@ -511,9 +515,8 @@ else{ | @@ -511,9 +515,8 @@ else{ | ||
511 | $cortePixels = $l->getmetadata("cortepixels"); | 515 | $cortePixels = $l->getmetadata("cortepixels"); |
512 | } | 516 | } |
513 | } | 517 | } |
514 | - $req->setParameter("LAYERS", implode(",",$layers)); | 518 | + $req->setParameter("LAYERS", implode(",",$lys)); |
515 | $req->setParameter("STYLES", ""); | 519 | $req->setParameter("STYLES", ""); |
516 | - //r_dump($req);exit; | ||
517 | } | 520 | } |
518 | } | 521 | } |
519 | } | 522 | } |
@@ -533,10 +536,10 @@ else{ | @@ -533,10 +536,10 @@ else{ | ||
533 | if(strtolower($grupo["ogc"]) == "sim"){ | 536 | if(strtolower($grupo["ogc"]) == "sim"){ |
534 | foreach($grupo["subgrupos"] as $sgrupo){ | 537 | foreach($grupo["subgrupos"] as $sgrupo){ |
535 | if(strtolower($sgrupo["ogc"]) == "sim"){ | 538 | if(strtolower($sgrupo["ogc"]) == "sim"){ |
536 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
537 | - foreach($temas as $tema){ | ||
538 | - if(strtolower($tema["ogc"]) == "sim"){ | ||
539 | - $codigosTema[] = array("tema"=>$tema["tid"],"fonte"=>$tema["link"]); | 539 | + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); |
540 | + foreach($lts as $t){ | ||
541 | + if(strtolower($t["ogc"]) == "sim"){ | ||
542 | + $codigosTema[] = array("tema"=>$t["tid"],"fonte"=>$t["link"]); | ||
540 | } | 543 | } |
541 | } | 544 | } |
542 | } | 545 | } |
@@ -544,10 +547,6 @@ else{ | @@ -544,10 +547,6 @@ else{ | ||
544 | } | 547 | } |
545 | } | 548 | } |
546 | } | 549 | } |
547 | - //echo "<pre>"; | ||
548 | - //var_dump($codigosTema); | ||
549 | - //exit; | ||
550 | - | ||
551 | foreach($codigosTema as $c){ | 550 | foreach($codigosTema as $c){ |
552 | $codigoTema = $c["tema"]; | 551 | $codigoTema = $c["tema"]; |
553 | if(file_exists($locaplic."/temas/".$codigoTema.".map")){ | 552 | if(file_exists($locaplic."/temas/".$codigoTema.".map")){ |
@@ -611,6 +610,13 @@ else{ | @@ -611,6 +610,13 @@ else{ | ||
611 | } | 610 | } |
612 | } | 611 | } |
613 | } | 612 | } |
613 | + // | ||
614 | + //a imagem do mapa recebera a legenda | ||
615 | + // | ||
616 | + if((isset($legenda)) && (strtolower($legenda) == "sim")){ | ||
617 | + $leg = $oMap->legend; | ||
618 | + $leg->set("status",MS_EMBED); | ||
619 | + } | ||
614 | $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); | 620 | $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); |
615 | $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); | 621 | $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); |
616 | $oMap->save($nomeMapfileTmp); | 622 | $oMap->save($nomeMapfileTmp); |
@@ -788,10 +794,10 @@ if(strtolower($req->getValueByName("REQUEST")) == "getlegendgraphic"){ | @@ -788,10 +794,10 @@ if(strtolower($req->getValueByName("REQUEST")) == "getlegendgraphic"){ | ||
788 | if (function_exists("mb_convert_encoding")){ | 794 | if (function_exists("mb_convert_encoding")){ |
789 | $leg = mb_convert_encoding($leg,"UTF-8","ISO-8859-1"); | 795 | $leg = mb_convert_encoding($leg,"UTF-8","ISO-8859-1"); |
790 | } | 796 | } |
791 | - echo $leg;exit; | 797 | + echo $leg; |
798 | + exit; | ||
792 | } | 799 | } |
793 | - } | ||
794 | - | 800 | + } |
795 | } | 801 | } |
796 | if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){ | 802 | if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){ |
797 | $l = $oMap->getlayer(0); | 803 | $l = $oMap->getlayer(0); |
@@ -814,54 +820,16 @@ if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo"){ | @@ -814,54 +820,16 @@ if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo"){ | ||
814 | $_GET["SRS"] = "EPSG:3857"; | 820 | $_GET["SRS"] = "EPSG:3857"; |
815 | } | 821 | } |
816 | } | 822 | } |
817 | -// | ||
818 | -//altera os caminhos das imagens | ||
819 | -// | ||
820 | -if((isset($legenda)) && (strtolower($legenda) == "sim")){ | ||
821 | - $leg = $oMap->legend; | ||
822 | - $leg->set("status",MS_EMBED); | ||
823 | -} | ||
824 | // | 823 | // |
825 | //altera o outputformat | 824 | //altera o outputformat |
826 | // | 825 | // |
827 | if(isset($OUTPUTFORMAT)){ | 826 | if(isset($OUTPUTFORMAT)){ |
828 | - if(strtolower($OUTPUTFORMAT) == "shape-zip"){ | ||
829 | - $l = $oMap->getlayer(0); | ||
830 | - $n = $l->name; | ||
831 | - $oMap->selectOutputFormat("shape-zip"); | ||
832 | - $oMap->outputformat->setOption("STORAGE", "memory"); | ||
833 | - $oMap->outputformat->setOption("FORM", "zip"); | ||
834 | - $oMap->outputformat->setOption("FILENAME", $n.".zip"); | ||
835 | - $l->setmetadata("wfs_getfeature_formatlist","shape-zip"); | ||
836 | - $oMap->save($nomeMapfileTmp); | ||
837 | - if(strtolower($request) != "getcapabilities"){ | ||
838 | - header('Content-Disposition: attachment; filename='.$n.'.zip'); | ||
839 | - } | ||
840 | - } | ||
841 | - if(strtolower($OUTPUTFORMAT) == "csv"){ | ||
842 | - $l = $oMap->getlayer(0); | ||
843 | - $n = $l->name."-csv"; | ||
844 | - $oMap->selectOutputFormat("csv"); | ||
845 | - $oMap->outputformat->setOption("STORAGE", "memory"); | ||
846 | - $oMap->outputformat->setOption("FILENAME", $n.".zip"); | ||
847 | - $oMap->outputformat->setOption("FORM", "zip"); | ||
848 | - $l->setmetadata("wfs_getfeature_formatlist","csv"); | ||
849 | - $oMap->save($nomeMapfileTmp); | ||
850 | - if(strtolower($request) != "getcapabilities"){ | ||
851 | - header('Content-Disposition: attachment; filename='.$n.'.zip'); | ||
852 | - } | ||
853 | - } | ||
854 | - if(strtolower($OUTPUTFORMAT) == "geojson"){ | ||
855 | - $l = $oMap->getlayer(0); | ||
856 | - $oMap->selectOutputFormat("geojson"); | ||
857 | - $l->setmetadata("wfs_getfeature_formatlist","geojson"); | ||
858 | - $oMap->save($nomeMapfileTmp); | ||
859 | - header("Content-type: application/json; subtype=geojson"); | ||
860 | - } | 827 | + processaOutputformatMapfile(); |
861 | } | 828 | } |
862 | ms_ioinstallstdouttobuffer(); | 829 | ms_ioinstallstdouttobuffer(); |
863 | - | ||
864 | -//verifica parametro outputformat | 830 | +// |
831 | +//verifica parametro outputformat e ajusta a requisicao | ||
832 | +// | ||
865 | if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){ | 833 | if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){ |
866 | $req->setParameter("format","image/png"); | 834 | $req->setParameter("format","image/png"); |
867 | } | 835 | } |
@@ -870,54 +838,14 @@ if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["inf | @@ -870,54 +838,14 @@ if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["inf | ||
870 | } | 838 | } |
871 | //json conforme cesium | 839 | //json conforme cesium |
872 | if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){ | 840 | if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){ |
873 | - $req->setParameter("info_format","application/vnd.ogc.gml"); | ||
874 | - $oMap->owsdispatch($req); | ||
875 | - ms_iostripstdoutbuffercontentheaders(); | ||
876 | - ob_clean(); | ||
877 | - $r = ms_iogetstdoutbufferstring(); | ||
878 | - //$r = converteenc($r); | ||
879 | - $nome = $oMap->getlayer(0)->name; | ||
880 | - $xml = simplexml_load_string($r); | ||
881 | - | ||
882 | - $json = json_encode($xml); | ||
883 | - $r = json_decode($json,TRUE); | ||
884 | - $propriedades = $r[$nome."_layer"]; | ||
885 | - $propriedades = $propriedades[$nome."_feature"]; | ||
886 | - $propriedades = converteenc(json_encode($propriedades)); | ||
887 | - $propriedades = json_decode($propriedades); | ||
888 | - $n = array(); | ||
889 | - $n[] = array ( | ||
890 | - "type" => "FeatureCollection", | ||
891 | - "features" => array( | ||
892 | - array( | ||
893 | - "type"=>"Feature", | ||
894 | - "id" => "", | ||
895 | - "geometry" => array(), | ||
896 | - "properties" => array( | ||
897 | - $propriedades | ||
898 | - ), | ||
899 | - "geometry_name" => "" | ||
900 | - ) | ||
901 | - ) | ||
902 | - ); | ||
903 | - header("Content-type: application/json"); | ||
904 | - $json = json_encode($n[0]); | ||
905 | - //verifica a substituicao de alias | ||
906 | - $itens = $oMap->getlayer(0)->getmetadata("ITENS"); // itens | ||
907 | - $itensdesc = $oMap->getlayer(0)->getmetadata("ITENSDESC"); // descrição dos itens | ||
908 | - $itens = explode(",",$itens); | ||
909 | - $itensdesc = explode(",",converteenc($itensdesc)); | ||
910 | - $n = count($itens); | ||
911 | - for($i = 0; $i < $n; $i++){ | ||
912 | - $json = str_ireplace($itens[$i],$itensdesc[$i],$json); | ||
913 | - } | ||
914 | - echo $json; | 841 | + getfeatureinfoJson(); |
915 | exit; | 842 | exit; |
916 | } | 843 | } |
917 | 844 | ||
918 | $oMap->owsdispatch($req); | 845 | $oMap->owsdispatch($req); |
919 | 846 | ||
920 | -$contenttype = ms_iostripstdoutbuffercontenttype(); | 847 | +$contenttype = ms_iostripstdoutbuffercontenttype(); |
848 | + | ||
921 | if(strtolower($request) == "getcapabilities"){ | 849 | if(strtolower($request) == "getcapabilities"){ |
922 | header('Content-Disposition: attachment; filename=getcapabilities.xml'); | 850 | header('Content-Disposition: attachment; filename=getcapabilities.xml'); |
923 | } | 851 | } |
@@ -975,17 +903,17 @@ function ogc_imprimeListaDeTemas(){ | @@ -975,17 +903,17 @@ function ogc_imprimeListaDeTemas(){ | ||
975 | foreach($grupo["subgrupos"] as $sgrupo){ | 903 | foreach($grupo["subgrupos"] as $sgrupo){ |
976 | if(strtolower($sgrupo["ogc"]) == "sim"){ | 904 | if(strtolower($sgrupo["ogc"]) == "sim"){ |
977 | $imprimesubgrupo = $sgrupo["nome"]; | 905 | $imprimesubgrupo = $sgrupo["nome"]; |
978 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
979 | - foreach($temas as $tema){ | ||
980 | - if(strtolower($tema["ogc"]) == "sim"){ | 906 | + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); |
907 | + foreach($lts as $t){ | ||
908 | + if(strtolower($t["ogc"]) == "sim"){ | ||
981 | $imprimir .= texto2iso($imprimegrupo)."->".texto2iso($imprimesubgrupo)."<br>"; | 909 | $imprimir .= texto2iso($imprimegrupo)."->".texto2iso($imprimesubgrupo)."<br>"; |
982 | $imprimir .= " "; | 910 | $imprimir .= " "; |
983 | - $imprimir .= "<span style=color:red >".$tema["tid"]."</span>"; | ||
984 | - $imprimir .= " - ".texto2iso($tema["nome"])." "; | ||
985 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wms&request=getcapabilities' >Getcapabilities</a>"; | ||
986 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=".$tema["tid"]."' >GetMap </a>"; | ||
987 | - if($tema["link"] != " ") | ||
988 | - $imprimir .= " <a href='".$tema["link"]."' >fonte</a>"; | 911 | + $imprimir .= "<span style=color:red >".$t["tid"]."</span>"; |
912 | + $imprimir .= " - ".texto2iso($t["nome"])." "; | ||
913 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&service=wms&request=getcapabilities' >Getcapabilities</a>"; | ||
914 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=".$t["tid"]."' >GetMap </a>"; | ||
915 | + if($t["link"] != " ") | ||
916 | + $imprimir .= " <a href='".$t["link"]."' >fonte</a>"; | ||
989 | $imprimir .= "<br>"; | 917 | $imprimir .= "<br>"; |
990 | } | 918 | } |
991 | } | 919 | } |
@@ -1011,17 +939,17 @@ function ogc_imprimeListaDeTemasWfs(){ | @@ -1011,17 +939,17 @@ function ogc_imprimeListaDeTemasWfs(){ | ||
1011 | foreach($grupo["subgrupos"] as $sgrupo){ | 939 | foreach($grupo["subgrupos"] as $sgrupo){ |
1012 | if(strtolower($sgrupo["ogc"]) == "sim"){ | 940 | if(strtolower($sgrupo["ogc"]) == "sim"){ |
1013 | $imprimesubgrupo = $sgrupo["nome"]; | 941 | $imprimesubgrupo = $sgrupo["nome"]; |
1014 | - $temas = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); | ||
1015 | - foreach($temas as $tema){ | ||
1016 | - if(strtolower($tema["ogc"]) == "sim" && strtolower($tema["down"]) !== "nao"){ | 942 | + $lts = $m->pegaListaDeTemas($grupo["id_n1"],$sgrupo["id_n2"],$menu["idmenu"]); |
943 | + foreach($lts as $t){ | ||
944 | + if(strtolower($t["ogc"]) == "sim" && strtolower($t["down"]) !== "nao"){ | ||
1017 | $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; | 945 | $imprimir .= $imprimegrupo."->".$imprimesubgrupo."<br>"; |
1018 | $imprimir .= " "; | 946 | $imprimir .= " "; |
1019 | - $imprimir .= "<span style=color:red >".$tema["tid"]."</span>"; | ||
1020 | - $imprimir .= " - ".$tema["nome"]." "; | ||
1021 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&service=wfs&request=getcapabilities' >Getcapabilities</a>"; | ||
1022 | - $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$tema["tid"]."&SRS=EPSG:4618&service=wfs&version=1.1.0&request=getfeature&typename=".$tema["tid"]."' >Getfeature </a>"; | ||
1023 | - if($tema["link"] != " ") | ||
1024 | - $imprimir .= " <a href='".$tema["link"]."' >fonte</a>"; | 947 | + $imprimir .= "<span style=color:red >".$t["tid"]."</span>"; |
948 | + $imprimir .= " - ".$t["nome"]." "; | ||
949 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&service=wfs&request=getcapabilities' >Getcapabilities</a>"; | ||
950 | + $imprimir .= " <a href='".$urli3geo."/ogc.php?tema=".$t["tid"]."&SRS=EPSG:4618&service=wfs&version=1.1.0&request=getfeature&typename=".$t["tid"]."' >Getfeature </a>"; | ||
951 | + if($t["link"] != " ") | ||
952 | + $imprimir .= " <a href='".$t["link"]."' >fonte</a>"; | ||
1025 | $imprimir .= "<br>"; | 953 | $imprimir .= "<br>"; |
1026 | } | 954 | } |
1027 | } | 955 | } |
@@ -1145,6 +1073,87 @@ function renderNocacheTms(){ | @@ -1145,6 +1073,87 @@ function renderNocacheTms(){ | ||
1145 | header("Content-type: image/png"); | 1073 | header("Content-type: image/png"); |
1146 | } | 1074 | } |
1147 | } | 1075 | } |
1076 | +function getfeatureinfoJson(){ | ||
1077 | + global $req, $oMap; | ||
1078 | + $req->setParameter("info_format","application/vnd.ogc.gml"); | ||
1079 | + $oMap->owsdispatch($req); | ||
1080 | + ms_iostripstdoutbuffercontentheaders(); | ||
1081 | + ob_clean(); | ||
1082 | + $r = ms_iogetstdoutbufferstring(); | ||
1083 | + //$r = converteenc($r); | ||
1084 | + $nome = $oMap->getlayer(0)->name; | ||
1085 | + $xml = simplexml_load_string($r); | ||
1086 | + | ||
1087 | + $json = json_encode($xml); | ||
1088 | + $r = json_decode($json,TRUE); | ||
1089 | + $propriedades = $r[$nome."_layer"]; | ||
1090 | + $propriedades = $propriedades[$nome."_feature"]; | ||
1091 | + $propriedades = converteenc(json_encode($propriedades)); | ||
1092 | + $propriedades = json_decode($propriedades); | ||
1093 | + $n = array(); | ||
1094 | + $n[] = array ( | ||
1095 | + "type" => "FeatureCollection", | ||
1096 | + "features" => array( | ||
1097 | + array( | ||
1098 | + "type"=>"Feature", | ||
1099 | + "id" => "", | ||
1100 | + "geometry" => array(), | ||
1101 | + "properties" => array( | ||
1102 | + $propriedades | ||
1103 | + ), | ||
1104 | + "geometry_name" => "" | ||
1105 | + ) | ||
1106 | + ) | ||
1107 | + ); | ||
1108 | + header("Content-type: application/json"); | ||
1109 | + $json = json_encode($n[0]); | ||
1110 | + //verifica a substituicao de alias | ||
1111 | + $itens = $oMap->getlayer(0)->getmetadata("ITENS"); // itens | ||
1112 | + $itensdesc = $oMap->getlayer(0)->getmetadata("ITENSDESC"); // descrição dos itens | ||
1113 | + $itens = explode(",",$itens); | ||
1114 | + $itensdesc = explode(",",converteenc($itensdesc)); | ||
1115 | + $n = count($itens); | ||
1116 | + for($i = 0; $i < $n; $i++){ | ||
1117 | + $json = str_ireplace($itens[$i],$itensdesc[$i],$json); | ||
1118 | + } | ||
1119 | + echo $json; | ||
1120 | +} | ||
1121 | +function processaOutputformatMapfile(){ | ||
1122 | + global $OUTPUTFORMAT, $oMap; | ||
1123 | + if(strtolower($OUTPUTFORMAT) == "shape-zip"){ | ||
1124 | + $l = $oMap->getlayer(0); | ||
1125 | + $n = $l->name; | ||
1126 | + $oMap->selectOutputFormat("shape-zip"); | ||
1127 | + $oMap->outputformat->setOption("STORAGE", "memory"); | ||
1128 | + $oMap->outputformat->setOption("FORM", "zip"); | ||
1129 | + $oMap->outputformat->setOption("FILENAME", $n.".zip"); | ||
1130 | + $l->setmetadata("wfs_getfeature_formatlist","shape-zip"); | ||
1131 | + $oMap->save($nomeMapfileTmp); | ||
1132 | + if(strtolower($request) != "getcapabilities"){ | ||
1133 | + header('Content-Disposition: attachment; filename='.$n.'.zip'); | ||
1134 | + } | ||
1135 | + } | ||
1136 | + if(strtolower($OUTPUTFORMAT) == "csv"){ | ||
1137 | + $l = $oMap->getlayer(0); | ||
1138 | + $n = $l->name."-csv"; | ||
1139 | + $oMap->selectOutputFormat("csv"); | ||
1140 | + $oMap->outputformat->setOption("STORAGE", "memory"); | ||
1141 | + $oMap->outputformat->setOption("FILENAME", $n.".zip"); | ||
1142 | + $oMap->outputformat->setOption("FORM", "zip"); | ||
1143 | + $l->setmetadata("wfs_getfeature_formatlist","csv"); | ||
1144 | + $oMap->save($nomeMapfileTmp); | ||
1145 | + if(strtolower($request) != "getcapabilities"){ | ||
1146 | + header('Content-Disposition: attachment; filename='.$n.'.zip'); | ||
1147 | + } | ||
1148 | + } | ||
1149 | + if(strtolower($OUTPUTFORMAT) == "geojson"){ | ||
1150 | + $l = $oMap->getlayer(0); | ||
1151 | + $oMap->selectOutputFormat("geojson"); | ||
1152 | + $l->setmetadata("wfs_getfeature_formatlist","geojson"); | ||
1153 | + $oMap->save($nomeMapfileTmp); | ||
1154 | + header("Content-type: application/json; subtype=geojson"); | ||
1155 | + } | ||
1156 | +} | ||
1148 | function converteenc($texto){ | 1157 | function converteenc($texto){ |
1149 | if (!mb_detect_encoding($texto,"UTF-8",true)){ | 1158 | if (!mb_detect_encoding($texto,"UTF-8",true)){ |
1150 | $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1"); | 1159 | $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1"); |