diff --git a/src/org/openstreetmap/josm/actions/MergeNodesAction.java b/src/org/openstreetmap/josm/actions/MergeNodesAction.java
index 4a99848..1d1ecdb 100644
|
a
|
b
|
import org.openstreetmap.josm.data.coor.EastNorth;
|
| 27 | 27 | import org.openstreetmap.josm.data.coor.LatLon; |
| 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.Relation; |
| 30 | 31 | import org.openstreetmap.josm.data.osm.RelationToChildReference; |
| 31 | 32 | import org.openstreetmap.josm.data.osm.TagCollection; |
| 32 | 33 | import org.openstreetmap.josm.data.osm.Way; |
| … |
… |
public class MergeNodesAction extends JosmAction {
|
| 260 | 261 | return null; |
| 261 | 262 | } |
| 262 | 263 | |
| 263 | | Set<RelationToChildReference> relationToNodeReferences = RelationToChildReference.getRelationToChildReferences(nodes); |
| | 264 | final Set<RelationToChildReference> relationToNodeReferences = RelationToChildReference.getRelationToChildReferences(nodes); |
| | 265 | final Set<Relation> relationsWithReferences = new HashSet<Relation>(); |
| | 266 | for (RelationToChildReference i : relationToNodeReferences) { |
| | 267 | relationsWithReferences.add(i.getParent()); |
| | 268 | } |
| 264 | 269 | |
| 265 | 270 | try { |
| 266 | 271 | TagCollection nodeTags = TagCollection.unionOfAllPrimitives(nodes); |
| 267 | | List<Command> resultion = CombinePrimitiveResolverDialog.launchIfNecessary(nodeTags, nodes, Collections.singleton(targetNode)); |
| | 272 | List<Command> resolution = CombinePrimitiveResolverDialog.launchIfNecessary( |
| | 273 | nodeTags, nodes, Collections.singleton(targetNode), relationsWithReferences, |
| | 274 | 1 /* safe to merge nodes being part of at most 1 relation */); |
| 268 | 275 | LinkedList<Command> cmds = new LinkedList<Command>(); |
| 269 | 276 | |
| 270 | 277 | // the nodes we will have to delete |
| … |
… |
public class MergeNodesAction extends JosmAction {
|
| 290 | 297 | newTargetNode.setCoor(targetLocationNode.getCoor()); |
| 291 | 298 | cmds.add(new ChangeCommand(targetNode, newTargetNode)); |
| 292 | 299 | } |
| 293 | | cmds.addAll(resultion); |
| | 300 | cmds.addAll(resolution); |
| 294 | 301 | if (!nodesToDelete.isEmpty()) { |
| 295 | 302 | cmds.add(new DeleteCommand(nodesToDelete)); |
| 296 | 303 | } |
diff --git a/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java b/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
index 1ef4418..7bdc315 100644
|
a
|
b
|
public class CombinePrimitiveResolverDialog extends JDialog {
|
| 439 | 439 | final TagCollection tagsOfPrimitives, |
| 440 | 440 | final Collection<? extends OsmPrimitive> primitives, |
| 441 | 441 | final Collection<? extends OsmPrimitive> targetPrimitives) throws UserCancelException { |
| | 442 | return launchIfNecessary(tagsOfPrimitives, primitives, targetPrimitives, OsmPrimitive.getParentRelations(primitives), 0); |
| | 443 | } |
| 442 | 444 | |
| 443 | | final TagCollection completeWayTags = new TagCollection(tagsOfPrimitives); |
| 444 | | TagConflictResolutionUtil.combineTigerTags(completeWayTags); |
| 445 | | TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing(completeWayTags, primitives); |
| 446 | | final TagCollection tagsToEdit = new TagCollection(completeWayTags); |
| | 445 | public static List<Command> launchIfNecessary( |
| | 446 | final TagCollection tagsOfPrimitives, |
| | 447 | final Collection<? extends OsmPrimitive> primitives, |
| | 448 | final Collection<? extends OsmPrimitive> targetPrimitives, |
| | 449 | final Collection<Relation> parentRelations, |
| | 450 | final int parentRelationsThreshold) throws UserCancelException { |
| | 451 | |
| | 452 | final TagCollection normalizedTags = new TagCollection(tagsOfPrimitives); |
| | 453 | TagConflictResolutionUtil.combineTigerTags(normalizedTags); |
| | 454 | TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing(normalizedTags, primitives); |
| | 455 | final TagCollection tagsToEdit = new TagCollection(normalizedTags); |
| 447 | 456 | TagConflictResolutionUtil.completeTagCollectionForEditing(tagsToEdit); |
| 448 | 457 | |
| 449 | 458 | final CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance(); |
| 450 | 459 | |
| 451 | | dialog.getTagConflictResolverModel().populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues()); |
| | 460 | dialog.getTagConflictResolverModel().populate(tagsToEdit, normalizedTags.getKeysWithMultipleValues()); |
| 452 | 461 | |
| 453 | | final Set<Relation> parentRelations = OsmPrimitive.getParentRelations(primitives); |
| 454 | 462 | dialog.getRelationMemberConflictResolverModel().populate(parentRelations, primitives); |
| 455 | 463 | dialog.prepareDefaultDecisions(); |
| 456 | 464 | |
| 457 | 465 | // show information dialog to non-experts |
| 458 | | if (!completeWayTags.isApplicableToPrimitive() && !ExpertToggleAction.isExpert()) { |
| 459 | | String conflicts = Utils.joinAsHtmlUnorderedList(Utils.transform(completeWayTags.getKeysWithMultipleValues(), new Function<String, String>() { |
| | 466 | if (!normalizedTags.isApplicableToPrimitive() && !ExpertToggleAction.isExpert()) { |
| | 467 | String conflicts = Utils.joinAsHtmlUnorderedList(Utils.transform(normalizedTags.getKeysWithMultipleValues(), new Function<String, String>() { |
| 460 | 468 | |
| 461 | 469 | @Override |
| 462 | 470 | public String apply(String key) { |
| 463 | | return tr("{0} ({1})", key, Utils.join(tr(", "), Utils.transform(completeWayTags.getValues(key), new Function<String, String>() { |
| | 471 | return tr("{0} ({1})", key, Utils.join(tr(", "), Utils.transform(normalizedTags.getValues(key), new Function<String, String>() { |
| 464 | 472 | |
| 465 | 473 | @Override |
| 466 | 474 | public String apply(String x) { |
| … |
… |
public class CombinePrimitiveResolverDialog extends JDialog {
|
| 487 | 495 | } |
| 488 | 496 | } |
| 489 | 497 | |
| 490 | | if (!parentRelations.isEmpty() && !ExpertToggleAction.isExpert()) { |
| | 498 | if (parentRelations.size() > parentRelationsThreshold && !ExpertToggleAction.isExpert()) { |
| 491 | 499 | String msg = trn("You are about to combine {1} objects, " |
| 492 | 500 | + "which are part of {0} relation:<br/>{2}" |
| 493 | 501 | + "Combining these objects may break this relation. If you are unsure, please cancel this operation.<br/>" |
| … |
… |
public class CombinePrimitiveResolverDialog extends JDialog {
|
| 513 | 521 | } |
| 514 | 522 | |
| 515 | 523 | // resolve tag conflicts if necessary |
| 516 | | if (!completeWayTags.isApplicableToPrimitive() || !parentRelations.isEmpty()) { |
| | 524 | if (!normalizedTags.isApplicableToPrimitive() || parentRelations.size() > parentRelationsThreshold) { |
| 517 | 525 | dialog.setVisible(true); |
| 518 | 526 | if (dialog.isCanceled()) { |
| 519 | 527 | throw new UserCancelException(); |