Changeset 19172 in josm


Ignore:
Timestamp:
2024-08-07T16:34:44+02:00 (5 months ago)
Author:
taylor.smock
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/resources/data/defaultpresets.xml

    r19169 r19172  
    196196    </chunk>
    197197    <chunk id="toilets">
    198         <check key="toilets" />
    199         <check key="toilets:unisex" />
    200         <combo key="toilets:wheelchair" values="yes,no,limited" values_context="toilets" />
    201         <combo key="toilets:access" values="customers,yes,no" />
     198        <check key="toilets" text="Toilets" />
     199        <check key="toilets:unisex" text="Gender neutral" />
     200        <combo key="toilets:wheelchair" values="yes,no,limited" values_context="toilets" text="Wheelchair accessible" />
     201        <combo key="toilets:access" values="customers,yes,no" text="Access" />
    202202    </chunk>
    203203    <chunk id="color">
     
    83888388            <reference ref="name_oh_wheelchair" />
    83898389            <optional>
    8390                 <combo key="agrarian" values="yes,pesticide,fertilizer,seed,feed,tools,machine_parts,agricultural_machinery" values_context="Tag:shop=agrarian" />
     8390                <combo key="agrarian" values="yes,pesticide,fertilizer,seed,feed,tools,machine_parts,agricultural_machinery" values_context="Tag:shop=agrarian" text="Products" />
    83918391            </optional>
    83928392            <reference ref="link_contact_address_payment" />
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r19170 r19172  
    417417                    } else if (i instanceof CheckGroup) {
    418418                        for (Check c : ((CheckGroup) i).checks) {
     419                            if (!"none".equals(c.match))
     420                                minData.add(c);
    419421                            addPresetValue(c);
    420422                        }
     
    422424                }
    423425                if (!minData.isEmpty()) {
    424                     presetIndex .put(p, minData);
     426                    presetIndex.put(p, minData);
    425427                }
    426428            }
     
    855857    private static boolean primitiveInRegions(IPrimitive primitive, Collection<String> regions, boolean excludeRegions) {
    856858        if (primitive instanceof INode) {
    857             return latLonInRegions((INode) primitive, regions) == excludeRegions;
     859            // 4 options:
     860            // In Region    | excluding region  | expected
     861            // true         | false             | true
     862            // true         | true              | false
     863            // false        | false             | false
     864            // false        | true              | true
     865            return latLonInRegions((INode) primitive, regions) != excludeRegions;
    858866        } else if (primitive instanceof IWay) {
    859867            return ((IWay<?>) primitive).getNodes().stream().anyMatch(n -> primitiveInRegions(n, regions, excludeRegions));
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    r19025 r19172  
    233233    @Test
    234234    void testRegionKey() throws IOException {
    235         final List<TestError> errors = test(OsmUtils.createPrimitive("node highway=crossing crossing_ref=zebra"));
     235        final List<TestError> errors = test(OsmUtils.createPrimitive("node payment:ep_avant=yes"));
    236236        assertEquals(1, errors.size());
    237237        assertEquals("Key from a preset is invalid in this region", errors.get(0).getMessage());
    238         assertEquals("Preset Pedestrian Crossing should not have the key crossing_ref", errors.get(0).getDescription());
     238        assertEquals("Preset Payment Methods should not have the key payment:ep_avant", errors.get(0).getDescription());
    239239        assertEquals(Severity.WARNING, errors.get(0).getSeverity());
    240240        assertFalse(errors.get(0).isFixable());
Note: See TracChangeset for help on using the changeset viewer.