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 1459 $resultadoFinal = true;
1460 1460 }
1461 1461 else{
  1462 + $shapesSel = retornaShapesSelecionados($layer,$map_file,$map);//
  1463 +
1462 1464 $items = pegaItens($layer);
1463 1465 // cria o dbf
1464 1466 $def = array();
... ... @@ -1479,29 +1481,17 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1479 1481 $dbname = $nomeshp.".dbf";
1480 1482 $reg = array();
1481 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 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 1490 foreach ($items as $ni)
1501 1491 {
1502 1492 $vreg = $shape->values[$ni];
1503 1493 if(strlen($vreg) > 255){
1504   - $vreg = substr($vreg,0,255);
  1494 + $vreg = substr($vreg,0,255);
1505 1495 }
1506 1496 $reg[] = $vreg;
1507 1497 }
... ... @@ -2365,7 +2355,6 @@ function carregaquery2($mapfile,&amp;$objlayer,&amp;$objmapa)
2365 2355 fclose ($handle);
2366 2356 $shp = unserialize($conteudo);
2367 2357 foreach ($shp as $indx){
2368   -
2369 2358 $objmapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);
2370 2359 }
2371 2360 return "sim";
... ... @@ -2456,14 +2445,18 @@ function retornaShapesMapext($objLayer,$objMapa){
2456 2445 function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2457 2446 $shapes = array();
2458 2447 $qyfile = dirname($map_file)."/".$objLayer->name.".php";
  2448 +
2459 2449 if(!file_exists($qyfile))
2460 2450 {return $shapes;}
  2451 +
2461 2452 $handle = fopen ($qyfile, "r");
2462 2453 $conteudo = fread ($handle, filesize ($qyfile));
2463 2454 fclose ($handle);
2464 2455 $listaDeIndices = unserialize($conteudo);
  2456 + //echo count($listaDeIndices);exit;
2465 2457 if(count($listaDeIndices) == 0)
2466 2458 {return $shapes;}
  2459 +
2467 2460 $versao = versao();
2468 2461 $versao = $versao["principal"];
2469 2462 if ($objLayer->connectiontype != MS_POSTGIS){
... ... @@ -2476,6 +2469,7 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2476 2469 $centroides = array();
2477 2470 $shapes = array();
2478 2471 //pega um shape especifico
  2472 +
2479 2473 for ($i = 0; $i < $res_count; ++$i)
2480 2474 {
2481 2475 if($versao == 6)
... ... @@ -2490,6 +2484,7 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){
2490 2484 $fechou = $objLayer->close();
2491 2485 }
2492 2486 else{
  2487 + //var_dump($listaDeIndices);exit;
2493 2488 $rect = ms_newRectObj();
2494 2489 $rect->set("minx",-180);
2495 2490 $rect->set("miny",-90);
... ...