From 7231a9018b544f834cb82568faf49846f2500193 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Thu, 17 Oct 2024 12:40:32 -0600 Subject: [PATCH] Fix #15: Steps should be treated as sidewalks for crossing purposes Signed-off-by: Taylor Smock --- .../street_level/actions/mapmode/SidewalkMode.java | 6 +++--- .../actions/mapmode/SidewalkModeTest.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkMode.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkMode.java index b5ad30d..ef5a127 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkMode.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkMode.java @@ -109,6 +109,7 @@ public boolean isEditableDataLayer(Layer l) { private static final String CROSSING = "crossing"; private static final String FOOTWAY = "footway"; + private static final String STEPS = "steps"; private static final String HIGHWAY = "highway"; private static final String SIDEWALK = "sidewalk"; private static final String SURFACE = "surface"; @@ -306,12 +307,11 @@ private void createCrossingWay(Way way, Way crossingWay, Way possibleCrossing, C final var undoRedoHandler = UndoRedoHandler.getInstance(); final var newNodes = new ArrayList<>(way.getNodes()); final var usuallyRightCommands = new ArrayList(6); - final boolean isCrossing = !possibleCrossing.hasTag(HIGHWAY, "pedestrian", FOOTWAY, "path") + final boolean isCrossing = !possibleCrossing.hasTag(HIGHWAY, "pedestrian", FOOTWAY, "path", STEPS) && !(possibleCrossing.hasTag(HIGHWAY, "service") // Service roads with these "common" tags are often small and don't have a real // crossing from a pedestrian perspective. We do want to add crossing - // information - // when there is no service information. + // information when there is no service information. && possibleCrossing.hasTag("service", "alley", "drive-through", "driveway", "emergency_access")); crossingWay.put(HIGHWAY, FOOTWAY); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkModeTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkModeTest.java index d6760dc..c5d7452 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkModeTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/street_level/actions/mapmode/SidewalkModeTest.java @@ -268,6 +268,18 @@ void testDividedHighwayReversed() throws UserCancelException { () -> assertEquals(4, crossing.getNodesCount())); } + @Test + void testCrossingSteps() { + final var steps = newWay("highway=steps", 42.983577, -70.9456852, 42.9836648, -70.9454839); + this.ds.addPrimitiveRecursive(steps); + clickAt(42.9833574, -70.9452684); + clickAt(42.9835067, -70.9453736); + clickAt(42.9836879, -70.9455033); + clickAt(42.9836879, -70.9455033); + assertFalse(steps.lastNode().isTagged()); + assertEquals(2, steps.lastNode().getParentWays().size()); + } + @Test void testFourWayIntersectionCrossing() { final var neSidewalk = newWay("highway=footway footway=sidewalk", 39.0995956, -108.5016914, 39.0995628,