Commit 503f6099e7f1be8058536e595f84d47836a2ffe8
1 parent
68bd0095
Exists in
master
and in
7 other branches
Opção que permite salvar as geometrias do editor vetorial em arquivos shapefile e adicionar no mapa
Showing
6 changed files
with
99 additions
and
67 deletions
Show diff stats
admin/admin.db
No preview for this file type
classesjs/classe_barradebotoes.js
| ... | ... | @@ -1098,7 +1098,7 @@ i3GEO.barraDeBotoes = { |
| 1098 | 1098 | i3GEO.editorOL.layergrafico = new OpenLayers.Layer.Vector("Edição",{displayInLayerSwitcher:false,visibility:true}); |
| 1099 | 1099 | i3GEO.editorOL.mapa.addLayers([i3GEO.editorOL.layergrafico]); |
| 1100 | 1100 | i3GEO.editorOL.criaBotoes(i3GEO.editorOL.botoes); |
| 1101 | - i3GEO.editorOL.criaJanelaAtivaTema(); | |
| 1101 | + //i3GEO.editorOL.criaJanelaAtivaTema(); | |
| 1102 | 1102 | //i3GEOOL.inicia(); |
| 1103 | 1103 | } |
| 1104 | 1104 | } | ... | ... |
classesjs/classe_interface.js
| ... | ... | @@ -719,6 +719,7 @@ i3GEO.Interface = { |
| 719 | 719 | openlayers.ordenaLayers(); |
| 720 | 720 | openlayers.recalcPar(); |
| 721 | 721 | i3GEO.janela.fechaAguarde(); |
| 722 | + openlayers.sobeLayersGraficos(); | |
| 722 | 723 | }, |
| 723 | 724 | cria: function(w,h){ |
| 724 | 725 | var f,ins, |
| ... | ... | @@ -875,6 +876,7 @@ i3GEO.Interface = { |
| 875 | 876 | urlfundo = configura.locaplic+"/classesphp/mapa_openlayers.php?g_sid="+i3GEO.configura.sid+"&layer=&tipolayer=fundo&TIPOIMAGEM="+configura.tipoimagem, |
| 876 | 877 | nlayers = i3GEO.arvoreDeCamadas.CAMADAS.length, |
| 877 | 878 | layer, |
| 879 | + layers, | |
| 878 | 880 | camada, |
| 879 | 881 | urllayer, |
| 880 | 882 | opcoes, |
| ... | ... | @@ -948,6 +950,19 @@ i3GEO.Interface = { |
| 948 | 950 | try |
| 949 | 951 | {i3geoOL.addLayers(i3GEO.Interface.openlayers.LAYERSADICIONAIS);} |
| 950 | 952 | catch(e){} |
| 953 | + // | |
| 954 | + //sobe o nível das camadas gráficas | |
| 955 | + // | |
| 956 | + }, | |
| 957 | + sobeLayersGraficos: function(){ | |
| 958 | + var nlayers = i3geoOL.getNumLayers(), | |
| 959 | + layers = i3geoOL.layers, | |
| 960 | + i; | |
| 961 | + for(i=0;i<nlayers;i++){ | |
| 962 | + if(layers[i].CLASS_NAME == "OpenLayers.Layer.Vector"){ | |
| 963 | + i3geoOL.raiseLayer(i3geoOL.layers[i],nlayers); | |
| 964 | + } | |
| 965 | + } | |
| 951 | 966 | }, |
| 952 | 967 | inverteModoTile: function(){ |
| 953 | 968 | var nlayers = i3GEO.arvoreDeCamadas.CAMADAS.length, | ... | ... |
classesphp/classe_analise.php
| ... | ... | @@ -2216,18 +2216,26 @@ $locaplic - Localização do I3geo |
| 2216 | 2216 | |
| 2217 | 2217 | $geometrias {Array} - lista de WKT |
| 2218 | 2218 | |
| 2219 | - $operacao {String} - operação suportada pelo Mapserver, por exemplo, union, intersects, etc | |
| 2219 | + $operacao {String} - operação suportada pelo Mapserver, por exemplo, union, intersects, etc. converteSHP irá converter as geometrias em um tema e adicioná-lo ao mapa | |
| 2220 | + | |
| 2221 | + $dir_tmp - Diretório temporário do mapserver. Utilizado apenas se $operacao = "converteSHP" | |
| 2222 | + | |
| 2223 | + $imgdir - Diretório das imagens do mapa atual. Utilizado apenas se $operacao = "converteSHP" | |
| 2220 | 2224 | |
| 2221 | 2225 | Return: |
| 2222 | 2226 | |
| 2223 | 2227 | {string wkt} |
| 2224 | 2228 | */ |
| 2225 | - function aplicaFuncaoListaWKT($geometrias,$operacao){ | |
| 2229 | + function aplicaFuncaoListaWKT($geometrias,$operacao,$dir_tmp="",$imgdir=""){ | |
| 2230 | + if($operacao === "converteSHP"){ | |
| 2231 | + $this->incmapageometrias($dir_tmp,$imgdir,$geometrias,$tipoLista="arraywkt"); | |
| 2232 | + return "ok"; | |
| 2233 | + } | |
| 2234 | + | |
| 2226 | 2235 | $geos = array(); |
| 2227 | 2236 | foreach ($geometrias as $geo){ |
| 2228 | 2237 | $geos[] = ms_shapeObjFromWkt($geo); |
| 2229 | 2238 | } |
| 2230 | - | |
| 2231 | 2239 | $n = count($geos); |
| 2232 | 2240 | if ($n == 1) |
| 2233 | 2241 | { |
| ... | ... | @@ -2397,26 +2405,37 @@ $dir_tmp - Diretório temporário do mapserver |
| 2397 | 2405 | $imgdir - Diretório das imagens do mapa atual |
| 2398 | 2406 | |
| 2399 | 2407 | $lista - Nomes, sem o caminho, dos arquivos com as geometrias, separados por vírgula. |
| 2408 | + | |
| 2409 | +$tipoLista - tipo de valores que são passados em $lista stringArquivos|arraywkt. O default é stringArquivos | |
| 2400 | 2410 | */ |
| 2401 | - function incmapageometrias($dir_tmp,$imgdir,$lista) | |
| 2411 | + function incmapageometrias($dir_tmp,$imgdir,$lista,$tipoLista="stringArquivos") | |
| 2402 | 2412 | { |
| 2403 | - $lista = explode(",",$lista); | |
| 2404 | 2413 | $dir = $dir_tmp."/".$imgdir."/"; |
| 2405 | - $shapes = array(); | |
| 2406 | - $valoresoriginais = array(); | |
| 2407 | - foreach ($lista as $l) | |
| 2408 | - { | |
| 2409 | - $geos = &$this->unserializeGeo($dir.$l); | |
| 2410 | - //pega todas as geometrias | |
| 2411 | - foreach ($geos["dados"] as $geo) | |
| 2414 | + if($tipoLista == "stringArquivos"){ | |
| 2415 | + $lista = explode(",",$lista); | |
| 2416 | + $shapes = array(); | |
| 2417 | + $valoresoriginais = array(); | |
| 2418 | + foreach ($lista as $l) | |
| 2412 | 2419 | { |
| 2413 | - //echo $geo["wkt"]."<br>"; | |
| 2414 | - $shapes[] = ms_shapeObjFromWkt(str_replace("'","",$geo["wkt"])); | |
| 2415 | - foreach ($geo["valores"] as $v) | |
| 2416 | - {$valorestemp[] = $v["item"]."=".$v["valor"];} | |
| 2417 | - $valoresoriginais[] = implode(" ",$valorestemp); | |
| 2420 | + $geos = &$this->unserializeGeo($dir.$l); | |
| 2421 | + //pega todas as geometrias | |
| 2422 | + foreach ($geos["dados"] as $geo) | |
| 2423 | + { | |
| 2424 | + //echo $geo["wkt"]."<br>"; | |
| 2425 | + $shapes[] = ms_shapeObjFromWkt(str_replace("'","",$geo["wkt"])); | |
| 2426 | + foreach ($geo["valores"] as $v) | |
| 2427 | + {$valorestemp[] = $v["item"]."=".$v["valor"];} | |
| 2428 | + $valoresoriginais[] = implode(" ",$valorestemp); | |
| 2429 | + } | |
| 2418 | 2430 | } |
| 2419 | 2431 | } |
| 2432 | + if($tipoLista == "arraywkt"){ | |
| 2433 | + $shapes = array(); | |
| 2434 | + $valoresoriginais = array(); | |
| 2435 | + foreach ($lista as $l){ | |
| 2436 | + $shapes[] = ms_shapeObjFromWkt($l); | |
| 2437 | + } | |
| 2438 | + } | |
| 2420 | 2439 | //verifica o tipo |
| 2421 | 2440 | if (count($shapes) == 0){return("erro.");} |
| 2422 | 2441 | $tiposhape = $shapes[0]->type; | ... | ... |
classesphp/mapa_controle.php
| ... | ... | @@ -338,7 +338,7 @@ A lista de WKTs deve usar o separador | |
| 338 | 338 | case "FUNCOESGEOMETRIASWKT": |
| 339 | 339 | include_once("classe_analise.php"); |
| 340 | 340 | $m = new Analise($map_file,""); |
| 341 | - $retorno = $m->aplicaFuncaoListaWKT(explode("|",$geometrias),$operacao); | |
| 341 | + $retorno = $m->aplicaFuncaoListaWKT(explode("|",$geometrias),$operacao,$dir_tmp,$imgdir); | |
| 342 | 342 | break; |
| 343 | 343 | /* |
| 344 | 344 | Valor: CALCULAGEOMETRIAS | ... | ... |
mashups/openlayers.js.php
| ... | ... | @@ -120,7 +120,6 @@ i3GEO.editorOL = { |
| 120 | 120 | {i3GEO.editorOL.mapa.zoomToMaxExtent();} |
| 121 | 121 | i3GEO.editorOL.coordenadas(); |
| 122 | 122 | i3GEO.editorOL.criaJanelaBusca(); |
| 123 | - i3GEO.editorOL.criaJanelaAtivaTema(); | |
| 124 | 123 | i3GEO.editorOL.criaBotoes(i3GEO.editorOL.botoes); |
| 125 | 124 | }, |
| 126 | 125 | layersLigados: function(){ |
| ... | ... | @@ -198,36 +197,52 @@ i3GEO.editorOL = { |
| 198 | 197 | } |
| 199 | 198 | catch(e){} |
| 200 | 199 | }, |
| 201 | - criaJanelaAtivaTema: function(){ | |
| 200 | + criaComboTemas: function(){ | |
| 202 | 201 | var layers = i3GEO.editorOL.layersLigados(), |
| 203 | 202 | nlayers = layers.length, |
| 204 | 203 | i, |
| 205 | 204 | temp, |
| 206 | 205 | combo = "<select id=i3GEOOLlistaTemasAtivos >"; |
| 206 | + //i3GEO.editorOL.layergrafico.setLayerIndex(i3GEO.editorOL.getNumLayers() + 1); | |
| 207 | 207 | for(i=0;i<nlayers;i++){ |
| 208 | 208 | combo += "<option value='"+i+"' >"+layers[i].name+"</option>"; |
| 209 | 209 | } |
| 210 | 210 | combo += "</select>"; |
| 211 | + return combo; | |
| 212 | + }, | |
| 213 | + atualizaJanelaAtivaTema: function(){ | |
| 214 | + var combo = i3GEO.editorOL.criaComboTemas(); | |
| 215 | + YAHOO.temaativo.container.panel.setBody(combo); | |
| 216 | + document.getElementById("i3GEOOLlistaTemasAtivos").onchange = function(){ | |
| 217 | + if(botaoIdentifica){ | |
| 218 | + botaoIdentifica.layers = [i3GEO.editorOL.layersLigados()[this.value]]; | |
| 219 | + } | |
| 220 | + }; | |
| 221 | + }, | |
| 222 | + criaJanelaAtivaTema: function(){ | |
| 223 | + var temp; | |
| 211 | 224 | if(!document.getElementById("paneltemaativo")){ |
| 212 | 225 | YAHOO.namespace("temaativo.container"); |
| 213 | 226 | YAHOO.temaativo.container.panel = new YAHOO.widget.Panel("paneltemaativo", {zIndex:20000, iframe:true, width:"250px", visible:false, draggable:true, close:true } ); |
| 214 | - YAHOO.temaativo.container.panel.setBody(combo); | |
| 227 | + YAHOO.temaativo.container.panel.setBody(""); | |
| 215 | 228 | if(typeof i3GEO != undefined && i3GEO != "") |
| 216 | 229 | {YAHOO.temaativo.container.panel.setHeader("Tema ativo<div id='paneltemaativo_minimizaCabecalho' class='container-minimiza'></div>");} |
| 217 | 230 | else |
| 218 | 231 | {YAHOO.temaativo.container.panel.setHeader("Tema ativo");} |
| 219 | 232 | YAHOO.temaativo.container.panel.setFooter(""); |
| 220 | 233 | YAHOO.temaativo.container.panel.render(document.body); |
| 234 | + YAHOO.temaativo.container.panel.show(); | |
| 221 | 235 | YAHOO.temaativo.container.panel.center(); |
| 236 | + i3GEO.editorOL.atualizaJanelaAtivaTema(); | |
| 222 | 237 | YAHOO.util.Event.addListener(YAHOO.temaativo.container.panel.close, "click", function(){ |
| 223 | 238 | i3GEOpanelEditor.deactivate(); |
| 224 | 239 | i3GEOpanelEditor.activate(); |
| 225 | - if(i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search("i3GEO.editorOL.criaJanelaAtivaTema()") > 0) | |
| 226 | - {i3GEO.eventos.ATUALIZAARVORECAMADAS.remove("i3GEO.editorOL.criaJanelaAtivaTema()");} | |
| 240 | + if(i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search("i3GEO.editorOL.atualizaJanelaAtivaTema()") > 0) | |
| 241 | + {i3GEO.eventos.ATUALIZAARVORECAMADAS.remove("i3GEO.editorOL.atualizaJanelaAtivaTema()");} | |
| 227 | 242 | }); |
| 228 | 243 | if(typeof i3GEO != undefined && i3GEO != ""){ |
| 229 | - if(i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search("i3GEO.editorOL.criaJanelaAtivaTema()") < 0) | |
| 230 | - {i3GEO.eventos.ATUALIZAARVORECAMADAS.push("i3GEO.editorOL.criaJanelaAtivaTema()");} | |
| 244 | + if(i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search("i3GEO.editorOL.atualizaJanelaAtivaTema()") < 0) | |
| 245 | + {i3GEO.eventos.ATUALIZAARVORECAMADAS.push("i3GEO.editorOL.atualizaJanelaAtivaTema()");} | |
| 231 | 246 | } |
| 232 | 247 | temp = $i("paneltemaativo_minimizaCabecalho"); |
| 233 | 248 | if(temp){ |
| ... | ... | @@ -235,15 +250,8 @@ i3GEO.editorOL = { |
| 235 | 250 | } |
| 236 | 251 | } |
| 237 | 252 | else{ |
| 238 | - YAHOO.temaativo.container.panel.setBody(combo); | |
| 239 | - YAHOO.temaativo.container.panel.render(document.body); | |
| 240 | 253 | YAHOO.temaativo.container.panel.show(); |
| 241 | 254 | } |
| 242 | - document.getElementById("i3GEOOLlistaTemasAtivos").onchange = function(){ | |
| 243 | - if(botaoIdentifica){ | |
| 244 | - botaoIdentifica.layers = [i3GEO.editorOL.layersLigados()[this.value]]; | |
| 245 | - } | |
| 246 | - }; | |
| 247 | 255 | }, |
| 248 | 256 | ativaTema: function(id){ |
| 249 | 257 | document.getElementById("i3GEOOLlistaTemasAtivos").value = id; |
| ... | ... | @@ -388,29 +396,33 @@ i3GEO.editorOL = { |
| 388 | 396 | }); |
| 389 | 397 | }, |
| 390 | 398 | salvaGeometrias: function(){ |
| 391 | - try{ | |
| 392 | - YAHOO.namespace("salvaGeometrias.container"); | |
| 393 | - YAHOO.salvaGeometrias.container.panel = new YAHOO.widget.Panel("panelsalvageometrias", {zIndex:2000, iframe:false, width:"250px", visible:false, draggable:true, close:true } ); | |
| 394 | - YAHOO.salvaGeometrias.container.panel.setHeader("Geometrias"); | |
| 395 | - YAHOO.salvaGeometrias.container.panel.setBody(""); | |
| 396 | - YAHOO.salvaGeometrias.container.panel.setFooter(""); | |
| 397 | - YAHOO.salvaGeometrias.container.panel.render(document.body); | |
| 398 | - YAHOO.salvaGeometrias.container.panel.center(); | |
| 399 | - } | |
| 400 | - catch(e){} | |
| 401 | - YAHOO.salvaGeometrias.container.panel.show(); | |
| 402 | 399 | var geos = i3GEO.editorOL.layergrafico.selectedFeatures; |
| 403 | 400 | var n = geos.length; |
| 404 | 401 | var ins = ""; |
| 405 | 402 | if(n > 0){ |
| 403 | + try{ | |
| 404 | + YAHOO.namespace("salvaGeometrias.container"); | |
| 405 | + YAHOO.salvaGeometrias.container.panel = new YAHOO.widget.Panel("panelsalvageometrias", {zIndex:2000, iframe:false, width:"250px", visible:false, draggable:true, close:true } ); | |
| 406 | + YAHOO.salvaGeometrias.container.panel.setHeader("Geometrias"); | |
| 407 | + YAHOO.salvaGeometrias.container.panel.setBody(""); | |
| 408 | + YAHOO.salvaGeometrias.container.panel.setFooter(""); | |
| 409 | + YAHOO.salvaGeometrias.container.panel.render(document.body); | |
| 410 | + YAHOO.salvaGeometrias.container.panel.center(); | |
| 411 | + } | |
| 412 | + catch(e){} | |
| 413 | + YAHOO.salvaGeometrias.container.panel.show(); | |
| 406 | 414 | ins += "<p class=paragrafo >Foram encontrada(s) "+n+" geometria(s) selecionada(s) </p>"; |
| 407 | - ins += "<p class=paragrafo ><a href='#' onclick='i3GEO.editorOL.listaGeometriasSel()' > Listar geometrias</a> "; | |
| 408 | - ins += "<a href='#' onclick='"+i3GEO.editorOL.nomeFuncaoSalvar+"' >Salvar geometria(s)</a></p>"; | |
| 415 | + ins += "<p class=paragrafo ><a href='#' onclick='i3GEO.editorOL.listaGeometriasSel()' >Listar</a> "; | |
| 416 | + ins += "<a href='#' onclick='"+i3GEO.editorOL.nomeFuncaoSalvar+"' >Salvar</a> "; | |
| 417 | + ins += "<a href='#' onclick='i3GEO.editorOL.exportarSHP()' >Exportar (shapefile)</a></p>"; | |
| 409 | 418 | YAHOO.salvaGeometrias.container.panel.setBody(ins); |
| 410 | 419 | } |
| 411 | 420 | else |
| 412 | 421 | {alert("Selecione pelo menos um elemento");} |
| 413 | 422 | }, |
| 423 | + exportarSHP: function(){ | |
| 424 | + i3GEO.editorOL.processageo("converteSHP"); | |
| 425 | + }, | |
| 414 | 426 | listaGeometriasSel: function(){ |
| 415 | 427 | var geos = i3GEO.editorOL.layergrafico.selectedFeatures; |
| 416 | 428 | var n = geos.length; |
| ... | ... | @@ -631,7 +643,6 @@ i3GEO.editorOL = { |
| 631 | 643 | { |
| 632 | 644 | displayClass: "editorOLedita", |
| 633 | 645 | title: "modifica figura", |
| 634 | - //onModification: function(evt){alert("oi");i3GEO.editorOL.guardaBackup();}, | |
| 635 | 646 | clickout: true, |
| 636 | 647 | toggle: true, |
| 637 | 648 | mode: OpenLayers.Control.ModifyFeature.RESHAPE |
| ... | ... | @@ -891,9 +902,7 @@ i3GEO.editorOL = { |
| 891 | 902 | YAHOO.editorOL.container.panel.render(document.body); |
| 892 | 903 | |
| 893 | 904 | YAHOO.editorOL.container.panel.center(); |
| 894 | - YAHOO.util.Event.addListener(YAHOO.editorOL.container.panel.close, "click", function(){}); | |
| 895 | - if(i3GEO.eventos && i3GEO.eventos.ATUALIZAARVORECAMADAS.toString().search("i3GEO.editorOL.criaJanelaAtivaTema()") < 0) | |
| 896 | - {i3GEO.eventos.ATUALIZAARVORECAMADAS.push("i3GEO.editorOL.criaJanelaAtivaTema()");} | |
| 905 | + YAHOO.util.Event.addListener(YAHOO.editorOL.container.panel.close, "click", function(){}); | |
| 897 | 906 | temp = $i("panelpropriedadesEditor_minimizaCabecalho"); |
| 898 | 907 | if(temp){ |
| 899 | 908 | temp.onclick = function(){i3GEO.janela.minimiza("panelpropriedadesEditor");} |
| ... | ... | @@ -975,7 +984,7 @@ i3GEO.editorOL = { |
| 975 | 984 | var geosel = i3GEO.editorOL.layergrafico.selectedFeatures, |
| 976 | 985 | fwkt = new OpenLayers.Format.WKT(), |
| 977 | 986 | polis,linhas,pontos,uniaopolis,uniaolinhas,uniaopontos,n,i,temp; |
| 978 | - if(geosel.length > 1){ | |
| 987 | + if(geosel.length > 0){ | |
| 979 | 988 | polis = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.Polygon"); |
| 980 | 989 | linhas = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.LineString"); |
| 981 | 990 | pontos = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.Point"); |
| ... | ... | @@ -983,8 +992,12 @@ i3GEO.editorOL = { |
| 983 | 992 | i3GEO.janela.fechaAguarde("i3GEO.editorPoli"); |
| 984 | 993 | i3GEO.janela.fechaAguarde("i3GEO.editorLinhas"); |
| 985 | 994 | i3GEO.janela.fechaAguarde("i3GEO.editorPontos"); |
| 986 | - if(retorno != "" && retorno.data && retorno.data != "") | |
| 995 | + if(retorno != "" && retorno.data && retorno.data != "" && operacao != "converteSHP") | |
| 987 | 996 | {i3GEO.editorOL.substituiFeaturesSel(retorno.data);} |
| 997 | + if(operacao === "converteSHP"){ | |
| 998 | + i3GEO.atualiza(); | |
| 999 | + i3GEO.janela.minimiza("paneltemaativo"); | |
| 1000 | + } | |
| 988 | 1001 | } |
| 989 | 1002 | if(polis.length > 0){ |
| 990 | 1003 | i3GEO.janela.abreAguarde("i3GEO.editorPoli","Poligonos"); |
| ... | ... | @@ -999,21 +1012,6 @@ i3GEO.editorOL = { |
| 999 | 1012 | i3GEO.php.funcoesGeometriasWkt(temp,pontos.join("|"),operacao); |
| 1000 | 1013 | } |
| 1001 | 1014 | return; |
| 1002 | - /* | |
| 1003 | - if(polis) | |
| 1004 | - {uniaopolis = i3GEO.editorOL.uniaojts(polis);} | |
| 1005 | - if(linhas) | |
| 1006 | - {uniaolinhas = i3GEO.editorOL.uniaojts(linhas);} | |
| 1007 | - if(pontos) | |
| 1008 | - {uniaopontos = i3GEO.editorOL.uniaojts(pontos);} | |
| 1009 | - | |
| 1010 | - if(uniaopolis) | |
| 1011 | - {i3GEO.editorOL.layergrafico.addFeatures(uniaopolis);} | |
| 1012 | - if(uniaolinhas) | |
| 1013 | - {i3GEO.editorOL.layergrafico.addFeatures(uniaolinhas);} | |
| 1014 | - if(uniaopontos) | |
| 1015 | - {i3GEO.editorOL.layergrafico.addFeatures(uniaopontos);} | |
| 1016 | - */ | |
| 1017 | 1015 | } |
| 1018 | 1016 | else |
| 1019 | 1017 | {alert("Selecione pelo menos dois elementos");} | ... | ... |