Skip to content

Commit 1e93e25

Browse files
committed
Revert "remove walk safety for now"
This reverts commit 996a637.
1 parent 996a637 commit 1e93e25

File tree

18 files changed

+3772
-3026
lines changed

18 files changed

+3772
-3026
lines changed

application/src/main/java/org/opentripplanner/osm/tagmapping/OsmTagMapper.java

Lines changed: 96 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,42 +62,63 @@ public void populateProperties(WayPropertySet props) {
6262
props.setProperties("mtb:scale=4", noneWayProperties);
6363
props.setProperties("mtb:scale=5", noneWayProperties);
6464
props.setProperties("mtb:scale=6", noneWayProperties);
65-
props.setProperties("highway=bridleway", withModes(NONE).bicycleSafety(1.3));
65+
props.setProperties("highway=bridleway", withModes(NONE).walkSafety(1.3).bicycleSafety(1.3));
6666

6767
/* PEDESTRIAN */
68-
props.setProperties("highway=corridor", withModes(PEDESTRIAN));
68+
props.setProperties("highway=corridor", withModes(PEDESTRIAN).walkSafety(0.9));
6969
props.setProperties("highway=steps", withModes(PEDESTRIAN));
70-
props.setProperties("highway=crossing", withModes(PEDESTRIAN));
70+
props.setProperties("highway=crossing", withModes(PEDESTRIAN).walkSafety(0.9));
7171
props.setProperties("highway=platform", withModes(PEDESTRIAN));
7272
props.setProperties("public_transport=platform", withModes(PEDESTRIAN));
7373
props.setProperties("railway=platform", withModes(PEDESTRIAN));
74-
props.setProperties("highway=pedestrian", withModes(PEDESTRIAN).bicycleSafety(0.9));
75-
props.setProperties("highway=footway", withModes(PEDESTRIAN).bicycleSafety(1.1));
76-
props.setProperties("mtb:scale=1", withModes(PEDESTRIAN).bicycleSafety(1.5));
77-
props.setProperties("mtb:scale=2", withModes(PEDESTRIAN).bicycleSafety(3.0));
74+
props.setProperties(
75+
"highway=pedestrian",
76+
withModes(PEDESTRIAN).walkSafety(0.8).bicycleSafety(0.9)
77+
);
78+
props.setProperties(
79+
"highway=footway",
80+
withModes(PEDESTRIAN).walkSafety(0.8).bicycleSafety(1.1)
81+
);
82+
props.setProperties("mtb:scale=1", withModes(PEDESTRIAN).walkSafety(1.5).bicycleSafety(1.5));
83+
props.setProperties("mtb:scale=2", withModes(PEDESTRIAN).walkSafety(3.0).bicycleSafety(3.0));
7884

7985
/* BICYCLE */
80-
props.setProperties("highway=cycleway", withModes(BICYCLE).bicycleSafety(0.6));
86+
props.setProperties("highway=cycleway", withModes(BICYCLE).walkSafety(2.0).bicycleSafety(0.6));
8187

8288
/* PEDESTRIAN_AND_BICYCLE */
8389
props.setProperties("mtb:scale=0", withModes(PEDESTRIAN_AND_BICYCLE));
84-
props.setProperties("highway=path", withModes(PEDESTRIAN_AND_BICYCLE).bicycleSafety(0.75));
90+
props.setProperties(
91+
"highway=path",
92+
withModes(PEDESTRIAN_AND_BICYCLE).walkSafety(0.85).bicycleSafety(0.75)
93+
);
8594

8695
/* ALL */
87-
props.setProperties("highway=living_street", withModes(ALL).bicycleSafety(0.9));
96+
props.setProperties(
97+
"highway=living_street",
98+
withModes(ALL).walkSafety(0.95).bicycleSafety(0.9)
99+
);
88100
props.setProperties("highway=unclassified", allWayProperties);
89101
props.setProperties("highway=road", allWayProperties);
90-
props.setProperties("highway=byway", withModes(ALL).bicycleSafety(1.3));
91-
props.setProperties("highway=track", withModes(ALL).bicycleSafety(1.3));
92-
props.setProperties("highway=service", withModes(ALL).bicycleSafety(1.1));
93-
props.setProperties("highway=residential", withModes(ALL).bicycleSafety(0.98));
94-
props.setProperties("highway=residential_link", withModes(ALL).bicycleSafety(0.98));
102+
props.setProperties("highway=byway", withModes(ALL).walkSafety(1.3).bicycleSafety(1.3));
103+
props.setProperties("highway=track", withModes(ALL).walkSafety(1.3).bicycleSafety(1.3));
104+
props.setProperties("highway=service", withModes(ALL).walkSafety(1.1).bicycleSafety(1.1));
105+
props.setProperties("highway=residential", withModes(ALL).walkSafety(0.98).bicycleSafety(0.98));
106+
props.setProperties(
107+
"highway=residential_link",
108+
withModes(ALL).walkSafety(0.98).bicycleSafety(0.98)
109+
);
95110
props.setProperties("highway=tertiary", allWayProperties);
96111
props.setProperties("highway=tertiary_link", allWayProperties);
97-
props.setProperties("highway=secondary", withModes(ALL).bicycleSafety(1.5));
98-
props.setProperties("highway=secondary_link", withModes(ALL).bicycleSafety(1.5));
99-
props.setProperties("highway=primary", withModes(ALL).bicycleSafety(2.06));
100-
props.setProperties("highway=primary_link", withModes(ALL).bicycleSafety(2.06));
112+
props.setProperties("highway=secondary", withModes(ALL).walkSafety(1.5).bicycleSafety(1.5));
113+
props.setProperties(
114+
"highway=secondary_link",
115+
withModes(ALL).walkSafety(1.5).bicycleSafety(1.5)
116+
);
117+
props.setProperties("highway=primary", withModes(ALL).walkSafety(2.06).bicycleSafety(2.06));
118+
props.setProperties(
119+
"highway=primary_link",
120+
withModes(ALL).walkSafety(2.06).bicycleSafety(2.06)
121+
);
101122
props.setProperties("highway=trunk", withModes(ALL).walkSafety(7.47).bicycleSafety(7.47));
102123
props.setProperties("highway=trunk_link", withModes(ALL).walkSafety(7.47).bicycleSafety(2.06));
103124

@@ -185,6 +206,17 @@ public void populateProperties(WayPropertySet props) {
185206
)
186207
);
187208

