Changeset 28350 in osm for applications


Ignore:
Timestamp:
2012-04-24T21:09:24+02:00 (12 years ago)
Author:
joshdoe
Message:

[josm_utilsplugin2] show conflict dialog with Replace Geometry only when really needed

Only show if multiple values exist for the same tag, or if both objects have relation memberships.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java

    r28335 r28350  
    1717/**
    1818 *
    19  * @author Josh
     19 * @author joshdoe
    2020 */
    2121public final class ReplaceGeometryUtils {
     
    3434            return buildReplaceWayWithNewCommand(Arrays.asList((Way) firstObject, (Way) secondObject));
    3535        } else if (firstObject instanceof Node) {
    36             return createUpgradeNodeCommand((Node) firstObject, secondObject);
     36            return buildUpgradeNodeCommand((Node) firstObject, secondObject);
    3737        } else if (secondObject instanceof Node) {
    38             return createUpgradeNodeCommand((Node) secondObject, firstObject);
     38            return buildUpgradeNodeCommand((Node) secondObject, firstObject);
    3939        } else {
    4040            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."));
     
    5656            return buildReplaceWayCommand((Way) subjectObject, (Way) referenceSubject);
    5757        } else if (subjectObject instanceof Node) {
    58             return createUpgradeNodeCommand((Node) subjectObject, referenceSubject);
     58            return buildUpgradeNodeCommand((Node) subjectObject, referenceSubject);
    5959        } else if (referenceSubject instanceof Node) {
    6060            // TODO: fix this illogical reversal?
    61             return createUpgradeNodeCommand((Node) referenceSubject, subjectObject);
     61            return buildUpgradeNodeCommand((Node) referenceSubject, subjectObject);
    6262        } else {
    6363            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."));
     
    108108     * @param referenceObject object with greater spatial quality
    109109     */
    110     public static ReplaceGeometryCommand createUpgradeNodeCommand(Node subjectNode, OsmPrimitive referenceObject) {
     110    public static ReplaceGeometryCommand buildUpgradeNodeCommand(Node subjectNode, OsmPrimitive referenceObject) {
    111111        if (!OsmPrimitive.getFilteredList(subjectNode.getReferrers(), Way.class).isEmpty()) {
    112112            throw new ReplaceGeometryException(tr("Node belongs to way(s), cannot replace."));
     
    429429     */
    430430    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           
    431440        Collection<OsmPrimitive> primitives = Arrays.asList(source, target);
    432441       
     
    448457
    449458        // 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())) {
    452463            dialog.setVisible(true);
    453464            if (dialog.isCanceled()) {
Note: See TracChangeset for help on using the changeset viewer.