Commit 91ab497bffb14aa1951f9fca64da7a987c447b26

Authored by Edmar Moretti
1 parent 73c18c9e

Correções no aplicativo datadownload. Agora o nome do shape file é igual ao do tema.

classesjs/datadownload.js
@@ -102,7 +102,7 @@ function DDinicia() @@ -102,7 +102,7 @@ function DDinicia()
102 { 102 {
103 if (g_tipo == "menutemas") 103 if (g_tipo == "menutemas")
104 { 104 {
105 - var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegalistadegrupos&map_file=''"; 105 + var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegalistadegrupos&map_file=";
106 var cp = new cpaint(); 106 var cp = new cpaint();
107 //cp.set_debug(2) 107 //cp.set_debug(2)
108 cp.set_response_type("JSON"); 108 cp.set_response_type("JSON");
@@ -359,7 +359,7 @@ tema - código do tema para download @@ -359,7 +359,7 @@ tema - código do tema para download
359 function download(tema) 359 function download(tema)
360 { 360 {
361 document.getElementById("corpo").innerHTML = "Aguarde. Gerando arquivos..." 361 document.getElementById("corpo").innerHTML = "Aguarde. Gerando arquivos..."
362 - var p = g_locaplic+"/classesphp/mapa_controle.php?map_file=''&funcao=download&tema="+tema; 362 + var p = g_locaplic+"/classesphp/mapa_controle.php?map_file=&funcao=download&tema="+tema;
363 var cp = new cpaint(); 363 var cp = new cpaint();
364 //cp.set_debug(2) 364 //cp.set_debug(2)
365 cp.set_response_type("JSON"); 365 cp.set_response_type("JSON");
@@ -376,7 +376,7 @@ function mostraDownload(retorno) @@ -376,7 +376,7 @@ function mostraDownload(retorno)
376 { 376 {
377 var retorno = retorno.data 377 var retorno = retorno.data
378 var arqs = retorno.split(",") 378 var arqs = retorno.split(",")
379 - var ins = "<b>Clique nos links para pegar os arquivos:</b><br><br>" 379 + var ins = "<b>Clique nos links para pegar os arquivos. Para obter os metadados, veja o link na árvore ao lado.</b><br><br>"
380 for (var arq=0;arq<arqs.length;arq++) 380 for (var arq=0;arq<arqs.length;arq++)
381 { 381 {
382 var temp = arqs[arq].split("."); 382 var temp = arqs[arq].split(".");
classesphp/classe_menutemas.php
@@ -80,7 +80,7 @@ $map_file - string $map_file Endereço do mapfile no servidor. @@ -80,7 +80,7 @@ $map_file - string $map_file Endereço do mapfile no servidor.
80 $this->xmlsistemas = ""; 80 $this->xmlsistemas = "";
81 if ($locsistemas != "") 81 if ($locsistemas != "")
82 $this->xmlsistemas = simplexml_load_file($locsistemas); 82 $this->xmlsistemas = simplexml_load_file($locsistemas);
83 - if ($map_file != "") 83 + if (($map_file != "") && (file_exists($map_file)))
84 { 84 {
85 $this->mapa = ms_newMapObj($map_file); 85 $this->mapa = ms_newMapObj($map_file);
86 $this->arquivo = $map_file; 86 $this->arquivo = $map_file;
classesphp/funcoes_gerais.php
@@ -1476,8 +1476,10 @@ $map_file -Nome do arquivo map file. Inclua o caminho completo no servidor. @@ -1476,8 +1476,10 @@ $map_file -Nome do arquivo map file. Inclua o caminho completo no servidor.
1476 $locaplic - Diretório onde está a aplicação no servidor. 1476 $locaplic - Diretório onde está a aplicação no servidor.
1477 1477
1478 $dir_tmp - Diretório temporário 1478 $dir_tmp - Diretório temporário
  1479 +
  1480 +$nomeRand - Gera um nome randomico para o shapefile (TRUE) ou utiliza o nome do tema (FALSE)
1479 */ 1481 */
1480 -function criaSHP($tema,$map_file,$locaplic,$dir_tmp) 1482 +function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE)
1481 { 1483 {
1482 //para manipular dbf 1484 //para manipular dbf
1483 if(file_exists($locaplic."/pacotes/phpxbase/api_conversion.php")) 1485 if(file_exists($locaplic."/pacotes/phpxbase/api_conversion.php"))
@@ -1491,8 +1493,13 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp) @@ -1491,8 +1493,13 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp)
1491 $tipol = MS_SHP_POINT; 1493 $tipol = MS_SHP_POINT;
1492 if ($layer->type == MS_LAYER_LINE){$tipol = MS_SHP_ARC;} 1494 if ($layer->type == MS_LAYER_LINE){$tipol = MS_SHP_ARC;}
1493 if ($layer->type == MS_LAYER_POLYGON){$tipol = MS_SHP_POLYGON;} 1495 if ($layer->type == MS_LAYER_POLYGON){$tipol = MS_SHP_POLYGON;}
  1496 + if ($nomeRand)
1494 $novonomelayer = nomeRandomico(20); 1497 $novonomelayer = nomeRandomico(20);
  1498 + else
  1499 + $novonomelayer = $tema;
1495 $nomeshp = $dir_tmp."/".$novonomelayer; 1500 $nomeshp = $dir_tmp."/".$novonomelayer;
  1501 + if(file_exists($nomeshp.".shp"))
  1502 + {return $nomeshp;}
1496 if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) 1503 if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
1497 {$mapt = ms_newMapObj($locaplic."\\aplicmap\\novotema.map");} 1504 {$mapt = ms_newMapObj($locaplic."\\aplicmap\\novotema.map");}
1498 else 1505 else
@@ -1590,12 +1597,12 @@ Include: @@ -1590,12 +1597,12 @@ Include:
1590 function downloadTema($map_file,$tema,$locaplic,$dir_tmp) 1597 function downloadTema($map_file,$tema,$locaplic,$dir_tmp)
1591 { 1598 {
1592 ini_set("max_execution_time","1800"); 1599 ini_set("max_execution_time","1800");
1593 - if (!@ms_newMapObj($map_file)) //a funcao foi chamada do aplicativo datadownload 1600 + if(file_exists($locaplic."/ms_configura.php"))
  1601 + require_once($locaplic."/ms_configura.php");
  1602 + else
  1603 + require_once("../ms_configura.php");
  1604 + if (($map_file == "") || (!@ms_newMapObj($map_file))) //a funcao foi chamada do aplicativo datadownload
1594 { 1605 {
1595 - if(file_exists($locaplic."/ms_configura.php"))  
1596 - require_once($locaplic."/ms_configura.php");  
1597 - else  
1598 - require_once("../ms_configura.php");  
1599 if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) 1606 if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
1600 {$map_tmp = ms_newMapObj($locaplic."/aplicmap/geral1windows.map");} 1607 {$map_tmp = ms_newMapObj($locaplic."/aplicmap/geral1windows.map");}
1601 else 1608 else
@@ -1672,17 +1679,20 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) @@ -1672,17 +1679,20 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp)
1672 {$arq = $sp.$dados;} 1679 {$arq = $sp.$dados;}
1673 if ($arq != "") 1680 if ($arq != "")
1674 { 1681 {
1675 - $novonomelayer = nomeRandomico(20); 1682 + $novonomelayer = $tema; //nomeRandomico(20);
1676 $nomeshp = $dir_tmp."/".$novonomelayer; 1683 $nomeshp = $dir_tmp."/".$novonomelayer;
1677 $arq = explode(".shp",$arq); 1684 $arq = explode(".shp",$arq);
1678 - copy($arq[0].".shp",$nomeshp.".shp");  
1679 - copy($arq[0].".shx",$nomeshp.".shx");  
1680 - copy($arq[0].".dbf",$nomeshp.".dbf"); 1685 + if(!file_exists($nomeshp.".shp"))
  1686 + {
  1687 + copy($arq[0].".shp",$nomeshp.".shp");
  1688 + copy($arq[0].".shx",$nomeshp.".shx");
  1689 + copy($arq[0].".dbf",$nomeshp.".dbf");
  1690 + }
1681 $resultado[] = str_replace($radtmp,"",$nomeshp); 1691 $resultado[] = str_replace($radtmp,"",$nomeshp);
1682 } 1692 }
1683 else 1693 else
1684 { 1694 {
1685 - $restemp = criaSHP($tema,$map_file,$locaplic,$dir_tmp); 1695 + $restemp = criaSHP($tema,$map_file,$locaplic,$dir_tmp,FALSE);
1686 $resultado[] = str_replace($radtmp,"",$restemp); 1696 $resultado[] = str_replace($radtmp,"",$restemp);
1687 } 1697 }
1688 } 1698 }
classesphp/mapa_controle.php
@@ -79,7 +79,7 @@ Include: @@ -79,7 +79,7 @@ Include:
79 <pega_variaveis.php>, <carrega_ext.php>, <cpaint2.inc.php>, <classe_vermultilayer.php>, <classe_estatistica.php>, <funcoes_gerais.php> 79 <pega_variaveis.php>, <carrega_ext.php>, <cpaint2.inc.php>, <classe_vermultilayer.php>, <classe_estatistica.php>, <funcoes_gerais.php>
80 80
81 */ 81 */
82 -//error_reporting(0); 82 +error_reporting(0);
83 83
84 //sleep(5); 84 //sleep(5);
85 85
@@ -134,12 +134,22 @@ $_SESSION[&quot;ultimopid&quot;] = getmypid(); @@ -134,12 +134,22 @@ $_SESSION[&quot;ultimopid&quot;] = getmypid();
134 if ($funcao == "criaMapa") 134 if ($funcao == "criaMapa")
135 { 135 {
136 session_destroy(); 136 session_destroy();
137 - include("../ms_configura.php"); 137 + //
  138 + //primeiro é necessário carregar o ms_configura.php para pegar a variável $locaplic
  139 + //
  140 + $d = "";
  141 + if(!file_exists($d."ms_configura.php"))
  142 + $d = "../";
  143 + include($d."ms_configura.php");
  144 + //
  145 + //é necessário mudar o diretório em função dos includes que são feitos pelo ms_criamapa.php
  146 + //
138 chdir($locaplic); 147 chdir($locaplic);
139 $interface = "mashup"; 148 $interface = "mashup";
140 include("ms_criamapa.php"); 149 include("ms_criamapa.php");
141 $cp->set_data(session_id()); 150 $cp->set_data(session_id());
142 $cp->return_data(); 151 $cp->return_data();
  152 + return;
143 } 153 }
144 if (!isset($map_file)) 154 if (!isset($map_file))
145 { 155 {
@@ -1493,6 +1503,9 @@ Include: @@ -1493,6 +1503,9 @@ Include:
1493 case "pegalistadegrupos": 1503 case "pegalistadegrupos":
1494 include("classe_menutemas.php"); 1504 include("classe_menutemas.php");
1495 $m = new Menutemas($map_file,$perfil,$locsistemas); 1505 $m = new Menutemas($map_file,$perfil,$locsistemas);
  1506 + if(!isset($idmenu)){$idmenu="";}
  1507 + if(!isset($listasistemas)){$listasistemas="nao";}
  1508 + if(!isset($listasgrupos)){$listasgrupos="sim";}
1496 $cp->set_data(array("grupos"=>$m->pegaListaDeGrupos($idmenu,$listasistemas,$listasgrupos))); 1509 $cp->set_data(array("grupos"=>$m->pegaListaDeGrupos($idmenu,$listasistemas,$listasgrupos)));
1497 break; 1510 break;
1498 /* 1511 /*
@@ -2349,6 +2362,7 @@ Lista os arquivos de um diretório. @@ -2349,6 +2362,7 @@ Lista os arquivos de um diretório.
2349 } 2362 }
2350 if (!connection_aborted()) 2363 if (!connection_aborted())
2351 { 2364 {
  2365 + if(isset($map_file) && isset($postgis_mapa))
2352 restauraCon($map_file,$postgis_mapa); 2366 restauraCon($map_file,$postgis_mapa);
2353 $cp->return_data(); 2367 $cp->return_data();
2354 } 2368 }
menutemas/menutemas.xml
@@ -105,6 +105,7 @@ File: i3geo/menutemas/menutemas.xml @@ -105,6 +105,7 @@ File: i3geo/menutemas/menutemas.xml
105 <TNOME>Biomas</TNOME> 105 <TNOME>Biomas</TNOME>
106 <TDESC></TDESC> 106 <TDESC></TDESC>
107 <TLINK></TLINK> 107 <TLINK></TLINK>
  108 + <DOWNLOAD>SIM</DOWNLOAD>
108 </TEMA> 109 </TEMA>
109 <TEMA> 110 <TEMA>
110 <TID>biomaerro</TID> 111 <TID>biomaerro</TID>
temas/bioma.map
@@ -14,6 +14,7 @@ LAYER @@ -14,6 +14,7 @@ LAYER
14 TEMA "Bioma" 14 TEMA "Bioma"
15 CLASSE "SIM" 15 CLASSE "SIM"
16 ESCALA "5000000" 16 ESCALA "5000000"
  17 + DOWNLOAD "SIM"
17 END 18 END
18 MINSCALE 50 19 MINSCALE 50
19 TRANSPARENCY 80 20 TRANSPARENCY 80