Commit f8bab1e88c08140df7483d42b7af939ea7bd800c

Authored by Edmar Moretti
1 parent 965f17fc

--no commit message

admin/admin.db
No preview for this file type
classesphp/classe_selecao.php
... ... @@ -789,8 +789,11 @@ $dir_tmp - localização do diretório temporário
789 789 {
790 790 if(!$this->layer){return "erro";}
791 791 $this->layer->setfilter("");
792   - $nomeshp = criaSHP($this->nome,$this->arquivo,$locaplic,$dir_tmp);
  792 + $nomeshp = criaSHP($this->nome,$this->arquivo,$locaplic,$dir_tmp,true,"",false);
793 793 $novolayer = criaLayer($this->mapa,$this->layer->type,MS_DEFAULT,"Seleção de ".(pegaNome($this->layer))." (".$this->nome.")",$metaClasse="SIM");
  794 + if($this->layer->getprojection() != ""){
  795 + $novolayer->setprojection($this->layer->getprojection());
  796 + }
794 797 $novolayer->set("data",$nomeshp.".shp");
795 798 $novolayer->set("name",basename($nomeshp));
796 799 $down = "nao";
... ...
classesphp/funcoes_gerais.php
... ... @@ -1397,11 +1397,13 @@ $nomeRand {boleano} - Gera um nome randomico para o shapefile (TRUE) ou utiliza
1397 1397  
1398 1398 $prj {string} - String que sera gravada no arquivo prj
1399 1399  
  1400 +$projetaToMap {boolean} - Projeta os shapes para a projecao do mapa
  1401 +
1400 1402 Retorno:
1401 1403  
1402 1404 {string} - nome do arquivo criado ou false se ocorrer erro
1403 1405 */
1404   -function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE,$prj="")
  1406 +function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE,$prj="",$projetaToMap=true)
1405 1407 {
1406 1408 $versao = versao();
1407 1409 $versao = $versao["principal"];
... ... @@ -1510,7 +1512,9 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE,$prj="")
1510 1512 if ($res_count > 0){
1511 1513 for ($i = 0; $i < $res_count; ++$i){
1512 1514 $shape = $shapesSel[$i];
1513   - $shape->project($projInObj, $projOutObj);
  1515 + if($projetaToMap == true){
  1516 + $shape->project($projInObj, $projOutObj);
  1517 + }
1514 1518 foreach ($items as $ni){
1515 1519 $vreg = $shape->values[$ni];
1516 1520 if(strlen($vreg) > 255){
... ... @@ -1570,6 +1574,15 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE,$prj=&quot;&quot;)
1570 1574 if($prj != ""){
1571 1575 gravaDados(array($prj),$nomeshp.".prj");
1572 1576 }
  1577 + //se prj for vazio mas existir o arquivo prj original e a projecao do shape nao estiver ativa
  1578 + //copia o arquivo prj original se existir
  1579 + elseif ($projetaToMap == false){
  1580 + $nomePrjOriginal = str_replace(".shp",".prj",$layer->data);
  1581 + $nomeDestino = $nomeshp.".prj";
  1582 + if(file_exists($nomePrjOriginal) && !file_exists($nomeDestino)){
  1583 + copy($nomePrjOriginal,$nomeDestino);
  1584 + }
  1585 + }
1573 1586 return $nomeshp;
1574 1587 }
1575 1588 }
... ...