Changeset 18921 in josm for trunk/test/unit


Ignore:
Timestamp:
2023-12-20T19:04:18+01:00 (11 months ago)
Author:
taylor.smock
Message:

Fix #23308: Fix a false positive for "Water area inside water area" validation (patch by gaben, modified)

A coastline as an area follows the right-side rule like coastlines as a way.
This means that a water area inside the area, as defined for almost every other
area tag, may be valid, depending upon the directionality of the coastline way.

Modifications are as follows:

  • Look for water areas inside oceans (coastline is drawn in clockwise direction)
    • This is anticipated to be a rare occurrence since most coastlines are expected to be part of a large area.
  • Add non-regression test
  • Keep previous spacing for easier svn blame usage
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r18799 r18921  
    22package org.openstreetmap.josm.data.validation.tests;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertFalse;
     
    3132import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3233import org.openstreetmap.josm.data.osm.OsmUtils;
     34import org.openstreetmap.josm.data.osm.Way;
    3335import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
    3436import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
     
    4143import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    4244import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
     45import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    4346import org.openstreetmap.josm.io.OsmReader;
    4447import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     
    447450    }
    448451
     452    /**
     453     * A water area inside a coastline, where the coastline way is oriented away from the water area
     454     * (the water area is not inside the ocean).
     455     */
     456    @Test
     457    void testTicket23308() {
     458        final MapCSSTagChecker test = new MapCSSTagChecker();
     459        final Way innerWay = TestUtils.newWay("natural=water",
     460                new Node(new LatLon(32.775, -117.238)),
     461                new Node(new LatLon(32.774, -117.238)),
     462                new Node(new LatLon(32.774, -117.237)),
     463                new Node(new LatLon(32.775, -117.237)));
     464        final Way outerWay = TestUtils.newWay("natural=coastline",
     465                new Node(new LatLon(32.779, -117.232)),
     466                new Node(new LatLon(32.777, -117.241)),
     467                new Node(new LatLon(32.771, -117.240)),
     468                new Node(new LatLon(32.771, -117.235)));
     469        final DataSet ds = new DataSet();
     470        ds.addPrimitiveRecursive(innerWay);
     471        ds.addPrimitiveRecursive(outerWay);
     472        innerWay.addNode(innerWay.firstNode());
     473        outerWay.addNode(outerWay.firstNode());
     474        assertDoesNotThrow(test::initialize);
     475        test.startTest(NullProgressMonitor.INSTANCE);
     476        test.visit(ds.allPrimitives());
     477        test.endTest();
     478        assertTrue(test.getErrors().isEmpty());
     479    }
    449480}
Note: See TracChangeset for help on using the changeset viewer.