Changeset 17430 in josm


Ignore:
Timestamp:
2021-01-02T09:37:50+01:00 (4 years ago)
Author:
GerdP
Message:

fix #20330: Crossing landuse=residential and natural=water should not produce a warning

  • ignore crossing ways when one is landuse=residential and the other is natural=water or landuse=reservoir

(both should be implemented in mapcss rules if wanted)

  • add unit test
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r17400 r17430  
    119119            if (isBuilding(w1) && isBuilding(w2))
    120120                return true; // handled by mapcss tests
    121             if (((isResidentialArea(w1) || w1.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY)) && isResidentialArea(w2))
    122              || ((isResidentialArea(w2) || w2.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY)) && isResidentialArea(w1)))
     121            if (((isResidentialArea(w1) || w1.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY) || isWaterArea(w1))
     122                    && isResidentialArea(w2))
     123                    || ((isResidentialArea(w2) || w2.hasKey(BARRIER, HIGHWAY, RAILWAY, WATERWAY) || isWaterArea(w2))
     124                            && isResidentialArea(w1)))
    123125                return true;
    124126            if (isWaterArea(w1) && isWaterArea(w2))
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java

    r17400 r17430  
    4747    private static void testMessage(int code, CrossingWays test, String tags1, String tags2) {
    4848        assertEquals(code, test.createMessage(TestUtils.newWay(tags1), TestUtils.newWay(tags2)).code);
     49    }
     50
     51    private static void testIgnore(boolean expected, CrossingWays test, String tags1, String tags2) {
     52        // test both possible combinations
     53        assertEquals(expected, test.ignoreWaySegmentCombination(TestUtils.newWay(tags1), TestUtils.newWay(tags2)));
     54        assertEquals(expected, test.ignoreWaySegmentCombination(TestUtils.newWay(tags2), TestUtils.newWay(tags1)));
    4955    }
    5056
     
    156162        testMessage(665, test, "barrier=hedge", "natural=water");
    157163
     164        testIgnore(true, test, "landuse=residential", "natural=water");
     165        testIgnore(false, test, "landuse=residential", "building=yes");
     166
    158167        assertFalse(test.isPrimitiveUsable(newUsableWay("amenity=restaurant")));
    159168        assertFalse(test.isPrimitiveUsable(TestUtils.newWay("barrier=yes"))); // Unusable (0 node)
Note: See TracChangeset for help on using the changeset viewer.