diff --git a/ferramentas/editorol/editorol.js b/ferramentas/editorol/editorol.js index 691e396..91a166c 100755 --- a/ferramentas/editorol/editorol.js +++ b/ferramentas/editorol/editorol.js @@ -1326,22 +1326,14 @@ i3GEO.editorOL = temp.className = "editorOLapagaItemInactive olButton"; temp.title = $trad("excsel"); temp.onclick = function(){ - var x, i, s, nsel = i3GEO.editorOL.idsSelecionados.length; + var x, nsel = i3GEO.editorOL.idsSelecionados.length; i3GEO.editorOL.featuresBackup = []; i3GEO.editorOL.marcaBotao(); if(nsel > 0){ x = window.confirm($trad("excsel") + "?"); if(x){ - s = i3GEO.desenho.layergrafico.getSource(); - for(i=0; i" + $trad("opcoes") + ""; + ins += "" + $trad("u6") + "" + $trad("opcoes") + ""; while (n > 0) { n -= 1; @@ -1983,9 +1929,7 @@ i3GEO.editorOL = + id + "\")'>selecionalimpabrilha"; + + "\")'>limpa"; } } ins += ""; @@ -2002,6 +1946,7 @@ i3GEO.editorOL = temp.style.height = "100px"; temp.innerHTML = ins; }, + //TODO incuir um botao para executar a operacao ao inves do evento onchange ferramentas : function() { if (!document.getElementById("panelferramentasEditor")) { YAHOO.namespace("editorOL.ferramentas"); @@ -2017,6 +1962,7 @@ i3GEO.editorOL = "" + '

' + $trad("opsel") + ':

' + + '
' + '' + '

Apaga tudo'; + '
'; YAHOO.editorOL.ferramentas.panel.setBody(ins); if (i3GEO && typeof i3GEO != undefined && i3GEO != "") { @@ -2083,11 +2029,31 @@ i3GEO.editorOL = if (operacao === "") { return; } - var geosel = i3GEO.desenho.layergrafico.selectedFeatures, polis, linhas, pontos, temp; - if (geosel.length > 0) { - polis = i3GEO.editorOL.retornaGeometriasTipo(geosel, "OpenLayers.Geometry.Polygon"); - linhas = i3GEO.editorOL.retornaGeometriasTipo(geosel, "OpenLayers.Geometry.LineString"); - pontos = i3GEO.editorOL.retornaGeometriasTipo(geosel, "OpenLayers.Geometry.Point"); + var polis, linhas, pontos, temp, nsel = i3GEO.editorOL.idsSelecionados.length; + + /* + + var s, i, nsel, id, clone; + s = i3GEO.desenho.layergrafico.getSource(); + nsel = i3GEO.editorOL.idsSelecionados.length; + for(i=0; i 0) { + polis = i3GEO.editorOL.retornaGeometriasTipo("Polygon"); + linhas = i3GEO.editorOL.retornaGeometriasTipo("LineString"); + pontos = i3GEO.editorOL.retornaGeometriasTipo("Point"); temp = function(retorno) { if (i3GEO.janela) { i3GEO.janela.fechaAguarde("i3GEO.editorPoli"); @@ -2144,17 +2110,18 @@ i3GEO.editorOL = i3GEO.php.funcoesGeometriasWkt(temp, pontos.join("|"), operacao); } } + i3GEO.desenho.layergrafico.getSource().changed(); return; } else { i3GEO.janela.tempoMsg("Selecione pelo menos dois elementos"); } }, merge : function(geoms) { - var n = geoms.length, w = new Wkt.Wkt(), g, m, i; - w.read(geoms[0].toString()); + var n = geoms.length, w = new Wkt.Wkt(), g, m, i, format = new ol.format.WKT(); + w.read(format.writeFeatures([geoms[0]])); if (n > 1) { for (i = 1; i < n; i++) { - g = geoms[i].toString(); + g = format.writeFeatures([geoms[i]]); m = new Wkt.Wkt(); m.read(g); w.merge(m); @@ -2163,28 +2130,34 @@ i3GEO.editorOL = return w.write(); }, uniaojts : function(geoms) { - var n = geoms.length, rwkt = new jsts.io.WKTReader(), wwkt = new jsts.io.WKTWriter(), fwkt = new OpenLayers.Format.WKT(), g, i, uniao; + var n = geoms.length, + fwkt = new ol.format.WKT(), + rwkt = new jsts.io.WKTReader(), + wwkt = new jsts.io.WKTWriter(), + g, i, uniao; if (n > 1) { - uniao = (fwkt.read(geoms[0]).geometry).toString(); + uniao = fwkt.writeFeatures([geoms[0]]); uniao = rwkt.read(uniao); for (i = 1; i <= n; i++) { - g = (fwkt.read(geoms[i]).geometry).toString(); + g = fwkt.writeFeatures([geoms[i]]); uniao = uniao.union(rwkt.read(g)); } uniao = wwkt.write(uniao); return [ - fwkt.read(uniao) + fwkt.readFeatures(uniao) ]; } else { return false; } }, - retornaGeometriasTipo : function(features, tipo) { - var n = features.length, lista = [], i, temp; + retornaGeometriasTipo : function(tipo) { + var n = i3GEO.editorOL.idsSelecionados.length, lista = [], i, + s = i3GEO.desenho.layergrafico.getSource(), + fwkt = new ol.format.WKT(); for (i = 0; i < n; i++) { - temp = features[i].geometry; - if (temp.CLASS_NAME == tipo) { - lista.push(temp); + f = s.getFeatureById(i3GEO.editorOL.idsSelecionados[i]); + if (f.getGeometry().getType() == tipo) { + lista.push(fwkt.writeFeatures([f])); } } return lista; @@ -2262,31 +2235,23 @@ i3GEO.editorOL = } // i3GEO.editorOL.backup.removeFeatures(i3GEO.editorOL.backup.features); }, - //TODO remover? - substituiFeaturesSel : function(wkt) { - i3GEO.editorOL.guardaBackup(); - try { - var f, fwkt = new OpenLayers.Format.WKT(); - i3GEO.desenho.layergrafico.removeFeatures(i3GEO.desenho.layergrafico.selectedFeatures); - f = fwkt.read(wkt); - f["attributes"] = { - opacidade : i3GEO.editorOL.simbologia.opacidade, - texto : i3GEO.editorOL.simbologia.texto, - fillColor : i3GEO.editorOL.simbologia.fillColor, - strokeWidth : i3GEO.editorOL.simbologia.strokeWidth, - strokeColor : i3GEO.editorOL.simbologia.strokeColor, - pointRadius : i3GEO.editorOL.simbologia.pointRadius, - graphicName : i3GEO.editorOL.simbologia.graphicName - }; - i3GEO.desenho.layergrafico.addFeatures([ - f - ]); - if (document.getElementById("panellistagEditor")) { - i3GEO.editorOL.listaGeometrias(); - } - } catch (e) { - i3GEO.editorOL.restauraBackup(); - } + substituiFeaturesSel : function(f) { + i3GEO.editorOL.removeFeaturesSel(); + var fwkt = new ol.format.WKT(); + f = fwkt.readFeatures(f)[0]; + f.setStyle( + new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: 'rgba(' + i3GEO.editorOL.simbologia.strokeColor + ',' + i3GEO.editorOL.simbologia.opacidade + ')', + width: i3GEO.editorOL.simbologia.strokeWidth + }), + fill: new ol.style.Fill({ + color: 'rgba(' + i3GEO.editorOL.simbologia.fillColor + ',' + i3GEO.editorOL.simbologia.opacidade + ')' + }) + }) + ); + f.setId(i3GEO.util.uid()); + i3GEO.desenho.layergrafico.getSource().addFeature(f); }, adicionaFeatureWkt : function(wkt, atributos) { var f, fwkt = new OpenLayers.Format.WKT(); -- libgit2 0.21.2