Changeset 28350 in osm for applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap
- Timestamp:
- 2012-04-24T21:09:24+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java
r28335 r28350 17 17 /** 18 18 * 19 * @author Josh19 * @author joshdoe 20 20 */ 21 21 public final class ReplaceGeometryUtils { … … 34 34 return buildReplaceWayWithNewCommand(Arrays.asList((Way) firstObject, (Way) secondObject)); 35 35 } else if (firstObject instanceof Node) { 36 return createUpgradeNodeCommand((Node) firstObject, secondObject);36 return buildUpgradeNodeCommand((Node) firstObject, secondObject); 37 37 } else if (secondObject instanceof Node) { 38 return createUpgradeNodeCommand((Node) secondObject, firstObject);38 return buildUpgradeNodeCommand((Node) secondObject, firstObject); 39 39 } else { 40 40 throw new IllegalArgumentException(tr("This tool can only replace a node, upgrade a node to a way or a multipolygon, or replace a way with a way.")); … … 56 56 return buildReplaceWayCommand((Way) subjectObject, (Way) referenceSubject); 57 57 } else if (subjectObject instanceof Node) { 58 return createUpgradeNodeCommand((Node) subjectObject, referenceSubject);58 return buildUpgradeNodeCommand((Node) subjectObject, referenceSubject); 59 59 } else if (referenceSubject instanceof Node) { 60 60 // TODO: fix this illogical reversal? 61 return createUpgradeNodeCommand((Node) referenceSubject, subjectObject);61 return buildUpgradeNodeCommand((Node) referenceSubject, subjectObject); 62 62 } else { 63 63 throw new IllegalArgumentException(tr("This tool can only replace a node, upgrade a node to a way or a multipolygon, or replace a way with a way.")); … … 108 108 * @param referenceObject object with greater spatial quality 109 109 */ 110 public static ReplaceGeometryCommand createUpgradeNodeCommand(Node subjectNode, OsmPrimitive referenceObject) {110 public static ReplaceGeometryCommand buildUpgradeNodeCommand(Node subjectNode, OsmPrimitive referenceObject) { 111 111 if (!OsmPrimitive.getFilteredList(subjectNode.getReferrers(), Way.class).isEmpty()) { 112 112 throw new ReplaceGeometryException(tr("Node belongs to way(s), cannot replace.")); … … 429 429 */ 430 430 protected static List<Command> getTagConflictResolutionCommands(OsmPrimitive source, OsmPrimitive target) { 431 // determine if the same key in each object has different values 432 boolean keysWithMultipleValues; 433 Set<OsmPrimitive> set = new HashSet<OsmPrimitive>(); 434 set.add(source); 435 set.add(target); 436 TagCollection tagCol = TagCollection.unionOfAllPrimitives(set); 437 Set<String> keys = tagCol.getKeysWithMultipleValues(); 438 keysWithMultipleValues = !keys.isEmpty(); 439 431 440 Collection<OsmPrimitive> primitives = Arrays.asList(source, target); 432 441 … … 448 457 449 458 // conflict resolution is necessary if there are conflicts in the merged tags 450 // or if at least one of the merged nodes is referred to by a relation 451 if (!tags.isApplicableToPrimitive() || relationToNodeReferences.size() > 1) { 459 // or if both objects have relation memberships 460 if (keysWithMultipleValues || 461 (!RelationToChildReference.getRelationToChildReferences(source).isEmpty() && 462 !RelationToChildReference.getRelationToChildReferences(target).isEmpty())) { 452 463 dialog.setVisible(true); 453 464 if (dialog.isCanceled()) {
Note:
See TracChangeset
for help on using the changeset viewer.