Commit ca448575a2bf55ee43460f51d239ca8c8f5759c1
1 parent
c0280439
Exists in
master
and in
7 other branches
$1
Showing
5 changed files
with
48 additions
and
11 deletions
Show diff stats
classesjs/datadownload.js
| ... | ... | @@ -279,10 +279,14 @@ function datadownload_download(obj) |
| 279 | 279 | YAHOO.datadownloadLista.panel.show(); |
| 280 | 280 | //document.getElementById("corpo").innerHTML = "Aguarde. Gerando arquivos..." |
| 281 | 281 | var p = g_locaplic+"/classesphp/mapa_controle.php?map_file=&funcao=download3&tema="+obj.title; |
| 282 | - //caso a camada venha do sistema de metadados estatisticos | |
| 282 | + //caso a camada venha do sistema de metadados estatisticos e seja uma variavel | |
| 283 | 283 | if(obj.name && obj.name === "metaestat"){ |
| 284 | 284 | p = g_locaplic+"/classesphp/mapa_controle.php?map_file=&funcao=download3&id_medida_variavel="+obj.title; |
| 285 | 285 | } |
| 286 | + if(obj.name && obj.name === "regioesmetaestat"){ | |
| 287 | + p = g_locaplic+"/classesphp/mapa_controle.php?map_file=&funcao=download3&codigo_tipo_regiao="+obj.title.replace("metaregiao_",""); | |
| 288 | + } | |
| 289 | + | |
| 286 | 290 | temaEscolhidoDownload = obj.title; |
| 287 | 291 | var cp = new cpaint(); |
| 288 | 292 | //cp.set_debug(2) |
| ... | ... | @@ -375,4 +379,4 @@ function dataDownloadLinks(rss) |
| 375 | 379 | cp.call(p,"listaRSSws2",monta); |
| 376 | 380 | } |
| 377 | 381 | } |
| 378 | -} | |
| 379 | 382 | \ No newline at end of file |
| 383 | +} | ... | ... |
classesphp/classe_selecao.php
| ... | ... | @@ -627,12 +627,12 @@ function: selecaoLimpa |
| 627 | 627 | |
| 628 | 628 | Limpa a seleção do tema. |
| 629 | 629 | */ |
| 630 | - function selecaoLimpa() | |
| 630 | + function selecaoLimpa($apagaQyfile=false) | |
| 631 | 631 | { |
| 632 | 632 | //apaga o arquivo do i3geo com os ids selecionados |
| 633 | 633 | if(file_exists($this->qyfileTema)) |
| 634 | 634 | {unlink($this->qyfileTema);} |
| 635 | - if ($this->nome != "") //limpa de um tema | |
| 635 | + if ($this->nome != "" && $apagaQyfile == false) //limpa de um tema | |
| 636 | 636 | { |
| 637 | 637 | if(!$this->layer){return "erro";} |
| 638 | 638 | if (file_exists($this->qyfile)) |
| ... | ... | @@ -955,4 +955,4 @@ $geos - array com os dados |
| 955 | 955 | fclose($fp); |
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | -?> | |
| 959 | 958 | \ No newline at end of file |
| 959 | +?> | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -1421,7 +1421,6 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1421 | 1421 | else |
| 1422 | 1422 | {$novonomelayer = $tema;} |
| 1423 | 1423 | |
| 1424 | - | |
| 1425 | 1424 | $novonomelayer = str_replace(".","-",$novonomelayer); |
| 1426 | 1425 | $nomeshp = $dir_tmp."/".$novonomelayer; |
| 1427 | 1426 | |
| ... | ... | @@ -1460,7 +1459,6 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1460 | 1459 | } |
| 1461 | 1460 | else{ |
| 1462 | 1461 | $shapesSel = retornaShapesSelecionados($layer,$map_file,$map);// |
| 1463 | - | |
| 1464 | 1462 | $items = pegaItens($layer); |
| 1465 | 1463 | // cria o dbf |
| 1466 | 1464 | $def = array(); |
| ... | ... | @@ -1483,7 +1481,6 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1483 | 1481 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); |
| 1484 | 1482 | |
| 1485 | 1483 | $res_count = count($shapesSel); |
| 1486 | - | |
| 1487 | 1484 | if ($res_count > 0){ |
| 1488 | 1485 | for ($i = 0; $i < $res_count; ++$i){ |
| 1489 | 1486 | $shape = $shapesSel[$i]; |
| ... | ... | @@ -1649,6 +1646,7 @@ function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) |
| 1649 | 1646 | } |
| 1650 | 1647 | //se o layer não existir no mapfile, pega da pasta i3geo/temas e adiciona em $map |
| 1651 | 1648 | if($teste == ""){ |
| 1649 | + //tema pode ser o nome de um arquivo mapfile | |
| 1652 | 1650 | if(file_exists($tema.".map")){ |
| 1653 | 1651 | $maptemp = ms_newMapObj($tema.".map"); |
| 1654 | 1652 | $tema = basename($tema); |
| ... | ... | @@ -1689,12 +1687,18 @@ function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) |
| 1689 | 1687 | $map = $gm->addLayers($map,$gvsigview,$dataView["layerNames"]); |
| 1690 | 1688 | $temas = array_merge($temas,$gm->nomesLayersAdicionados); |
| 1691 | 1689 | } |
| 1692 | - //$temas = $gm->nomesLayersAdicionados; | |
| 1693 | 1690 | } |
| 1694 | 1691 | // |
| 1695 | 1692 | //salva o mapfile com um outro nome para evitar que o mapa atual, se estiver aberto, seja modificado |
| 1696 | 1693 | // |
| 1697 | - $map_file = str_replace(".map","tmp.map",$map_file); | |
| 1694 | + //verifica se tem query e copia o arquivo | |
| 1695 | + $qyfile = str_replace(".map",".qy",$map_file); | |
| 1696 | + $nr = nomerandomico(10); | |
| 1697 | + $map_file = str_replace(".map",$nr."tmp.map",$map_file); | |
| 1698 | + if(file_exists($qyfile)){ | |
| 1699 | + $nqyfile = str_replace(".map",".qy",$map_file); | |
| 1700 | + copy($qyfile,$nqyfile); | |
| 1701 | + } | |
| 1698 | 1702 | $map->save($map_file); |
| 1699 | 1703 | substituiCon($map_file,$postgis_mapa); |
| 1700 | 1704 | //$map_file agora contem os LAYERS necessários |
| ... | ... | @@ -1782,6 +1786,25 @@ function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) |
| 1782 | 1786 | } |
| 1783 | 1787 | } |
| 1784 | 1788 | else{ //se for vetorial, extrai o arquivo |
| 1789 | + // | |
| 1790 | + //verifica se existe selecao, caso contrario, faz a selecao baseada na extensao | |
| 1791 | + //do mapfile | |
| 1792 | + // | |
| 1793 | + include(dirname(__FILE__)."/../classesphp/classe_selecao.php"); | |
| 1794 | + $sel = New Selecao($map_file,$tema); | |
| 1795 | + //carrega a query para ver se o layer possui selecao ou nao | |
| 1796 | + $numSel = 0; | |
| 1797 | + if(file_exists($sel->qyfile)){ | |
| 1798 | + $map->loadquery($sel->qyfile); | |
| 1799 | + $numSel = $l->getNumresults(); | |
| 1800 | + } | |
| 1801 | + // | |
| 1802 | + //se nao existir selecao seleciona por box | |
| 1803 | + // | |
| 1804 | + if(!file_exists($sel->qyfile) || $numSel < 1){ | |
| 1805 | + $box = $rectextent->minx." ".$rectextent->miny." ".$rectextent->maxx." ".$rectextent->maxy; | |
| 1806 | + $sel->selecaoBOX("novo",$box); | |
| 1807 | + } | |
| 1785 | 1808 | $nomeshp = criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand); |
| 1786 | 1809 | if($nomeshp == false){ |
| 1787 | 1810 | return array("arquivos"=>"<span style=color:red >Ocorreu um erro, tente novamente","nreg"=>0); | ... | ... |
classesphp/mapa_controle.php
| ... | ... | @@ -890,6 +890,16 @@ Gera os arquivos para download de um tema for&ccedil;ando um mapfile vazio. |
| 890 | 890 | */ |
| 891 | 891 | case "DOWNLOAD3": |
| 892 | 892 | //caso o tema tenha de vir do sistema de metadados estatisticos |
| 893 | + | |
| 894 | + //pode ser uma regiao cadastrada no sistema de metadados | |
| 895 | + if(isset($codigo_tipo_regiao) && $codigo_tipo_regiao != ""){ | |
| 896 | + include(dirname(__FILE__)."/../admin/php/classe_metaestat.php"); | |
| 897 | + $m = new Metaestat(); | |
| 898 | + $m->nomecache = "ogcmetaestatreg".$codigo_tipo_regiao; | |
| 899 | + $tema = $m->mapfileTipoRegiao($codigo_tipo_regiao); | |
| 900 | + $tema = str_replace(".map","",$tema["mapfile"]); | |
| 901 | + } | |
| 902 | + //pode ser uma medida de uma variavel | |
| 893 | 903 | if(isset($id_medida_variavel) && $id_medida_variavel != ""){ |
| 894 | 904 | include(dirname(__FILE__)."/../admin/php/classe_metaestat.php"); |
| 895 | 905 | $m = new Metaestat(); | ... | ... |
datadownload.htm
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | <meta name="description" content="Mapa interativo do MMA"> |
| 7 | 7 | <meta name="keywords" content="WMS OGC mapa sig gis webmapping geo geoprocessamento interativo meio ambiente MMA cartografia geografia"> |
| 8 | 8 | <meta name="robots" content="index,follow"> |
| 9 | -<script type="text/javascript" src="classesjs/i3geonaocompacto.js"></script> | |
| 9 | +<script type="text/javascript" src="classesjs/i3geo.js"></script> | |
| 10 | 10 | <script type="text/javascript" src="classesjs/datadownload.js"></script> |
| 11 | 11 | <style> |
| 12 | 12 | P | ... | ... |