Hi All, I did a modification to MergeTowSelectedPolygonsPlugin to works with more than two polygon. Below the execute to use. It works with geometry union and in my case is useful to merge more than 2 polygon
maybe something must be correct for undo because it works but it doesn't recovery exactly to original state. could you someone in development team check it and evalutate if could be used to modify the function in oj core code? thanks luca public boolean execute(PlugInContext context) throws Exception{ Collection features = context.getWorkbenchContext().getLayerViewPanel().getSelectionManager().getFeaturesWithSelectedItems(); Feature mergedF = (Feature) ((ArrayList) features).get(0); ArrayList fToDelete = new ArrayList(); for (int j = 1 ; j < features.size() ; j++) { Geometry g = ((Feature) ((ArrayList) features).get(j)).getGeometry(); if (!(g instanceof Polygon)) continue; mergedF.setGeometry((Geometry)mergedF.getGeometry().union (g)); fToDelete.add((Feature) ((ArrayList) features).get(j)); } //-- merge using an edit transaction to enable undo ArrayList fToEdit = new ArrayList(); fToEdit.add(mergedF); Map layer2FeatList = LayerTools.getLayer2FeatureMap(fToEdit, context); Layer[] layersWithFeatures = (Layer[])layer2FeatList.keySet().toArray(new Layer[0]); EditTransaction edtr = new EditTransaction(fToEdit,"setgeom",layersWithFeatures[0],true,false,context.getLayerViewPanel()); Geometry g = mergedF.getGeometry(); edtr.setGeometry(mergedF,g); edtr.commit(); edtr.clearEnvelopeCaches(); //-- delete other feature FeatureCollectionTools.deleteFeatures(fToDelete,context); return true; } luca marletta www.beopen.it ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel