Commit 620592c942ee5d8f72460a677c22d9ddb13d6fe6
1 parent
db0232bb
Exists in
master
and in
7 other branches
Inclusão da opção de teste da tabela de atributos no editor de mapfiles
Showing
9 changed files
with
153 additions
and
22 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/admin.php
| @@ -47,7 +47,11 @@ error_reporting(0); | @@ -47,7 +47,11 @@ error_reporting(0); | ||
| 47 | //carrega o phpmapscript | 47 | //carrega o phpmapscript |
| 48 | // | 48 | // |
| 49 | include_once ($locaplic."/classesphp/carrega_ext.php"); | 49 | include_once ($locaplic."/classesphp/carrega_ext.php"); |
| 50 | + | ||
| 50 | include_once ($locaplic."/classesphp/funcoes_gerais.php"); | 51 | include_once ($locaplic."/classesphp/funcoes_gerais.php"); |
| 52 | + | ||
| 53 | +//TODO sera que isso e necessario? | ||
| 54 | + | ||
| 51 | $mapfile = mapfilebase($base,$locaplic); | 55 | $mapfile = mapfilebase($base,$locaplic); |
| 52 | 56 | ||
| 53 | // | 57 | // |
admin/php/login.php
| @@ -63,6 +63,7 @@ error_reporting(0); | @@ -63,6 +63,7 @@ error_reporting(0); | ||
| 63 | //pega as variaveis passadas com get ou post | 63 | //pega as variaveis passadas com get ou post |
| 64 | // | 64 | // |
| 65 | include_once(dirname(__FILE__)."/../safe.php"); | 65 | include_once(dirname(__FILE__)."/../safe.php"); |
| 66 | + | ||
| 66 | include_once(dirname(__FILE__)."/admin.php"); | 67 | include_once(dirname(__FILE__)."/admin.php"); |
| 67 | 68 | ||
| 68 | //verifica se o login pode ser realizado | 69 | //verifica se o login pode ser realizado |
admin1/catalogo/mapfile/editor/index.js
| @@ -35,6 +35,10 @@ i3GEOadmin.editor = { | @@ -35,6 +35,10 @@ i3GEOadmin.editor = { | ||
| 35 | testa: function(codigo){ | 35 | testa: function(codigo){ |
| 36 | i3GEOadmin.core.modalAguarde(true); | 36 | i3GEOadmin.core.modalAguarde(true); |
| 37 | i3GEOadmin.teste.testaImg("../../../..",codigo,"","",$("#modalGeral .modal-body")) | 37 | i3GEOadmin.teste.testaImg("../../../..",codigo,"","",$("#modalGeral .modal-body")) |
| 38 | + }, | ||
| 39 | + testaTabela: function(codigo){ | ||
| 40 | + i3GEOadmin.core.modalAguarde(true); | ||
| 41 | + i3GEOadmin.teste.testaTabela("../../../..",codigo,$("#modalGeral .modal-body")) | ||
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | }; | 44 | }; |
| 41 | \ No newline at end of file | 45 | \ No newline at end of file |
admin1/catalogo/mapfile/editor/index.php
| 1 | <?php | 1 | <?php |
| 2 | //TODO botoes de copiar, colar, limpar | 2 | //TODO botoes de copiar, colar, limpar |
| 3 | -//TODO testa tabela do mapfile em um modal | ||
| 4 | //TODO preview com openlayers | 3 | //TODO preview com openlayers |
| 5 | //TODO editor de cores | 4 | //TODO editor de cores |
| 6 | // | 5 | // |
| @@ -53,7 +52,7 @@ $textoMapfile = textoMapfile ( $codigo ); | @@ -53,7 +52,7 @@ $textoMapfile = textoMapfile ( $codigo ); | ||
| 53 | <a onclick="i3GEOadmin.editor.preview()" class="btn btn-primary" style="color: #008579;" href="#" role="button"> Preview </a> | 52 | <a onclick="i3GEOadmin.editor.preview()" class="btn btn-primary" style="color: #008579;" href="#" role="button"> Preview </a> |
| 54 | <a onclick="i3GEOadmin.editor.testa('<?php echo $codigo;?>')" href="javascript:void(0)" class="btn btn-primary" style="color: #008579;" role="button"> {{{testaLayer}}} </a> | 53 | <a onclick="i3GEOadmin.editor.testa('<?php echo $codigo;?>')" href="javascript:void(0)" class="btn btn-primary" style="color: #008579;" role="button"> {{{testaLayer}}} </a> |
| 55 | <a onclick="window.open('../../../../ms_criamapa.php?temasa=<?php echo $codigo;?>&layers=<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="javascript:void(0)" role="button"> {{{testarI3geo}}} </a> | 54 | <a onclick="window.open('../../../../ms_criamapa.php?temasa=<?php echo $codigo;?>&layers=<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="javascript:void(0)" role="button"> {{{testarI3geo}}} </a> |
| 56 | - <a onclick="window.open('../../../../ferramentas/recline/default.php?tema=<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="javascript:void(0)" role="button"> {{{tabela}}} </a> | 55 | + <a onclick="i3GEOadmin.editor.testaTabela('<?php echo $codigo;?>')" class="btn btn-primary" style="color: #008579;" href="javascript:void(0)" role="button"> {{{tabela}}} </a> |
| 57 | </div> | 56 | </div> |
| 58 | <form action="index.php?codigo=<?php echo $codigo;?>&id_tema=<?php echo $id_tema;?>" method="post"> | 57 | <form action="index.php?codigo=<?php echo $codigo;?>&id_tema=<?php echo $id_tema;?>" method="post"> |
| 59 | <TEXTAREA id=editor name=texto class="well form-control" style='font-size: 16px; width: 100%; float: left; border: 2px dotted lightgray;'> | 58 | <TEXTAREA id=editor name=texto class="well form-control" style='font-size: 16px; width: 100%; float: left; border: 2px dotted lightgray;'> |
admin1/catalogo/mapfile/teste/exec.php
| @@ -28,6 +28,7 @@ error_reporting ( 0 ); | @@ -28,6 +28,7 @@ error_reporting ( 0 ); | ||
| 28 | // | 28 | // |
| 29 | 29 | ||
| 30 | include_once (dirname ( __FILE__ ) . "/../../../../admin/php/login.php"); | 30 | include_once (dirname ( __FILE__ ) . "/../../../../admin/php/login.php"); |
| 31 | + | ||
| 31 | if (verificaOperacaoSessao ( "admin/html/editormapfile" ) === false) { | 32 | if (verificaOperacaoSessao ( "admin/html/editormapfile" ) === false) { |
| 32 | header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" ); | 33 | header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" ); |
| 33 | exit (); | 34 | exit (); |
| @@ -45,22 +46,28 @@ if(!file_exists($tema)){ | @@ -45,22 +46,28 @@ if(!file_exists($tema)){ | ||
| 45 | header ( "HTTP/1.1 500 erro mapfile nao encontrado" ); | 46 | header ( "HTTP/1.1 500 erro mapfile nao encontrado" ); |
| 46 | exit (); | 47 | exit (); |
| 47 | } | 48 | } |
| 49 | + | ||
| 48 | $funcao = strtoupper ( $funcao ); | 50 | $funcao = strtoupper ( $funcao ); |
| 49 | switch ($funcao) { | 51 | switch ($funcao) { |
| 50 | case "TESTAIMG" : | 52 | case "TESTAIMG" : |
| 51 | - //include($locaplic . "/classesphp/funcoes_gerais.php"); | ||
| 52 | $versao = versao(); | 53 | $versao = versao(); |
| 53 | $versao = $versao["principal"]; | 54 | $versao = $versao["principal"]; |
| 54 | ms_ResetErrorList(); | 55 | ms_ResetErrorList(); |
| 55 | $tempo = microtime(true); | 56 | $tempo = microtime(true); |
| 56 | - $retorno = verifica($tema); | 57 | + $retorno = testaMapaImg($tema); |
| 58 | + retornaJSON ( $retorno ); | ||
| 59 | + break; | ||
| 60 | + case "TESTATABELA" : | ||
| 61 | + $versao = versao(); | ||
| 62 | + $versao = $versao["principal"]; | ||
| 63 | + ms_ResetErrorList(); | ||
| 64 | + $tempo = microtime(true); | ||
| 65 | + $retorno = testaTabela($tema); | ||
| 57 | retornaJSON ( $retorno ); | 66 | retornaJSON ( $retorno ); |
| 58 | break; | 67 | break; |
| 59 | } | 68 | } |
| 60 | -function verifica($tema){ | ||
| 61 | - global $locaplic,$postgis_mapa,$versao,$base,$dir_tmp,$tempo; | ||
| 62 | - | ||
| 63 | - if($base == "" or !isset($base)){ | 69 | +function mapaBase($locaplic,$versao,$base){ |
| 70 | + if($base == "" || !isset($base)){ | ||
| 64 | $base = ""; | 71 | $base = ""; |
| 65 | if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ | 72 | if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ |
| 66 | $base = $locaplic."/aplicmap/geral1windowsv".$versao.".map"; | 73 | $base = $locaplic."/aplicmap/geral1windowsv".$versao.".map"; |
| @@ -80,23 +87,104 @@ function verifica($tema){ | @@ -80,23 +87,104 @@ function verifica($tema){ | ||
| 80 | } | 87 | } |
| 81 | } | 88 | } |
| 82 | } | 89 | } |
| 83 | - else{ | ||
| 84 | - if(!file_exists($base)){ | ||
| 85 | - $base = $locaplic."/aplicmap/".$base; | 90 | + return $base; |
| 91 | +} | ||
| 92 | +function testaTabela($tema){ | ||
| 93 | + global $locaplic,$postgis_mapa,$versao,$base,$dir_tmp,$tempo; | ||
| 94 | + | ||
| 95 | + $base = mapaBase($locaplic,$versao,$base); | ||
| 96 | + | ||
| 97 | + $mapa = ms_newMapObj($base); | ||
| 98 | + $nmapa = ms_newMapObj($tema); | ||
| 99 | + error_reporting(0); | ||
| 100 | + ms_ResetErrorList(); | ||
| 101 | + | ||
| 102 | + $numlayers = $nmapa->numlayers; | ||
| 103 | + $dados = ""; | ||
| 104 | + for ($i=0;$i < $numlayers;$i++){ | ||
| 105 | + $layern = $nmapa->getlayer($i); | ||
| 106 | + $layern->set("status",MS_DEFAULT); | ||
| 107 | + error_reporting(0); | ||
| 108 | + if($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == ""){ | ||
| 109 | + $tipotemp = $layern->type; | ||
| 110 | + $tiporep = $layern->getmetadata("tipooriginal"); | ||
| 111 | + $layern->set("type",MS_LAYER_POLYGON); | ||
| 112 | + if ($tiporep == "linear"){ | ||
| 113 | + $layern->set("type",MS_LAYER_LINE); | ||
| 114 | + } | ||
| 115 | + if ($tiporep == "pontual"){ | ||
| 116 | + $layern->set("type",MS_LAYER_POINT); | ||
| 117 | + } | ||
| 118 | + $sld = $layern->generateSLD(); | ||
| 119 | + if($sld != ""){ | ||
| 120 | + $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); | ||
| 121 | + } | ||
| 122 | + $layern->set("type",$tipotemp); | ||
| 86 | } | 123 | } |
| 124 | + $layerAdicionado = ms_newLayerObj($mapa, $layern); | ||
| 125 | + $pegarext = $layern->name; | ||
| 87 | } | 126 | } |
| 88 | - //echo $base;exit; | 127 | + |
| 128 | + zoomTema($pegarext,$mapa); | ||
| 129 | + include_once($locaplic."/classesphp/classe_atributos.php"); | ||
| 130 | + | ||
| 131 | + $t = new Atributos($mapa,$layern->name); | ||
| 132 | + | ||
| 133 | + $r = $t->itensTexto(); | ||
| 134 | + $colunas = explode(";",$r["itens"]); | ||
| 135 | + | ||
| 136 | + $ncolunas = count($colunas); | ||
| 137 | + $registros = $r["valores"]; | ||
| 138 | + $nregistros = count($registros); | ||
| 139 | + $error = ""; | ||
| 140 | + $error = ms_GetErrorObj(); | ||
| 141 | + $tab = ""; | ||
| 142 | + while($error && $error->code != MS_NOERR){ | ||
| 143 | + $tab .= "<br>Error in %s: %s<br>"; | ||
| 144 | + $tab .= $error->routine; | ||
| 145 | + $tab .= $error->message; | ||
| 146 | + $error = $error->next(); | ||
| 147 | + } | ||
| 148 | + $tab .= "Registros em ISO-8859-1 são convertidos para UTF8<br>"; | ||
| 149 | + $tab .= "Registros: ".$nregistros;"<br>"; | ||
| 150 | + $tab .= "<br><b>Tempo leitura (s): "; | ||
| 151 | + $tab .= microtime(true) - $tempo; | ||
| 152 | + $tab .= "</b>"; | ||
| 153 | + $tab .= "<table>"; | ||
| 154 | + $tab .= "<tr>"; | ||
| 155 | + foreach($colunas as $co){ | ||
| 156 | + $tab .= "<td><b>".$co."</b></td>"; | ||
| 157 | + } | ||
| 158 | + $tab .= "</tr>"; | ||
| 159 | + foreach($registros as $reg){ | ||
| 160 | + $tab .= "<tr>"; | ||
| 161 | + $cc = explode(";",$reg); | ||
| 162 | + foreach($cc as $c){ | ||
| 163 | + if (mb_detect_encoding ( $c, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") { | ||
| 164 | + $c = utf8_encode ( $c ); | ||
| 165 | + } | ||
| 166 | + $tab .= "<td>".$c."</td>"; | ||
| 167 | + } | ||
| 168 | + $tab .= "</tr>"; | ||
| 169 | + } | ||
| 170 | + $tab .= "</table>"; | ||
| 171 | + $tab .= "<br><b>Tempo total (montagem da tabela) (s): "; | ||
| 172 | + $tab .= microtime(true) - $tempo; | ||
| 173 | + $tab .= "</b>"; | ||
| 174 | + return $tab; | ||
| 175 | +} | ||
| 176 | +function testaMapaImg($tema){ | ||
| 177 | + global $locaplic,$postgis_mapa,$versao,$base,$dir_tmp,$tempo; | ||
| 178 | + | ||
| 179 | + $base = mapaBase($locaplic,$versao,$base); | ||
| 89 | $mapa = ms_newMapObj($base); | 180 | $mapa = ms_newMapObj($base); |
| 90 | error_reporting(0); | 181 | error_reporting(0); |
| 91 | ms_ResetErrorList(); | 182 | ms_ResetErrorList(); |
| 92 | - | ||
| 93 | try { | 183 | try { |
| 94 | ms_newMapObj ( $tema ); | 184 | ms_newMapObj ( $tema ); |
| 95 | } catch ( Exception $e ) { | 185 | } catch ( Exception $e ) { |
| 96 | return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>"Objeto map nao pode ser criado. Erro fatal."); | 186 | return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>"Objeto map nao pode ser criado. Erro fatal."); |
| 97 | } | 187 | } |
| 98 | - | ||
| 99 | - | ||
| 100 | if(@ms_newMapObj($tema)){ | 188 | if(@ms_newMapObj($tema)){ |
| 101 | $nmapa = ms_newMapObj($tema); | 189 | $nmapa = ms_newMapObj($tema); |
| 102 | } | 190 | } |
| @@ -111,8 +199,8 @@ function verifica($tema){ | @@ -111,8 +199,8 @@ function verifica($tema){ | ||
| 111 | } | 199 | } |
| 112 | return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>$erro); | 200 | return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>$erro); |
| 113 | } | 201 | } |
| 114 | - restauraConObj($mapa,$postgis_mapa); | ||
| 115 | - restauraConObj($nmapa,$postgis_mapa); | 202 | + substituiConObj($mapa,$postgis_mapa); |
| 203 | + substituiConObj($nmapa,$postgis_mapa); | ||
| 116 | 204 | ||
| 117 | $numlayers = $nmapa->numlayers; | 205 | $numlayers = $nmapa->numlayers; |
| 118 | $dados = ""; | 206 | $dados = ""; |
admin1/catalogo/mapfile/teste/index.js
| @@ -58,5 +58,30 @@ i3GEOadmin.teste = { | @@ -58,5 +58,30 @@ i3GEOadmin.teste = { | ||
| 58 | } | 58 | } |
| 59 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | 59 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); |
| 60 | }); | 60 | }); |
| 61 | + }, | ||
| 62 | + testaTabela: function(locaplic,codigo,onde){ | ||
| 63 | + if(onde && onde != ""){ | ||
| 64 | + i3GEOadmin.core.iconeAguarde(onde); | ||
| 65 | + } | ||
| 66 | + $.post( | ||
| 67 | + locaplic+"/admin1/catalogo/mapfile/teste/exec.php?funcao=testaTabela", | ||
| 68 | + "codigo=" + codigo | ||
| 69 | + ) | ||
| 70 | + .done( | ||
| 71 | + function(data, status){ | ||
| 72 | + //objeto json com os dados vindos do banco | ||
| 73 | + var json = jQuery.parseJSON(data); | ||
| 74 | + if(onde && onde != ""){ | ||
| 75 | + onde.html(json); | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + ) | ||
| 79 | + .fail(function(data){ | ||
| 80 | + if(onde && onde != ""){ | ||
| 81 | + onde.html(""); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | ||
| 85 | + }); | ||
| 61 | } | 86 | } |
| 62 | }; | 87 | }; |
| 63 | \ No newline at end of file | 88 | \ No newline at end of file |
classesphp/classe_atributos.php
| @@ -90,7 +90,7 @@ class Atributos | @@ -90,7 +90,7 @@ class Atributos | ||
| 90 | 90 | ||
| 91 | parameters: | 91 | parameters: |
| 92 | 92 | ||
| 93 | - $map_file - Endereço do mapfile no servidor. | 93 | + $map_file - Endereço do mapfile no servidor ou objeto mapObj. |
| 94 | 94 | ||
| 95 | $tema - nome do tema | 95 | $tema - nome do tema |
| 96 | 96 | ||
| @@ -113,12 +113,19 @@ class Atributos | @@ -113,12 +113,19 @@ class Atributos | ||
| 113 | $this->v = versao(); | 113 | $this->v = versao(); |
| 114 | $this->v = $this->v["principal"]; | 114 | $this->v = $this->v["principal"]; |
| 115 | if($map_file != ""){ | 115 | if($map_file != ""){ |
| 116 | - $this->qyfile = str_replace(".map",".qy",$map_file); | 116 | + |
| 117 | $this->locaplic = $locaplic; | 117 | $this->locaplic = $locaplic; |
| 118 | - $this->mapa = ms_newMapObj($map_file); | 118 | + if(is_string($map_file)){ |
| 119 | + $this->mapa = ms_newMapObj($map_file); | ||
| 120 | + $this->arquivo = str_replace(".map","",$map_file).".map"; | ||
| 121 | + $this->qyfile = str_replace(".map",".qy",$map_file); | ||
| 122 | + } | ||
| 123 | + else { | ||
| 124 | + $this->mapa = $map_file; | ||
| 125 | + $this->arquivo = ""; | ||
| 126 | + } | ||
| 119 | substituiConObj($this->mapa,$postgis_mapa); | 127 | substituiConObj($this->mapa,$postgis_mapa); |
| 120 | 128 | ||
| 121 | - $this->arquivo = str_replace(".map","",$map_file).".map"; | ||
| 122 | if($tema != "" && @$this->mapa->getlayerbyname($tema)) | 129 | if($tema != "" && @$this->mapa->getlayerbyname($tema)) |
| 123 | { | 130 | { |
| 124 | $this->layer = $this->mapa->getlayerbyname($tema); | 131 | $this->layer = $this->mapa->getlayerbyname($tema); |
| @@ -147,7 +154,9 @@ class Atributos | @@ -147,7 +154,9 @@ class Atributos | ||
| 147 | $this->mapa->setProjection($this->projO); | 154 | $this->mapa->setProjection($this->projO); |
| 148 | } | 155 | } |
| 149 | restauraConObj($this->mapa,$this->postgis_mapa); | 156 | restauraConObj($this->mapa,$this->postgis_mapa); |
| 150 | - $this->mapa->save($this->arquivo); | 157 | + if($this->arquivo != ""){ |
| 158 | + $this->mapa->save($this->arquivo); | ||
| 159 | + } | ||
| 151 | } | 160 | } |
| 152 | 161 | ||
| 153 | /* | 162 | /* |