Changeset 11136 in josm
- Timestamp:
- 2016-10-16T23:29:37+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r11100 r11136 105 105 CrossingWays.Boundaries.class, // ID 601 .. 699 106 106 CrossingWays.Barrier.class, // ID 601 .. 699 107 CrossingWays.SelfCrossing.class, // ID 601 .. 699 107 108 SimilarNamedWays.class, // ID 701 .. 799 108 109 Coastlines.class, // ID 901 .. 999 -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r11129 r11136 6 6 import java.awt.geom.Point2D; 7 7 import java.util.ArrayList; 8 import java.util.Arrays;9 8 import java.util.HashMap; 10 9 import java.util.List; … … 67 66 @Override 68 67 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 68 if (w1 == w2) 69 return false; 69 70 if (!Objects.equals(getLayer(w1), getLayer(w2))) { 70 71 return true; … … 172 173 173 174 /** 175 * Self crossing ways test (for all the rest) 176 */ 177 public static class SelfCrossing extends CrossingWays { 178 CrossingWays.Ways normalTest = new Ways(); 179 CrossingWays.Barrier barrierTest = new Barrier(); 180 CrossingWays.Boundaries boundariesTest = new Boundaries(); 181 182 /** 183 * Constructs a new SelfIntersection test. 184 */ 185 public SelfCrossing() { 186 super(tr("Self crossing")); 187 } 188 189 @Override 190 public boolean isPrimitiveUsable(OsmPrimitive p) { 191 return super.isPrimitiveUsable(p) && !(normalTest.isPrimitiveUsable(p) || barrierTest.isPrimitiveUsable(p) 192 || boundariesTest.isPrimitiveUsable(p)); 193 } 194 195 @Override 196 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 197 return (w1 != w2); // should not happen 198 } 199 200 @Override 201 String createMessage(Way w1, Way w2) { 202 return tr("Self-crossing ways"); 203 } 204 } 205 206 /** 174 207 * Constructs a new {@code CrossingWays} test. 175 208 * @param title The test title … … 221 254 @Override 222 255 public void visit(Way w) { 256 if (this instanceof SelfCrossing) { 257 // free memory, we are not interested in previous ways 258 cellSegments.clear(); 259 seenWays.clear(); 260 } 223 261 224 262 int nodesSize = w.getNodesCount(); … … 231 269 continue; 232 270 } 233 for (List<WaySegment> segments : getSegments( en1, en2)) {271 for (List<WaySegment> segments : getSegments(cellSegments, en1, en2)) { 234 272 for (WaySegment es2 : segments) { 235 273 List<Way> prims; … … 240 278 } 241 279 242 prims = Arrays.asList(es1.way, es2.way); 280 prims = new ArrayList<>(); 281 prims.add(es1.way); 282 if (es1.way != es2.way) 283 prims.add(es2.way); 243 284 if ((highlight = seenWays.get(prims)) == null) { 244 285 highlight = new ArrayList<>(); … … 266 307 * Returns all the cells this segment crosses. Each cell contains the list 267 308 * of segments already processed 268 * 309 * @param cellSegments map with already collected way segments 269 310 * @param n1 The first EastNorth 270 311 * @param n2 The second EastNorth 271 312 * @return A list with all the cells the segment crosses 272 313 */ 273 p rivate List<List<WaySegment>> getSegments(EastNorth n1, EastNorth n2) {314 public static List<List<WaySegment>> getSegments(Map<Point2D, List<WaySegment>> cellSegments, EastNorth n1, EastNorth n2) { 274 315 275 316 List<List<WaySegment>> cells = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWay.java
r11129 r11136 32 32 public void visit(Way w) { 33 33 Set<Node> nodes = new HashSet<>(); 34 35 for (int i = 1; i < w.getNodesCount() - 1; i++) { 34 int last = w.getNodesCount(); 35 if (last < 2) 36 return; 37 if (w.firstNode() == w.lastNode()) 38 last--; // closed way, ignore last node 39 nodes.add(w.firstNode()); 40 for (int i = 1; i < last; i++) { 36 41 Node n = w.getNode(i); 37 42 if (nodes.contains(n)) {
Note:
See TracChangeset
for help on using the changeset viewer.