Changeset 6202 in josm
- Timestamp:
- 2013-08-27T11:42:13+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r6130 r6202 28 28 import org.openstreetmap.josm.data.osm.Node; 29 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 30 import org.openstreetmap.josm.data.osm.RelationToChildReference;31 30 import org.openstreetmap.josm.data.osm.TagCollection; 32 31 import org.openstreetmap.josm.data.osm.Way; … … 50 49 * The "surviving" node will be moved to that location if it is 51 50 * different from the last selected node. 51 * 52 * @since 422 52 53 */ 53 54 public class MergeNodesAction extends JosmAction { 54 55 56 /** 57 * Constructs a new {@code MergeNodesAction}. 58 */ 55 59 public MergeNodesAction() { 56 60 super(tr("Merge Nodes"), "mergenodes", tr("Merge nodes into the oldest one."), … … 247 251 } 248 252 253 /** 254 * Merges the nodes in {@code nodes} at the specified node's location. Uses the dataset 255 * managed by {@code layer} as reference. 256 * @param layer layer the reference data layer. Must not be null 257 * @param nodes the collection of nodes. Ignored if null 258 * @param targetLocationNode this node's location will be used for the target node 259 * @throws IllegalArgumentException thrown if {@code layer} is null 260 */ 249 261 public static void doMergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetLocationNode) { 250 262 if (nodes == null) { … … 253 265 Set<Node> allNodes = new HashSet<Node>(nodes); 254 266 allNodes.add(targetLocationNode); 255 Node target = selectTargetNode(allNodes); 267 Node target; 268 if (nodes.contains(targetLocationNode) && !targetLocationNode.isNew()) { 269 target = targetLocationNode; // keep existing targetLocationNode as target to avoid unnecessary changes (see #2447) 270 } else { 271 target = selectTargetNode(allNodes); 272 } 256 273 257 274 Command cmd = mergeNodes(layer, nodes, target, targetLocationNode); … … 262 279 } 263 280 281 /** 282 * Merges the nodes in {@code nodes} at the specified node's location. Uses the dataset 283 * managed by {@code layer} as reference. 284 * 285 * @param layer layer the reference data layer. Must not be null. 286 * @param nodes the collection of nodes. Ignored if null. 287 * @param targetLocationNode this node's location will be used for the targetNode. 288 * @return The command necessary to run in order to perform action, or {@code null} if there is nothing to do 289 * @throws IllegalArgumentException thrown if {@code layer} is null 290 */ 264 291 public static Command mergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetLocationNode) { 265 292 if (nodes == null) { … … 279 306 * @param targetNode the target node the collection of nodes is merged to. Must not be null. 280 307 * @param targetLocationNode this node's location will be used for the targetNode. 308 * @return The command necessary to run in order to perform action, or {@code null} if there is nothing to do 281 309 * @throws IllegalArgumentException thrown if layer is null 282 310 */ … … 287 315 return null; 288 316 } 289 290 Set<RelationToChildReference> relationToNodeReferences = RelationToChildReference.getRelationToChildReferences(nodes);291 317 292 318 try { -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r6084 r6202 817 817 818 818 /** 819 * Merges the selected nodes to the one closest to the given mouse position if fthe control819 * Merges the selected nodes to the one closest to the given mouse position if the control 820 820 * key is pressed. If there is no such node, no action will be done and no error will be 821 821 * reported. If there is, it will execute the merge and add it to the undo buffer.
Note:
See TracChangeset
for help on using the changeset viewer.