209+
/* foot=designated */
210+
props.setMixinProperties(
211+
new ExactMatchSpecifier(
212+
new Equals("foot", "designated"),
213+
new Not(new Equals("highway", "footway")),
214+
new Not(new Equals("highway", "pedestrian")),
215+
new Not(new Equals("highway", "path"))
216+
),
217+
ofWalkSafety(0.9)
218+
);
219+
188220
/* sidewalk and crosswalk */
189221
props.setMixinProperties("footway=sidewalk", ofBicycleSafety(2.5));
190222
props.setMixinProperties("footway=crossing", ofBicycleSafety(2.5));
@@ -221,6 +253,51 @@ public void populateProperties(WayPropertySet props) {
221253
ofBicycleSafety(0.7)
222254
);
223255

256+
// prefer walking on sidewalks
257+
props.setMixinProperties(
258+
new LogicalOrSpecifier(
259+
new ExactMatchSpecifier(
260+
new Equals("sidewalk", "yes"),
261+
new Not(new Condition.OneOf("highway", "footway", "pedestrian", "path", "trunk"))
262+
),
263+
new ExactMatchSpecifier(
264+
new Equals("sidewalk", "left"),
265+
new Not(new Condition.OneOf("highway", "footway", "pedestrian", "path", "trunk"))
266+
),
267+
new ExactMatchSpecifier(
268+
new Equals("sidewalk", "right"),
269+
new Not(new Condition.OneOf("highway", "footway", "pedestrian", "path", "trunk"))
270+
),
271+
new ExactMatchSpecifier(
272+
new Equals("sidewalk", "both"),
273+
new Not(new Condition.OneOf("highway", "footway", "pedestrian", "path", "trunk"))
274+
)
275+
),
276+
ofWalkSafety(0.9)
277+
);
278+
279+
props.setMixinProperties(
280+
new LogicalOrSpecifier(
281+
"highway=trunk;sidewalk=yes",
282+
"highway=trunk;sidewalk=left",
283+
"highway=trunk;sidewalk=right",
284+
"highway=trunk;sidewalk=both",
285+
"highway=trunk_link;sidewalk=yes",
286+
"highway=trunk_link;sidewalk=left",
287+
"highway=trunk_link;sidewalk=right",
288+
"highway=trunk_link;sidewalk=both"
289+
),
290+
ofWalkSafety(0.4)
291+
);
292+
293+
props.setMixinProperties(
294+
new ExactMatchSpecifier(
295+
new Equals("sidewalk", "lane"),
296+
new Not(new Condition.OneOf("highway", "footway", "pedestrian", "path"))
297+
),
298+
ofWalkSafety(0.95)
299+
);
300+
224301
/*
225302
* Automobile speeds in the United States: Based on my (mattwigway) personal experience, primarily in California
226303
*/

