Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
95 changes: 47 additions & 48 deletions doc/user/osm/Germany.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,54 +44,52 @@ For details, see [#6782](https://github.com/opentripplanner/OpenTripPlanner/pull
<!-- props BEGIN -->
<!-- NOTE! This section is auto-generated. Do not change, change doc in code instead. -->

| 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 | |

<!-- props END -->

Expand All @@ -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 | |
Expand Down