Commit db0232bb3e3dacaf34cf995150aebd9db746b8d8
1 parent
f55fcf47
Exists in
master
and in
7 other branches
Inclusao de teste de mapfile em um modal no editor de mapfiles
Showing
10 changed files
with
205 additions
and
14 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin1/catalogo/mapfile/editor/exec.php
| ... | ... | @@ -225,8 +225,6 @@ function salvaMapfile() { |
| 225 | 225 | $dataCol["kmz_tema"] = $meta; |
| 226 | 226 | } |
| 227 | 227 | $resultado = i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '$codigo'" ); |
| 228 | - $dbhw = null; | |
| 229 | - $dbh = null; | |
| 230 | 228 | } |
| 231 | 229 | } |
| 232 | 230 | ?> |
| 233 | 231 | \ No newline at end of file | ... | ... |
admin1/catalogo/mapfile/editor/index.js
| ... | ... | @@ -31,6 +31,10 @@ i3GEOadmin.editor = { |
| 31 | 31 | salvar: function(){ |
| 32 | 32 | i3GEOadmin.core.iconeAguarde($("#titulo")); |
| 33 | 33 | $("form").submit(); |
| 34 | + }, | |
| 35 | + testa: function(codigo){ | |
| 36 | + i3GEOadmin.core.modalAguarde(true); | |
| 37 | + i3GEOadmin.teste.testaImg("../../../..",codigo,"","",$("#modalGeral .modal-body")) | |
| 34 | 38 | } |
| 35 | 39 | |
| 36 | 40 | }; |
| 37 | 41 | \ No newline at end of file | ... | ... |
admin1/catalogo/mapfile/editor/index.php
| 1 | 1 | <?php |
| 2 | 2 | //TODO botoes de copiar, colar, limpar |
| 3 | -//TODO testa mapfile em um modal | |
| 3 | +//TODO testa tabela do mapfile em um modal | |
| 4 | 4 | //TODO preview com openlayers |
| 5 | 5 | //TODO editor de cores |
| 6 | 6 | // |
| ... | ... | @@ -51,7 +51,7 @@ $textoMapfile = textoMapfile ( $codigo ); |
| 51 | 51 | </blockquote> |
| 52 | 52 | <a onclick="i3GEOadmin.editor.salvar()" class="btn btn-primary" style="color: #008579;" href="#" role="button"> {{{salva}}} </a> |
| 53 | 53 | <a onclick="i3GEOadmin.editor.preview()" class="btn btn-primary" style="color: #008579;" href="#" role="button"> Preview </a> |
| 54 | - <a onclick="window.open('../../../../testamapfile.php?map=<?php echo $codigo;?>.map')" href="javascript:void(0)" class="btn btn-primary" style="color: #008579;" role="button"> {{{testaLayer}}} </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> | |
| 55 | 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> |
| 56 | 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> |
| 57 | 57 | </div> |
| ... | ... | @@ -66,6 +66,7 @@ $textoMapfile = textoMapfile ( $codigo ); |
| 66 | 66 | </div> |
| 67 | 67 | </div> |
| 68 | 68 | <script type="text/javascript" src="index.js"></script> |
| 69 | +<script type="text/javascript" src="../teste/index.js"></script> | |
| 69 | 70 | <script type="text/javascript" src="../../../dicionario/editormapfile.js"></script> |
| 70 | 71 | <script> |
| 71 | 72 | ... | ... |
admin1/catalogo/mapfile/opcoes/index.js
| ... | ... | @@ -51,5 +51,9 @@ i3GEOadmin.opcoesmapfile = { |
| 51 | 51 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); |
| 52 | 52 | } |
| 53 | 53 | ); |
| 54 | + }, | |
| 55 | + testa: function(codigo){ | |
| 56 | + i3GEOadmin.core.modalAguarde(true); | |
| 57 | + i3GEOadmin.teste.testaImg("../../../..",codigo,"","",$("#modalGeral .modal-body")) | |
| 54 | 58 | } |
| 55 | 59 | }; |
| 56 | 60 | \ No newline at end of file | ... | ... |
admin1/catalogo/mapfile/opcoes/index.php
| ... | ... | @@ -36,6 +36,7 @@ $id_tema = (int) $_GET ["id_tema"]; |
| 36 | 36 | include("templates/templateMaisOpcoes.php"); |
| 37 | 37 | ?> |
| 38 | 38 | <script type="text/javascript" src="index.js"></script> |
| 39 | +<script type="text/javascript" src="../teste/index.js"></script> | |
| 39 | 40 | <script type="text/javascript" src="../../../dicionario/editormapfile.js"></script> |
| 40 | 41 | <script> |
| 41 | 42 | $(document).ready(function(){ | ... | ... |
admin1/catalogo/mapfile/opcoes/templates/templateMaisOpcoes.php
| ... | ... | @@ -46,7 +46,7 @@ |
| 46 | 46 | <div class="list-group-item"> |
| 47 | 47 | <div class="row-content" > |
| 48 | 48 | <h4 class="list-group-item-heading"> |
| 49 | - <a title="{{{testaLayer}}}" onclick="window.open('../../../../testamapfile.php?map={{codigo}}.map')" href="javascript:void(0)" class="pull-right btn btn-danger btn-fab btn-fab-mini" role="button"> | |
| 49 | + <a title="{{{testaLayer}}}" onclick="i3GEOadmin.opcoesmapfile.testa('{{codigo}}')" href="javascript:void(0)" class="pull-right btn btn-danger btn-fab btn-fab-mini" role="button"> | |
| 50 | 50 | <i class="material-icons">sending</i> |
| 51 | 51 | </a> |
| 52 | 52 | {{{testaLayer}}} | ... | ... |
admin1/catalogo/mapfile/teste/exec.php
| ... | ... | @@ -28,7 +28,7 @@ error_reporting ( 0 ); |
| 28 | 28 | // |
| 29 | 29 | |
| 30 | 30 | include_once (dirname ( __FILE__ ) . "/../../../../admin/php/login.php"); |
| 31 | -if (verificaOperacaoSessao ( "admin/html/arvore" ) === false) { | |
| 31 | +if (verificaOperacaoSessao ( "admin/html/editormapfile" ) === false) { | |
| 32 | 32 | header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" ); |
| 33 | 33 | exit (); |
| 34 | 34 | } |
| ... | ... | @@ -36,15 +36,195 @@ if (verificaOperacaoSessao ( "admin/html/arvore" ) === false) { |
| 36 | 36 | include (dirname ( __FILE__ ) . "/../../../../admin/php/conexao.php"); |
| 37 | 37 | |
| 38 | 38 | $codigo = str_replace(" ","",$_POST["codigo"]); |
| 39 | - | |
| 39 | +if(empty($codigo)){ | |
| 40 | + header ( "HTTP/1.1 500 erro parametro invalido" ); | |
| 41 | + exit (); | |
| 42 | +} | |
| 43 | +$tema = $locaplic."/temas/".$codigo.".map"; | |
| 44 | +if(!file_exists($tema)){ | |
| 45 | + header ( "HTTP/1.1 500 erro mapfile nao encontrado" ); | |
| 46 | + exit (); | |
| 47 | +} | |
| 40 | 48 | $funcao = strtoupper ( $funcao ); |
| 41 | 49 | switch ($funcao) { |
| 42 | 50 | case "TESTAIMG" : |
| 43 | - if(empty($codigo)){ | |
| 44 | - header ( "HTTP/1.1 500 erro parametro invalido" ); | |
| 45 | - exit (); | |
| 46 | - } | |
| 47 | - retornaJSON ( array("imgMapa","imgLegenda") ); | |
| 51 | + //include($locaplic . "/classesphp/funcoes_gerais.php"); | |
| 52 | + $versao = versao(); | |
| 53 | + $versao = $versao["principal"]; | |
| 54 | + ms_ResetErrorList(); | |
| 55 | + $tempo = microtime(true); | |
| 56 | + $retorno = verifica($tema); | |
| 57 | + retornaJSON ( $retorno ); | |
| 48 | 58 | break; |
| 49 | 59 | } |
| 60 | +function verifica($tema){ | |
| 61 | + global $locaplic,$postgis_mapa,$versao,$base,$dir_tmp,$tempo; | |
| 62 | + | |
| 63 | + if($base == "" or !isset($base)){ | |
| 64 | + $base = ""; | |
| 65 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ | |
| 66 | + $base = $locaplic."/aplicmap/geral1windowsv".$versao.".map"; | |
| 67 | + } | |
| 68 | + else{ | |
| 69 | + if($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv'.$versao.'.map')){ | |
| 70 | + $base = "/var/www/i3geo/aplicmap/geral1debianv".$versao.".map"; | |
| 71 | + } | |
| 72 | + if($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
| 73 | + $base = "/var/www/html/i3geo/aplicmap/geral1fedorav".$versao.".map"; | |
| 74 | + } | |
| 75 | + if($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav'.$versao.'.map')){ | |
| 76 | + $base = "/opt/www/html/i3geo/aplicmap/geral1v".$versao.".map"; | |
| 77 | + } | |
| 78 | + if($base == ""){ | |
| 79 | + $base = $locaplic."/aplicmap/geral1v".$versao.".map"; | |
| 80 | + } | |
| 81 | + } | |
| 82 | + } | |
| 83 | + else{ | |
| 84 | + if(!file_exists($base)){ | |
| 85 | + $base = $locaplic."/aplicmap/".$base; | |
| 86 | + } | |
| 87 | + } | |
| 88 | + //echo $base;exit; | |
| 89 | + $mapa = ms_newMapObj($base); | |
| 90 | + error_reporting(0); | |
| 91 | + ms_ResetErrorList(); | |
| 92 | + | |
| 93 | + try { | |
| 94 | + ms_newMapObj ( $tema ); | |
| 95 | + } catch ( Exception $e ) { | |
| 96 | + return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>"Objeto map nao pode ser criado. Erro fatal."); | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 100 | + if(@ms_newMapObj($tema)){ | |
| 101 | + $nmapa = ms_newMapObj($tema); | |
| 102 | + } | |
| 103 | + else{ | |
| 104 | + $erro = ""; | |
| 105 | + $error = ms_GetErrorObj(); | |
| 106 | + while($error && $error->code != MS_NOERR){ | |
| 107 | + $erro .= "<br>Error in %s: %s<br>\n"; | |
| 108 | + $erro .= "<br>".$error->routine; | |
| 109 | + $erro .= "<br>".$error->message; | |
| 110 | + $error = $error->next(); | |
| 111 | + } | |
| 112 | + return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>$erro); | |
| 113 | + } | |
| 114 | + restauraConObj($mapa,$postgis_mapa); | |
| 115 | + restauraConObj($nmapa,$postgis_mapa); | |
| 116 | + | |
| 117 | + $numlayers = $nmapa->numlayers; | |
| 118 | + $dados = ""; | |
| 119 | + $simbolos = array(); | |
| 120 | + for ($i=0;$i < $numlayers;$i++){ | |
| 121 | + $layern = $nmapa->getlayer($i); | |
| 122 | + $layern->set("status",MS_DEFAULT); | |
| 123 | + autoClasses($layern,$nmapa); | |
| 124 | + error_reporting(0); | |
| 125 | + if($layern->classitem != "" && $layern->connectiontype == 7 && $layern->numclasses > 0 && $layern->getmetadata("wms_sld_body") == ""){ | |
| 126 | + $tipotemp = $layern->type; | |
| 127 | + $tiporep = $layern->getmetadata("tipooriginal"); | |
| 128 | + $layern->set("type",MS_LAYER_POLYGON); | |
| 129 | + if ($tiporep == "linear"){ | |
| 130 | + $layern->set("type",MS_LAYER_LINE); | |
| 131 | + } | |
| 132 | + if ($tiporep == "pontual"){ | |
| 133 | + $layern->set("type",MS_LAYER_POINT); | |
| 134 | + } | |
| 135 | + $sld = $layern->generateSLD(); | |
| 136 | + if($sld != ""){ | |
| 137 | + $layern->setmetadata("wms_sld_body",str_replace('"',"'",$sld)); | |
| 138 | + } | |
| 139 | + $layern->set("type",$tipotemp); | |
| 140 | + } | |
| 141 | + //pega simbolos locais e aplica no novo mapa | |
| 142 | + cloneInlineSymbol($layern,$nmapa,$mapa); | |
| 143 | + | |
| 144 | + $layerAdicionado = ms_newLayerObj($mapa, $layern); | |
| 145 | + | |
| 146 | + corrigeLayerGrid($layern,$layerAdicionado); | |
| 147 | + $pegarext = $layern->name; | |
| 148 | + } | |
| 149 | + zoomTema($pegarext,$mapa); | |
| 150 | + $mapa->setsize(500,500); | |
| 151 | + $sca = $mapa->scalebar; | |
| 152 | + $sca->set("status",MS_OFF); | |
| 153 | + $objImagem = @$mapa->draw(); | |
| 154 | + //corrige o titulo da legenda | |
| 155 | + $numlayers = $mapa->numlayers; | |
| 156 | + for ($j=0;$j < $numlayers;$j++){ | |
| 157 | + $l = $mapa->getlayer($j); | |
| 158 | + if($l->type != 3 && $l->type != 4){ | |
| 159 | + $nclass = $l->numclasses; | |
| 160 | + for($i=0;$i<$nclass;$i++){ | |
| 161 | + $classe = $l->getclass($i); | |
| 162 | + if($classe->title === ""){ | |
| 163 | + $classe->title = $classe->name; | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + } | |
| 168 | + $objImagemLegenda = @$mapa->drawLegend(); | |
| 169 | + if (!$objImagem){ | |
| 170 | + $error = ""; | |
| 171 | + $erro = ""; | |
| 172 | + $error = ms_GetErrorObj(); | |
| 173 | + while($error && $error->code != MS_NOERR){ | |
| 174 | + $erro .= "<br>Error in %s: %s<br>"; | |
| 175 | + $erro .= "<br>" . $error->routine; | |
| 176 | + $erro .= "<br>" . $error->message; | |
| 177 | + $error = $error->next(); | |
| 178 | + } | |
| 179 | + return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>$erro); | |
| 180 | + } | |
| 181 | + if($objImagem->imagepath == ""){ | |
| 182 | + return array("imgMapa"=>"","imgLegenda"=>"","tempo"=> (microtime(true) - $tempo),"erro"=>"Erro IMAGEPATH vazio"); | |
| 183 | + } | |
| 184 | + $nomec = ($objImagem->imagepath).nomeRandomico()."teste.png"; | |
| 185 | + $objImagem->saveImage($nomec); | |
| 186 | + | |
| 187 | + $nomel = ($objImagemLegenda->imagepath).nomeRandomico()."testel.png"; | |
| 188 | + $objImagemLegenda->saveImage($nomel); | |
| 189 | + | |
| 190 | + $erro = ""; | |
| 191 | + $error = ""; | |
| 192 | + $error = ms_GetErrorObj(); | |
| 193 | + while($error && $error->code != MS_NOERR){ | |
| 194 | + $erro .= "<br>Error in %s: %s<br>"; | |
| 195 | + $erro .= "<br>" . $error->routine; | |
| 196 | + $erro .= "<br>" . $error->message; | |
| 197 | + $error = $error->next(); | |
| 198 | + } | |
| 199 | + return array("imgMapa"=>($objImagem->imageurl).basename($nomec),"imgLegenda"=>($objImagemLegenda->imageurl).basename($nomel),"tempo"=> (microtime(true) - $tempo),"erro"=>$erro); | |
| 200 | +} | |
| 201 | +function zoomTema($nomelayer,&$mapa){ | |
| 202 | + $layer = $mapa->getlayerbyname($nomelayer); | |
| 203 | + if($layer->data == "" && $layer->connection == "") | |
| 204 | + {return;} | |
| 205 | + $prjMapa = $mapa->getProjection(); | |
| 206 | + $prjTema = $layer->getProjection(); | |
| 207 | + $extatual = $mapa->extent; | |
| 208 | + $ret = $layer->getmetadata("extensao"); | |
| 209 | + if($layer->type > 2 && $ret == "") | |
| 210 | + {return;} | |
| 211 | + $ct = $layer->connectiontype; | |
| 212 | + if(($ret == "") && ($ct != 1)) | |
| 213 | + {return;} | |
| 214 | + if ($ret == ""){ | |
| 215 | + $ret = $layer->getextent(); | |
| 216 | + //reprojeta o retangulo | |
| 217 | + if (($prjTema != "") && ($prjMapa != $prjTema)){ | |
| 218 | + $projInObj = ms_newprojectionobj($prjTema); | |
| 219 | + $projOutObj = ms_newprojectionobj($prjMapa); | |
| 220 | + $ret->project($projInObj, $projOutObj); | |
| 221 | + } | |
| 222 | + $extatual->setextent($ret->minx,$ret->miny,$ret->maxx,$ret->maxy); | |
| 223 | + } | |
| 224 | + else{ | |
| 225 | + $ret = explode(" ",$ret); | |
| 226 | + $extatual->setextent($ret[0],$ret[1],$ret[2],$ret[3]); | |
| 227 | + } | |
| 228 | +} | |
| 229 | + | |
| 50 | 230 | ?> | ... | ... |
admin1/catalogo/mapfile/teste/index.js
| ... | ... | @@ -23,7 +23,7 @@ Free Software Foundation, Inc., no endere&ccedil;o |
| 23 | 23 | |
| 24 | 24 | */ |
| 25 | 25 | i3GEOadmin.teste = { |
| 26 | - testaImg: function(locaplic,codigo,ondeMapa,ondeLegenda){ | |
| 26 | + testaImg: function(locaplic,codigo,ondeMapa,ondeLegenda,ondeAmbos){ | |
| 27 | 27 | if(ondeMapa && ondeMapa != ""){ |
| 28 | 28 | i3GEOadmin.core.iconeAguarde(ondeMapa); |
| 29 | 29 | } |
| ... | ... | @@ -44,6 +44,9 @@ i3GEOadmin.teste = { |
| 44 | 44 | if(ondeLegenda && ondeLegenda != ""){ |
| 45 | 45 | ondeLegenda.html("<img src='" + json.imgLegenda + "'>"); |
| 46 | 46 | } |
| 47 | + if(ondeAmbos && ondeAmbos != ""){ | |
| 48 | + ondeAmbos.html("<img src='" + json.imgMapa + "'><br><br><img src='" + json.imgLegenda + "'><br><br><p>Time: " + json.tempo + "<br>Erros: " + json.erro); | |
| 49 | + } | |
| 47 | 50 | } |
| 48 | 51 | ) |
| 49 | 52 | .fail(function(data){ | ... | ... |