Commit 5d3989bc6bdefafcddfd2d406a3c12f26d751099

Authored by Edmar Moretti
1 parent 136732c7
Exists in master

Atualização do código

classesphp/classe_selecao.php
... ... @@ -99,6 +99,8 @@ $ext - extensão geográfica do mapa
99 99 function __construct($map_file,$tema="",$ext="")
100 100 {
101 101 include_once(dirname(__FILE__)."/funcoes_gerais.php");
  102 + include(dirname(__FILE__)."/../ms_configura.php");
  103 + $this->postgis_mapa = $postgis_mapa;
102 104 $this->v = versao();
103 105 $this->v = $this->v["principal"];
104 106 $this->qyfile = str_replace(".map",".qy",$map_file);
... ... @@ -108,7 +110,10 @@ $ext - extensão geográfica do mapa
108 110 else{
109 111 $this->qyfileTema = "";
110 112 }
  113 +
111 114 $this->mapa = ms_newMapObj($map_file);
  115 + substituiConObj($this->mapa,$postgis_mapa);
  116 +
112 117 $this->arquivo = str_replace(".map","",$map_file).".map";
113 118 if($tema != "" && @$this->mapa->getlayerbyname($tema))
114 119 $this->layer = $this->mapa->getlayerbyname($tema);
... ... @@ -134,13 +139,12 @@ function: salva
134 139  
135 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 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 150 function: nSel
... ... @@ -165,7 +169,7 @@ $ys - lista de coordenadas y separadas por virgula
165 169  
166 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 174 function selecaoPorPoligono($tipo,$xs="",$ys="",$wkt="",$buffer=0)
171 175 {
... ... @@ -730,10 +734,10 @@ $shp_atual - Indices dos elementos já selecionados.
730 734 $indxlayer = $this->layer->index;
731 735 $shp = array_merge($shpi,$shp_atual);
732 736 $shp = array_unique($shp);
  737 +
733 738 $this->mapa->freequery($indxlayer);
734 739 foreach ($shp as $indx)
735 740 {@$this->mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);}
736   - //echo $this->layer->getNumresults();
737 741 $this->mapa->savequery($this->qyfile);
738 742 $this->serializeQ($this->qyfileTema,$shp);
739 743 return("ok");
... ... @@ -891,58 +895,53 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo
891 895  
892 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 900 $this->selecaoLimpa();
899 901 $tipo = "adiciona";
900 902 }
901   - if(!$this->layer){return "erro";}
  903 + if(!$this->layer){
  904 + return "erro";
  905 + }
902 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 916 $indxlayer = $this->layer->index;
910   - /*
911   - $res_count = $this->layer->getNumresults();
912 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 922 $shpi = array();
925 923 $temp = explode(" ",$ext);
926 924 $rect = ms_newRectObj();
  925 +
927 926 $rect->set("minx",(min(array($temp[0],$temp[2]))));
928 927 $rect->set("miny",(min(array($temp[1],$temp[3]))));
929 928 $rect->set("maxx",(max(array($temp[0],$temp[2]))));
930 929 $rect->set("maxy",(max(array($temp[1],$temp[3]))));
931 930 $ident = $this->layer->queryByRect($rect);
932   - if ($ident != 1)
933   - {
  931 + if ($ident != 1){
934 932 $res_count = $this->layer->getNumresults();
935 933 $shpi = array();
936   - for ($i = 0; $i < $res_count; ++$i)
937   - {
  934 + for ($i = 0; $i < $res_count; ++$i) {
938 935 $result = $this->layer->getResult($i);
939 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 947 function unserializeQ
... ...
classesphp/funcoes_gerais.php
... ... @@ -570,6 +570,36 @@ function substituiCon($map_file,$postgis_mapa)
570 570 }
571 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&ccedil;&atilde;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 604 Function: restauraCon
575 605  
... ...
ferramentas/parametrossql/ogc.php
... ... @@ -9,13 +9,16 @@ A diferenca e que esse servico processa o parametro &quot;plugin&quot;, aplicando os filtr
9 9 no plugin parametrossql
10 10 */
11 11 $cache = true;
12   -require_once(dirname(__FILE__)."/../../classesphp/carrega_ext.php");
  12 +include(dirname(__FILE__)."/classesphp/sani_request.php");
