Changeset 6722 in josm


Ignore:
Timestamp:
2014-01-17T23:35:14+01:00 (10 years ago)
Author:
simon04
Message:

fix #9577 - Remove automatic fix for "Way contains segment twice"

Since we highlight duplicate segments since r6694, it seems easier/safer to let the user manually fix this (rare?) error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r6694 r6722  
    1616import java.util.TreeSet;
    1717
    18 import org.openstreetmap.josm.command.ChangeNodesCommand;
    19 import org.openstreetmap.josm.command.Command;
    2018import org.openstreetmap.josm.data.osm.Node;
    2119import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2422import org.openstreetmap.josm.data.osm.Way;
    2523import org.openstreetmap.josm.data.osm.WaySegment;
    26 import org.openstreetmap.josm.data.validation.FixableTestError;
    2724import org.openstreetmap.josm.data.validation.Severity;
    2825import org.openstreetmap.josm.data.validation.Test;
     
    155152    }
    156153
    157     public static Pair<ChangeNodesCommand, Set<WaySegment>> fixDuplicateWaySegment(Way w) {
     154    protected static Set<WaySegment> checkDuplicateWaySegment(Way w) {
    158155        // test for ticket #4959
    159156        Set<WaySegment> segments = new TreeSet<WaySegment>(new Comparator<WaySegment>() {
     
    169166            }
    170167        });
    171         final Set<Integer> wayNodesToFix = new TreeSet<Integer>(Collections.reverseOrder());
    172168        final Set<WaySegment> duplicateWaySegments = new HashSet<WaySegment>();
    173169
     
    176172            final boolean wasInSet = !segments.add(segment);
    177173            if (wasInSet) {
    178                 wayNodesToFix.add(i);
    179174                duplicateWaySegments.add(segment);
    180175            }
    181176        }
    182         if (wayNodesToFix.size() > 1) {
    183             final List<Node> newNodes = new ArrayList<Node>(w.getNodes());
    184             for (final int i : wayNodesToFix) {
    185                 newNodes.remove(i);
    186             }
    187             return Pair.create(new ChangeNodesCommand(w, newNodes), duplicateWaySegments);
     177        if (duplicateWaySegments.size() > 1) {
     178            return duplicateWaySegments;
    188179        } else {
    189180            return null;
     
    194185    public void visit(Way w) {
    195186
    196         final Pair<ChangeNodesCommand, Set<WaySegment>> duplicateWaySegment = fixDuplicateWaySegment(w);
     187        final Set<WaySegment> duplicateWaySegment = checkDuplicateWaySegment(w);
    197188        if (duplicateWaySegment != null) {
    198             errors.add(new FixableTestError(this, Severity.ERROR, tr("Way contains segment twice"),
    199                     DUPLICATE_WAY_SEGMENT, Collections.singleton(w), duplicateWaySegment.b, duplicateWaySegment.a));
     189            errors.add(new TestError(this, Severity.ERROR, tr("Way contains segment twice"),
     190                    DUPLICATE_WAY_SEGMENT, Collections.singleton(w), duplicateWaySegment));
    200191            return;
    201192        }
Note: See TracChangeset for help on using the changeset viewer.