Commit d1297596428fd8a17434abcb94ceec3c5831040e

Authored by Edmar Moretti
1 parent 9bb67fb1
Exists in master

Correção na listagem de elementos selecionados na tabela de atributos

classesphp/classe_atributos.php
@@ -438,7 +438,7 @@ class Atributos @@ -438,7 +438,7 @@ class Atributos
438 else{ 438 else{
439 $alias = $items; 439 $alias = $items;
440 } 440 }
441 - $shapes = retornaShapesSelecionados($this->layer,$this->arquivo,$this->mapa); 441 + $shapes = retornaShapesSelecionados($this->layer,$this->arquivo,$this->mapa,true);
442 $res_count = count($shapes); 442 $res_count = count($shapes);
443 $resultadoFinal[] = array("totalSelecionados"=>$res_count,"itens"=>$items,"alias"=>$alias); 443 $resultadoFinal[] = array("totalSelecionados"=>$res_count,"itens"=>$items,"alias"=>$alias);
444 $registros = array(); 444 $registros = array();
@@ -451,6 +451,11 @@ class Atributos @@ -451,6 +451,11 @@ class Atributos
451 } 451 }
452 if ($tipolista == "selecionados"){ 452 if ($tipolista == "selecionados"){
453 $chk = "CHECKED"; 453 $chk = "CHECKED";
  454 + //cria um novo array apenas para funcionar no contador
  455 + $s = array();
  456 + foreach($shapes as $shape){
  457 + $s[] = $shape;
  458 + }
454 if ($fim != ""){ 459 if ($fim != ""){
455 if (($res_count >= $fim) && ($fim < $res_count)){ 460 if (($res_count >= $fim) && ($fim < $res_count)){
456 $res_count = $fim; 461 $res_count = $fim;
@@ -458,7 +463,8 @@ class Atributos @@ -458,7 +463,8 @@ class Atributos
458 } 463 }
459 for ($i = $inicio; $i < $res_count; ++$i){ 464 for ($i = $inicio; $i < $res_count; ++$i){
460 $valitem = array(); 465 $valitem = array();
461 - $shape = $shapes[$i]; 466 + $shape = $s[$i];
  467 + $indx = $shape->index;
462 foreach ($items as $item){ 468 foreach ($items as $item){
463 $valori = trim($shape->values[$item]); 469 $valori = trim($shape->values[$item]);
464 if($convC == true){ 470 if($convC == true){
@@ -482,10 +488,7 @@ class Atributos @@ -482,10 +488,7 @@ class Atributos
482 } 488 }
483 if ($tipolista == "tudo"){ 489 if ($tipolista == "tudo"){
484 //ini_set('memory_limit', '500M'); 490 //ini_set('memory_limit', '500M');
485 - $shp_atual = array();  
486 - for ($i = 0; $i < $res_count;++$i){  
487 - $shp_atual[$i] = $shapes[$i];;  
488 - } 491 + $shp_atual = $shapes;
489 $chk = ""; 492 $chk = "";
490 if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS){ 493 if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS){
491 $res_count = $this->layer->getNumresults(); 494 $res_count = $this->layer->getNumresults();
@@ -2408,4 +2411,4 @@ class Atributos @@ -2408,4 +2411,4 @@ class Atributos
2408 return $texto; 2411 return $texto;
2409 } 2412 }
2410 } 2413 }
2411 -?>  
2412 \ No newline at end of file 2414 \ No newline at end of file
  2415 +?>
classesphp/funcoes_gerais.php
@@ -2465,13 +2465,13 @@ function retornaShapesMapext($objLayer,$objMapa){ @@ -2465,13 +2465,13 @@ function retornaShapesMapext($objLayer,$objMapa){
2465 $objLayer->close(); 2465 $objLayer->close();
2466 return $shapes; 2466 return $shapes;
2467 } 2467 }
2468 -function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ 2468 +function retornaShapesSelecionados($objLayer,$map_file,$objMapa,$indexado=false){
2469 $shapes = array(); 2469 $shapes = array();
2470 $qyfile = dirname($map_file)."/".$objLayer->name.".php"; 2470 $qyfile = dirname($map_file)."/".$objLayer->name.".php";
2471 - 2471 +
2472 if(!file_exists($qyfile)) 2472 if(!file_exists($qyfile))
2473 {return $shapes;} 2473 {return $shapes;}
2474 - 2474 +
2475 $handle = fopen ($qyfile, "r"); 2475 $handle = fopen ($qyfile, "r");
2476 $conteudo = fread ($handle, filesize ($qyfile)); 2476 $conteudo = fread ($handle, filesize ($qyfile));
2477 fclose ($handle); 2477 fclose ($handle);
@@ -2479,12 +2479,14 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ @@ -2479,12 +2479,14 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2479 //echo count($listaDeIndices);exit; 2479 //echo count($listaDeIndices);exit;
2480 if(count($listaDeIndices) == 0) 2480 if(count($listaDeIndices) == 0)
2481 {return $shapes;} 2481 {return $shapes;}
2482 - 2482 +
2483 $versao = versao(); 2483 $versao = versao();
2484 $versao = $versao["principal"]; 2484 $versao = $versao["principal"];
  2485 +
2485 if ($objLayer->connectiontype != MS_POSTGIS){ 2486 if ($objLayer->connectiontype != MS_POSTGIS){
2486 //pega os shapes selecionados 2487 //pega os shapes selecionados
2487 carregaquery2($map_file,$objLayer,$objMapa); 2488 carregaquery2($map_file,$objLayer,$objMapa);
  2489 +
2488 $sopen = $objLayer->open(); 2490 $sopen = $objLayer->open();
2489 if($sopen == MS_FAILURE){return "erro";} 2491 if($sopen == MS_FAILURE){return "erro";}
2490 $objLayer->open(); 2492 $objLayer->open();
@@ -2492,17 +2494,24 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ @@ -2492,17 +2494,24 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2492 $centroides = array(); 2494 $centroides = array();
2493 $shapes = array(); 2495 $shapes = array();
2494 //pega um shape especifico 2496 //pega um shape especifico
2495 - 2497 +
2496 for ($i = 0; $i < $res_count; ++$i) 2498 for ($i = 0; $i < $res_count; ++$i)
2497 { 2499 {
2498 - if($versao == 6)  
2499 - {$shape = $objLayer->getShape($objLayer->getResult($i));} 2500 + if($versao == 6){
  2501 + $shape = $objLayer->getShape($objLayer->getResult($i));
  2502 + $shp_index = $shape->index;
  2503 + }
2500 else{ 2504 else{
2501 $result = $objLayer->getResult($i); 2505 $result = $objLayer->getResult($i);
2502 $shp_index = $result->shapeindex; 2506 $shp_index = $result->shapeindex;
2503 $shape = $objLayer->getfeature($shp_index,-1); 2507 $shape = $objLayer->getfeature($shp_index,-1);
2504 } 2508 }
2505 - $shapes[] = $shape; 2509 + if($indexado == true){
  2510 + $shapes[$shp_index] = $shape;
  2511 + }
  2512 + else{
  2513 + $shapes[] = $shape;
  2514 + }
2506 } 2515 }
2507 $fechou = $objLayer->close(); 2516 $fechou = $objLayer->close();
2508 } 2517 }
@@ -2518,7 +2527,12 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ @@ -2518,7 +2527,12 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2518 while ($shape = $objLayer->nextShape()) 2527 while ($shape = $objLayer->nextShape())
2519 { 2528 {
2520 if(in_array($shape->index,$listaDeIndices)){ 2529 if(in_array($shape->index,$listaDeIndices)){
2521 - $shapes[] = $shape; 2530 + if($indexado == true){
  2531 + $shapes[$shape->index] = $shape;
  2532 + }
  2533 + else{
  2534 + $shapes[] = $shape;
  2535 + }
2522 } 2536 }
2523 } 2537 }
2524 $objLayer->close(); 2538 $objLayer->close();