Commit 112cad2deabd6db4df32bbf547dbaa2017a260cf

Authored by Edmar Moretti
1 parent e7036494

$1

admin/js/estat_editor.js
@@ -527,12 +527,13 @@ i3GEOadmin.editor = { @@ -527,12 +527,13 @@ i3GEOadmin.editor = {
527 i3GEOadmin.editor.tabela.optionsTabela + 527 i3GEOadmin.editor.tabela.optionsTabela +
528 '</select></p>' + 528 '</select></p>' +
529 '<p class="paragrafo" >Tipo de opera&ccedil;&atilde;o:</p>' + 529 '<p class="paragrafo" >Tipo de opera&ccedil;&atilde;o:</p>' +
530 - '<p class="paragrafo" ><select id=i3GEOtipoOperacao name=tipoOperacao >' + 530 + '<select id=i3GEOtipoOperacao name=tipoOperacao >' +
531 '<option value=criar >Criar a tabela nova e incluir registros do SHP</option>' + 531 '<option value=criar >Criar a tabela nova e incluir registros do SHP</option>' +
532 '<option value=incluir >Adicionar novos registros</option>' + 532 '<option value=incluir >Adicionar novos registros</option>' +
533 '<option value=apagar >Apagar dados atuais e incluir do SHP</option>' + 533 '<option value=apagar >Apagar dados atuais e incluir do SHP</option>' +
534 '</select></p>' + 534 '</select></p>' +
535 '<p class="paragrafo" >C&oacute;digo da proje&ccedil;&atilde;o (SRID) Assegure-se que o shapefile esteja na proje&ccedil;&atilde;o geogr&aacute;fica se voc&ecirc; for usar com o sistema de metadados estat&iacute;sticos :<br><input class=digitar type="text" value="4326" size=20 id="srid" name="srid" style="top:0px;left:0px;cursor:pointer;"></p>' + 535 '<p class="paragrafo" >C&oacute;digo da proje&ccedil;&atilde;o (SRID) Assegure-se que o shapefile esteja na proje&ccedil;&atilde;o geogr&aacute;fica se voc&ecirc; for usar com o sistema de metadados estat&iacute;sticos :<br><input class=digitar type="text" value="4326" size=20 id="srid" name="srid" style="top:0px;left:0px;cursor:pointer;"></p>' +
  536 + '<p class="paragrafo" ><input type="checkbox" id="incluiserialshp" name="incluiserialshp" style="cursor:pointer;position:relative;top:2px;">&nbsp;Inclui uma coluna gid do tipo serial e chave prim&aacute;ria com c&oacute;digo &uacute;nico</p>' +
536 '<p class="paragrafo" ><input id=i3GEOuploadsubmit type="button" value="Enviar" size=12 />' + 537 '<p class="paragrafo" ><input id=i3GEOuploadsubmit type="button" value="Enviar" size=12 />' +
537 '<input type="hidden" name="MAX_FILE_SIZE" value="1000000">' + 538 '<input type="hidden" name="MAX_FILE_SIZE" value="1000000">' +
538 '<input type="hidden" id="i3GEOuploadcodigoconexao" name="i3GEOuploadcodigoconexao" value="">' + 539 '<input type="hidden" id="i3GEOuploadcodigoconexao" name="i3GEOuploadcodigoconexao" value="">' +
admin/menu.html
@@ -106,12 +106,7 @@ @@ -106,12 +106,7 @@
106 href: "html/estat_fonteinfo.html", 106 href: "html/estat_fonteinfo.html",
107 target: "principal" 107 target: "principal"
108 },{ 108 },{
109 - label: "Upload de dados para uma variável (para upload de shapefile, utilize o gerenciador de tabelas)",  
110 - type: "text",  
111 - href: "html/estat_uploaddados.html",  
112 - target: "principal"  
113 - },{  
114 - label: "Gerenciador de tabelas de dados estatísticos", 109 + label: "Gerenciador de tabelas de dados estatísticos (upload de SHP e CSV)",
115 type: "text", 110 type: "text",
116 href: "html/estat_editor.html", 111 href: "html/estat_editor.html",
117 target: "principal" 112 target: "principal"
@@ -126,6 +121,11 @@ @@ -126,6 +121,11 @@
126 type: "text", 121 type: "text",
127 href: "html/subirshapefile.html", 122 href: "html/subirshapefile.html",
128 target: "principal" 123 target: "principal"
  124 + },{
  125 + label: "Gerenciador de tabelas de dados estatísticos (upload de SHP e CSV)",
  126 + type: "text",
  127 + href: "html/estat_editor.html",
  128 + target: "principal"
129 } 129 }
130 ]},{ 130 ]},{
131 label: "Editor de mapfiles", 131 label: "Editor de mapfiles",
admin/php/metaestat_uploadshp_submit.php
@@ -147,7 +147,7 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){ @@ -147,7 +147,7 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
147 //a tabela nao existe e e do tipo create 147 //a tabela nao existe e e do tipo create
148 $sqltabela = array(); 148 $sqltabela = array();
149 if($tabelaExiste == false && $_POST["tipoOperacao"] == "criar"){ 149 if($tabelaExiste == false && $_POST["tipoOperacao"] == "criar"){
150 - $sql = "CREATE TABLE ".$_POST["i3GEOuploadesquema"].".".$_POST["tabelaDestino"]."(gid integer, the_geom geometry"; 150 + $sql = "CREATE TABLE ".$_POST["i3GEOuploadesquema"].".".$_POST["tabelaDestino"]."(the_geom geometry";
151 foreach($colunas as $coluna){ 151 foreach($colunas as $coluna){
152 $sql .= ",".strtolower($coluna)." ".$tipoColuna[$coluna]; 152 $sql .= ",".strtolower($coluna)." ".$tipoColuna[$coluna];
153 } 153 }
@@ -176,7 +176,7 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){ @@ -176,7 +176,7 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
176 } 176 }
177 //gera o script para inserir os dados 177 //gera o script para inserir os dados
178 $linhas = array(); 178 $linhas = array();
179 - $insert = "INSERT INTO ".$_POST["i3GEOuploadesquema"].".".$_POST["tabelaDestino"]."( gid,".strtolower(implode(",",$colunas)).",the_geom)"; 179 + $insert = "INSERT INTO ".$_POST["i3GEOuploadesquema"].".".$_POST["tabelaDestino"]." (".strtolower(implode(",",$colunas)).",the_geom)";
180 echo "<br>Preparando inclus&atilde;o de dados"; 180 echo "<br>Preparando inclus&atilde;o de dados";
181 ob_flush(); 181 ob_flush();
182 flush(); 182 flush();
@@ -184,7 +184,6 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){ @@ -184,7 +184,6 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
184 for ($i=0; $i<$numshapes;$i++){ 184 for ($i=0; $i<$numshapes;$i++){
185 $s = $layer->getShape(new resultObj($i)); 185 $s = $layer->getShape(new resultObj($i));
186 $vs = array(); 186 $vs = array();
187 - $vs[] = $i;  
188 foreach($colunas as $coluna){ 187 foreach($colunas as $coluna){
189 if($tipoColuna[$coluna] == "varchar"){ 188 if($tipoColuna[$coluna] == "varchar"){
190 $texto = $s->getValue($layer,$coluna); 189 $texto = $s->getValue($layer,$coluna);
@@ -204,6 +203,10 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){ @@ -204,6 +203,10 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
204 ob_flush(); 203 ob_flush();
205 flush(); 204 flush();
206 sleep(1); 205 sleep(1);
  206 + if($_POST["incluiserialshp"] == "on"){
  207 + $linhas[] = "alter table ".$_POST["i3GEOuploadesquema"].".".$_POST["tabelaDestino"]." add gid serial CONSTRAINT gid_pkey PRIMARY KEY";
  208 + }
  209 +
207 foreach($sqltabela as $linha){ 210 foreach($sqltabela as $linha){
208 try { 211 try {
209 $dbh->query($linha); 212 $dbh->query($linha);