Changeset 9023 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/validator/ignoretags.cfg
r7449 r9023 75 75 ; 76 76 K:type=is_in 77 K:bridge=viaduct78 K:bridge=aqueduct79 77 K:bridge=swing 80 78 ; 81 79 ; Highway Key/Value Pairs 82 80 ; 83 K:highway=motorway_link84 K:highway=trunk_link85 K:highway=primary_link86 K:highway=secondary_link87 81 K:oneway=-1 88 ;89 ; traffic_calming Tags90 ;91 K:traffic_calming=yes92 K:traffic_calming=bump93 K:traffic_calming=chicane94 K:traffic_calming=cushion95 K:traffic_calming=hump96 K:traffic_calming=rumble_strip97 K:traffic_calming=table98 K:traffic_calming=choker99 ;100 ; Aeroway Key/Value Pairs101 ;102 K:aeroway=apron103 K:aeroway=hanger104 K:aeroway=helipad105 K:aeroway=runway106 K:aeroway=taxiway107 K:aeroway=terminal108 K:aeroway=aerodrome109 82 ; 110 83 ; Amenity Key/Value Pairs 111 84 ; 112 K:amenity=arts_centre113 K:amenity=atm114 K:amenity=baby_hatch115 K:amenity=bank116 K:amenity=bbq117 K:amenity=bench118 K:amenity=biergarten119 K:amenity=bicycle_parking120 K:amenity=bicycle_rental121 K:amenity=bureau_de_change122 K:amenity=bus_station123 K:amenity=brothel124 K:amenity=cafe125 K:amenity=car_rental126 K:amenity=car_sharing127 K:amenity=cinema128 K:amenity=college129 K:amenity=courthouse130 85 K:amenity=crematorium 131 K:amenity=dentist132 K:amenity=doctors133 K:amenity=drinking_water134 K:amenity=embassy135 86 K:amenity=emergency_phone 136 K:amenity=fast_food137 K:amenity=ferry_terminal138 K:amenity=fire_station139 K:amenity=food_court140 K:amenity=fountain141 K:amenity=fuel142 87 K:amenity=gallery 143 K:amenity=grave_yard144 K:amenity=grit_bin145 88 K:amenity=gym 146 K:amenity=hospital147 K:amenity=hunting_stand148 K:amenity=kindergarten149 K:amenity=library150 K:amenity=marketplace151 K:amenity=nightclub152 K:amenity=parking153 K:amenity=pharmacy154 K:amenity=place_of_worship155 K:amenity=police156 K:amenity=post_box157 K:amenity=post_office158 K:amenity=prison159 K:amenity=pub160 K:amenity=public_building161 K:amenity=recycling162 K:amenity=restaurant163 K:amenity=school164 K:amenity=shelter165 89 K:amenity=signpost 166 K:amenity=studio167 K:amenity=taxi168 K:amenity=telephone169 K:amenity=theatre170 K:amenity=toilets171 K:amenity=townhall172 K:amenity=university173 K:amenity=vending_machine174 K:amenity=veterinary175 K:amenity=waste_basket176 K:amenity=waste_disposal177 90 ; 178 91 ; Cuisine Tags 179 92 ; 180 93 K:cuisine=coffee_shop 181 K:cuisine=fish_and_chips182 94 K:cuisine=pie 183 ;184 ; Cycleway Tags185 ;186 K:cycleway=lane187 K:cycleway=track188 K:cycleway=opposite_lane189 K:cycleway=opposite190 K:cycleway=opposite_track191 95 ; 192 96 ; Historic Tags 193 97 ; 194 K:historic=castle195 K:historic=monument196 K:historic=memorial197 K:historic=archaeological_site198 K:historic=ruins199 K:historic=battlefield200 98 K:historic=wreck 201 99 K:historic=yes … … 212 110 ; Natural Tags 213 111 ; 214 K:natural=bay215 K:natural=beach216 K:natural=cave_entrance217 K:natural=cliff218 K:natural=fell219 K:natural=glacier220 K:natural=heath221 112 K:natural=marsh 222 K:natural=mud223 K:natural=peak224 K:natural=scree225 K:natural=scrub226 K:natural=spring227 K:natural=tree228 K:natural=volcano229 K:natural=wetland230 ;231 ; Surface Key/Value Pairs232 ;233 K:surface=dirt234 K:surface=wood235 113 ; 236 114 ; Relation Tags … … 241 119 ; Christian Denominations 242 120 ; 243 K:denomination=anglican244 121 K:denomination=apostolic 245 K:denomination=baptist246 K:denomination=catholic247 122 K:denomination=christian_community 248 123 K:denomination=christian_scientist … … 250 125 K:denomination=czechoslovak_hussite 251 126 K:denomination=dutch_reformed 252 K:denomination=evangelical253 127 K:denomination=foursquare 254 K:denomination=greek_orthodox255 K:denomination=jehovahs_witness256 128 K:denomination=kabbalah 257 129 K:denomination=karaite 258 130 K:denomination=living_waters_church 259 K:denomination=lutheran260 131 K:denomination=maronite 261 132 K:denomination=mennonite 262 K:denomination=methodist263 K:denomination=mormon264 K:denomination=new_apostolic265 133 K:denomination=nondenominational 266 K:denomination=old_catholic267 K:denomination=orthodox268 K:denomination=pentecostal269 K:denomination=presbyterian270 K:denomination=protestant271 K:denomination=quaker272 K:denomination=roman_catholic273 K:denomination=russian_orthodox274 134 K:denomination=salvation_army 275 135 K:denomination=serbian_orthodox 276 K:denomination=seventh_day_adventist277 136 K:denomination=united 278 137 K:denomination=united_reformed … … 283 142 K:denomination=alternative 284 143 K:denomination=ashkenazi 285 K:denomination=conservative286 144 K:denomination=hasidic 287 145 K:denomination=humanistic … … 290 148 K:denomination=neo_orthodox 291 149 K:denomination=nondenominational 292 K:denomination=orthodox293 150 K:denomination=progressive 294 151 K:denomination=reconstructionist 295 K:denomination=reform296 152 K:denomination=renewal 297 153 K:denomination=samaritan … … 302 158 K:denomination=alaouite 303 159 K:denomination=druze 304 K:denomination=ibadi305 160 K:denomination=ismaili 306 161 K:denomination=nondenominational 307 K:denomination=shia308 K:denomination=sunni309 162 ; 310 163 ; Pastafarian Denominations … … 318 171 ; Shop Key/Value Pairs 319 172 ; 320 K:shop=alcohol321 K:shop=bakery322 K:shop=beverages323 K:shop=bicycle324 K:shop=books325 K:shop=butcher326 K:shop=car327 K:shop=car_repair328 K:shop=chemist329 K:shop=clothes330 K:shop=computer331 K:shop=confectionery332 K:shop=convenience333 K:shop=department_store334 K:shop=dry_cleaning335 K:shop=doityourself336 K:shop=electronics337 K:shop=florist338 K:shop=furniture339 K:shop=garden_centre340 K:shop=greengrocer341 K:shop=hairdresser342 K:shop=hardware343 K:shop=hifi344 K:shop=kiosk345 K:shop=laundry346 K:shop=mall347 K:shop=motorcycle348 K:shop=optician349 173 K:shop=organic 350 K:shop=outdoor351 K:shop=sports352 K:shop=stationery353 K:shop=supermarket354 K:shop=shoes355 K:shop=toys356 K:shop=travel_agency357 K:shop=video358 174 ; 359 175 ; Sports Tags … … 364 180 ; Tourism Tags 365 181 ; 366 K:tourism=alpine_hut367 K:tourism=attraction368 K:tourism=artwork369 K:tourism=camp_site370 K:tourism=caravan_site371 K:tourism=chalet372 K:tourism=guest_house373 K:tourism=hostel374 K:tourism=hotel375 K:tourism=information376 K:tourism=motel377 K:tourism=museum378 K:tourism=picnic_site379 K:tourism=theme_park380 K:tourism=viewpoint381 K:tourism=zoo382 182 K:tourism=yes 383 183 ; -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r8969 r9023 80 80 private static final List<String> ignoreDataEquals = new ArrayList<>(); 81 81 private static final List<String> ignoreDataEndsWith = new ArrayList<>(); 82 private static final List< IgnoreKeyPair> ignoreDataKeyPair= new ArrayList<>();82 private static final List<Tag> ignoreDataTag = new ArrayList<>(); 83 83 84 84 /** The preferences prefix */ … … 159 159 ignoreDataEquals.clear(); 160 160 ignoreDataEndsWith.clear(); 161 ignoreData KeyPair.clear();161 ignoreDataTag.clear(); 162 162 harmonizedKeys.clear(); 163 163 … … 207 207 break; 208 208 case "K:": 209 IgnoreKeyPair tmp = new IgnoreKeyPair(); 210 int mid = line.indexOf('='); 211 tmp.key = line.substring(0, mid); 212 tmp.value = line.substring(mid+1); 213 ignoreDataKeyPair.add(tmp); 209 ignoreDataTag.add(Tag.ofString(line)); 214 210 } 215 211 } else if (tagcheckerfile) { … … 309 305 310 306 /** 307 * Determines if the given key is in internal presets. 308 * @param key key 309 * @return {@code true} if the given key is in internal presets 310 * @since 9023 311 */ 312 public static boolean isKeyInPresets(String key) { 313 return presetsValueData.get(key) != null; 314 } 315 316 /** 317 * Determines if the given tag is in internal presets. 318 * @param key key 319 * @param value value 320 * @return {@code true} if the given tag is in internal presets 321 * @since 9023 322 */ 323 public static boolean isTagInPresets(String key, String value) { 324 final Set<String> values = presetsValueData.get(key); 325 return values != null && (values.isEmpty() || values.contains(value)); 326 } 327 328 /** 329 * Returns the list of ignored tags. 330 * @return the list of ignored tags 331 * @since 9023 332 */ 333 public static List<Tag> getIgnoredTags() { 334 return new ArrayList<>(ignoreDataTag); 335 } 336 337 /** 338 * Determines if the given tag is ignored for checks "key/tag not in presets". 339 * @param key key 340 * @param value value 341 * @return {@code true} if the given tag is ignored 342 * @since 9023 343 */ 344 public static boolean isTagIgnored(String key, String value) { 345 boolean tagInPresets = isTagInPresets(key, value); 346 boolean ignore = false; 347 348 for (String a : ignoreDataStartsWith) { 349 if (key.startsWith(a)) { 350 ignore = true; 351 } 352 } 353 for (String a : ignoreDataEquals) { 354 if (key.equals(a)) { 355 ignore = true; 356 } 357 } 358 for (String a : ignoreDataEndsWith) { 359 if (key.endsWith(a)) { 360 ignore = true; 361 } 362 } 363 364 if (!tagInPresets) { 365 for (Tag a : ignoreDataTag) { 366 if (key.equals(a.getKey()) && value.equals(a.getValue())) { 367 ignore = true; 368 } 369 } 370 } 371 return ignore; 372 } 373 374 /** 311 375 * Checks the primitive tags 312 376 * @param p The primitive to check … … 373 437 } 374 438 if (checkValues && key != null && value != null && !value.isEmpty() && presetsValueData != null) { 375 final Set<String> values = presetsValueData.get(key); 376 final boolean keyInPresets = values != null; 377 final boolean tagInPresets = values != null && (values.isEmpty() || values.contains(prop.getValue())); 378 379 boolean ignore = false; 380 for (String a : ignoreDataStartsWith) { 381 if (key.startsWith(a)) { 382 ignore = true; 383 } 384 } 385 for (String a : ignoreDataEquals) { 386 if (key.equals(a)) { 387 ignore = true; 388 } 389 } 390 for (String a : ignoreDataEndsWith) { 391 if (key.endsWith(a)) { 392 ignore = true; 393 } 394 } 395 396 if (!tagInPresets) { 397 for (IgnoreKeyPair a : ignoreDataKeyPair) { 398 if (key.equals(a.key) && value.equals(a.value)) { 399 ignore = true; 400 } 401 } 402 } 403 404 if (!ignore) { 405 if (!keyInPresets) { 439 if (!isTagIgnored(key, value)) { 440 if (!isKeyInPresets(key)) { 406 441 String prettifiedKey = harmonizeKey(key); 407 442 String fixedKey = harmonizedKeys.get(prettifiedKey); … … 420 455 withErrors.put(p, "UPK"); 421 456 } 422 } else if (! tagInPresets) {457 } else if (!isTagInPresets(key, value)) { 423 458 // try to fix common typos and check again if value is still unknown 424 459 String fixedValue = harmonizeValue(prop.getValue()); 425 Map<String, String> possibleValues = getPossibleValues( values);460 Map<String, String> possibleValues = getPossibleValues(presetsValueData.get(key)); 426 461 if (possibleValues.containsKey(fixedValue)) { 427 462 fixedValue = possibleValues.get(fixedValue); … … 642 677 643 678 return false; 644 }645 646 protected static class IgnoreKeyPair {647 public String key;648 public String value;649 679 } 650 680 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r8863 r9023 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertTrue; 5 6 6 7 import java.io.IOException; 8 import java.util.ArrayList; 7 9 import java.util.List; 8 10 … … 12 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 15 import org.openstreetmap.josm.data.osm.OsmUtils; 16 import org.openstreetmap.josm.data.osm.Tag; 14 17 import org.openstreetmap.josm.data.validation.TestError; 15 18 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; … … 68 71 assertEquals("Value 'forrest' for key 'landuse' not in presets.", errors.get(0).getDescription()); 69 72 } 73 74 /** 75 * Checks that tags specifically ignored are effectively not in internal presets. 76 * @throws IOException if any I/O error occurs 77 */ 78 @Test 79 public void testIgnoredTagsNotInPresets() throws IOException { 80 List<String> errors = new ArrayList<>(); 81 new TagChecker().initialize(); 82 for (Tag tag : TagChecker.getIgnoredTags()) { 83 if (TagChecker.isTagInPresets(tag.getKey(), tag.getValue())) { 84 errors.add(tag.toString()); 85 } 86 } 87 assertTrue(errors.toString(), errors.isEmpty()); 88 } 70 89 }
Note:
See TracChangeset
for help on using the changeset viewer.