From 9a9791f341f3608d5f7c8042979ddd5165b0c6fc Mon Sep 17 00:00:00 2001 From: swamil-5504 Date: Sat, 5 Dec 2026 10:24:03 +0100 Subject: [PATCH] Keep road class bicycle safety on German roundabouts The GermanyMapper roundabout rules replaced the road class's way properties: every non-residential roundabout became BICYCLE_AND_CAR with default safety. This dropped the road class bicycle safety and gave motorway roundabouts bicycle access, cycleway roundabouts car access and footway roundabouts no pedestrian access. Replace them with a mixin that only removes pedestrian access on roundabouts of major roads without a foot tag, so the road class properties and the general roundabout safety factors apply. --- .../osm/tagmapping/GermanyMapper.java | 30 +++++- .../osm/tagmapping/GermanyMapperTest.java | 32 +++++++ doc/user/osm/Germany.md | 95 +++++++++---------- 3 files changed, 104 insertions(+), 53 deletions(-) diff --git a/application/src/main/java/org/opentripplanner/osm/tagmapping/GermanyMapper.java b/application/src/main/java/org/opentripplanner/osm/tagmapping/GermanyMapper.java index 2884b53fd4b..521013f6b2b 100644 --- a/application/src/main/java/org/opentripplanner/osm/tagmapping/GermanyMapper.java +++ b/application/src/main/java/org/opentripplanner/osm/tagmapping/GermanyMapper.java @@ -3,11 +3,13 @@ import static org.opentripplanner.osm.wayproperty.MixinPropertiesBuilder.ofBicycleSafety; import static org.opentripplanner.osm.wayproperty.WayPropertiesBuilder.withModes; import static org.opentripplanner.street.model.StreetTraversalPermission.ALL; -import static org.opentripplanner.street.model.StreetTraversalPermission.BICYCLE_AND_CAR; import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN; import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE; +import org.opentripplanner.osm.wayproperty.MixinPropertiesBuilder; import org.opentripplanner.osm.wayproperty.WayPropertySet; +import org.opentripplanner.osm.wayproperty.specifier.Condition; +import org.opentripplanner.osm.wayproperty.specifier.ExactMatchSpecifier; /** * OSM way properties for German roads. Speed limits where adjusted to German regulation and some @@ -50,11 +52,29 @@ public WayPropertySet buildWayPropertySet() { props.setProperties("highway=track", withModes(PEDESTRIAN_AND_BICYCLE)); props.setProperties("highway=track;surface=*", withModes(PEDESTRIAN_AND_BICYCLE)); - props.setProperties( - "highway=residential;junction=roundabout", - withModes(ALL).bicycleSafety(0.98) + // No walking on roundabouts of major roads, unless a foot tag says otherwise. A mixin, so the + // road class's safety values are kept. + props.setMixinProperties( + new ExactMatchSpecifier( + new Condition.Equals("junction", "roundabout"), + new Condition.OneOf( + "highway", + // sorted so generated docs are stable + "primary", + "primary_link", + "secondary", + "secondary_link", + "service", + "tertiary", + "tertiary_link", + "trunk", + "trunk_link", + "unclassified" + ), + new Condition.Absent("foot") + ), + new MixinPropertiesBuilder().removePermission(PEDESTRIAN) ); - props.setProperties("highway=*;junction=roundabout", withModes(BICYCLE_AND_CAR)); // Pedestrian zones in Germany are forbidden for bicycles by default props.setProperties("highway=pedestrian", withModes(PEDESTRIAN)); diff --git a/application/src/test/java/org/opentripplanner/osm/tagmapping/GermanyMapperTest.java b/application/src/test/java/org/opentripplanner/osm/tagmapping/GermanyMapperTest.java index 55d2ee6fb9e..a24c12b77a2 100644 --- a/application/src/test/java/org/opentripplanner/osm/tagmapping/GermanyMapperTest.java +++ b/application/src/test/java/org/opentripplanner/osm/tagmapping/GermanyMapperTest.java @@ -298,4 +298,36 @@ public void testArea() { way = way.copy().withTag("bicycle", "yes").build(); assertEquals(PEDESTRIAN_AND_BICYCLE, WPS.getDataForEntity(way).getPermission()); } + + /** + * The roundabout penalty must be applied on top of the road class's bicycle safety, not replace + * it with the default. + */ + @Test + void roundaboutKeepsRoadClassBicycleSafety() { + var street = OsmWay.of().withTag("highway", "primary").build(); + var roundabout = street.copy().withTag("junction", "roundabout").build(); + + assertEquals(2.06, WPS.getDataForWay(street).forward().bicycleSafety(), 0.001); + assertEquals(3.09, WPS.getDataForWay(roundabout).forward().bicycleSafety(), 0.001); + } + + @Test + void roundaboutWithExplicitFootAccessAllowsPedestrians() { + var roundabout = OsmWay.of() + .withTag("highway", "primary") + .withTag("junction", "roundabout") + .withTag("foot", "yes") + .build(); + assertEquals(ALL, WPS.getDataForWay(roundabout).forward().getPermission()); + } + + @Test + void footwayRoundaboutAllowsPedestrians() { + var roundabout = OsmWay.of() + .withTag("highway", "footway") + .withTag("junction", "roundabout") + .build(); + assertEquals(PEDESTRIAN, WPS.getDataForWay(roundabout).forward().getPermission()); + } } diff --git a/doc/user/osm/Germany.md b/doc/user/osm/Germany.md index 6cfaa75ee27..2dd843c784d 100644 --- a/doc/user/osm/Germany.md +++ b/doc/user/osm/Germany.md @@ -44,54 +44,52 @@ For details, see [#6782](https://github.com/opentripplanner/OpenTripPlanner/pull -| specifier | permission | bike safety | walk safety | -|--------------------------------------------|--------------------------|-------------|-------------| -| `highway=track` | `PEDESTRIAN_AND_BICYCLE` | | | -| `highway=track; present(surface)` | `PEDESTRIAN_AND_BICYCLE` | | | -| `highway=residential; junction=roundabout` | `ALL` | 0.98 | | -| `present(highway); junction=roundabout` | `BICYCLE_AND_CAR` | | | -| `highway=pedestrian` | `PEDESTRIAN` | | | -| `highway=residential; maxspeed=30` | `ALL` | 0.9 | | -| `highway=footway; bicycle=yes` | `PEDESTRIAN_AND_BICYCLE` | 0.8 | | -| `highway=unclassified; cycleway=lane` | `ALL` | 0.87 | | -| `mtb:scale=3` | `NONE` | | | -| `mtb:scale=4` | `NONE` | | | -| `mtb:scale=5` | `NONE` | | | -| `mtb:scale=6` | `NONE` | | | -| `highway=bridleway` | `NONE` | 1.3 | 1.6 | -| `highway=corridor` | `PEDESTRIAN` | | 1.1 | -| `highway=steps` | `PEDESTRIAN` | | 1.2 | -| `highway=crossing` | `PEDESTRIAN` | | 1.1 | -| `highway=platform` | `PEDESTRIAN` | | 1.2 | -| `public_transport=platform` | `PEDESTRIAN` | | 1.2 | -| `railway=platform` | `PEDESTRIAN` | | 1.2 | -| `highway=pedestrian` | `PEDESTRIAN` | 0.9 | | -| `highway=footway` | `PEDESTRIAN` | 1.1 | | -| `mtb:scale=1` | `PEDESTRIAN` | 1.5 | 1.9 | -| `mtb:scale=2` | `PEDESTRIAN` | 3.0 | 3.8 | -| `indoor=area` | `PEDESTRIAN` | | 1.1 | -| `indoor=corridor` | `PEDESTRIAN` | | 1.1 | -| `highway=cycleway` | `BICYCLE` | 0.6 | 2.5 | -| `mtb:scale=0` | `PEDESTRIAN_AND_BICYCLE` | | 1.2 | -| `highway=path` | `PEDESTRIAN_AND_BICYCLE` | 0.75 | 1.05 | -| `highway=living_street` | `ALL` | 0.9 | 1.15 | -| `highway=unclassified` | `ALL` | | 1.25 | -| `highway=road` | `ALL` | | 1.25 | -| `highway=byway` | `ALL` | 1.3 | 1.7 | -| `highway=track` | `ALL` | 1.3 | 1.7 | -| `highway=service` | `ALL` | 1.1 | 1.3 | -| `highway=residential` | `ALL` | 0.98 | 1.2 | -| `highway=residential_link` | `ALL` | 0.98 | 1.2 | -| `highway=tertiary` | `ALL` | | 1.25 | -| `highway=tertiary_link` | `ALL` | | 1.25 | -| `highway=secondary` | `ALL` | 1.5 | 1.9 | -| `highway=secondary_link` | `ALL` | 1.5 | 1.9 | -| `highway=primary` | `ALL` | 2.06 | 2.6 | -| `highway=primary_link` | `ALL` | 2.06 | 2.6 | -| `highway=trunk` | `ALL` | 7.47 | 9.3 | -| `highway=trunk_link` | `ALL` | 2.06 | 9.3 | -| `highway=motorway_link` | `CAR` | 2.06 | | -| `highway=motorway` | `CAR` | 8.0 | | +| specifier | permission | bike safety | walk safety | +|---------------------------------------|--------------------------|-------------|-------------| +| `highway=track` | `PEDESTRIAN_AND_BICYCLE` | | | +| `highway=track; present(surface)` | `PEDESTRIAN_AND_BICYCLE` | | | +| `highway=pedestrian` | `PEDESTRIAN` | | | +| `highway=residential; maxspeed=30` | `ALL` | 0.9 | | +| `highway=footway; bicycle=yes` | `PEDESTRIAN_AND_BICYCLE` | 0.8 | | +| `highway=unclassified; cycleway=lane` | `ALL` | 0.87 | | +| `mtb:scale=3` | `NONE` | | | +| `mtb:scale=4` | `NONE` | | | +| `mtb:scale=5` | `NONE` | | | +| `mtb:scale=6` | `NONE` | | | +| `highway=bridleway` | `NONE` | 1.3 | 1.6 | +| `highway=corridor` | `PEDESTRIAN` | | 1.1 | +| `highway=steps` | `PEDESTRIAN` | | 1.2 | +| `highway=crossing` | `PEDESTRIAN` | | 1.1 | +| `highway=platform` | `PEDESTRIAN` | | 1.2 | +| `public_transport=platform` | `PEDESTRIAN` | | 1.2 | +| `railway=platform` | `PEDESTRIAN` | | 1.2 | +| `highway=pedestrian` | `PEDESTRIAN` | 0.9 | | +| `highway=footway` | `PEDESTRIAN` | 1.1 | | +| `mtb:scale=1` | `PEDESTRIAN` | 1.5 | 1.9 | +| `mtb:scale=2` | `PEDESTRIAN` | 3.0 | 3.8 | +| `indoor=area` | `PEDESTRIAN` | | 1.1 | +| `indoor=corridor` | `PEDESTRIAN` | | 1.1 | +| `highway=cycleway` | `BICYCLE` | 0.6 | 2.5 | +| `mtb:scale=0` | `PEDESTRIAN_AND_BICYCLE` | | 1.2 | +| `highway=path` | `PEDESTRIAN_AND_BICYCLE` | 0.75 | 1.05 | +| `highway=living_street` | `ALL` | 0.9 | 1.15 | +| `highway=unclassified` | `ALL` | | 1.25 | +| `highway=road` | `ALL` | | 1.25 | +| `highway=byway` | `ALL` | 1.3 | 1.7 | +| `highway=track` | `ALL` | 1.3 | 1.7 | +| `highway=service` | `ALL` | 1.1 | 1.3 | +| `highway=residential` | `ALL` | 0.98 | 1.2 | +| `highway=residential_link` | `ALL` | 0.98 | 1.2 | +| `highway=tertiary` | `ALL` | | 1.25 | +| `highway=tertiary_link` | `ALL` | | 1.25 | +| `highway=secondary` | `ALL` | 1.5 | 1.9 | +| `highway=secondary_link` | `ALL` | 1.5 | 1.9 | +| `highway=primary` | `ALL` | 2.06 | 2.6 | +| `highway=primary_link` | `ALL` | 2.06 | 2.6 | +| `highway=trunk` | `ALL` | 7.47 | 9.3 | +| `highway=trunk_link` | `ALL` | 2.06 | 9.3 | +| `highway=motorway_link` | `CAR` | 2.06 | | +| `highway=motorway` | `CAR` | 8.0 | | @@ -111,6 +109,7 @@ Multiple mixins can apply to the same way and their effects compound. | matcher | add permission | remove permission | bicycle safety | walk safety | |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|------------------------|-----------------------------------------------------|-------------| +| `junction=roundabout; highway one of [primary, primary_link, secondary, secondary_link, service, tertiary, tertiary_link, trunk, trunk_link, unclassified]; !foot` | | PEDESTRIAN | | | | `footway=sidewalk; highway=footway; bicycle=yes` | | | 0.6 | | | `highway=tertiary` | | | 1.2 | | | `maxspeed=70` | | | 1.5 | |