From 67ddb62b8f8deb57c1aeeb61ddbb1d3513f8d78b Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Mon, 30 May 2011 11:15:45 +0000 Subject: [PATCH] --- classesjs/classe_barradebotoes.js | 4 +++- mashups/openlayers.css | 6 ++++++ mashups/openlayers.js.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mashups/openlayers.php | 3 +++ mashups/openlayers.png | Bin 20351 -> 0 bytes ms_criamapa.php | 1 + 6 files changed, 86 insertions(+), 1 deletion(-) diff --git a/classesjs/classe_barradebotoes.js b/classesjs/classe_barradebotoes.js index 745c473..fa0444c 100644 --- a/classesjs/classe_barradebotoes.js +++ b/classesjs/classe_barradebotoes.js @@ -1081,12 +1081,14 @@ i3GEO.barraDeBotoes = { 'ponto':true, 'poligono':true, 'edita':true, + 'selecao':true, 'apaga':true, 'procura':false, 'propriedades':true, 'salva':true, 'ajuda':true, - 'fecha':true + 'fecha':true, + 'uniao':true }; i3GEO.editorOL.layergrafico = new OpenLayers.Layer.Vector("Edição",{displayInLayerSwitcher:false,visibility:true}); i3GEO.editorOL.mapa.addLayers([i3GEO.editorOL.layergrafico]); diff --git a/mashups/openlayers.css b/mashups/openlayers.css index 50d9829..73e3365 100644 --- a/mashups/openlayers.css +++ b/mashups/openlayers.css @@ -112,6 +112,12 @@ background-position:-522px 0; .olControlEditingToolbar1 .propriedadesItemActive { background-position:-522px -28px; } +.olControlEditingToolbar1 .uniaoItemInactive { + background-position:-551px 0; +} +.olControlEditingToolbar1 .uniaoItemActive { + background-position:-551px -28px; +} .olControlEditingToolbar1 { width:600px; float:right; diff --git a/mashups/openlayers.js.php b/mashups/openlayers.js.php index 43f6f31..c44a03c 100644 --- a/mashups/openlayers.js.php +++ b/mashups/openlayers.js.php @@ -52,8 +52,10 @@ i3GEO.editorOL = { 'ponto':true, 'poligono':true, 'edita':true, + 'uniao':true, 'apaga':true, 'procura':true, + 'selecao':true, 'salva':true, 'ajuda':true, 'propriedades':true, @@ -617,6 +619,17 @@ i3GEO.editorOL = { controles.push(button); adiciona = true; } + if(botoes.uniao===true){ + button = new OpenLayers.Control.Button({ + displayClass: "uniao", + trigger: function(){ + i3GEO.editorOL.carregajts("i3GEO.editorOL.uniao()"); + }, + title: "Une geometrias" + }); + controles.push(button); + adiciona = true; + } //botao de seleção if(botoes.selecao===true){ button = new OpenLayers.Control.SelectFeature( @@ -839,6 +852,63 @@ i3GEO.editorOL = { if(temp.checked === true) {i3GEOOLsplit.activate();} }, + uniao: function(){ + var geosel = i3GEO.editorOL.layergrafico.selectedFeatures, + polis,linhas,pontos,uniaopolis,uniaolinhas,uniaopontos; + if(geosel.length > 1){ + polis = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.Polygon"); + linhas = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.LineString"); + pontos = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.Point"); + if(polis) + {uniaopolis = i3GEO.editorOL.uniaojts(polis);} + if(linhas) + {uniaolinhas = i3GEO.editorOL.uniaojts(linhas);} + if(pontos) + {uniaopontos = i3GEO.editorOL.uniaojts(pontos);} + if(uniaopolis) + {i3GEO.editorOL.layergrafico.addFeatures(uniaopolis);} + if(uniaolinhas) + {i3GEO.editorOL.layergrafico.addFeatures(uniaolinhas);} + if(uniaopontos) + {i3GEO.editorOL.layergrafico.addFeatures(uniaopontos);} + } + else + {alert("Selecione pelo menos dois elementos");} + }, + uniaojts: function(geoms){ + var n = geoms.length, + rwkt = new jsts.io.WKTReader(), + wwkt = new jsts.io.WKTWriter(), + fwkt = new OpenLayers.Format.WKT(), + wkt, + g, + i,uniao; + if(n > 1){ + wkt = fwkt.write(geoms[0]); + alert(wkt) + uniao = rwkt.read(wkt); + for(i=1;i <= n;i++){ + wkt = fwkt.write(geoms[i]); + g = readerwkt.read(wkt); + uniao = uniao.union(g); + } + uniao = wwkt.write(uniao); + return [fwkt.read(uniao)]; + } + else + {return false;} + }, + retornaGeometriasTipo: function(features,tipo){ + var n = features.length, + lista = [], + i,temp; + for(i=0;i