From e63a10a1a91cd4f13d830bc557365cdbec3ce46e Mon Sep 17 00:00:00 2001 From: ratrun Date: Sun, 21 Apr 2024 17:27:03 +0200 Subject: [PATCH] Reduce bicycle speed to PUSHING_SECTION_SPEED for the tag vehicle=no --- .../routing/util/parsers/BikeCommonAverageSpeedParser.java | 2 ++ .../graphhopper/routing/util/parsers/BikeTagParserTest.java | 5 +++++ .../routing/util/parsers/OSMGetOffBikeParserTest.java | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java b/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java index bde7d88676a..1778020537a 100644 --- a/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java +++ b/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java @@ -208,6 +208,8 @@ else if (way.hasTag("highway", pushingSectionsHighways) speed = Math.min(speed, surfaceSpeed); } } + if (way.hasTag("vehicle", "no")) + speed = PUSHING_SECTION_SPEED; return speed; } diff --git a/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java b/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java index ff18c8846ba..78fc83cc552 100644 --- a/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java +++ b/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java @@ -278,6 +278,11 @@ public void testSpeedAndPriority() { way.clearTags(); way.setTag("highway", "trunk"); assertPriorityAndSpeed(REACH_DESTINATION, 18, way); + + way.clearTags(); + way.setTag("highway", "cycleway"); + way.setTag("vehicle", "no"); + assertPriorityAndSpeed(VERY_NICE, PUSHING_SECTION_SPEED, way); } @Test diff --git a/core/src/test/java/com/graphhopper/routing/util/parsers/OSMGetOffBikeParserTest.java b/core/src/test/java/com/graphhopper/routing/util/parsers/OSMGetOffBikeParserTest.java index 422d6e29737..a40dcc97a63 100644 --- a/core/src/test/java/com/graphhopper/routing/util/parsers/OSMGetOffBikeParserTest.java +++ b/core/src/test/java/com/graphhopper/routing/util/parsers/OSMGetOffBikeParserTest.java @@ -102,6 +102,11 @@ public void testHandleCommonWayTags() { assertFalse(isGetOffBike(way)); // for now only designated will trigger true way.setTag("foot", "designated"); assertTrue(isGetOffBike(way)); + + way = new ReaderWay(1); + way.setTag("highway", "cycleway"); + way.setTag("vehicle", "no"); + assertFalse(isGetOffBike(way)); } @Test