Commit e34bc948efe2cf6bc67f310b2ea273d1ea05f305
1 parent
80d0eadb
Exists in
master
and in
7 other branches
Correção no uso da variável $postgis_mapa
Showing
7 changed files
with
63 additions
and
72 deletions
Show diff stats
classesphp/funcoes_gerais.php
| ... | ... | @@ -699,39 +699,36 @@ Retorno: |
| 699 | 699 | function substituiCon($map_file,$postgis_mapa) |
| 700 | 700 | { |
| 701 | 701 | error_reporting(0); |
| 702 | - if ((isset($postgis_mapa)) && (file_exists($map_file))) | |
| 702 | + if (!empty($postgis_mapa) && (file_exists($map_file))) | |
| 703 | 703 | { |
| 704 | - if (($postgis_mapa != "") || ($postgis_mapa != " ")) | |
| 704 | + if(!@ms_newMapObj($map_file)){return false;} | |
| 705 | + $objMap = ms_newMapObj($map_file); | |
| 706 | + $numlayers = $objMap->numlayers; | |
| 707 | + for ($i=0;$i < $numlayers;++$i) | |
| 705 | 708 | { |
| 706 | - if(!@ms_newMapObj($map_file)){return false;} | |
| 707 | - $objMap = ms_newMapObj($map_file); | |
| 708 | - $numlayers = $objMap->numlayers; | |
| 709 | - for ($i=0;$i < $numlayers;++$i) | |
| 709 | + $layer = $objMap->getlayer($i); | |
| 710 | + if ($layer->connectiontype == MS_POSTGIS) | |
| 710 | 711 | { |
| 711 | - $layer = $objMap->getlayer($i); | |
| 712 | - if ($layer->connectiontype == MS_POSTGIS) | |
| 712 | + $lcon = $layer->connection; | |
| 713 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | |
| 713 | 714 | { |
| 714 | - $lcon = $layer->connection; | |
| 715 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | |
| 715 | + // | |
| 716 | + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | |
| 717 | + // | |
| 718 | + if(($lcon == " ") || ($lcon == "")) | |
| 716 | 719 | { |
| 717 | - // | |
| 718 | - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | |
| 719 | - // | |
| 720 | - if(($lcon == " ") || ($lcon == "")) | |
| 721 | - { | |
| 722 | - $layer->set("connection",$postgis_mapa); | |
| 723 | - $layer->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 724 | - } | |
| 725 | - else | |
| 726 | - { | |
| 727 | - $layer->set("connection",$postgis_mapa[$lcon]); | |
| 728 | - $layer->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 729 | - } | |
| 720 | + $layer->set("connection",$postgis_mapa); | |
| 721 | + $layer->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 730 | 722 | } |
| 723 | + else | |
| 724 | + { | |
| 725 | + $layer->set("connection",$postgis_mapa[$lcon]); | |
| 726 | + $layer->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 727 | + } | |
| 731 | 728 | } |
| 732 | 729 | } |
| 733 | - $objMap->save($map_file); | |
| 734 | 730 | } |
| 731 | + $objMap->save($map_file); | |
| 735 | 732 | } |
| 736 | 733 | return true; |
| 737 | 734 | } |
| ... | ... | @@ -749,7 +746,7 @@ $postgis_mapa {string} - lista de conexão com o banco |
| 749 | 746 | function restauraCon($map_file,$postgis_mapa) |
| 750 | 747 | { |
| 751 | 748 | if(!@ms_newMapObj($map_file)){return;} |
| 752 | - if (isset($postgis_mapa) && $postgis_mapa != "") | |
| 749 | + if (!empty($postgis_mapa)) | |
| 753 | 750 | { |
| 754 | 751 | $objMap = ms_newMapObj($map_file); |
| 755 | 752 | $numlayers = $objMap->numlayers; |
| ... | ... | @@ -2018,7 +2015,7 @@ $locaplic {string} - Diretório da aplicação. |
| 2018 | 2015 | |
| 2019 | 2016 | $dir_tmp {string} - Diretório temporário |
| 2020 | 2017 | |
| 2021 | -$postgismapa - variavel definida em ms_configura.php | |
| 2018 | +$postgis_mapa - variavel definida em ms_configura.php | |
| 2022 | 2019 | |
| 2023 | 2020 | Retorno: |
| 2024 | 2021 | ... | ... |
classesphp/mapa_googleearth.php
| ... | ... | @@ -134,7 +134,7 @@ function retornaWms($map_fileX,$postgis_mapa){ |
| 134 | 134 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") |
| 135 | 135 | { |
| 136 | 136 | $l->set("status",MS_DEFAULT); |
| 137 | - if (isset($postgis_mapa) && ($postgis_mapa != "") && ($postgis_mapa != " ")) | |
| 137 | + if (!empty($postgis_mapa)) | |
| 138 | 138 | { |
| 139 | 139 | if ($l->connectiontype == MS_POSTGIS) |
| 140 | 140 | { | ... | ... |
classesphp/mapa_googlemaps.php
| ... | ... | @@ -144,7 +144,7 @@ if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao´e alter |
| 144 | 144 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") |
| 145 | 145 | { |
| 146 | 146 | $l->set("status",MS_DEFAULT); |
| 147 | - if (($postgis_mapa != "") && ($postgis_mapa != " ")) | |
| 147 | + if (!empty($postgis_mapa)) | |
| 148 | 148 | { |
| 149 | 149 | if ($l->connectiontype == MS_POSTGIS) |
| 150 | 150 | { | ... | ... |
classesphp/mapa_openlayers.php
| ... | ... | @@ -99,7 +99,7 @@ if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alter |
| 99 | 99 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") |
| 100 | 100 | { |
| 101 | 101 | $l->set("status",MS_DEFAULT); |
| 102 | - if (($postgis_mapa != "") && ($postgis_mapa != " ")) | |
| 102 | + if (!empty($postgis_mapa != "")) | |
| 103 | 103 | { |
| 104 | 104 | if ($l->connectiontype == MS_POSTGIS) |
| 105 | 105 | { | ... | ... |
ms_configura.php
| ... | ... | @@ -293,29 +293,32 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) |
| 293 | 293 | |
| 294 | 294 | Com o uso opcional dessa variável é possível esconder a string de conexão com o banco de dados. O Mapserver |
| 295 | 295 | não permite esconder essa string, por isso, no i3geo, foi implementado um esquema de substituição. |
| 296 | - Toda vez que um objeto "map" é criado via PHP Mapscript, a string de conexão é substituída de " " para o valor de $postgis_mapa. | |
| 296 | + Toda vez que um objeto "map" é criado via PHP Mapscript, a string de conexão é substituída pelo valor de $postgis_mapa. | |
| 297 | 297 | Se não for desejado a substituição, deixe essa variável em branco. |
| 298 | 298 | Se vc especificar essa variável, o mapa será forçado a recusar o modo de operação CGI. |
| 299 | 299 | |
| 300 | 300 | Para mais detalhes veja a função substituiCon em classesphp/funcoes_gerais.php |
| 301 | 301 | |
| 302 | - Importante - se vc usar o modo de substituição de strings, as interfaces que dependem do modo CGI | |
| 303 | - para funcionarem, não serão capazes de acessar os dados. Isso afeta por exemplo, a interface Google Maps e Openlayers. | |
| 304 | - | |
| 305 | 302 | exemplo - |
| 306 | 303 | |
| 307 | 304 | $postgis_mapa = array( |
| 308 | - "conexao1"=>"user=geodados password=geodados dbname=geodados host=10.1.1.36 port=5432", | |
| 305 | + "teste"=>"user=geodados password=geodados dbname=geodados host=10.1.1.36 port=5432", | |
| 309 | 306 | "conexao2"=>"user=geodados password=geodados dbname=geodadosteste host=10.1.1.36 port=5432" |
| 310 | 307 | ) |
| 311 | 308 | |
| 309 | + No exemplo, vc pode usar "teste" ou "conexao2" no seu mapfile veja em i3geo/temas/testesubstring.map | |
| 310 | + | |
| 311 | + Se vc não quiser usar essa substituição, deixe como está ou use | |
| 312 | + | |
| 313 | + $postgis_mapa = "" | |
| 314 | + | |
| 312 | 315 | Tipo: |
| 313 | 316 | {array ou string} |
| 314 | 317 | */ |
| 315 | 318 | $postgis_mapa = array( |
| 316 | 319 | "teste"=>"user=postgres password=postgres dbname=postgis host=localhost port=5432 options='-c client_encoding=LATIN1'", |
| 317 | 320 | "postgres"=>"user=postgres password=postgres dbname=postgis host=localhost port=5432", |
| 318 | - ); //"user=geodados password=geodados dbname=geodados host=10.1.1.36 port=5432"; | |
| 321 | + ); | |
| 319 | 322 | /* |
| 320 | 323 | Variable: utilizacgi |
| 321 | 324 | ... | ... |
ogc.php
| ... | ... | @@ -247,29 +247,26 @@ if ($tipo == "" || $tipo == "metadados") |
| 247 | 247 | if($extensao == "") |
| 248 | 248 | {$extensao = $extensaoMap;} |
| 249 | 249 | $l->setmetadata("wms_extent",$extensao); |
| 250 | - if (isset($postgis_mapa)) | |
| 251 | - { | |
| 252 | - if ($postgis_mapa != "") | |
| 253 | - { | |
| 254 | - if ($l->connectiontype == MS_POSTGIS) | |
| 250 | + if (!empty($postgis_mapa)) | |
| 251 | + { | |
| 252 | + if ($l->connectiontype == MS_POSTGIS) | |
| 253 | + { | |
| 254 | + $lcon = $l->connection; | |
| 255 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | |
| 255 | 256 | { |
| 256 | - $lcon = $l->connection; | |
| 257 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | |
| 257 | + // | |
| 258 | + //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | |
| 259 | + // | |
| 260 | + if(($lcon == " ") || ($lcon == "")) | |
| 258 | 261 | { |
| 259 | - // | |
| 260 | - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | |
| 261 | - // | |
| 262 | - if(($lcon == " ") || ($lcon == "")) | |
| 263 | - { | |
| 264 | - $l->set("connection",$postgis_mapa); | |
| 265 | - $l->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 266 | - } | |
| 267 | - else | |
| 268 | - { | |
| 269 | - $l->set("connection",$postgis_mapa[$lcon]); | |
| 270 | - $l->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 271 | - } | |
| 262 | + $l->set("connection",$postgis_mapa); | |
| 263 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 272 | 264 | } |
| 265 | + else | |
| 266 | + { | |
| 267 | + $l->set("connection",$postgis_mapa[$lcon]); | |
| 268 | + $l->setmetadata("CONEXAOORIGINAL",$lcon); | |
| 269 | + } | |
| 273 | 270 | } |
| 274 | 271 | } |
| 275 | 272 | } | ... | ... |
testamapfile.php
| ... | ... | @@ -217,28 +217,22 @@ function verifica($map,$solegenda) |
| 217 | 217 | { |
| 218 | 218 | $layern = $nmapa->getLayerByName($teman); |
| 219 | 219 | $layern->set("status",MS_DEFAULT); |
| 220 | - if (isset($postgis_mapa)) | |
| 220 | + if (!empty($postgis_mapa)) | |
| 221 | 221 | { |
| 222 | - if (($postgis_mapa != "") || ($postgis_mapa != " ")) | |
| 222 | + if ($layern->connectiontype == MS_POSTGIS) | |
| 223 | 223 | { |
| 224 | - if ($layern->connectiontype == MS_POSTGIS) | |
| 224 | + $lcon = $layern->connection; | |
| 225 | + error_reporting(0); | |
| 226 | + if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | |
| 225 | 227 | { |
| 226 | - $lcon = $layern->connection; | |
| 227 | - error_reporting(0); | |
| 228 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))) | |
| 228 | + if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade | |
| 229 | 229 | { |
| 230 | - // | |
| 231 | - //o metadata CONEXAOORIGINAL guarda o valor original para posterior substituição | |
| 232 | - // | |
| 233 | - if(($lcon == " ") || ($lcon == "")) | |
| 234 | - { | |
| 235 | - $layern->set("connection",$postgis_mapa); | |
| 236 | - } | |
| 237 | - else | |
| 238 | - { | |
| 239 | - $layern->set("connection",$postgis_mapa[$lcon]); | |
| 240 | - } | |
| 230 | + $layern->set("connection",$postgis_mapa); | |
| 241 | 231 | } |
| 232 | + else | |
| 233 | + { | |
| 234 | + $layern->set("connection",$postgis_mapa[$lcon]); | |
| 235 | + } | |
| 242 | 236 | } |
| 243 | 237 | } |
| 244 | 238 | } | ... | ... |