diff --git a/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java b/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java
index aed103c9ce..93735aab42 100644
|
a
|
b
|
public class TurnrestrictionTest extends Test {
|
| 51 | 51 | "no_entry", "no_exit" |
| 52 | 52 | ); |
| 53 | 53 | |
| | 54 | // This should really be replaced with a transport mode hierarchy, i.e. #18383 |
| | 55 | private static final List<String> SUPPORTED_VEHICLE_TYPES = Arrays.asList( |
| | 56 | "agricultural", "bicycle", "bus", "caravan", "foot", "hazmat", |
| | 57 | "hgv", "horse", "motor_vehicle", "motorcar", "motorcycle", |
| | 58 | "psv", "vehicle" |
| | 59 | ); |
| | 60 | |
| | 61 | /** A string for "restriction" */ |
| | 62 | private static final String RESTRICTION_STRING = "restriction"; |
| | 63 | /** A string for "conditional" */ |
| | 64 | private static final String CONDITIONAL_STRING = "conditional"; |
| | 65 | |
| 54 | 66 | /** |
| 55 | 67 | * Constructs a new {@code TurnrestrictionTest}. |
| 56 | 68 | */ |
| … |
… |
public class TurnrestrictionTest extends Test {
|
| 58 | 70 | super(tr("Turn restrictions"), tr("This test checks if turn restrictions are valid.")); |
| 59 | 71 | } |
| 60 | 72 | |
| 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) { |
| | 73 | /** |
| | 74 | * Check for any restriction tag (e.g., "restriction:mode:conditional") |
| | 75 | * @param key The key to check |
| | 76 | * @param value The value to check |
| | 77 | * @return {@code true} if the tag is supported |
| | 78 | */ |
| | 79 | private static boolean restrictionTagIsSupported(final String key, final String value) { |
| | 80 | if (key.startsWith(RESTRICTION_STRING) && key.endsWith(CONDITIONAL_STRING) |
| | 81 | && SUPPORTED_VEHICLE_TYPES.contains(key.substring(RESTRICTION_STRING.length() + 1, key.length() - CONDITIONAL_STRING.length() - 1))) { |
| 66 | 82 | try { |
| 67 | | List<ConditionalValue> values = ConditionalValue.parse(conditionalValue); |
| 68 | | return !values.isEmpty() && SUPPORTED_RESTRICTIONS.contains(values.get(0).restrictionValue); |
| | 83 | final List<ConditionalValue> conditionalValues = ConditionalValue.parse(value); |
| | 84 | return !conditionalValues.isEmpty() && conditionalValues.stream() |
| | 85 | .anyMatch(conditional -> SUPPORTED_RESTRICTIONS.contains(conditional.restrictionValue)); |
| 69 | 86 | } catch (ConditionalParsingException e) { |
| 70 | 87 | Logging.trace(e); |
| 71 | 88 | } |
| | 89 | } else if (key.startsWith(RESTRICTION_STRING)) { |
| | 90 | return SUPPORTED_RESTRICTIONS.contains(value); |
| 72 | 91 | } |
| 73 | 92 | return false; |
| 74 | 93 | } |
| 75 | 94 | |
| | 95 | private static boolean hasSupportedRestrictionTag(Relation r) { |
| | 96 | if (r.hasTag(RESTRICTION_STRING, SUPPORTED_RESTRICTIONS)) |
| | 97 | return true; |
| | 98 | return r.getKeys().entrySet().stream() |
| | 99 | .anyMatch(entry -> restrictionTagIsSupported(entry.getKey(), entry.getValue())); |
| | 100 | } |
| | 101 | |
| 76 | 102 | @Override |
| 77 | 103 | public void visit(Relation r) { |
| 78 | 104 | if (!r.hasTag("type", "restriction")) |