Commit 989f5ac60eb20dc1963a3473d237de3218299e76

Authored by Edmar Moretti
1 parent a854ed12

Alteração de classe_temas.php para permitir o uso de mais de um tema ao aplicar um filtro

Showing 2 changed files with 64 additions and 47 deletions   Show diff stats
admin/admin.db
No preview for this file type
classesphp/classe_temas.php
... ... @@ -100,7 +100,7 @@ Cria um objeto map e seta a variavel tema
100 100 parameters:
101 101 $map_file - Endereço do mapfile no servidor.
102 102  
103   -$tema - nome do tema que será processado
  103 +$tema - nome do tema que será processado. (Pode ser uma lista separada por ',' mas só funciona nas funções que trabalham sobre os índices dos layers)
104 104  
105 105 $locaplic - (opcional) endereço do i3geo
106 106  
... ... @@ -124,20 +124,24 @@ $ext - (opcional) extensão geográfica que será aplicada ao mapa
124 124 $this->arquivo = $map_file;
125 125 if($tema != "" && @$this->mapa->getlayerbyname($tema))
126 126 {
127   - $this->layer = $this->mapa->getlayerbyname($tema);
128   - $this->nome = $tema;
129   - $vermultilayer = new vermultilayer();
130   - $vermultilayer->verifica($map_file,$tema);
131   - if ($vermultilayer->resultado == 1) // o tema e multi layer
132   - {$ls = $vermultilayer->temas;}
133   - else
134   - {$ls[] = $tema;}
135   - $this->grupo = $ls;
136   - $this->visiveis = $vermultilayer->temasvisiveis;
137   - foreach ($ls as $l)
138   - {
139   - $t = $this->mapa->getlayerbyname($l);
140   - $this->indices[] = $t->index;
  127 + $listaTemas = str_replace(" ",",",$tema);
  128 + $listaTemas = explode(",",$tema);
  129 + foreach ($listaTemas as $tema){
  130 + $this->layer = $this->mapa->getlayerbyname($tema);
  131 + $this->nome = $tema;
  132 + $vermultilayer = new vermultilayer();
  133 + $vermultilayer->verifica($map_file,$tema);
  134 + if ($vermultilayer->resultado == 1) // o tema e multi layer
  135 + {$ls = $vermultilayer->temas;}
  136 + else
  137 + {$ls[] = $tema;}
  138 + $this->grupo = $ls;
  139 + $this->visiveis = $vermultilayer->temasvisiveis;
  140 + foreach ($ls as $l)
  141 + {
  142 + $t = $this->mapa->getlayerbyname($l);
  143 + $this->indices[] = $t->index;
  144 + }
141 145 }
142 146 }
143 147 if($ext && $ext != ""){
... ... @@ -458,45 +462,58 @@ $testa - Testa o filtro e retorna uma imagem.
458 462 */
459 463 function insereFiltro($filtro,$testa="")
460 464 {
461   - if(!$this->layer){return "erro";}
462   - $this->layer->setmetadata("cache","");
463   - $fil = $this->layer->getFilterString();
464   - $filtro = str_replace("|","'",$filtro);
465   - if ($this->layer->connectiontype == MS_POSTGIS)
466   - {
467   - $filtro = str_replace("'[","",$filtro);
468   - $filtro = str_replace("[","",$filtro);
469   - $filtro = str_replace("]'","",$filtro);
470   - $filtro = str_replace("]","",$filtro);
471   - $filtro = str_replace("("," ",$filtro);
472   - $filtro = str_replace(")"," ",$filtro);
473   - }
474   - if ($filtro == "")
475   - {$this->layer->setfilter($filtro);}
476   - else
477   - {
478   - $this->layer->setfilter($filtro);
479   - $v = versao();
480   - //corrige bug do mapserver
481   - if (($v["completa"] == "4.10.0") && ($this->layer->connectiontype == MS_POSTGIS))
482   - {$this->layer->setfilter("\"".$filtro."\"");}
483   - }
484   - if ($testa == "")
485   - {
486   - $img = $this->mapa->prepareimage();
487   - if ($this->layer->draw($img) == 0)
  465 + foreach($this->indices as $indice){
  466 + $layer = $this->mapa->getlayer($indice);
  467 + if(!$layer){return "erro";}
  468 + $layer->setmetadata("cache","");
  469 + $fil = $layer->getFilterString();
  470 + $filtro = str_replace("|","'",$filtro);
  471 + if ($layer->connectiontype == MS_POSTGIS)
488 472 {
489   - $this->layer->setMetaData("cache","");
490   - return ("ok");
  473 + $filtro = str_replace("'[","",$filtro);
  474 + $filtro = str_replace("[","",$filtro);
  475 + $filtro = str_replace("]'","",$filtro);
  476 + $filtro = str_replace("]","",$filtro);
  477 + $filtro = str_replace("("," ",$filtro);
  478 + $filtro = str_replace(")"," ",$filtro);
491 479 }
  480 + if ($filtro == "")
  481 + {$layer->setfilter($filtro);}
492 482 else
493   - {return ("erro. Problemas com o filtro."." ".$filtro);}
  483 + {
  484 + $layer->setfilter($filtro);
  485 + $v = versao();
  486 + //corrige bug do mapserver
  487 + if (($v["completa"] == "4.10.0") && ($layer->connectiontype == MS_POSTGIS))
  488 + {$layer->setfilter("\"".$filtro."\"");}
  489 + }
  490 + if ($testa == "")
  491 + {
  492 + $layer->setMetaData("cache","");
  493 + /*
  494 + $img = $this->mapa->prepareimage();
  495 + if ($this->layer->draw($img) == 0)
  496 + {
  497 + $this->layer->setMetaData("cache","");
  498 + return ("ok");
  499 + }
  500 + else
  501 + {return ("erro. Problemas com o filtro."." ".$filtro);}
  502 + */
  503 + }
  504 + /*
  505 + else
  506 + {
  507 + $i = gravaImagemMapa($this->mapa);
  508 + return ($i["url"]);
  509 + }
  510 + */
494 511 }
495   - else
496   - {
  512 + if ($testa != ""){
497 513 $i = gravaImagemMapa($this->mapa);
498 514 return ($i["url"]);
499 515 }
  516 + return "ok";
500 517 }
501 518 /*
502 519 function: mudaTransparencia
... ...