Commit ffa25349b10ac6818e5ce3f5f664fd8c1140a97a

Authored by Edmar Moretti
1 parent e619c589
Exists in master

Correção na montagem da expressão de seleção quando se usa querybyattributes na …

…versão 7 do Mapserver
Showing 1 changed file with 27 additions and 17 deletions   Show diff stats
classesphp/classe_selecao.php
... ... @@ -171,12 +171,10 @@ $wkt - string wkt opcional ao uso de xs e ys
171 171  
172 172 $buffer - buffer que ser� aplicado
173 173 */
174   - function selecaoPorPoligono($tipo,$xs="",$ys="",$wkt="",$buffer=0)
175   - {
  174 + function selecaoPorPoligono($tipo,$xs="",$ys="",$wkt="",$buffer=0){
176 175 if(!$this->layer){return "erro";}
177 176 $this->layer->set("tolerance",0);
178   - if ($tipo == "novo")
179   - {
  177 + if ($tipo == "novo"){
180 178 $this->selecaoLimpa();
181 179 $tipo = "adiciona";
182 180 }
... ... @@ -499,8 +497,7 @@ $valor - Valor.
499 497  
500 498 $tipo - Tipo de operação adiciona|retira|inverte|limpa|novo
501 499 */
502   - function selecaoAtributos2($filtro,$tipo)
503   - {
  500 + function selecaoAtributos2($filtro,$tipo){
504 501 $items = pegaItens($this->layer);
505 502 if ($tipo == "novo")
506 503 {
... ... @@ -521,8 +518,8 @@ $valor - Valor.
521 518 $shpi = array();
522 519  
523 520 $filtro = str_replace("|","'",$filtro);
524   - if ($this->layer->connectiontype == MS_POSTGIS)
525   - {
  521 +
  522 + if ($this->layer->connectiontype == MS_POSTGIS && $this->v < 7) {
526 523 $filtro = str_replace("'[","",$filtro);
527 524 $filtro = str_replace("[","",$filtro);
528 525 $filtro = str_replace("]'","",$filtro);
... ... @@ -530,24 +527,26 @@ $valor - Valor.
530 527 $filtro = str_replace("("," ",$filtro);
531 528 $filtro = str_replace(")"," ",$filtro);
532 529 }
  530 +
533 531 $teste = $this->layer->querybyattributes($items[0],$filtro,1);
534 532 if($teste != MS_SUCCESS){
535   - $teste = $this->layer->queryByAttributes($itens[0], mb_convert_encoding($filtro,"ISO-8859-1","UTF-8"), 1);
536   - }
  533 + $teste = $this->layer->queryByAttributes($items[0], mb_convert_encoding($filtro,"ISO-8859-1","UTF-8"), 1);
  534 + }
537 535 if($teste != MS_SUCCESS){
538   - $teste = $this->layer->queryByAttributes($itens[0], mb_convert_encoding($filtro,"UTF-8","ISO-8859-1"), 1);
  536 + $teste = $this->layer->queryByAttributes($items[0], mb_convert_encoding($filtro,"UTF-8","ISO-8859-1"), 1);
539 537 }
540 538 $res_count = $this->layer->getNumresults();
541 539 $shpi = array();
542   - for ($i = 0; $i < $res_count; ++$i)
543   - {
  540 + for ($i = 0; $i < $res_count; ++$i){
544 541 $result = $this->layer->getResult($i);
545 542 $shpi[] = $result->shapeindex;
546 543 }
547   - if ($tipo == "adiciona")
548   - {return($this->selecaoAdiciona($shpi,$shp_atual));}
549   - if ($tipo == "retira")
550   - {return($this->selecaoRetira($shpi,$shp_atual));}
  544 + if ($tipo == "adiciona"){
  545 + return($this->selecaoAdiciona($shpi,$shp_atual));
  546 + }
  547 + if ($tipo == "retira"){
  548 + return($this->selecaoRetira($shpi,$shp_atual));
  549 + }
551 550 return("ok");
552 551 }
553 552 /*
... ... @@ -686,6 +685,17 @@ Inverte sele&amp;ccedil;&amp;atilde;o do tema.
686 685 if($this->qyfileTema != "" && file_exists($this->qyfileTema)){
687 686 $shp_atual = $this->unserializeQ($this->qyfileTema);
688 687 }
  688 + //TODO utilizar atributos qd for postgis para melhorar a performance
  689 + /*
  690 + if($this->layer->connectiontype == MS_POSTGIS){
  691 + $items = pegaItens($this->layer);
  692 + $this->layer->querybyattributes($items[0],$items[0].' > 0 ',1);
  693 + echo $this->layer->getNumresults();exit;
  694 + }
  695 + else {
  696 + $this->layer->queryByrect($this->mapa->extent);
  697 + }
  698 + */
689 699 $this->layer->queryByrect($this->mapa->extent);
690 700 $res_count = $this->layer->getNumresults();
691 701 $shp_todos = array();
... ...