13 13 include(dirname(__FILE__)."/../../ms_configura.php");
14   -include(dirname(__FILE__)."/../../classesphp/pega_variaveis.php");
15 14 include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php");
  15 +$_GET = array_merge($_GET,$_POST);
16 16 $projDefault = pegaProjecaoDefault();
17 17  
18   -$temas = $tema;
  18 +$tema = basename($_GET["tema"]);
  19 +if($tema == ""){
  20 + exit;
  21 +}
19 22 if(isset($_GET["sld"]) || isset($_GET["filter"])){
20 23 $cache = false;
21 24 }
... ... @@ -41,7 +44,7 @@ if($_GET[&quot;SRS&quot;] == &quot;EPSG:900913&quot;){
41 44 $_GET["SRS"] = "EPSG:3857";
42 45 }
43 46 $req = ms_newowsrequestobj();
44   -$_GET = array_merge($_GET,$_POST);
  47 +
45 48 if(!isset($_GET["srs"]) && !isset($_GET["SRS"])){
46 49 $_GET["srs"] = "EPSG:".$projDefault["epsg"];
47 50 }
... ... @@ -72,13 +75,14 @@ $agora = intval(time() / 1000);
72 75 if(isset($_GET["Z"]) && isset($_GET["X"])){
73 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 79 $nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp);
77 80 $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp);
78 81 //essa variavel e usada para definir se a imagem final gerada devera ser cortada ou nao
79 82 $cortePixels = 0;
80 83 if(file_exists($nomeMapfileTmp)){
81 84 $oMap = ms_newMapobj($nomeMapfileTmp);
  85 + substituiConObj($oMap,$postgis_mapa);
82 86 }
83 87 else{
84 88 if(empty($ogcwsmap)){
... ... @@ -218,12 +222,15 @@ else{
218 222  
219 223 $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename));
220 224 $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename));
  225 + $nomeMapfileTmp = str_replace(".map","",$nomeMapfileTmp).".map";
221 226 $oMap->save($nomeMapfileTmp);
  227 +
222 228 $oMap = ms_newMapobj($nomeMapfileTmp);
223 229 }
224 230 if(ob_get_contents ()){
225 231 ob_end_clean();
226 232 }
  233 +restauraCon($nomeMapfileTmp,$postgis_mapa);
227 234 //
228 235 //verifica se a requisicao e do tipo TMS.
229 236 //
... ... @@ -570,6 +577,8 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){
570 577 exit;
571 578 }
572 579 function execProg($prog){
  580 + $prog = str_replace(".php","",$prog);
  581 + $prog = str_replace(".","",$prog).".php";
573 582 include($prog);
574 583 //$retorno variavel deve ser retornada pelo programa $prog
575 584 //veja como exemplo i3geo/aplicmap/daods/listaano.php
... ...
ogc.php
... ... @@ -371,9 +371,11 @@ $cortePixels = 0;
371 371 $ogcwsmap = $_GET["ogcwsmap"];
372 372  
373 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 377 $oMap = ms_newMapobj($nomeMapfileTmp);
376   - restauraCon($nomeMapfileTmp,$postgis_mapa);
  378 + substituiConObj($oMap,$postgis_mapa);
377 379 }
378 380 else{
379 381 if(empty($ogcwsmap)){
... ... @@ -764,7 +766,6 @@ else{
764 766 $oMap->save($nomeMapfileTmp);
765 767 validaAcessoTemas($nomeMapfileTmp,true);
766 768  
767   -
768 769 substituiCon($nomeMapfileTmp,$postgis_mapa);
769 770 $oMap = ms_newMapobj($nomeMapfileTmp);
770 771 restauraCon($nomeMapfileTmp,$postgis_mapa);
... ...