- Timestamp:
- 2019-05-11T21:15:10+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data_nodist/restriction.osm
r14966 r15071 295 295 <node id='-138978' action='modify' lat='51.11929761964' lon='14.1607307948' /> 296 296 <node id='-138980' action='modify' lat='51.11938242064' lon='14.1607607948' /> 297 <node id='-139147' action='modify' lat='51.12600394515' lon='14.1602059678' /> 298 <node id='-139148' action='modify' lat='51.12545534658' lon='14.15967261709' /> 299 <node id='-139149' action='modify' lat='51.1257203484' lon='14.15988743891' /> 300 <node id='-139150' action='modify' lat='51.12552508405' lon='14.16119859274' /> 301 <node id='-139152' action='modify' lat='51.12608298001' lon='14.1608430256'> 302 <tag k='name' v='05.4 - no u-turn via way (oneway, conditional)' /> 303 </node> 304 <node id='-139153' action='modify' lat='51.12589701544' lon='14.16097636327' /> 305 <node id='-139155' action='modify' lat='51.12605520638' lon='14.16056440756' /> 297 306 <way id='-138981' timestamp='2009-09-09T15:30:17Z'> 298 307 <nd ref='-112783' /> … … 953 962 <nd ref='-138964' /> 954 963 <tag k='highway' v='unclassified' /> 964 </way> 965 <way id='-139151' action='modify'> 966 <nd ref='-139148' /> 967 <nd ref='-139149' /> 968 <nd ref='-139147' /> 969 <tag k='highway' v='unclassified' /> 970 <tag k='oneway' v='yes' /> 971 </way> 972 <way id='-139154' action='modify'> 973 <nd ref='-139147' /> 974 <nd ref='-139155' /> 975 <nd ref='-139152' /> 976 <tag k='highway' v='unclassified' /> 977 <tag k='oneway' v='yes' /> 978 </way> 979 <way id='-139156' action='modify'> 980 <nd ref='-139152' /> 981 <nd ref='-139153' /> 982 <nd ref='-139150' /> 983 <tag k='highway' v='unclassified' /> 984 <tag k='oneway' v='yes' /> 955 985 </way> 956 986 <relation id='-139094' action='modify' timestamp='2009-09-09T15:30:17Z'> … … 1282 1312 <tag k='type' v='restriction' /> 1283 1313 </relation> 1314 <relation id='-139207' action='modify'> 1315 <member type='way' ref='-139151' role='from' /> 1316 <member type='way' ref='-139154' role='via' /> 1317 <member type='way' ref='-139156' role='to' /> 1318 <tag k='name' v='OK 05.4 - no u-turn via way (oneway, conditional)' /> 1319 <tag k='restriction:conditional' v='no_u_turn @ (Mo-Fr 16:00-18:00)' /> 1320 <tag k='type' v='restriction' /> 1321 </relation> 1284 1322 </osm> -
trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java
r14879 r15071 38 38 /*,"hov","emergency","hazmat","disabled"*/)); 39 39 40 private static final Pattern CONDITIONAL_PATTERN; 41 static { 42 final String part = Pattern.compile("([^@\\p{Space}][^@]*?)" 43 + "\\s*@\\s*" + "(\\([^)\\p{Space}][^)]+?\\)|[^();\\p{Space}][^();]*?)\\s*").toString(); 44 CONDITIONAL_PATTERN = Pattern.compile('(' + part + ")(;\\s*" + part + ")*"); 45 } 46 40 47 /** 41 48 * Constructs a new {@code ConditionalKeys}. … … 164 171 // <restriction-value> @ <condition>[;<restriction-value> @ <condition>] 165 172 final List<ConditionalValue> r = new ArrayList<>(); 166 final String part = Pattern.compile("([^@\\p{Space}][^@]*?)" 167 + "\\s*@\\s*" + "(\\([^)\\p{Space}][^)]+?\\)|[^();\\p{Space}][^();]*?)\\s*").toString(); 168 final Matcher m = Pattern.compile('(' + part + ")(;\\s*" + part + ")*").matcher(value); 173 final Matcher m = CONDITIONAL_PATTERN.matcher(value); 169 174 if (!m.matches()) { 170 175 throw new ConditionalParsingException(tr("Does not match pattern ''restriction value @ condition''")); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java
r15019 r15071 16 16 import org.openstreetmap.josm.data.validation.Test; 17 17 import org.openstreetmap.josm.data.validation.TestError; 18 import org.openstreetmap.josm.data.validation.tests.ConditionalKeys.ConditionalParsingException; 19 import org.openstreetmap.josm.data.validation.tests.ConditionalKeys.ConditionalValue; 20 import org.openstreetmap.josm.tools.Logging; 18 21 19 22 /** … … 56 59 } 57 60 61 private static boolean hasSupportedRestrictionTag(Relation r) { 62 if (r.hasTag("restriction", SUPPORTED_RESTRICTIONS)) 63 return true; 64 String conditionalValue = r.get("restriction:conditional"); 65 if (conditionalValue != null) { 66 try { 67 List<ConditionalValue> values = ConditionalValue.parse(conditionalValue); 68 return !values.isEmpty() && SUPPORTED_RESTRICTIONS.contains(values.get(0).restrictionValue); 69 } catch (ConditionalParsingException e) { 70 Logging.trace(e); 71 } 72 } 73 return false; 74 } 75 58 76 @Override 59 77 public void visit(Relation r) { … … 61 79 return; 62 80 63 if (! r.hasTag("restriction", SUPPORTED_RESTRICTIONS)) {81 if (!hasSupportedRestrictionTag(r)) { 64 82 errors.add(TestError.builder(this, Severity.ERROR, UNKNOWN_RESTRICTION) 65 83 .message(tr("Unknown turn restriction")) -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ConditionalKeysTest.java
r12568 r15071 47 47 assertTrue(test.isKeyValid("oneway:backward:conditional")); 48 48 assertTrue(test.isKeyValid("fee:conditional")); 49 assertTrue(test.isKeyValid("restriction:conditional")); 49 50 assertFalse(test.isKeyValid("maxspeed:hgv:conditional:backward")); 50 51 } … … 67 68 assertFalse(test.isValueValid("motor_vehicle:conditional", "no @ (10:00until18:00 AND length>5)")); 68 69 assertTrue(test.isValueValid("maxspeed:hgv:conditional", "60 @ (weight>7.5)")); 70 assertTrue(test.isValueValid("restriction:conditional", "no_left_turn @ (Mo-Fr 16:00-18:00)")); 69 71 } 70 72 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ValidatorTestUtils.java
r15034 r15071 66 66 } else if (t.hasKey("name") && namePredicate != null && namePredicate.test(t.getName())) { 67 67 fail(name + " lacks josm_error_codes tag"); 68 } else if (t.hasKey("name") && name.startsWith("OK") && !errors.isEmpty()) {69 fail(name + "has unexpected error(s) ");68 } else if (t.hasKey("name") && t.get("name").startsWith("OK") && !errors.isEmpty()) { 69 fail(name + "has unexpected error(s): " + errors); 70 70 } 71 71 }
Note:
See TracChangeset
for help on using the changeset viewer.