Changeset 6694 in josm for trunk/src/org


Ignore:
Timestamp:
2014-01-15T21:59:27+01:00 (11 years ago)
Author:
simon04
Message:

see #9577 - Highlight duplicate way segments of "Way contains segment twice" test

File:
1 edited

Legend:

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

    r6693 r6694  
    1010import java.util.Comparator;
    1111import java.util.HashMap;
     12import java.util.HashSet;
    1213import java.util.List;
    1314import java.util.Map;
     
    154155    }
    155156
    156     public static Command fixDuplicateWaySegment(Way w) {
     157    public static Pair<ChangeNodesCommand, Set<WaySegment>> fixDuplicateWaySegment(Way w) {
    157158        // test for ticket #4959
    158159        Set<WaySegment> segments = new TreeSet<WaySegment>(new Comparator<WaySegment>() {
     
    169170        });
    170171        final Set<Integer> wayNodesToFix = new TreeSet<Integer>(Collections.reverseOrder());
    171        
     172        final Set<WaySegment> duplicateWaySegments = new HashSet<WaySegment>();
     173
    172174        for (int i = 0; i < w.getNodesCount() - 1; i++) {
    173             final boolean wasInSet = !segments.add(new WaySegment(w, i));
     175            final WaySegment segment = new WaySegment(w, i);
     176            final boolean wasInSet = !segments.add(segment);
    174177            if (wasInSet) {
    175178                wayNodesToFix.add(i);
     179                duplicateWaySegments.add(segment);
    176180            }
    177181        }
     
    181185                newNodes.remove(i);
    182186            }
    183             return new ChangeNodesCommand(w, newNodes);
     187            return Pair.create(new ChangeNodesCommand(w, newNodes), duplicateWaySegments);
    184188        } else {
    185189            return null;
     
    190194    public void visit(Way w) {
    191195
    192         final Command duplicateWaySegmentFix = fixDuplicateWaySegment(w);
    193         if (duplicateWaySegmentFix != null) {
     196        final Pair<ChangeNodesCommand, Set<WaySegment>> duplicateWaySegment = fixDuplicateWaySegment(w);
     197        if (duplicateWaySegment != null) {
    194198            errors.add(new FixableTestError(this, Severity.ERROR, tr("Way contains segment twice"),
    195                     DUPLICATE_WAY_SEGMENT, w, duplicateWaySegmentFix));
     199                    DUPLICATE_WAY_SEGMENT, Collections.singleton(w), duplicateWaySegment.b, duplicateWaySegment.a));
    196200            return;
    197201        }
Note: See TracChangeset for help on using the changeset viewer.