Ticket #20121: 20121.patch
File 20121.patch, 5.4 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
111 111 112 112 @Override 113 113 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 114 if (w1 == w2) 115 return false; 116 if (areLayerOrLevelDifferent(w1, w2)) { 114 if (areLayerOrLevelDifferent(w1, w2)) 117 115 return true; 118 }119 116 if (isBuilding(w1) && isBuilding(w2)) 120 return true; 121 if (w1.hasKey(HIGHWAY) && w2.hasKey(HIGHWAY) && !Objects.equals(w1.get("level"), w2.get("level"))) { 122 return true; 123 } 117 return true; // handled by mapcss tests 124 118 if (((isResidentialArea(w1) || w1.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY)) && isResidentialArea(w2)) 125 119 || ((isResidentialArea(w2) || w2.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY)) && isResidentialArea(w1))) 126 120 return true; 127 if (isSubwayOrTramOrRazed(w2)) { 128 return true; 129 } 130 if (isCoastline(w1) != isCoastline(w2)) { 131 return true; 132 } 133 if ((w1.hasTag(WATERWAY, "river", "stream", "canal", "drain", "ditch") && w2.hasTag(WATERWAY, "riverbank")) 134 || (w2.hasTag(WATERWAY, "river", "stream", "canal", "drain", "ditch") && w1.hasTag(WATERWAY, "riverbank"))) { 135 return true; 136 } 137 return isProposedOrAbandoned(w2); 121 if (isWaterArea(w1) && isWaterArea(w2)) 122 return true; // handled by mapcss tests 123 return (w1.hasTag(WATERWAY, "river", "stream", "canal", "drain", "ditch") && w2.hasTag(WATERWAY, "riverbank")) 124 || (w2.hasTag(WATERWAY, "river", "stream", "canal", "drain", "ditch") && w1.hasTag(WATERWAY, "riverbank")); 138 125 } 139 126 140 127 @Override … … 269 256 } 270 257 271 258 /** 272 * Self crossing ways test (for all the rest)259 * Self crossing ways test (for all ways) 273 260 */ 274 261 public static class SelfCrossing extends CrossingWays { 275 262 276 263 protected static final int CROSSING_SELF = 604; 277 264 278 CrossingWays.Ways normalTest = new Ways();279 CrossingWays.Boundaries boundariesTest = new Boundaries();280 281 265 /** 282 266 * Constructs a new SelfIntersection test. 283 267 */ … … 286 270 } 287 271 288 272 @Override 289 public boolean isPrimitiveUsable(OsmPrimitive p) {290 return super.isPrimitiveUsable(p) && !(normalTest.isPrimitiveUsable(p)291 || boundariesTest.isPrimitiveUsable(p));292 }293 294 @Override295 273 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 296 274 return w1 != w2; // should not happen 297 275 } … … 327 305 return w.hasTag("natural", "water", "coastline") || w.hasTag(LANDUSE, "reservoir"); 328 306 } 329 307 308 static boolean isWaterArea(OsmPrimitive w) { 309 return w.hasTag("natural", "water") || w.hasTag(LANDUSE, "reservoir"); 310 } 311 330 312 static boolean isHighway(OsmPrimitive w) { 331 313 return w.hasTagDifferent(HIGHWAY, "rest_area", "services", "bus_stop", "platform"); 332 314 } … … 353 335 354 336 @Override 355 337 public void visit(Way w) { 356 if (this instanceof SelfCrossing) { 338 boolean findSelfCrossingOnly = this instanceof SelfCrossing; 339 if (findSelfCrossingOnly) { 357 340 // free memory, we are not interested in previous ways 358 341 cellSegments.clear(); 359 342 seenWays.clear(); … … 373 356 List<Way> prims; 374 357 List<WaySegment> highlight; 375 358 376 if (!es1.intersects(es2) || ignoreWaySegmentCombination(es1.way, es2.way)) { 359 if (!es1.intersects(es2) 360 || (!findSelfCrossingOnly && ignoreWaySegmentCombination(es1.way, es2.way))) { 377 361 continue; 378 362 } 379 363 -
test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
8 8 import java.util.HashMap; 9 9 import java.util.List; 10 10 11 import org.junit.jupiter.api.Test; 11 12 import org.junit.jupiter.api.extension.RegisterExtension; 12 import org.junit.jupiter.api.Test;13 13 import org.openstreetmap.josm.TestUtils; 14 14 import org.openstreetmap.josm.data.coor.EastNorth; 15 15 import org.openstreetmap.josm.data.coor.LatLon; … … 173 173 void testSelfCrossing() { 174 174 SelfCrossing test = new CrossingWays.SelfCrossing(); 175 175 // isPrimitiveUsable 176 assertFalse(test.isPrimitiveUsable(newUsableWay("highway=motorway")));177 assertFalse(test.isPrimitiveUsable(newUsableWay("barrier=yes")));178 assertFalse(test.isPrimitiveUsable(newUsableWay("boundary=administrative")));179 176 assertFalse(test.isPrimitiveUsable(TestUtils.newWay("amenity=restaurant"))); // Unusable (0 node) 180 assertTrue(test.isPrimitiveUsable(newUsableWay("amenity=restaurant"))); // Usable (2 nodes)181 177 } 182 178 }