Commit 858ae235a834fc81df90a8ba75e563005b0b8ab3

Authored by Edmar Moretti
1 parent a972231d

$1

Showing 1 changed file with 14 additions and 19 deletions   Show diff stats
classesphp/funcoes_gerais.php
@@ -1459,6 +1459,8 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) @@ -1459,6 +1459,8 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1459 $resultadoFinal = true; 1459 $resultadoFinal = true;
1460 } 1460 }
1461 else{ 1461 else{
  1462 + $shapesSel = retornaShapesSelecionados($layer,$map_file,$map);//
  1463 +
1462 $items = pegaItens($layer); 1464 $items = pegaItens($layer);
1463 // cria o dbf 1465 // cria o dbf
1464 $def = array(); 1466 $def = array();
@@ -1479,29 +1481,17 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) @@ -1479,29 +1481,17 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1479 $dbname = $nomeshp.".dbf"; 1481 $dbname = $nomeshp.".dbf";
1480 $reg = array(); 1482 $reg = array();
1481 $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); 1483 $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2);
1482 - //le o arquivo de query se existir e checa se existe seleção para o tema  
1483 - $existesel = carregaquery2($map_file,$layer,$map);  
1484 - if ($existesel == "nao")  
1485 - {@$layer->queryByrect($map->extent);}  
1486 - //pega cada registro  
1487 - $res_count = $layer->getNumresults(); 1484 +
  1485 + $res_count = count($shapesSel);
  1486 +
1488 if ($res_count > 0){ 1487 if ($res_count > 0){
1489 - $sopen = $layer->open();  
1490 - if($sopen == MS_FAILURE){return "erro";}  
1491 - for ($i = 0; $i < $res_count; ++$i)  
1492 - {  
1493 - if($versao == 6)  
1494 - {$shape = $layer->getShape($layer->getResult($i));}  
1495 - else{  
1496 - $result = $layer->getResult($i);  
1497 - $shp_index = $result->shapeindex;  
1498 - $shape = $layer->getfeature($shp_index,-1);  
1499 - } 1488 + for ($i = 0; $i < $res_count; ++$i){
  1489 + $shape = $shapesSel[$i];
1500 foreach ($items as $ni) 1490 foreach ($items as $ni)
1501 { 1491 {
1502 $vreg = $shape->values[$ni]; 1492 $vreg = $shape->values[$ni];
1503 if(strlen($vreg) > 255){ 1493 if(strlen($vreg) > 255){
1504 - $vreg = substr($vreg,0,255); 1494 + $vreg = substr($vreg,0,255);
1505 } 1495 }
1506 $reg[] = $vreg; 1496 $reg[] = $vreg;
1507 } 1497 }
@@ -2365,7 +2355,6 @@ function carregaquery2($mapfile,&amp;$objlayer,&amp;$objmapa) @@ -2365,7 +2355,6 @@ function carregaquery2($mapfile,&amp;$objlayer,&amp;$objmapa)
2365 fclose ($handle); 2355 fclose ($handle);
2366 $shp = unserialize($conteudo); 2356 $shp = unserialize($conteudo);
2367 foreach ($shp as $indx){ 2357 foreach ($shp as $indx){
2368 -  
2369 $objmapa->querybyindex($indxlayer,-1,$indx,MS_TRUE); 2358 $objmapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);
2370 } 2359 }
2371 return "sim"; 2360 return "sim";
@@ -2456,14 +2445,18 @@ function retornaShapesMapext($objLayer,$objMapa){ @@ -2456,14 +2445,18 @@ function retornaShapesMapext($objLayer,$objMapa){
2456 function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ 2445 function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2457 $shapes = array(); 2446 $shapes = array();
2458 $qyfile = dirname($map_file)."/".$objLayer->name.".php"; 2447 $qyfile = dirname($map_file)."/".$objLayer->name.".php";
  2448 +
2459 if(!file_exists($qyfile)) 2449 if(!file_exists($qyfile))
2460 {return $shapes;} 2450 {return $shapes;}
  2451 +
2461 $handle = fopen ($qyfile, "r"); 2452 $handle = fopen ($qyfile, "r");
2462 $conteudo = fread ($handle, filesize ($qyfile)); 2453 $conteudo = fread ($handle, filesize ($qyfile));
2463 fclose ($handle); 2454 fclose ($handle);
2464 $listaDeIndices = unserialize($conteudo); 2455 $listaDeIndices = unserialize($conteudo);
  2456 + //echo count($listaDeIndices);exit;
2465 if(count($listaDeIndices) == 0) 2457 if(count($listaDeIndices) == 0)
2466 {return $shapes;} 2458 {return $shapes;}
  2459 +
2467 $versao = versao(); 2460 $versao = versao();
2468 $versao = $versao["principal"]; 2461 $versao = $versao["principal"];
2469 if ($objLayer->connectiontype != MS_POSTGIS){ 2462 if ($objLayer->connectiontype != MS_POSTGIS){
@@ -2476,6 +2469,7 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ @@ -2476,6 +2469,7 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2476 $centroides = array(); 2469 $centroides = array();
2477 $shapes = array(); 2470 $shapes = array();
2478 //pega um shape especifico 2471 //pega um shape especifico
  2472 +
2479 for ($i = 0; $i < $res_count; ++$i) 2473 for ($i = 0; $i < $res_count; ++$i)
2480 { 2474 {
2481 if($versao == 6) 2475 if($versao == 6)
@@ -2490,6 +2484,7 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ @@ -2490,6 +2484,7 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2490 $fechou = $objLayer->close(); 2484 $fechou = $objLayer->close();
2491 } 2485 }
2492 else{ 2486 else{
  2487 + //var_dump($listaDeIndices);exit;
2493 $rect = ms_newRectObj(); 2488 $rect = ms_newRectObj();
2494 $rect->set("minx",-180); 2489 $rect->set("minx",-180);
2495 $rect->set("miny",-90); 2490 $rect->set("miny",-90);