Commit bd257c54e6d42b556a181117151b35e45905bd6a
1 parent
76780c04
Exists in
master
and in
7 other branches
Atualização do código
Showing
5 changed files
with
89 additions
and
40 deletions
Show diff stats
admin/admin.db
No preview for this file type
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 | { |
| @@ -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 | ||
| @@ -602,6 +632,24 @@ function restauraCon($map_file,$postgis_mapa) | @@ -602,6 +632,24 @@ function restauraCon($map_file,$postgis_mapa) | ||
| 602 | $objMap->save($map_file); | 632 | $objMap->save($map_file); |
| 603 | } | 633 | } |
| 604 | } | 634 | } |
| 635 | +function restauraConObj($objMap,$postgis_mapa) | ||
| 636 | +{ | ||
| 637 | + if (!empty($postgis_mapa)) | ||
| 638 | + { | ||
| 639 | + $numlayers = $objMap->numlayers; | ||
| 640 | + for ($i=0;$i < $numlayers;++$i) | ||
| 641 | + { | ||
| 642 | + $layer = $objMap->getlayer($i); | ||
| 643 | + if ($layer->connectiontype == MS_POSTGIS) | ||
| 644 | + { | ||
| 645 | + if (!is_array($postgis_mapa) && $layer->connection == $postgis_mapa) | ||
| 646 | + {$layer->set("connection"," ");} | ||
| 647 | + if($layer->getmetadata("conexaooriginal") != "") | ||
| 648 | + {$layer->set("connection",$layer->getmetadata("conexaooriginal"));} | ||
| 649 | + } | ||
| 650 | + } | ||
| 651 | + } | ||
| 652 | +} | ||
| 605 | /* | 653 | /* |
| 606 | Function: retornaReferencia | 654 | Function: retornaReferencia |
| 607 | 655 |
ferramentas/parametrossql/ogc.php
| @@ -82,6 +82,7 @@ $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); | @@ -82,6 +82,7 @@ $nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp); | ||
| 82 | $cortePixels = 0; | 82 | $cortePixels = 0; |
| 83 | if(file_exists($nomeMapfileTmp)){ | 83 | if(file_exists($nomeMapfileTmp)){ |
| 84 | $oMap = ms_newMapobj($nomeMapfileTmp); | 84 | $oMap = ms_newMapobj($nomeMapfileTmp); |
| 85 | + substituiConObj($oMap,$postgis_mapa); | ||
| 85 | } | 86 | } |
| 86 | else{ | 87 | else{ |
| 87 | if(empty($ogcwsmap)){ | 88 | if(empty($ogcwsmap)){ |
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); |