Ticket #20130: 20130.2.patch
| File 20130.2.patch, 10.5 KB (added by , 5 years ago) |
|---|
-
resources/data/validator/geometry.mapcss
200 200 throwWarning: tr("Water area inside water area"); 201 201 } 202 202 203 /* #20130 Building crossing landuse (spatial test) */ 204 area:closed:areaStyle[landuse=~ /^(commercial|farmyard|garages|industrial|retail|residential)$/] ⧉o area[building][building!~/no|entrance/] { 205 throwWarning: tr("Building partly outside of landuse area"); 206 } 207 203 208 area:closed:areaStyle ⧉ area:closed:areaStyle { 204 209 throwOther: tr("Overlapping Areas"); 205 210 } -
src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
56 56 * Type of way. Entries have to be declared in alphabetical order, see sort below. 57 57 */ 58 58 private enum WayType { 59 BARRIER, BUILDING, HIGHWAY, RAILWAY, RESIDENTIAL_AREA,WATERWAY, WAY;59 BARRIER, BUILDING, HIGHWAY, RAILWAY, WATERWAY, WAY; 60 60 61 61 static WayType of(Way w) { 62 62 if (w.hasKey(CrossingWays.BARRIER)) … … 67 67 return HIGHWAY; 68 68 else if (isRailway(w)) 69 69 return RAILWAY; 70 else if (isResidentialArea(w))71 return RESIDENTIAL_AREA;72 70 else if (w.hasKey(CrossingWays.WATERWAY)) 73 71 return WATERWAY; 74 72 else … … 106 104 || isRailway(w) 107 105 || isCoastline(w) 108 106 || isBuilding(w) 109 || w.hasKey(BARRIER) 110 || isResidentialArea(w)); 107 || w.hasKey(BARRIER)); 111 108 } 112 109 113 110 @Override … … 118 115 return true; 119 116 if (isBuilding(w1) && isBuilding(w2)) 120 117 return true; // handled by mapcss tests 121 if (((isResidentialArea(w1) || w1.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY) || isWaterArea(w1))122 && isResidentialArea(w2))123 || ((isResidentialArea(w2) || w2.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY) || isWaterArea(w2))124 && isResidentialArea(w1)))125 return true;126 118 if (isWaterArea(w1) && isWaterArea(w2)) 127 119 return true; // handled by mapcss tests 128 120 if (w1.hasKey(RAILWAY) && w2.hasKey(RAILWAY) && w1.hasTag(RAILWAY, "yard") != w2.hasTag(RAILWAY, "yard")) { … … 174 166 return new MessageHelper(tr("Crossing building/highway"), 612); 175 167 case RAILWAY: 176 168 return new MessageHelper(tr("Crossing building/railway"), 613); 177 case RESIDENTIAL_AREA:178 return new MessageHelper(tr("Crossing building/residential area"), 614);179 169 case WATERWAY: 180 170 return new MessageHelper(tr("Crossing building/waterway"), 615); 181 171 case WAY: … … 200 190 default: 201 191 return new MessageHelper(tr("Crossing railway/way"), 631); 202 192 } 203 case RESIDENTIAL_AREA:204 return new MessageHelper(tr("Crossing residential area/way"), 641);205 193 case WATERWAY: 206 194 default: 207 195 return new MessageHelper(tr("Crossing waterway/way"), 651); -
src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
217 217 | < SUPERSET_OR_EQUAL: "⊇" > 218 218 | < NOT_SUPERSET_OR_EQUAL: "⊉" > 219 219 | < CROSSING: "⧉" > 220 | < CROSSING_OUTSIDE: "⧉o" > 220 221 | < PERCENT: "%" > 221 222 | < COMMENT_START: "/*" > : COMMENT 222 223 | < UNEXPECTED_CHAR : ~[] > // avoid TokenMgrErrors because they are hard to recover from … … 633 634 <NOT_SUPERSET_OR_EQUAL> { type = Selector.ChildOrParentSelectorType.NOT_SUPERSET_OR_EQUAL; } 634 635 | 635 636 <CROSSING> { type = Selector.ChildOrParentSelectorType.CROSSING; } 637 | 638 <CROSSING_OUTSIDE> { type = Selector.ChildOrParentSelectorType.CROSSING_OUTSIDE; } 636 639 ) 637 640 w() 638 641 | -
src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
126 126 * @see ChildOrParentSelector 127 127 */ 128 128 enum ChildOrParentSelectorType { 129 CHILD, PARENT, SUBSET_OR_EQUAL, NOT_SUBSET_OR_EQUAL, SUPERSET_OR_EQUAL, NOT_SUPERSET_OR_EQUAL, CROSSING, SIBLING, 129 CHILD, PARENT, SUBSET_OR_EQUAL, NOT_SUBSET_OR_EQUAL, SUPERSET_OR_EQUAL, NOT_SUPERSET_OR_EQUAL, CROSSING, SIBLING, CROSSING_OUTSIDE, 130 130 } 131 131 132 132 /** … … 324 324 private Area area; 325 325 /** Will contain all way segments, grouped by cells */ 326 326 Map<Point2D, List<WaySegment>> cellSegments; 327 private final boolean markOutsideArea; 327 328 328 private CrossingFinder(Environment e ) {329 private CrossingFinder(Environment e, boolean markOutside) { 329 330 super(e); 330 331 CheckParameterUtil.ensureThat(isArea(e.osm), "Only areas are supported"); 331 332 layer = OsmUtils.getLayer(e.osm); 333 this.markOutsideArea = markOutside; 332 334 } 333 335 334 336 private Area getAreaEastNorth(IPrimitive p, Environment e) { … … 393 395 Pair<PolygonIntersection, Area> is = Geometry.polygonIntersectionResult( 394 396 otherArea, area, Geometry.INTERSECTION_EPS_EAST_NORTH); 395 397 if (Geometry.PolygonIntersection.CROSSING == is.a) { 398 final Area hiliteArea; 399 if (markOutsideArea) { 400 hiliteArea = new Area(area); 401 hiliteArea.subtract(otherArea); 402 if (hiliteArea.isEmpty()) { 403 return; // can happen with multipolygon if only a node is shared 404 } 405 } else { 406 hiliteArea = is.b; 407 } 396 408 addToChildren(e, p); 397 409 // store intersection area to improve highlight and zoom to problem 398 410 if (e.intersections == null) { 399 411 e.intersections = new HashMap<>(); 400 412 } 401 e.intersections.put(p, is.b);413 e.intersections.put(p, hiliteArea); 402 414 } 403 415 } 404 405 416 } 406 417 407 418 private void useFindCrossings(IPrimitive p) { … … 545 556 visitBBox(e, insideOrEqualFinder); 546 557 return ChildOrParentSelectorType.SUPERSET_OR_EQUAL == type ? e.children != null : e.children == null; 547 558 548 } else if (ChildOrParentSelectorType.CROSSING == type ) {559 } else if (ChildOrParentSelectorType.CROSSING == type || ChildOrParentSelectorType.CROSSING_OUTSIDE == type) { 549 560 e.parent = e.osm; 550 561 if (e.osm.getDataSet() != null && isArea(e.osm)) { 551 final CrossingFinder crossingFinder = new CrossingFinder(e); 562 boolean markOutside = ChildOrParentSelectorType.CROSSING_OUTSIDE == type; 563 final CrossingFinder crossingFinder = new CrossingFinder(e, markOutside); 552 564 visitBBox(e, crossingFinder); 553 565 return e.children != null; 554 566 } -
test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
133 133 assertTrue(test.isPrimitiveUsable(newUsableWay("railway=rail"))); 134 134 assertTrue(test.isPrimitiveUsable(newUsableWay("natural=water"))); 135 135 assertTrue(test.isPrimitiveUsable(newUsableWay("building=yes"))); 136 assert True(test.isPrimitiveUsable(newUsableWay("landuse=residential")));136 assertFalse(test.isPrimitiveUsable(newUsableWay("landuse=residential"))); 137 137 // createMessage 138 138 testMessage(601, test, "amenity=restaurant", "amenity=restaurant"); 139 139 testMessage(611, test, "building=yes", "amenity=restaurant"); … … 140 140 testMessage(611, test, "building=yes", "natural=water"); 141 141 testMessage(612, test, "building=yes", "highway=road"); 142 142 testMessage(613, test, "building=yes", "railway=rail"); 143 testMessage(614, test, "building=yes", "landuse=residential");144 143 testMessage(615, test, "building=yes", "waterway=river"); 145 144 testMessage(620, test, "highway=road", "highway=road"); 146 145 testMessage(621, test, "highway=road", "amenity=restaurant"); … … 151 150 testMessage(631, test, "railway=rail", "amenity=restaurant"); 152 151 testMessage(631, test, "railway=rail", "natural=water"); 153 152 testMessage(632, test, "railway=rail", "waterway=river"); 154 testMessage(641, test, "landuse=residential", "amenity=restaurant");155 153 testMessage(650, test, "waterway=river", "waterway=river"); 156 154 testMessage(651, test, "waterway=river", "amenity=restaurant"); 157 155 testMessage(603, test, "barrier=hedge", "barrier=yes"); … … 161 159 testMessage(664, test, "barrier=hedge", "waterway=river"); 162 160 testMessage(665, test, "barrier=hedge", "natural=water"); 163 161 164 testIgnore(true, test, "landuse=residential", "natural=water");165 testIgnore(false, test, "landuse=residential", "building=yes");166 167 162 assertFalse(test.isPrimitiveUsable(newUsableWay("amenity=restaurant"))); 168 163 assertFalse(test.isPrimitiveUsable(TestUtils.newWay("barrier=yes"))); // Unusable (0 node) 169 164 assertTrue(test.isPrimitiveUsable(newUsableWay("barrier=yes"))); // Usable (2 nodes)
