Skip to content

Commit 1f5a7ae

Browse files
authored
fix(bicycle): respect directional access tags like vehicle:forward=agricultural (#7597)
1 parent 329bad0 commit 1f5a7ae

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

features/bicycle/access.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ Feature: Bike - Access tags on ways
186186
| residential | tram | | yes | cycling | pushing bike |
187187
| service | tram | psv | yes | cycling | pushing bike |
188188

189+
Scenario: Bike - Directional access tag blacklisting (e.g. vehicle:forward=agricultural)
190+
Then routability should be
191+
| highway | vehicle:forward | vehicle:backward | bicycle | forw | backw |
192+
| primary | | | | cycling | cycling |
193+
| primary | agricultural | | | | cycling |
194+
| primary | | agricultural | | cycling | |
195+
| primary | agricultural | agricultural | | | |
196+
| primary | agricultural | | yes | cycling | cycling |
197+
| primary | | agricultural | yes | cycling | cycling |
198+
| primary | | | agricultural | | |
199+
189200
Scenario: Bike - Access combinations
190201
Then routability should be
191202
| highway | access | bothw |

profiles/bicycle.lua

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Sequence = require('lib/sequence')
77
Handlers = require("lib/way_handlers")
88
TrafficSignal = require("lib/traffic_signal")
99
find_access_tag = require("lib/access").find_access_tag
10+
resolve_access = require("lib/access").resolve_access
11+
Tags = require('lib/tags')
1012
limit = require("lib/maxspeed").limit
1113
Measure = require("lib/measure")
1214

@@ -299,9 +301,16 @@ function handle_bicycle_tags(profile,way,result,data)
299301
return false
300302
end
301303

302-
-- access
304+
-- access (supports directional tags like vehicle:forward=agricultural)
303305
data.access = find_access_tag(way, profile.access_tags_hierarchy)
304-
if data.access and profile.access_tag_blacklist[data.access] then
306+
data.forward_access, data.backward_access =
307+
Tags.get_forward_backward_by_set(way, data, profile.access_tags_hierarchy)
308+
data.forward_access = resolve_access(data.forward_access, profile)
309+
data.backward_access = resolve_access(data.backward_access, profile)
310+
if (data.access and profile.access_tag_blacklist[data.access])
311+
or (data.forward_access and data.backward_access
312+
and profile.access_tag_blacklist[data.forward_access]
313+
and profile.access_tag_blacklist[data.backward_access]) then
305314
return false
306315
end
307316

@@ -349,6 +358,17 @@ function handle_bicycle_tags(profile,way,result,data)
349358
end
350359

351360
safety_handler(profile,way,result,data)
361+
362+
-- Apply per-direction access blacklisting for directional tags
363+
-- (e.g. vehicle:forward=agricultural blocks only the forward direction)
364+
if data.forward_access and profile.access_tag_blacklist[data.forward_access] then
365+
result.forward_mode = mode.inaccessible
366+
result.forward_speed = 0
367+
end
368+
if data.backward_access and profile.access_tag_blacklist[data.backward_access] then
369+
result.backward_mode = mode.inaccessible
370+
result.backward_speed = 0
371+
end
352372
end
353373

354374
-- Block ways where the cycleway is mapped as a separate parallel way.

taginfo.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,18 @@
297297
{"key": "motorcar"},
298298
{"key": "motor_vehicle"},
299299
{"key": "vehicle"},
300+
{"key": "motorcar:forward", "description": "Directional access tag for forward travel direction", "object_types": ["way"]},
301+
{"key": "motorcar:backward", "description": "Directional access tag for backward travel direction", "object_types": ["way"]},
302+
{"key": "motor_vehicle:forward", "description": "Directional access tag for forward travel direction", "object_types": ["way"]},
303+
{"key": "motor_vehicle:backward", "description": "Directional access tag for backward travel direction", "object_types": ["way"]},
304+
{"key": "vehicle:forward", "description": "Directional access tag for forward travel direction", "object_types": ["way"]},
305+
{"key": "vehicle:backward", "description": "Directional access tag for backward travel direction", "object_types": ["way"]},
306+
{"key": "access:forward", "description": "Directional access tag for forward travel direction", "object_types": ["way"]},
307+
{"key": "access:backward", "description": "Directional access tag for backward travel direction", "object_types": ["way"]},
308+
{"key": "bicycle:forward", "description": "Directional bicycle access tag for forward travel direction", "object_types": ["way"]},
309+
{"key": "bicycle:backward", "description": "Directional bicycle access tag for backward travel direction", "object_types": ["way"]},
310+
{"key": "foot:forward", "description": "Directional foot access tag for forward travel direction", "object_types": ["way"]},
311+
{"key": "foot:backward", "description": "Directional foot access tag for backward travel direction", "object_types": ["way"]},
300312
{
301313
"key": "barrier"
302314
},

0 commit comments

Comments
 (0)