Changeset 6722 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-01-17T23:35:14+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r6694 r6722 16 16 import java.util.TreeSet; 17 17 18 import org.openstreetmap.josm.command.ChangeNodesCommand;19 import org.openstreetmap.josm.command.Command;20 18 import org.openstreetmap.josm.data.osm.Node; 21 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 24 22 import org.openstreetmap.josm.data.osm.Way; 25 23 import org.openstreetmap.josm.data.osm.WaySegment; 26 import org.openstreetmap.josm.data.validation.FixableTestError;27 24 import org.openstreetmap.josm.data.validation.Severity; 28 25 import org.openstreetmap.josm.data.validation.Test; … … 155 152 } 156 153 157 p ublic static Pair<ChangeNodesCommand, Set<WaySegment>> fixDuplicateWaySegment(Way w) {154 protected static Set<WaySegment> checkDuplicateWaySegment(Way w) { 158 155 // test for ticket #4959 159 156 Set<WaySegment> segments = new TreeSet<WaySegment>(new Comparator<WaySegment>() { … … 169 166 } 170 167 }); 171 final Set<Integer> wayNodesToFix = new TreeSet<Integer>(Collections.reverseOrder());172 168 final Set<WaySegment> duplicateWaySegments = new HashSet<WaySegment>(); 173 169 … … 176 172 final boolean wasInSet = !segments.add(segment); 177 173 if (wasInSet) { 178 wayNodesToFix.add(i);179 174 duplicateWaySegments.add(segment); 180 175 } 181 176 } 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; 188 179 } else { 189 180 return null; … … 194 185 public void visit(Way w) { 195 186 196 final Pair<ChangeNodesCommand, Set<WaySegment>> duplicateWaySegment = fixDuplicateWaySegment(w);187 final Set<WaySegment> duplicateWaySegment = checkDuplicateWaySegment(w); 197 188 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)); 200 191 return; 201 192 }
Note:
See TracChangeset
for help on using the changeset viewer.