application/src/main/java/org/opentripplanner/osm/tagmapping/PortlandMapper.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,24 @@ class PortlandMapper extends OsmTagMapper {
1313

1414
@Override
1515
public void populateProperties(WayPropertySet props) {
16+
props.setMixinProperties("highway=footway", ofWalkSafety(1 / 0.8));
1617
props.setMixinProperties("footway=sidewalk", ofWalkSafety(1.1));
1718
props.setMixinProperties(new ExactMatchSpecifier(new Absent("name")), ofWalkSafety(1.2));
1819
props.setMixinProperties("highway=trunk", ofWalkSafety(1.2 / 7.47));
1920
props.setMixinProperties("highway=trunk_link", ofWalkSafety(1.2 / 7.47));
20-
props.setMixinProperties("highway=primary", ofWalkSafety(1.2));
21-
props.setMixinProperties("highway=primary_link", ofWalkSafety(1.2));
22-
props.setMixinProperties("highway=secondary", ofWalkSafety(1.1));
23-
props.setMixinProperties("highway=secondary_link", ofWalkSafety(1.1));
21+
props.setMixinProperties("highway=primary", ofWalkSafety(1.2 / 2.06));
22+
props.setMixinProperties("highway=primary_link", ofWalkSafety(1.2 / 2.06));
23+
props.setMixinProperties("highway=secondary", ofWalkSafety(1.1 / 1.5));
24+
props.setMixinProperties("highway=secondary_link", ofWalkSafety(1.1 / 1.5));
2425
props.setMixinProperties("highway=tertiary", ofWalkSafety(1.1));
2526
props.setMixinProperties("highway=tertiary_link", ofWalkSafety(1.1));
27+
props.setMixinProperties("highway=residential", ofWalkSafety(1 / 0.98));
28+
props.setMixinProperties("highway=residential_link", ofWalkSafety(1 / 0.98));
2629
props.setMixinProperties(
2730
new ExactMatchSpecifier(new GreaterThan("lanes", 4)),
2831
ofWalkSafety(1.1)
2932
);
30-
props.setMixinProperties("sidewalk=both", ofWalkSafety(0.8));
31-
props.setMixinProperties("sidewalk=left", ofWalkSafety(0.9));
32-
props.setMixinProperties("sidewalk=right", ofWalkSafety(0.9));
33+
props.setMixinProperties("sidewalk=both", ofWalkSafety(0.8 / 0.9));
3334
props.setMixinProperties("surface=unpaved", ofWalkSafety(1.4));
3435
// high penalty for streets with no sidewalk
3536
// these are using the exact() call to generate a ExactMatch. without it several of these

application/src/main/java/org/opentripplanner/osm/tagmapping/UKMapper.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.opentripplanner.osm.tagmapping;
22

3+
import static org.opentripplanner.osm.wayproperty.MixinPropertiesBuilder.ofWalkSafety;
34
import static org.opentripplanner.osm.wayproperty.WayPropertiesBuilder.withModes;
45
import static org.opentripplanner.street.model.StreetTraversalPermission.ALL;
56
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN;
@@ -8,6 +9,7 @@
89
import org.opentripplanner.osm.wayproperty.MixinPropertiesBuilder;
910
import org.opentripplanner.osm.wayproperty.WayProperties;
1011
import org.opentripplanner.osm.wayproperty.WayPropertySet;
12+
import org.opentripplanner.osm.wayproperty.specifier.LogicalOrSpecifier;
1113

1214
/**
1315
* OSM way properties for UK roads. The main differences compared to the default property set are:
@@ -35,6 +37,21 @@ public void populateProperties(WayPropertySet props) {
3537
props.setProperties("highway=trunk", withModes(ALL).walkSafety(2.5).bicycleSafety(2.5));
3638
props.setProperties("highway=trunk_link", withModes(ALL).walkSafety(2.5).bicycleSafety(2.06));
3739

40+
// cancel out the effect of the reduced safety mixin for walking on trunk roads with pavement
41+
props.setMixinProperties(
42+
new LogicalOrSpecifier(
43+
"highway=trunk;sidewalk=yes",
44+
"highway=trunk;sidewalk=left",
45+
"highway=trunk;sidewalk=right",
46+
"highway=trunk;sidewalk=both",
47+
"highway=trunk_link;sidewalk=yes",
48+
"highway=trunk_link;sidewalk=left",
49+
"highway=trunk_link;sidewalk=right",
50+
"highway=trunk_link;sidewalk=both"
51+
),
52+
ofWalkSafety(2)
53+
);
54+
3855
props.setMixinProperties(
3956
"expressway=yes",
4057
MixinPropertiesBuilder.ofBicycleSafety(5).walkSafety(5)

application/src/test/java/org/opentripplanner/osm/tagmapping/GermanyMapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void cyclewayOpposite() {
6363
way.addTag("zone:traffic", "DE:urban");
6464
assertEquals(0.9, wps.getDataForWay(way).forward().bicycleSafety(), epsilon);
6565
// walk safety should be default
66-
assertEquals(1, wps.getDataForWay(way).forward().walkSafety(), epsilon);
66+
assertEquals(0.9, wps.getDataForWay(way).forward().walkSafety(), epsilon);
6767
}
6868

6969
@Test

application/src/test/java/org/opentripplanner/osm/tagmapping/OsmTagMapperTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ void testAccessPrivate() {
100100
void testFootway() {
101101
OsmWay footway = WayTestData.footway();
102102
assertEquals(PEDESTRIAN, wps.getDataForEntity(footway).getPermission());
103+
assertEquals(0.8, wps.getDataForWay(footway).forward().walkSafety());
104+
105+
footway.addTag("sidewalk", "both");
106+
assertEquals(0.8, wps.getDataForWay(footway).forward().walkSafety());
103107
}
104108

105109
@Test
@@ -188,7 +192,22 @@ void testTrunkMotorroad() {
188192
@Test
189193
void testTrunkWalkSafety() {
190194
var rawScore = wps.getDataForWay(WayTestData.highwayTrunk()).forward().walkSafety();
195+
var scoreWithLane = wps
196+
.getDataForWay((OsmWay) WayTestData.highwayTrunk().addTag("sidewalk", "lane"))
197+
.forward()
198+
.walkSafety();
199+
var scoreWithSidewalk = wps
200+
.getDataForWay((OsmWay) WayTestData.highwayTrunk().addTag("sidewalk", "both"))
201+
.forward()
202+
.walkSafety();
203+
var scoreWithSeparateSidewalk = wps
204+
.getDataForWay((OsmWay) WayTestData.highwayTrunk().addTag("sidewalk", "separate"))
205+
.forward()
206+
.walkSafety();
191207
assertTrue(rawScore > 5);
208+
assertTrue(scoreWithLane < rawScore);
209+
assertTrue(scoreWithSidewalk < scoreWithLane);
210+
assertEquals(rawScore, scoreWithSeparateSidewalk);
192211
}
193212

194213
@Test

0 commit comments

Comments
 (0)