Skip to content

Commit

Permalink
Make sidewalk PermissionLabeler more restrictive
Browse files Browse the repository at this point in the history
Disallow walking anywhere driving is allowed
  • Loading branch information
ansoncfit committed Aug 10, 2024
1 parent 1355d0d commit 1fe1c83
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
}

}

0 comments on commit 1fe1c83

Please sign in to comment.