- Timestamp:
- 2011-11-02T09:49:44+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r3713 r4557 36 36 if (!isEnabled()) 37 37 return; 38 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 39 if (sel.size() < 1) return; 38 Collection<Node> selectedNodes = getCurrentDataSet().getSelectedNodes(); 39 // Allow multiple selected nodes too? 40 if (selectedNodes.size() != 1) return; 41 42 Node node = selectedNodes.iterator().next(); 40 43 41 44 Collection<Command> cmds = new LinkedList<Command>(); 42 45 43 for (OsmPrimitive osm : sel) { 44 if (!(osm instanceof Node)) { 45 continue; 46 } 47 Node node = (Node) osm; 46 // If the user has selected some ways, only join the node to these. 47 boolean restrictToSelectedWays = 48 getCurrentDataSet().getSelectedWays().size() > 0; 48 49 49 50 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments( … … 51 52 HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); 52 53 for (WaySegment ws : wss) { 54 // Maybe cleaner to pass a "isSelected" predicate to getNearestWaySegements, but this is atm. less invasive. 55 if(restrictToSelectedWays && !ws.way.isSelected()) { 56 continue; 57 } 58 53 59 List<Integer> is; 54 60 if (insertPoints.containsKey(ws.way)) { … … 81 87 cmds.add(new ChangeCommand(w, wnew)); 82 88 } 83 } 84 if (cmds.size() == 0) return; 85 Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds)); 86 Main.map.repaint(); 89 if (cmds.size() == 0) return; 90 Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds)); 91 Main.map.repaint(); 87 92 } 88 93
Note:
See TracChangeset
for help on using the changeset viewer.