Skip to content

Commit f9e90b8

Browse files
authored
Apply configurable penalty to gates in car profile (#7334)
* Remove gate and lift_gate from car profile barrier whitelist * Add the CHANGELOG.md entry * Add configurable gate penalty (60s default) with new Gate obstacle type * Fix gate penalty to allow routing instead of blocking
1 parent a5a3ba6 commit f9e90b8

7 files changed

Lines changed: 83 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- FIXED: Crash when route starts or ends at `type=manoeuvre` relation via node [#7287](https://github.com/Project-OSRM/osrm-backend/issues/7287)
55
- Profiles:
66
- ADDED: Make `max_collapse_distance` configurable via Lua profiles to preserve short road crossings in pedestrian routing [#6171](https://github.com/Project-OSRM/osrm-backend/issues/6171)
7+
- CHANGED: Apply configurable penalty (default 60s) to gates in car profile [#6757](https://github.com/Project-OSRM/osrm-backend/issues/6757)
78
- ADDED: Add exception for audible fences (`barrier=fence` with `sensory=audible` or `sensory=audio`) that deter livestock but do not block vehicles [#6964](https://github.com/Project-OSRM/osrm-backend/issues/6964)
89
- ADDED: Use `is_sidepath:of:name` and `street:name` as fallback names for unnamed sidewalks and sidepaths in foot and bicycle profiles [#7259](https://github.com/Project-OSRM/osrm-backend/issues/7259)
910
- Build:

docs/profiles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ traffic_calming |
179179
mini_roundabout |
180180
turning_loop |
181181
turning_circle |
182+
gate |
182183

183184
#### obstacle_direction
184185
An enum with the following keys:

features/car/access.feature

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,16 @@ Feature: Car - Restricted access
253253
| primary | no | yes | yes | x | x |
254254

255255

256-
Scenario: Car - barrier=gate should be routed over unless explicitely forbidden
256+
Scenario: Car - barrier=gate routable with penalty unless access=no
257257
Then routability should be
258-
| node/barrier | access | bothw |
259-
| gate | | x |
260-
| gate | no | |
261-
| gate | yes | x |
262-
| gate | permissive | x |
263-
| gate | designated | x |
264-
| gate | private | x |
265-
| gate | garbagetag | x |
258+
| node/barrier | node/access | bothw |
259+
| gate | | x |
260+
| gate | no | |
261+
| gate | yes | x |
262+
| gate | permissive | x |
263+
| gate | designated | x |
264+
| gate | private | x |
265+
| gate | garbagetag | x |
266266

267267
Scenario: Car - a way with conditional access
268268
Then routability should be

features/car/barrier.feature

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Feature: Car - Barriers
3131
| gate | no | |
3232
| gate | private | x |
3333
| gate | agricultural | |
34+
| lift_gate | | x |
35+
| lift_gate | yes | x |
36+
| lift_gate | permissive | x |
37+
| lift_gate | designated | x |
38+
| lift_gate | no | |
39+
| lift_gate | private | x |
40+
| lift_gate | agricultural | |
3441
| wall | | |
3542
| wall | yes | x |
3643
| wall | permissive | x |
@@ -73,3 +80,50 @@ Feature: Car - Barriers
7380
| height_restrictor | 1 | |
7481
| height_restrictor | 3 | x |
7582
| height_restrictor | default | x |
83+
84+
Scenario: Car - Gate penalties
85+
Given the node map
86+
"""
87+
a-b-c d-e-f g-h-i
88+
"""
89+
90+
And the ways
91+
| nodes | highway |
92+
| abc | primary |
93+
| def | primary |
94+
| ghi | primary |
95+
96+
And the nodes
97+
| node | barrier |
98+
| e | gate |
99+
| h | lift_gate |
100+
101+
When I route I should get
102+
| from | to | time | # |
103+
| a | c | 11s | no barrier |
104+
| d | f | 71s +-1 | gate penalty |
105+
| g | i | 71s +-1 | lift_gate penalty |
106+
107+
108+
Scenario: Car - Gate penalty skipped with explicit access tag
109+
Given the node map
110+
"""
111+
a-b-c d-e-f
112+
"""
113+
114+
And the ways
115+
| nodes | highway |
116+
| abc | primary |
117+
| def | primary |
118+
119+
And the nodes
120+
| node | barrier | access |
121+
| b | gate | |
122+
| e | gate | yes |
123+
124+
When I route I should get
125+
| from | to | time | # |
126+
| a | c | 71s +-1 | gate without access gets penalty |
127+
| d | f | 11s | gate with access=yes skips penalty |
128+
129+

include/extractor/obstacles.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct Obstacle
7070
TurningLoop = 0x0080,
7171
TurningCircle = 0x0100,
7272
StopMinor = 0x0200,
73+
Gate = 0x0400,
7374

7475
Turning = MiniRoundabout | TurningLoop | TurningCircle,
7576
Incompressible = Barrier | Turning,

profiles/car.lua

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ function setup()
5656
'border_control',
5757
'toll_booth',
5858
'sally_port',
59-
'gate',
60-
'lift_gate',
6159
'no',
6260
'entrance',
6361
'height_restrictor',
@@ -169,6 +167,11 @@ function setup()
169167
["drive-thru"] = 0.5
170168
},
171169

170+
barrier_penalties = {
171+
gate = 60,
172+
lift_gate = 60,
173+
},
174+
172175
restricted_highway_whitelist = Set {
173176
'motorway',
174177
'motorway_link',
@@ -361,14 +364,24 @@ function process_node(profile, node, result, relations)
361364
local sensory = node:get_value_by_key("sensory")
362365
local audible_fence = barrier == "fence" and sensory and (sensory == "audible" or sensory == "audio")
363366

367+
-- check if barrier has a configurable penalty (e.g., gates)
368+
local barrier_penalty = profile.barrier_penalties[barrier]
369+
364370
if not profile.barrier_whitelist[barrier]
365371
and not rising_bollard
366372
and not flat_kerb
367373
and not highway_crossing_kerb
368374
and not audible_fence
375+
and not barrier_penalty
369376
or restricted_by_height then
370377
obstacle_map:add(node, Obstacle.new(obstacle_type.barrier))
371378
end
379+
380+
-- apply configurable penalty to gates/lift_gates
381+
if barrier_penalty then
382+
obstacle_map:add(node, Obstacle.new(obstacle_type.gate,
383+
obstacle_direction.both, barrier_penalty, 0))
384+
end
372385
end
373386
end
374387

src/extractor/obstacles.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const std::initializer_list<std::pair<std::string_view, Obstacle::Type>>
4444
{"traffic_calming", Obstacle::Type::TrafficCalming},
4545
{"mini_roundabout", Obstacle::Type::MiniRoundabout},
4646
{"turning_loop", Obstacle::Type::TurningLoop},
47-
{"turning_circle", Obstacle::Type::TurningCircle}};
47+
{"turning_circle", Obstacle::Type::TurningCircle},
48+
{"gate", Obstacle::Type::Gate}};
4849

4950
const std::initializer_list<std::pair<std::string_view, Obstacle::Direction>>
5051
Obstacle::enum_direction_initializer_list{{"none", Obstacle::Direction::None},

0 commit comments

Comments
 (0)