diff --git a/CHANGELOG.md b/CHANGELOG.md index f7316ddeea..886964e259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ RELEASING: - python code on decoding polylines including elevation data - Czech language support (thanks to [trendspotter](https://github.com/trendspotter) for the translation) ### Fixed +- allow bridleways with bicycle=yes for bike profiles ([#1167](https://github.com/GIScience/openrouteservice/issues/1167)) - improved log file settings error message ([#1110](https://github.com/GIScience/openrouteservice/issues/1110)) - Dockerfile now creates intermediate directories if they are not present ([#1109](https://github.com/GIScience/openrouteservice/issues/1109)) - internal properties of `IsochronesRequest` model not ignored for swagger file generation diff --git a/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/CommonBikeFlagEncoder.java b/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/CommonBikeFlagEncoder.java index 761f926320..e0adcde7eb 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/CommonBikeFlagEncoder.java +++ b/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/CommonBikeFlagEncoder.java @@ -65,6 +65,7 @@ public abstract class CommonBikeFlagEncoder extends ORSAbstractFlagEncoder { public static final String KEY_JUNCTION = "junction"; public static final String KEY_SEGREGATED = "segregated"; public static final String KEY_ONEWAY_BICYCLE = "oneway:bicycle"; + public static final String KEY_BRIDLEWAY = "bridleway"; // Pushing section highways are parts where you need to get off your bike and push it (German: Schiebestrecke) protected final HashSet pushingSectionsHighways = new HashSet<>(); @@ -240,6 +241,10 @@ protected CommonBikeFlagEncoder(int speedBits, double speedFactor, int maxTurnCo avoidHighwayTags.add(KEY_MOTORWAY); avoidHighwayTags.add(KEY_MOTORWAY_LINK); + // bridleways are allowed to ride over in some cases + setHighwaySpeed(KEY_BRIDLEWAY, 6); + avoidHighwayTags.add(KEY_BRIDLEWAY); + setCyclingNetworkPreference("icn", BEST.getValue()); setCyclingNetworkPreference("ncn", BEST.getValue()); setCyclingNetworkPreference("rcn", VERY_NICE.getValue()); @@ -336,7 +341,7 @@ public EncodingManager.Access getAccess(ReaderWay way) { } // accept only if explicitly tagged for bike usage - if (KEY_MOTORWAY.equals(highwayValue) || KEY_MOTORWAY_LINK.equals(highwayValue)) { + if (KEY_MOTORWAY.equals(highwayValue) || KEY_MOTORWAY_LINK.equals(highwayValue) || KEY_BRIDLEWAY.equals(highwayValue)) { return EncodingManager.Access.CAN_SKIP; } diff --git a/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/RoadBikeFlagEncoder.java b/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/RoadBikeFlagEncoder.java index 6f7e6cada7..7c33910333 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/RoadBikeFlagEncoder.java +++ b/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/RoadBikeFlagEncoder.java @@ -138,6 +138,7 @@ public RoadBikeFlagEncoder(int speedBits, double speedFactor, int maxTurnCosts, addPushingSection("footway"); addPushingSection("pedestrian"); addPushingSection("steps"); + addPushingSection(KEY_BRIDLEWAY); setCyclingNetworkPreference("icn", PriorityCode.BEST.getValue()); setCyclingNetworkPreference("ncn", PriorityCode.BEST.getValue()); diff --git a/openrouteservice/src/test/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/RegularBikeFlagEncoderTest.java b/openrouteservice/src/test/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/RegularBikeFlagEncoderTest.java new file mode 100644 index 0000000000..62fdce827e --- /dev/null +++ b/openrouteservice/src/test/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/RegularBikeFlagEncoderTest.java @@ -0,0 +1,52 @@ +/* + * This file is part of Openrouteservice. + * + * Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, see . + */ + +package org.heigit.ors.routing.graphhopper.extensions.flagencoders; + +import com.graphhopper.reader.ReaderWay; +import com.graphhopper.routing.util.EncodingManager; +import org.heigit.ors.routing.graphhopper.extensions.ORSDefaultFlagEncoderFactory; +import org.heigit.ors.routing.graphhopper.extensions.flagencoders.bike.RegularBikeFlagEncoder; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class RegularBikeFlagEncoderTest { + private final RegularBikeFlagEncoder flagEncoder; + private ReaderWay way; + + public RegularBikeFlagEncoderTest() { + EncodingManager encodingManager = EncodingManager.create(new ORSDefaultFlagEncoderFactory(), FlagEncoderNames.BIKE_ORS, 4); + flagEncoder = (RegularBikeFlagEncoder) encodingManager.getEncoder(FlagEncoderNames.BIKE_ORS); + } + + @Before + public void initWay() { + way = new ReaderWay(1); + } + + @Test + public void acceptBridlewayOnlyWithBicycleTag() { + way.setTag("highway", "bridleway"); + assertTrue(flagEncoder.getAccess(way).canSkip()); + + way.setTag("bicycle", "yes"); + assertTrue(flagEncoder.getAccess(way).isWay()); + + way.setTag("bicycle", "no"); + assertTrue(flagEncoder.getAccess(way).canSkip()); + } +}