Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/Lanes.java
r6603 r6606 34 34 } 35 35 36 protected void check EqualNumberOfLanes(final OsmPrimitive p, String lanesKey, String message) {36 protected void checkNumberOfLanesByKey(final OsmPrimitive p, String lanesKey, String message) { 37 37 final Collection<String> keysForPattern = Utils.filter(p.keySet(), 38 38 Predicates.stringContainsPattern(Pattern.compile(":" + lanesKey + "$"))); … … 62 62 } 63 63 64 protected void checkNumberOfLanes(final OsmPrimitive p) { 65 final String lanes = p.get("lanes"); 66 final String forward = Utils.firstNonNull(p.get("lanes:forward"), "0"); 67 final String backward = Utils.firstNonNull(p.get("lanes:backward"), "0"); 68 try { 69 if (Integer.parseInt(lanes) < Integer.parseInt(forward) + Integer.parseInt(backward)) { 70 errors.add(new TestError(this, Severity.WARNING, 71 tr("Number of {0} greater than {1}", tr("{0}+{1}", "lanes:forward", "lanes:backward"), "lanes"), 3101, p)); 72 } 73 } catch (NumberFormatException ignore) { 74 Main.debug(ignore.getMessage()); 75 } 76 } 77 64 78 @Override 65 79 public void check(OsmPrimitive p) { 66 checkEqualNumberOfLanes(p, "lanes", tr("Number of lane dependent values inconsistent")); 67 checkEqualNumberOfLanes(p, "lanes:forward", tr("Number of lane dependent values inconsistent in forward direction")); 68 checkEqualNumberOfLanes(p, "lanes:backward", tr("Number of lane dependent values inconsistent in backward direction")); 80 checkNumberOfLanesByKey(p, "lanes", tr("Number of lane dependent values inconsistent")); 81 checkNumberOfLanesByKey(p, "lanes:forward", tr("Number of lane dependent values inconsistent in forward direction")); 82 checkNumberOfLanesByKey(p, "lanes:backward", tr("Number of lane dependent values inconsistent in backward direction")); 83 checkNumberOfLanes(p); 69 84 } 70 85 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/LanesTest.groovy
r6598 r6606 49 49 assert lanes.errors.isEmpty() 50 50 } 51 52 void test7() { 53 lanes.check(TestUtils.createPrimitive("way lanes=3 lanes:forward=3 lanes:backward=7")) 54 assert lanes.errors.get(0).getMessage() == "Number of lanes:forward+lanes:backward greater than lanes" 55 } 51 56 }
Note:
See TracChangeset
for help on using the changeset viewer.