From 1fe1c83ea905a4b0b4619da53f2ed109b3b66360 Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 16:23:27 -0400 Subject: [PATCH] Make sidewalk PermissionLabeler more restrictive Disallow walking anywhere driving is allowed --- .../SidewalkTraversalPermissionLabeler.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java b/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java index dd8c53e23..34d2c8465 100644 --- a/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java +++ b/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java @@ -1,5 +1,7 @@ package com.conveyal.r5.labeling; +import com.conveyal.osmlib.Way; +import com.conveyal.r5.streets.EdgeStore; /** * Traversal permission labeler that restricts walking on most driving ways (useful for networks with complete @@ -11,8 +13,23 @@ public class SidewalkTraversalPermissionLabeler extends TraversalPermissionLabel addPermissions("bridleway", "bicycle=yes;foot=yes"); //horse=yes but we don't support horse addPermissions("cycleway", "bicycle=yes;foot=yes"); addPermissions("trunk|primary|secondary|tertiary|unclassified|residential|living_street|road|service|track", - "access=yes;foot=no"); // Note foot=no + "access=yes"); + } + @Override + public RoadPermission getPermissions(Way way) { + RoadPermission rp = super.getPermissions(way); + if (rp.forward.contains(EdgeStore.EdgeFlag.ALLOWS_CAR) || + rp.forward.contains(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_CAR) || + rp.backward.contains(EdgeStore.EdgeFlag.ALLOWS_CAR) || + rp.backward.contains(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_CAR) + ) { + rp.forward.remove(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN); + rp.forward.remove(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_PEDESTRIAN); + rp.backward.remove(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN); + rp.backward.remove(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_PEDESTRIAN); + } + return rp; } }