Changeset 6513 in josm
- Timestamp:
- 2013-12-23T00:13:58+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/validator/tagchecker.cfg
r6510 r6513 37 37 # Empty lines and space signs are ignored 38 38 39 way : W : highway == * && name == /.* (Ave|Blvd|Br|Brg|Cct|Cir|Cl|Cr|Crct|Cres|Crt|Ct|Dr|Drv|Esp|Espl|Hwy|Ln|Mw|Mwy|Pl|Rd|Qy|Qys|Sq|St|Str|Ter|Tce|Tr|Wy)\.?$/i # abbreviated street name40 41 node : W : oneway == * # oneway tag on a node42 node : W : bridge == BOOLEAN_TRUE # bridge tag on a node43 node : W : highway == /motorway*|trunk*|primary*|secondary*|tertiary*|unclassified|residential|service|living_street|pedestrian|track|path|footway/ # wrong highway tag on a node44 way : W : /highway|railway/ == crossing # wrong crossing tag on a way45 way : I : highway == unclassified && name != * # Unnamed unclassified highway46 way : I : highway == /motorway|trunk|primary|secondary|tertiary/ && ref != * # highway without a reference47 * : W : highway == road # temporary highway type48 39 * : W : / *name */i == * && name != * # misspelled key name 49 40 … … 52 43 #way : W : highway == /motorway|trunk|primary|secondary|tertiary|residential|pedestrian/ && /name|ref|(name:.*)|(.*_name)|(.*_ref)/ != * # Unnamed 53 44 54 way : W : highway == cycleway && bicycle == BOOLEAN_FALSE # cycleway with tag bicycle55 way : W : highway == footway && foot == BOOLEAN_FALSE # footway with tag foot56 #way : I : highway == cycleway && bicycle == * # cycleway with tag bicycle57 #way : I : highway == footway && foot == * # footway with tag foot58 way : W : highway == cycleway && cycleway == lane # separate cycleway as lane on a cycleway59 way : W : highway == * && barrier == * # barrier used on a way60 61 #way : I : waterway == * && layer != * # waterway without layer tag62 way : I : highway == footway && maxspeed == * # maxspeed used for footway63 way : I : highway == steps && maxspeed == * # maxspeed used for footway64 65 45 # see #5844, #6760 66 46 #way : W : oneway != BOOLEAN_FALSE && /.*:(backward|forward)/ == * # oneway combined with *:backward/forward 67 68 * : W : layer == /\+.*/ # layer tag with + sign69 70 * : I : name == /.*Strasse.*/i # street name contains ss71 47 72 48 relation : E : type != * # relation without type … … 217 193 218 194 # measurement values and units warnings (ticket #8687) 195 * : W : layer == /\+.*/ # layer tag with + sign 219 196 way : W : layer == * && layer != /^0$|^-?[1-5]$/ # layer should be between -5 and 5 220 197 * : W : level == * && level != /^((([0-9]|-[1-9])|[1-9][0-9]*)(\.5)?)(;(([0-9]|-[1-9])|[1-9][0-9]*)(\.5)?)*$|^-0\.5$/ # level should be numbers with optional .5 increments -
trunk/src/org/openstreetmap/josm/data/osm/Tag.java
r6512 r6513 99 99 } 100 100 101 /** 102 * This constructs a {@link Tag} by splitting {@code s} on the first equality sign. 103 * @see org.openstreetmap.josm.tools.TextTagParser 104 * @param s the string to convert 105 * @return the constructed tag 106 */ 101 107 public static Tag ofString(String s) { 102 108 CheckParameterUtil.ensureParameterNotNull(s, "s"); -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r6512 r6513 229 229 public void initialize() throws Exception { 230 230 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/deprecated.mapcss"), "UTF-8")); 231 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/highway.mapcss"), "UTF-8")); 231 232 } 232 233 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r6455 r6513 38 38 } 39 39 40 public static Condition create(String k, boolean not, boolean yes, Context context) {40 public static Condition create(String k, boolean not, boolean yes, boolean no, Context context) { 41 41 switch (context) { 42 42 case PRIMITIVE: 43 return new KeyCondition(k, not, yes );43 return new KeyCondition(k, not, yes, no); 44 44 case LINK: 45 if (yes )45 if (yes || no) 46 46 throw new MapCSSException("Question mark operator ''?'' not supported in LINK context"); 47 47 if (not) … … 216 216 * ["a label"?] PRIMITIVE: the primitive has a tag "a label" whose value evaluates to a true-value 217 217 * LINK: not supported 218 * 219 * ["a label"?!] PRIMITIVE: the primitive has a tag "a label" whose value evaluates to a false-value 220 * LINK: not supported 218 221 * </pre> 219 222 */ … … 221 224 222 225 private String label; 223 private boolean exclamationMarkPresent; 224 private boolean questionMarkPresent; 225 226 /** 227 * 228 * @param label 229 * @param exclamationMarkPresent 230 * @param questionMarkPresent 231 */ 232 public KeyCondition(String label, boolean exclamationMarkPresent, boolean questionMarkPresent){ 226 private boolean negateResult; 227 private boolean testForTrueValues; 228 private boolean testForFalseValues; 229 230 public KeyCondition(String label, boolean negateResult, boolean testForTrueValues, boolean testForFalseValues){ 233 231 this.label = label; 234 this.exclamationMarkPresent = exclamationMarkPresent; 235 this.questionMarkPresent = questionMarkPresent; 232 this.negateResult = negateResult; 233 this.testForTrueValues = testForTrueValues; 234 this.testForFalseValues = testForFalseValues; 236 235 } 237 236 … … 240 239 switch(e.getContext()) { 241 240 case PRIMITIVE: 242 if (questionMarkPresent) 243 return OsmUtils.isTrue(e.osm.get(label)) ^ exclamationMarkPresent; 241 if (testForTrueValues) 242 return OsmUtils.isTrue(e.osm.get(label)) ^ negateResult; 243 else if (testForFalseValues) 244 return OsmUtils.isFalse(e.osm.get(label)) ^ negateResult; 244 245 else 245 return e.osm.hasKey(label) ^ exclamationMarkPresent;246 return e.osm.hasKey(label) ^ negateResult; 246 247 case LINK: 247 248 Utils.ensure(false, "Illegal state: KeyCondition not supported in LINK context"); … … 253 254 @Override 254 255 public String toString() { 255 return "[" + ( exclamationMarkPresent ? "!" : "") + label + "]";256 return "[" + (negateResult ? "!" : "") + label + "]"; 256 257 } 257 258 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r6455 r6513 345 345 boolean not = false; 346 346 boolean yes = false; 347 boolean no = false; 347 348 String key; 348 349 } … … 350 351 ( <EXCLAMATION> { not = true; } )? 351 352 key=tag_key() 353 ( LOOKAHEAD(2) <QUESTION> <EXCLAMATION> { no = true; } )? 352 354 ( <QUESTION> { yes = true; } )? 353 { return Condition.create(key, not, yes, context); }355 { return Condition.create(key, not, yes, no, context); } 354 356 } 355 357 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r6512 r6513 10 10 import org.openstreetmap.josm.data.osm.Tag; 11 11 import org.openstreetmap.josm.data.osm.Way; 12 import org.openstreetmap.josm.tools.TextTagParser; 12 13 13 14 import java.io.StringReader; … … 55 56 56 57 OsmPrimitive createPrimitiveForAssertion(String assertion) { 57 final String[] x = assertion.split("\\s+" );58 final String[] x = assertion.split("\\s+", 2); 58 59 final OsmPrimitive p = "n".equals(x[0]) || "node".equals(x[0]) 59 60 ? new Node() … … 66 67 throw new IllegalArgumentException("Expecting n/node/w/way/r/relation, but got " + x[0]); 67 68 } 68 for (int i = 1; i < x.length; i++) { 69 final Tag tag = Tag.ofString(x[i]); 70 p.put(tag.getKey(), tag.getValue()); 69 for (final Map.Entry<String, String> i : TextTagParser.getValidatedTagsFromText(x[1]).entrySet()) { 70 p.put(i.getKey(), i.getValue()); 71 71 } 72 72 return p; … … 95 95 for (final MapCSSTagChecker.TagCheck check : c.checks) { 96 96 for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) { 97 if (check.matchesPrimitive(createPrimitiveForAssertion(i.getKey())) != i.getValue()) { 98 final String error = "Expecting test '" + check.getMessage() + "' to " + (i.getValue() ? "" : "not ") + "match " + i.getKey(); 97 final OsmPrimitive p = createPrimitiveForAssertion(i.getKey()); 98 if (check.matchesPrimitive(p) != i.getValue()) { 99 final String error = "Expecting test '" + check.getMessage() + "' to " + (i.getValue() ? "" : "not ") + "match " + i.getKey() + ", i.e., " + p.getKeys(); 99 100 System.err.println(error); 100 101 assertionErrors.add(error);
Note:
See TracChangeset
for help on using the changeset viewer.