Ticket #18217: 18217.2.patch
File 18217.2.patch, 2.4 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/data/validation/tests/Highways.java
38 38 protected static final int SOURCE_MAXSPEED_CONTEXT_MISMATCH_VS_MAXSPEED = 2705; 39 39 protected static final int SOURCE_MAXSPEED_CONTEXT_MISMATCH_VS_HIGHWAY = 2706; 40 40 protected static final int SOURCE_WRONG_LINK = 2707; 41 protected static final int AREA_ON_MAJOR_HIGHWAY = 2708; 41 42 42 43 protected static final String SOURCE_MAXSPEED = "source:maxspeed"; 43 44 … … 60 61 "urban", "rural", "zone", "zone10", "zone:10", "zone20", "zone:20", "zone30", "zone:30", "zone40", "zone:40", "zone60", "zone:60", 61 62 "nsl_single", "nsl_dual", "motorway", "trunk", "living_street", "bicycle_road")); 62 63 64 private static final Set<String> MAJOR_HIGHWAYS = new HashSet<>(Arrays.asList("motorway", "motorway_link", "trunk", "trunk_link", "primary", 65 "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link")); 66 63 67 private static final Set<String> ISO_COUNTRIES = new HashSet<>(Arrays.asList(Locale.getISOCountries())); 64 68 65 69 private boolean leftByPedestrians; … … 105 109 // Check maxspeed, including context against highway 106 110 testSourceMaxspeed(w, true); 107 111 } 112 areaTagOnMajorRoadTest(w); 108 113 testHighwayLink(w); 109 114 } 110 115 } … … 195 200 return !sameClass.isEmpty(); 196 201 } 197 202 203 private boolean isMajorHighway(Way way) 204 { 205 return way.hasKey(HIGHWAY) && MAJOR_HIGHWAYS.stream().anyMatch(s -> s.equals(way.get(HIGHWAY))); 206 } 207 208 private void areaTagOnMajorRoadTest(final Way way) 209 { 210 if (way.hasKey("area") && way.get("area").equals("yes") && this.isMajorHighway(way)) 211 { 212 errors.add(TestError.builder(this, Severity.ERROR, AREA_ON_MAJOR_HIGHWAY) 213 .message(tr("Area=yes should not be used on major highway. Pleas adjust tags accordingly.")) 214 .primitives(way) 215 .build()); 216 } 217 } 218 198 219 private void testHighwayLink(final Way way) { 199 220 if (!isHighwayLinkOkay(way)) { 200 221 errors.add(TestError.builder(this, Severity.WARNING, SOURCE_WRONG_LINK)