From 9d50ff5aa6b2f62dd2380c74ff78dd4627d32213 Mon Sep 17 00:00:00 2001 From: "taylor.smock" Date: Wed, 7 Aug 2024 14:34:44 +0000 Subject: [PATCH] Fix #23290: Use checks in checkgroups when looking for out-of-region tags Also fix an i18n issue and update a test to use a key that is currently invalid in a region. git-svn-id: https://josm.openstreetmap.de/svn/trunk@19172 0c6e7542-c601-0410-84e7-c038aed88b3b --- resources/data/defaultpresets.xml | 10 +++++----- .../josm/data/validation/tests/TagChecker.java | 12 ++++++++++-- .../josm/data/validation/tests/TagCheckerTest.java | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/resources/data/defaultpresets.xml b/resources/data/defaultpresets.xml index 31279d71aa3..2233e8e4ddf 100644 --- a/resources/data/defaultpresets.xml +++ b/resources/data/defaultpresets.xml @@ -195,10 +195,10 @@ - - - - + + + + @@ -8387,7 +8387,7 @@ - + diff --git a/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java b/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java index 6608bc6dd77..d0ba44e1d0d 100644 --- a/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java +++ b/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java @@ -416,12 +416,14 @@ public static void initializePresets() { addPresetValue((KeyedItem) i); } else if (i instanceof CheckGroup) { for (Check c : ((CheckGroup) i).checks) { + if (!"none".equals(c.match)) + minData.add(c); addPresetValue(c); } } } if (!minData.isEmpty()) { - presetIndex .put(p, minData); + presetIndex.put(p, minData); } } } @@ -854,7 +856,13 @@ private void tagCheckReal(TaggingPreset preset, OsmPrimitive p, LatLon center, R */ private static boolean primitiveInRegions(IPrimitive primitive, Collection regions, boolean excludeRegions) { if (primitive instanceof INode) { - return latLonInRegions((INode) primitive, regions) == excludeRegions; + // 4 options: + // In Region | excluding region | expected + // true | false | true + // true | true | false + // false | false | false + // false | true | true + return latLonInRegions((INode) primitive, regions) != excludeRegions; } else if (primitive instanceof IWay) { return ((IWay) primitive).getNodes().stream().anyMatch(n -> primitiveInRegions(n, regions, excludeRegions)); } else if (primitive instanceof IRelation) { diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java index fe3f00e6b2d..92857b8a033 100644 --- a/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java +++ b/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java @@ -232,10 +232,10 @@ void testValueDifferentCase() throws IOException { @Test void testRegionKey() throws IOException { - final List errors = test(OsmUtils.createPrimitive("node highway=crossing crossing_ref=zebra")); + final List errors = test(OsmUtils.createPrimitive("node payment:ep_avant=yes")); assertEquals(1, errors.size()); assertEquals("Key from a preset is invalid in this region", errors.get(0).getMessage()); - assertEquals("Preset Pedestrian Crossing should not have the key crossing_ref", errors.get(0).getDescription()); + assertEquals("Preset Payment Methods should not have the key payment:ep_avant", errors.get(0).getDescription()); assertEquals(Severity.WARNING, errors.get(0).getSeverity()); assertFalse(errors.get(0).isFixable());