- Timestamp:
- 2019-05-11T21:15:10+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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"))
Note:
See TracChangeset
for help on using the changeset viewer.