From ebaf80fdfbd315df7ca1b42c6a34ca5e83b24ba6 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Sat, 29 Apr 2017 13:07:02 -0300 Subject: [PATCH] Criação do formulário para upload de arquivos shapefile para o servidor de banco de dados e criação automática do respectivo arquivo de configuração mapfile. --- admin/admin.db | Bin 340992 -> 0 bytes admin/php/metaestat_uploadshp_submit.php | 11 +++++++++++ admin1/catalogo/mapfile/editor/funcoes.php | 1 + admin1/catalogo/mapfile/editor/index.php | 2 +- admin1/dicionario/menup.js | 7 ++++++- admin1/dicionario/uploadshp.js | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- admin1/index.php | 4 ++++ admin1/js/bdexplorer.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- admin1/menu.js | 2 +- admin1/php/bdexplorer.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------- admin1/upload/arquivo/exec.php | 26 +++++++++++++++----------- admin1/upload/arquivo/index.php | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------ admin1/upload/banco/index.php | 36 ------------------------------------ admin1/upload/shp2pg/exec.php | 443 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ admin1/upload/shp2pg/index.js | 25 +++++++++++++++++++++++++ admin1/upload/shp2pg/index.php | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ classesphp/classe_bdexplorer.php | 32 ++++++++++++++++++++++++++++---- ms_configura.php | 40 ++++++++++++++++++++++++++-------------- temas/bacia_ipojuca.map | 79 ------------------------------------------------------------------------------- 19 files changed, 1113 insertions(+), 271 deletions(-) delete mode 100755 admin1/upload/banco/index.php create mode 100755 admin1/upload/shp2pg/exec.php create mode 100755 admin1/upload/shp2pg/index.js create mode 100755 admin1/upload/shp2pg/index.php delete mode 100644 temas/bacia_ipojuca.map diff --git a/admin/admin.db b/admin/admin.db index e148ae6..426081b 100755 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/admin/php/metaestat_uploadshp_submit.php b/admin/php/metaestat_uploadshp_submit.php index f573908..12b1b9c 100755 --- a/admin/php/metaestat_uploadshp_submit.php +++ b/admin/php/metaestat_uploadshp_submit.php @@ -113,6 +113,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ //pega os parametros de conexao include("classe_metaestat.php"); $m = new Metaestat(); + $conexao = $m->listaConexao($_POST["i3GEOuploadcodigoconexao"],true); //array(5) { ["codigo_estat_conexao"]=> string(1) "1" ["bancodedados"]=> string(8) "geosaude" ["host"]=> string(9) "localhost" ["porta"]=> string(4) "5432" ["usuario"]=> string(8) "postgres" } //pega as colunas do shapefile @@ -218,6 +219,10 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ flush(); sleep(1); } + + + + if($tabelaExiste == true && $_POST["tipoOperacao"] == "criar"){ echo "A tabela existe. Não pode ser criada."; exit; @@ -237,6 +242,12 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ ob_flush(); flush(); sleep(1); + + + + + + $srid = 4326; $escapar = "'"; $projOutObj = ""; diff --git a/admin1/catalogo/mapfile/editor/funcoes.php b/admin1/catalogo/mapfile/editor/funcoes.php index 1d8151e..73588f4 100755 --- a/admin1/catalogo/mapfile/editor/funcoes.php +++ b/admin1/catalogo/mapfile/editor/funcoes.php @@ -217,5 +217,6 @@ function salvaMapfile() { } $resultado = \admin\php\funcoesAdmin\i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '$codigo'" ); } + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $mapfile ); } ?> \ No newline at end of file diff --git a/admin1/catalogo/mapfile/editor/index.php b/admin1/catalogo/mapfile/editor/index.php index 5765775..4aa39ed 100755 --- a/admin1/catalogo/mapfile/editor/index.php +++ b/admin1/catalogo/mapfile/editor/index.php @@ -77,7 +77,7 @@ $textoMapfile = \admin\catalogo\mapfile\editor\textoMapfile ( $codigo );
-
+ "; unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); @@ -154,7 +155,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { unlink ( $dirmap . "/" . $nomePrefixo . ".prj" ); exit (); } - $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".shx", "Arquivo shx invalido
"; unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); @@ -163,7 +164,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { unlink ( $dirmap . "/" . $nomePrefixo . ".prj" ); exit (); } - $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".dbf", "Arquivo dbf invalido
"; unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); @@ -173,11 +174,14 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { exit (); } echo ""; + ob_flush ();flush (); sleep ( 2 ); if ($i3GEOuploadCriaMapfile == "on" && file_exists ( $_SESSION ["locaplic"] . "/temas/" . $nomePrefixo . ".map" )) { echo ""; $i3GEOuploadCriaMapfile = ""; } if ($i3GEOuploadCriaMapfile == "on") { + echo ""; + ob_flush ();flush (); sleep ( 2 ); // verifica se o usuario marcou a opcao de cria mapfile // nesse caso o aplicativo de upload esta sendo executado de dentro do sistema de administracao, e o mapfile devera // ser criado e registrado no sistema @@ -187,9 +191,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { $en = $nomePrefixo; $es = $nomePrefixo; $sfileObj = ms_newShapefileObj ( $dirmap . "/" . $nomePrefixo . ".shp", - 1 ); - if (! isset ( $tipo ) || $tipo == "") { - $tipo = $sfileObj->type; - } + $tipo = $sfileObj->type; if ($tipo == 1) { $tipoLayer = MS_LAYER_POINT; } @@ -207,6 +209,9 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { $layer = $mapa->getLayerByName ( $codigo ); $layer->set ( "data", $data ); $layer->set ( "type", $tipoLayer ); + if(file_exists($dirmap . "/" . $nomePrefixo . ".prj")){ + $layer->setprojection("AUTO"); + } $mapa->save ( $_SESSION ["locaplic"] . "/temas/" . $codigo . ".map" ); echo ""; } else { @@ -229,7 +234,6 @@ function verificaNome($nome) { $extensao = $lista [count ( $lista ) - 1]; if (($extensao != "dbf") && ($extensao != "shx") && ($extensao != "shp") && ($extensao != "prj")) { echo "Nome de arquivo inválido. $nome"; - paraAguarde (); exit (); } } diff --git a/admin1/upload/arquivo/index.php b/admin1/upload/arquivo/index.php index e7de854..41a1c2c 100755 --- a/admin1/upload/arquivo/index.php +++ b/admin1/upload/arquivo/index.php @@ -3,7 +3,7 @@ define ( "ONDEI3GEO", "../../.." ); include ("exec.php"); include "../../head.php"; // monta o combo com a lista de pastas para armazenar os arquivos -$chaves = array_keys ( $_SESSION ["i3geoUploadDataWL"] ); +$chaves = array_keys ( $_SESSION ["i3geoUploadDataWL"]["arquivos"] ); $comboPastas = '";
- - - -