Commit 91ab497bffb14aa1951f9fca64da7a987c447b26
1 parent
73c18c9e
Exists in
master
and in
7 other branches
Correções no aplicativo datadownload. Agora o nome do shape file é igual ao do tema.
Showing
6 changed files
with
43 additions
and
17 deletions
Show diff stats
classesjs/datadownload.js
... | ... | @@ -102,7 +102,7 @@ function DDinicia() |
102 | 102 | { |
103 | 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 | 106 | var cp = new cpaint(); |
107 | 107 | //cp.set_debug(2) |
108 | 108 | cp.set_response_type("JSON"); |
... | ... | @@ -359,7 +359,7 @@ tema - código do tema para download |
359 | 359 | function download(tema) |
360 | 360 | { |
361 | 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 | 363 | var cp = new cpaint(); |
364 | 364 | //cp.set_debug(2) |
365 | 365 | cp.set_response_type("JSON"); |
... | ... | @@ -376,7 +376,7 @@ function mostraDownload(retorno) |
376 | 376 | { |
377 | 377 | var retorno = retorno.data |
378 | 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 | 380 | for (var arq=0;arq<arqs.length;arq++) |
381 | 381 | { |
382 | 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 | 80 | $this->xmlsistemas = ""; |
81 | 81 | if ($locsistemas != "") |
82 | 82 | $this->xmlsistemas = simplexml_load_file($locsistemas); |
83 | - if ($map_file != "") | |
83 | + if (($map_file != "") && (file_exists($map_file))) | |
84 | 84 | { |
85 | 85 | $this->mapa = ms_newMapObj($map_file); |
86 | 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 | 1476 | $locaplic - Diretório onde está a aplicação no servidor. |
1477 | 1477 | |
1478 | 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 | 1484 | //para manipular dbf |
1483 | 1485 | if(file_exists($locaplic."/pacotes/phpxbase/api_conversion.php")) |
... | ... | @@ -1491,8 +1493,13 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp) |
1491 | 1493 | $tipol = MS_SHP_POINT; |
1492 | 1494 | if ($layer->type == MS_LAYER_LINE){$tipol = MS_SHP_ARC;} |
1493 | 1495 | if ($layer->type == MS_LAYER_POLYGON){$tipol = MS_SHP_POLYGON;} |
1496 | + if ($nomeRand) | |
1494 | 1497 | $novonomelayer = nomeRandomico(20); |
1498 | + else | |
1499 | + $novonomelayer = $tema; | |
1495 | 1500 | $nomeshp = $dir_tmp."/".$novonomelayer; |
1501 | + if(file_exists($nomeshp.".shp")) | |
1502 | + {return $nomeshp;} | |
1496 | 1503 | if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) |
1497 | 1504 | {$mapt = ms_newMapObj($locaplic."\\aplicmap\\novotema.map");} |
1498 | 1505 | else |
... | ... | @@ -1590,12 +1597,12 @@ Include: |
1590 | 1597 | function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
1591 | 1598 | { |
1592 | 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 | 1606 | if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) |
1600 | 1607 | {$map_tmp = ms_newMapObj($locaplic."/aplicmap/geral1windows.map");} |
1601 | 1608 | else |
... | ... | @@ -1672,17 +1679,20 @@ function downloadTema($map_file,$tema,$locaplic,$dir_tmp) |
1672 | 1679 | {$arq = $sp.$dados;} |
1673 | 1680 | if ($arq != "") |
1674 | 1681 | { |
1675 | - $novonomelayer = nomeRandomico(20); | |
1682 | + $novonomelayer = $tema; //nomeRandomico(20); | |
1676 | 1683 | $nomeshp = $dir_tmp."/".$novonomelayer; |
1677 | 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 | 1691 | $resultado[] = str_replace($radtmp,"",$nomeshp); |
1682 | 1692 | } |
1683 | 1693 | else |
1684 | 1694 | { |
1685 | - $restemp = criaSHP($tema,$map_file,$locaplic,$dir_tmp); | |
1695 | + $restemp = criaSHP($tema,$map_file,$locaplic,$dir_tmp,FALSE); | |
1686 | 1696 | $resultado[] = str_replace($radtmp,"",$restemp); |
1687 | 1697 | } |
1688 | 1698 | } | ... | ... |
classesphp/mapa_controle.php
... | ... | @@ -79,7 +79,7 @@ Include: |
79 | 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 | 84 | //sleep(5); |
85 | 85 | |
... | ... | @@ -134,12 +134,22 @@ $_SESSION["ultimopid"] = getmypid(); |
134 | 134 | if ($funcao == "criaMapa") |
135 | 135 | { |
136 | 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 | 147 | chdir($locaplic); |
139 | 148 | $interface = "mashup"; |
140 | 149 | include("ms_criamapa.php"); |
141 | 150 | $cp->set_data(session_id()); |
142 | 151 | $cp->return_data(); |
152 | + return; | |
143 | 153 | } |
144 | 154 | if (!isset($map_file)) |
145 | 155 | { |
... | ... | @@ -1493,6 +1503,9 @@ Include: |
1493 | 1503 | case "pegalistadegrupos": |
1494 | 1504 | include("classe_menutemas.php"); |
1495 | 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 | 1509 | $cp->set_data(array("grupos"=>$m->pegaListaDeGrupos($idmenu,$listasistemas,$listasgrupos))); |
1497 | 1510 | break; |
1498 | 1511 | /* |
... | ... | @@ -2349,6 +2362,7 @@ Lista os arquivos de um diretório. |
2349 | 2362 | } |
2350 | 2363 | if (!connection_aborted()) |
2351 | 2364 | { |
2365 | + if(isset($map_file) && isset($postgis_mapa)) | |
2352 | 2366 | restauraCon($map_file,$postgis_mapa); |
2353 | 2367 | $cp->return_data(); |
2354 | 2368 | } | ... | ... |
menutemas/menutemas.xml