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 438 else{
439 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 442 $res_count = count($shapes);
443 443 $resultadoFinal[] = array("totalSelecionados"=>$res_count,"itens"=>$items,"alias"=>$alias);
444 444 $registros = array();
... ... @@ -451,6 +451,11 @@ class Atributos
451 451 }
452 452 if ($tipolista == "selecionados"){
453 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 459 if ($fim != ""){
455 460 if (($res_count >= $fim) && ($fim < $res_count)){
456 461 $res_count = $fim;
... ... @@ -458,7 +463,8 @@ class Atributos
458 463 }
459 464 for ($i = $inicio; $i < $res_count; ++$i){
460 465 $valitem = array();
461   - $shape = $shapes[$i];
  466 + $shape = $s[$i];
  467 + $indx = $shape->index;
462 468 foreach ($items as $item){
463 469 $valori = trim($shape->values[$item]);
464 470 if($convC == true){
... ... @@ -482,10 +488,7 @@ class Atributos
482 488 }
483 489 if ($tipolista == "tudo"){
484 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 492 $chk = "";
490 493 if (@$this->layer->queryByrect($this->mapa->extent) == MS_SUCCESS){
491 494 $res_count = $this->layer->getNumresults();
... ... @@ -2408,4 +2411,4 @@ class Atributos
2408 2411 return $texto;
2409 2412 }
2410 2413 }
2411   -?>
2412 2414 \ No newline at end of file
  2415 +?>
... ...
classesphp/funcoes_gerais.php
... ... @@ -2465,13 +2465,13 @@ function retornaShapesMapext($objLayer,$objMapa){
2465 2465 $objLayer->close();
2466 2466 return $shapes;
2467 2467 }
2468   -function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
  2468 +function retornaShapesSelecionados($objLayer,$map_file,$objMapa,$indexado=false){
2469 2469 $shapes = array();
2470 2470 $qyfile = dirname($map_file)."/".$objLayer->name.".php";
2471   -
  2471 +
2472 2472 if(!file_exists($qyfile))
2473 2473 {return $shapes;}
2474   -
  2474 +
2475 2475 $handle = fopen ($qyfile, "r");
2476 2476 $conteudo = fread ($handle, filesize ($qyfile));
2477 2477 fclose ($handle);
... ... @@ -2479,12 +2479,14 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2479 2479 //echo count($listaDeIndices);exit;
2480 2480 if(count($listaDeIndices) == 0)
2481 2481 {return $shapes;}
2482   -
  2482 +
2483 2483 $versao = versao();
2484 2484 $versao = $versao["principal"];
  2485 +
2485 2486 if ($objLayer->connectiontype != MS_POSTGIS){
2486 2487 //pega os shapes selecionados
2487 2488 carregaquery2($map_file,$objLayer,$objMapa);
  2489 +
2488 2490 $sopen = $objLayer->open();
2489 2491 if($sopen == MS_FAILURE){return "erro";}
2490 2492 $objLayer->open();
... ... @@ -2492,17 +2494,24 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2492 2494 $centroides = array();
2493 2495 $shapes = array();
2494 2496 //pega um shape especifico
2495   -
  2497 +
2496 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 2504 else{
2501 2505 $result = $objLayer->getResult($i);
2502 2506 $shp_index = $result->shapeindex;
2503 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 2516 $fechou = $objLayer->close();
2508 2517 }
... ... @@ -2518,7 +2527,12 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2518 2527 while ($shape = $objLayer->nextShape())
2519 2528 {
2520 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 2538 $objLayer->close();
... ...