Changeset 6694 in josm for trunk/src/org
- Timestamp:
- 2014-01-15T21:59:27+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r6693 r6694 10 10 import java.util.Comparator; 11 11 import java.util.HashMap; 12 import java.util.HashSet; 12 13 import java.util.List; 13 14 import java.util.Map; … … 154 155 } 155 156 156 public static CommandfixDuplicateWaySegment(Way w) {157 public static Pair<ChangeNodesCommand, Set<WaySegment>> fixDuplicateWaySegment(Way w) { 157 158 // test for ticket #4959 158 159 Set<WaySegment> segments = new TreeSet<WaySegment>(new Comparator<WaySegment>() { … … 169 170 }); 170 171 final Set<Integer> wayNodesToFix = new TreeSet<Integer>(Collections.reverseOrder()); 171 172 final Set<WaySegment> duplicateWaySegments = new HashSet<WaySegment>(); 173 172 174 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); 174 177 if (wasInSet) { 175 178 wayNodesToFix.add(i); 179 duplicateWaySegments.add(segment); 176 180 } 177 181 } … … 181 185 newNodes.remove(i); 182 186 } 183 return new ChangeNodesCommand(w, newNodes);187 return Pair.create(new ChangeNodesCommand(w, newNodes), duplicateWaySegments); 184 188 } else { 185 189 return null; … … 190 194 public void visit(Way w) { 191 195 192 final Command duplicateWaySegmentFix= fixDuplicateWaySegment(w);193 if (duplicateWaySegment Fix!= null) {196 final Pair<ChangeNodesCommand, Set<WaySegment>> duplicateWaySegment = fixDuplicateWaySegment(w); 197 if (duplicateWaySegment != null) { 194 198 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)); 196 200 return; 197 201 }
Note:
See TracChangeset
for help on using the changeset viewer.