Commit 5d3989bc6bdefafcddfd2d406a3c12f26d751099
1 parent
136732c7
Exists in
master
Atualização do código
Showing
4 changed files
with
85 additions
and
46 deletions
Show diff stats
classesphp/classe_selecao.php
@@ -99,6 +99,8 @@ $ext - extensão geográfica do mapa | @@ -99,6 +99,8 @@ $ext - extensão geográfica do mapa | ||
99 | function __construct($map_file,$tema="",$ext="") | 99 | function __construct($map_file,$tema="",$ext="") |
100 | { | 100 | { |
101 | include_once(dirname(__FILE__)."/funcoes_gerais.php"); | 101 | include_once(dirname(__FILE__)."/funcoes_gerais.php"); |
102 | + include(dirname(__FILE__)."/../ms_configura.php"); | ||
103 | + $this->postgis_mapa = $postgis_mapa; | ||
102 | $this->v = versao(); | 104 | $this->v = versao(); |
103 | $this->v = $this->v["principal"]; | 105 | $this->v = $this->v["principal"]; |
104 | $this->qyfile = str_replace(".map",".qy",$map_file); | 106 | $this->qyfile = str_replace(".map",".qy",$map_file); |
@@ -108,7 +110,10 @@ $ext - extensão geográfica do mapa | @@ -108,7 +110,10 @@ $ext - extensão geográfica do mapa | ||
108 | else{ | 110 | else{ |
109 | $this->qyfileTema = ""; | 111 | $this->qyfileTema = ""; |
110 | } | 112 | } |
113 | + | ||
111 | $this->mapa = ms_newMapObj($map_file); | 114 | $this->mapa = ms_newMapObj($map_file); |
115 | + substituiConObj($this->mapa,$postgis_mapa); | ||
116 | + | ||
112 | $this->arquivo = str_replace(".map","",$map_file).".map"; | 117 | $this->arquivo = str_replace(".map","",$map_file).".map"; |
113 | if($tema != "" && @$this->mapa->getlayerbyname($tema)) | 118 | if($tema != "" && @$this->mapa->getlayerbyname($tema)) |
114 | $this->layer = $this->mapa->getlayerbyname($tema); | 119 | $this->layer = $this->mapa->getlayerbyname($tema); |
@@ -134,13 +139,12 @@ function: salva | @@ -134,13 +139,12 @@ function: salva | ||
134 | 139 | ||
135 | Salva o mapfile atual | 140 | Salva o mapfile atual |
136 | */ | 141 | */ |
137 | - function salva() | ||
138 | - { | ||
139 | - if($this->mapa->getmetadata("interface") == "googlemaps") | ||
140 | - {$this->mapa->setProjection($this->projO);} | 142 | + function salva(){ |
143 | + if($this->mapa->getmetadata("interface") == "googlemaps"){ | ||
144 | + $this->mapa->setProjection($this->projO); | ||
145 | + } | ||
141 | $this->mapa->save($this->arquivo); | 146 | $this->mapa->save($this->arquivo); |
142 | - include(dirname(__FILE__)."/../ms_configura.php"); | ||
143 | - restauraCon($this->arquivo,$postgis_mapa); | 147 | + restauraCon($this->arquivo,$this->postgis_mapa); |
144 | } | 148 | } |
145 | /* | 149 | /* |
146 | function: nSel | 150 | function: nSel |
@@ -165,7 +169,7 @@ $ys - lista de coordenadas y separadas por virgula | @@ -165,7 +169,7 @@ $ys - lista de coordenadas y separadas por virgula | ||
165 | 169 | ||
166 | $wkt - string wkt opcional ao uso de xs e ys | 170 | $wkt - string wkt opcional ao uso de xs e ys |
167 | 171 | ||
168 | -$buffer - buffer que será aplicado | 172 | +$buffer - buffer que ser� aplicado |
169 | */ | 173 | */ |
170 | function selecaoPorPoligono($tipo,$xs="",$ys="",$wkt="",$buffer=0) | 174 | function selecaoPorPoligono($tipo,$xs="",$ys="",$wkt="",$buffer=0) |
171 | { | 175 | { |
@@ -730,10 +734,10 @@ $shp_atual - Indices dos elementos já selecionados. | @@ -730,10 +734,10 @@ $shp_atual - Indices dos elementos já selecionados. | ||
730 | $indxlayer = $this->layer->index; | 734 | $indxlayer = $this->layer->index; |
731 | $shp = array_merge($shpi,$shp_atual); | 735 | $shp = array_merge($shpi,$shp_atual); |
732 | $shp = array_unique($shp); | 736 | $shp = array_unique($shp); |
737 | + | ||
733 | $this->mapa->freequery($indxlayer); | 738 | $this->mapa->freequery($indxlayer); |
734 | foreach ($shp as $indx) | 739 | foreach ($shp as $indx) |
735 | {@$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | 740 | {@$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} |
736 | - //echo $this->layer->getNumresults(); | ||
737 | $this->mapa->savequery($this->qyfile); | 741 | $this->mapa->savequery($this->qyfile); |
738 | $this->serializeQ($this->qyfileTema,$shp); | 742 | $this->serializeQ($this->qyfileTema,$shp); |
739 | return("ok"); | 743 | return("ok"); |
@@ -891,58 +895,53 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo | @@ -891,58 +895,53 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo | ||
891 | 895 | ||
892 | $ext - coordenadas separadas por espaços no estilo xmin ymin xmax ymax | 896 | $ext - coordenadas separadas por espaços no estilo xmin ymin xmax ymax |
893 | */ | 897 | */ |
894 | - function selecaoBOX($tipo,$ext) | ||
895 | - { | ||
896 | - if ($tipo == "novo") | ||
897 | - { | 898 | + function selecaoBOX($tipo,$ext) { |
899 | + if ($tipo == "novo"){ | ||
898 | $this->selecaoLimpa(); | 900 | $this->selecaoLimpa(); |
899 | $tipo = "adiciona"; | 901 | $tipo = "adiciona"; |
900 | } | 902 | } |
901 | - if(!$this->layer){return "erro";} | 903 | + if(!$this->layer){ |
904 | + return "erro"; | ||
905 | + } | ||
902 | $this->layer->set("tolerance",0); | 906 | $this->layer->set("tolerance",0); |
903 | - if ($tipo == "limpa") | ||
904 | - {return ($this->selecaoLimpa());} | ||
905 | - if ($tipo == "inverte") | ||
906 | - {return ($this->selecaoInverte());} | ||
907 | - if (file_exists($this->qyfile)) | ||
908 | - {$this->mapa->loadquery($this->qyfile);} | 907 | + if ($tipo == "limpa"){ |
908 | + return ($this->selecaoLimpa()); | ||
909 | + } | ||
910 | + if ($tipo == "inverte") { | ||
911 | + return ($this->selecaoInverte()); | ||
912 | + } | ||
913 | + if (file_exists($this->qyfile)) { | ||
914 | + $this->mapa->loadquery($this->qyfile); | ||
915 | + } | ||
909 | $indxlayer = $this->layer->index; | 916 | $indxlayer = $this->layer->index; |
910 | - /* | ||
911 | - $res_count = $this->layer->getNumresults(); | ||
912 | $shp_atual = array(); | 917 | $shp_atual = array(); |
913 | - for ($i = 0; $i < $res_count;++$i) | ||
914 | - { | ||
915 | - $rc = $this->layer->getResult($i); | ||
916 | - $shp_atual[] = $rc->shapeindex; | 918 | + if($this->qyfileTema != "" && file_exists($this->qyfileTema)) { |
919 | + $shp_atual = $this->unserializeQ($this->qyfileTema); | ||
917 | } | 920 | } |
918 | - $this->mapa->freequery($indxlayer); | ||
919 | - */ | ||
920 | - $shp_atual = array(); | ||
921 | - if($this->qyfileTema != "" && file_exists($this->qyfileTema)) | ||
922 | - {$shp_atual = $this->unserializeQ($this->qyfileTema);} | ||
923 | 921 | ||
924 | $shpi = array(); | 922 | $shpi = array(); |
925 | $temp = explode(" ",$ext); | 923 | $temp = explode(" ",$ext); |
926 | $rect = ms_newRectObj(); | 924 | $rect = ms_newRectObj(); |
925 | + | ||
927 | $rect->set("minx",(min(array($temp[0],$temp[2])))); | 926 | $rect->set("minx",(min(array($temp[0],$temp[2])))); |
928 | $rect->set("miny",(min(array($temp[1],$temp[3])))); | 927 | $rect->set("miny",(min(array($temp[1],$temp[3])))); |
929 | $rect->set("maxx",(max(array($temp[0],$temp[2])))); | 928 | $rect->set("maxx",(max(array($temp[0],$temp[2])))); |
930 | $rect->set("maxy",(max(array($temp[1],$temp[3])))); | 929 | $rect->set("maxy",(max(array($temp[1],$temp[3])))); |
931 | $ident = $this->layer->queryByRect($rect); | 930 | $ident = $this->layer->queryByRect($rect); |
932 | - if ($ident != 1) | ||
933 | - { | 931 | + if ($ident != 1){ |
934 | $res_count = $this->layer->getNumresults(); | 932 | $res_count = $this->layer->getNumresults(); |
935 | $shpi = array(); | 933 | $shpi = array(); |
936 | - for ($i = 0; $i < $res_count; ++$i) | ||
937 | - { | 934 | + for ($i = 0; $i < $res_count; ++$i) { |
938 | $result = $this->layer->getResult($i); | 935 | $result = $this->layer->getResult($i); |
939 | $shpi[] = $result->shapeindex; | 936 | $shpi[] = $result->shapeindex; |
940 | } | 937 | } |
941 | } | 938 | } |
942 | - if ($tipo == "adiciona") | ||
943 | - {return($this->selecaoAdiciona($shpi,$shp_atual));} | ||
944 | - if ($tipo == "retira") | ||
945 | - {return($this->selecaoRetira($shpi,$shp_atual));} | 939 | + if ($tipo == "adiciona"){ |
940 | + return($this->selecaoAdiciona($shpi,$shp_atual)); | ||
941 | + } | ||
942 | + if ($tipo == "retira"){ | ||
943 | + return($this->selecaoRetira($shpi,$shp_atual)); | ||
944 | + } | ||
946 | } | 945 | } |
947 | /* | 946 | /* |
948 | function unserializeQ | 947 | function unserializeQ |
classesphp/funcoes_gerais.php
@@ -570,6 +570,36 @@ function substituiCon($map_file,$postgis_mapa) | @@ -570,6 +570,36 @@ function substituiCon($map_file,$postgis_mapa) | ||
570 | } | 570 | } |
571 | return true; | 571 | return true; |
572 | } | 572 | } |
573 | +function substituiConObj($objMap,$postgis_mapa){ | ||
574 | + error_reporting(0); | ||
575 | + if (!empty($postgis_mapa)){ | ||
576 | + $numlayers = $objMap->numlayers; | ||
577 | + for ($i=0;$i < $numlayers;++$i) | ||
578 | + { | ||
579 | + $layer = $objMap->getlayer($i); | ||
580 | + if ($layer->connectiontype == MS_POSTGIS) | ||
581 | + { | ||
582 | + $lcon = $layer->connection; | ||
583 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | ||
584 | + { | ||
585 | + // | ||
586 | + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | ||
587 | + // | ||
588 | + if(($lcon == " ") || ($lcon == "")) | ||
589 | + { | ||
590 | + $layer->set("connection",$postgis_mapa); | ||
591 | + $layer->setmetadata("CONEXAOORIGINAL",$lcon); | ||
592 | + } | ||
593 | + else | ||
594 | + { | ||
595 | + $layer->set("connection",$postgis_mapa[$lcon]); | ||
596 | + $layer->setmetadata("CONEXAOORIGINAL",$lcon); | ||
597 | + } | ||
598 | + } | ||
599 | + } | ||
600 | + } | ||
601 | + } | ||
602 | +} | ||
573 | /* | 603 | /* |
574 | Function: restauraCon | 604 | Function: restauraCon |
575 | 605 |
ferramentas/parametrossql/ogc.php
@@ -9,13 +9,16 @@ A diferenca e que esse servico processa o parametro "plugin", aplicando os filtr | @@ -9,13 +9,16 @@ A diferenca e que esse servico processa o parametro "plugin", aplicando os filtr | ||
9 | no plugin parametrossql | 9 | no plugin parametrossql |
10 | */ | 10 | */ |
11 | $cache = true; | 11 | $cache = true; |
12 | -require_once(dirname(__FILE__)."/../../classesphp/carrega_ext.php"); | 12 | +include(dirname(__FILE__)."/classesphp/sani_request.php"); |
13 | include(dirname(__FILE__)."/../../ms_configura.php"); | 13 | include(dirname(__FILE__)."/../../ms_configura.php"); |
14 | -include(dirname(__FILE__)."/../../classesphp/pega_variaveis.php"); | ||
15 | include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php"); | 14 | include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php"); |
15 | +$_GET = array_merge($_GET,$_POST); | ||
16 | $projDefault = pegaProjecaoDefault(); | 16 | $projDefault = pegaProjecaoDefault(); |
17 | 17 | ||
18 | -$temas = $tema; | 18 | +$tema = basename($_GET["tema"]); |
19 | +if($tema == ""){ | ||
20 | + exit; | ||
21 | +} | ||
19 | if(isset($_GET["sld"]) || isset($_GET["filter"])){ | 22 | if(isset($_GET["sld"]) || isset($_GET["filter"])){ |
20 | $cache = false; | 23 | $cache = false; |
21 | } | 24 | } |
@@ -41,7 +44,7 @@ if($_GET["SRS"] == "EPSG:900913"){ | @@ -41,7 +44,7 @@ if($_GET["SRS"] == "EPSG:900913"){ | ||
41 | $_GET["SRS"] = "EPSG:3857"; | 44 | $_GET["SRS"] = "EPSG:3857"; |
42 | } | 45 | } |
43 | $req = ms_newowsrequestobj(); | 46 | $req = ms_newowsrequestobj(); |
44 | -$_GET = array_merge($_GET,$_POST); | 47 | + |
45 | if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){ | 48 | if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){ |
46 | $_GET["srs"] = "EPSG:".$projDefault["epsg"]; | 49 | $_GET["srs"] = "EPSG:".$projDefault["epsg"]; |
47 | } | 50 | } |
@@ -72,13 +75,14 @@ $agora = intval(time() / 1000); | @@ -72,13 +75,14 @@ $agora = intval(time() / 1000); | ||
72 | if(isset($_GET["Z"]) && isset($_GET["X"])){ | 75 | if(isset($_GET["Z"]) && isset($_GET["X"])){ |
73 | $agora .= "google"; | 76 | $agora .= "google"; |
74 | } | 77 | } |
75 | -$nomeMapfileTmp = $dir_tmp."/ogc_".md5($tema.$plugin.($req->getValueByName("SRS")))."_".$agora.".map"; | 78 | +$nomeMapfileTmp = $dir_tmp."/ogcpsql_".md5($tema.$plugin.($req->getValueByName("SRS")))."_".$agora.".map"; |
76 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); | 79 | $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp); |
77 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); | 80 | $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); |
78 | //essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao | 81 | //essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao |
79 | $cortePixels = 0; | 82 | $cortePixels = 0; |
80 | if(file_exists($nomeMapfileTmp)){ | 83 | if(file_exists($nomeMapfileTmp)){ |
81 | $oMap = ms_newMapobj($nomeMapfileTmp); | 84 | $oMap = ms_newMapobj($nomeMapfileTmp); |
85 | + substituiConObj($oMap,$postgis_mapa); | ||
82 | } | 86 | } |
83 | else{ | 87 | else{ |
84 | if(empty($ogcwsmap)){ | 88 | if(empty($ogcwsmap)){ |
@@ -218,12 +222,15 @@ else{ | @@ -218,12 +222,15 @@ else{ | ||
218 | 222 | ||
219 | $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); | 223 | $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); |
220 | $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); | 224 | $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); |
225 | + $nomeMapfileTmp = str_replace(".map","",$nomeMapfileTmp).".map"; | ||
221 | $oMap->save($nomeMapfileTmp); | 226 | $oMap->save($nomeMapfileTmp); |
227 | + | ||
222 | $oMap = ms_newMapobj($nomeMapfileTmp); | 228 | $oMap = ms_newMapobj($nomeMapfileTmp); |
223 | } | 229 | } |
224 | if(ob_get_contents ()){ | 230 | if(ob_get_contents ()){ |
225 | ob_end_clean(); | 231 | ob_end_clean(); |
226 | } | 232 | } |
233 | +restauraCon($nomeMapfileTmp,$postgis_mapa); | ||
227 | // | 234 | // |
228 | //verifica se a requisicao e do tipo TMS. | 235 | //verifica se a requisicao e do tipo TMS. |
229 | // | 236 | // |
@@ -570,6 +577,8 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){ | @@ -570,6 +577,8 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){ | ||
570 | exit; | 577 | exit; |
571 | } | 578 | } |
572 | function execProg($prog){ | 579 | function execProg($prog){ |
580 | + $prog = str_replace(".php","",$prog); | ||
581 | + $prog = str_replace(".","",$prog).".php"; | ||
573 | include($prog); | 582 | include($prog); |
574 | //$retorno variavel deve ser retornada pelo programa $prog | 583 | //$retorno variavel deve ser retornada pelo programa $prog |
575 | //veja como exemplo i3geo/aplicmap/daods/listaano.php | 584 | //veja como exemplo i3geo/aplicmap/daods/listaano.php |
ogc.php
@@ -371,9 +371,11 @@ $cortePixels = 0; | @@ -371,9 +371,11 @@ $cortePixels = 0; | ||
371 | $ogcwsmap = $_GET["ogcwsmap"]; | 371 | $ogcwsmap = $_GET["ogcwsmap"]; |
372 | 372 | ||
373 | if(file_exists($nomeMapfileTmp) && $tipo == ""){ | 373 | if(file_exists($nomeMapfileTmp) && $tipo == ""){ |
374 | - substituiCon($nomeMapfileTmp,$postgis_mapa); | 374 | + //substituiCon($nomeMapfileTmp,$postgis_mapa); |
375 | + //$oMap = ms_newMapobj($nomeMapfileTmp); | ||
376 | + //restauraCon($nomeMapfileTmp,$postgis_mapa); | ||
375 | $oMap = ms_newMapobj($nomeMapfileTmp); | 377 | $oMap = ms_newMapobj($nomeMapfileTmp); |
376 | - restauraCon($nomeMapfileTmp,$postgis_mapa); | 378 | + substituiConObj($oMap,$postgis_mapa); |
377 | } | 379 | } |
378 | else{ | 380 | else{ |
379 | if(empty($ogcwsmap)){ | 381 | if(empty($ogcwsmap)){ |
@@ -764,7 +766,6 @@ else{ | @@ -764,7 +766,6 @@ else{ | ||
764 | $oMap->save($nomeMapfileTmp); | 766 | $oMap->save($nomeMapfileTmp); |
765 | validaAcessoTemas($nomeMapfileTmp,true); | 767 | validaAcessoTemas($nomeMapfileTmp,true); |
766 | 768 | ||
767 | - | ||
768 | substituiCon($nomeMapfileTmp,$postgis_mapa); | 769 | substituiCon($nomeMapfileTmp,$postgis_mapa); |
769 | $oMap = ms_newMapobj($nomeMapfileTmp); | 770 | $oMap = ms_newMapobj($nomeMapfileTmp); |
770 | restauraCon($nomeMapfileTmp,$postgis_mapa); | 771 | restauraCon($nomeMapfileTmp,$postgis_mapa); |