Changeset 25857 in osm
- Timestamp:
- 2011-04-16T19:53:11+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/dumbutils/src/dumbutils/ReplaceGeometryAction.java
r25854 r25857 1 1 package dumbutils; 2 2 3 import java.awt.geom.Area; 4 import org.openstreetmap.josm.data.osm.Node; 5 import java.util.*; 3 6 import org.openstreetmap.josm.command.*; 4 import java.util.List;5 7 import org.openstreetmap.josm.Main; 6 8 import javax.swing.JOptionPane; … … 47 49 48 50 // Now do the replacement 51 List<Command> commands = new ArrayList<Command>(); 49 52 Way result = new Way(way); 50 53 result.setNodes(geometry.getNodes()); 54 // Copy tags from temporary way (source etc.) 55 for( String key : geometry.keySet() ) 56 result.put(key, geometry.get(key)); 57 commands.add(new ChangeCommand(way, result)); 58 commands.add(new DeleteCommand(geometry)); 59 60 // Check if there are unconnected nodes, delete them 61 Set<Node> nodesToDelete = new HashSet<Node>(); 62 Area a = getCurrentDataSet().getDataSourceArea(); 63 for( Node node : way.getNodes() ) { 64 if( !node.isDeleted() && node.isReferredByWays(1) && (node.isNewOrUndeleted() || a.contains(node.getCoor())) ) 65 nodesToDelete.add(node); 66 } 67 if( !nodesToDelete.isEmpty() ) 68 commands.add(new DeleteCommand(nodesToDelete)); 51 69 52 70 // Two items in undo stack: change original way and delete geometry way 53 Command changeCommand = new ChangeCommand(way, result);54 Command deleteCommand = new DeleteCommand(geometry);55 71 Main.main.undoRedo.add(new SequenceCommand( 56 72 tr("Replace geometry of way {0}", way.getDisplayName(DefaultNameFormatter.getInstance())), 57 c hangeCommand, deleteCommand));73 commands)); 58 74 } 59 75 }
Note:
See TracChangeset
for help on using the changeset viewer.