feat(profiles): handle priority=forward/backward way tag in car profile#7541
feat(profiles): handle priority=forward/backward way tag in car profile#7541DennisOSRM merged 8 commits intomasterfrom
Conversation
Implements support for the OSM `priority=*` tag (closes #4387). When a way is tagged `priority=forward` the backward direction receives a configurable speed/weight penalty (default 0.7×); `priority=backward` applies the same penalty to the forward direction. Changes: - profiles/car.lua: add `priority_penalty = 0.7` config knob - profiles/lib/way_handlers.lua: read `priority` tag and apply per-direction penalty inside WayHandlers.penalties() - taginfo.json: document the two new priority tag values Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove inaccurate 'narrow roads' qualifier from priority_penalty comment; the penalty applies to any way tagged priority=forward/backward regardless of road width - Fix misleading scenario title: penalty does apply to oneways when the permitted direction lacks priority, rename accordingly - Fix feature file description that incorrectly said 'narrow sections' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…7543) * fix(ci): follow-up to #7485 — unblock certain macOS configurations Follow-up to #7485 to unblock certain macOS configurations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: allow unused include directives on macOS --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…is bidirectional Only set result.weight when forward and backward penalties are equal; add comment clarifying priority_penalty semantics\n\nAddresses PR #7541\n\nTests: features/car/priority.feature passes locally Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ional weight Covers PR #7541 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Clarify priority_penalty semantics and scope in car.lua and way_handlers.lua\n- Only set bidirectional weight when penalties are equal (prior change)\n- Rename oneway scenario for clarity and rename duplicate foot scenario\n- Gate unused-command-line-argument warning on Clang/AppleClang in cmake/warnings.cmake\n\nAddresses PR #7541 review threads Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| -- Penalty multiplier for the disadvantaged direction on ways tagged 'priority=forward'/'priority=backward'. | ||
| -- Applies to the per-direction rate (speed). A value < 1 reduces the disadvantaged | ||
| -- direction's rate which increases its routing weight (weight ≈ duration / rate). | ||
| -- This is applied to any way with a 'priority' tag; add an explicit width/lanes | ||
| -- guard if the penalty should only target narrow or single-lane roads. | ||
| priority_penalty = 0.7, |
| Scenario: Foot - Leisure track handling | ||
| Then routability should be | ||
| | highway | leisure | forw | | ||
| | (nil) | track | | |
| Scenario: Car - Directional penalty avoids bidirectional weight | ||
| Then routability should be | ||
| | highway | maxspeed | priority | forw | backw | forw_rate | backw_rate | | ||
| | primary | 60 | forward | 48 km/h | 48 km/h | 13.3 | 9.3 | | ||
| | primary | 60 | backward | 48 km/h | 48 km/h | 9.3 | 13.3 | |
|
Thanks for the review — replies below:
|
Summary
Closes #4387.
Adds support for the OSM
priority=*tag in the car profile. This tag records the right-of-way direction on narrow road sections, allowing routing algorithms to account for the delay a driver faces when travelling against the priority direction (e.g. having to yield or slow down).Functional change
New config knob –
priority_penalty(default0.7)Added to
profiles/car.lua. Controls how much the non-priority direction is penalised relative to the priority direction. A value of0.7means the routing weight for the disadvantaged direction is multiplied by 0.7× (making it less attractive).Tag handling –
WayHandlers.penalties()profiles/lib/way_handlers.luanow reads theprioritykey from each way:priority=forwardpriority_penaltymultiplied into its weight/speed ratepriority=backwardpriority_penaltymultipliedThe penalty is applied via
math.min()alongside the existing service, width, alternating, and sideroad penalties, so it stacks correctly with other factors without exceeding a 1.0× factor.Profiles that do not set
profile.priority_penaltyare unaffected (guarded by anilcheck).taginfo.json
Documents the two new tag values (
priority=forwardandpriority=backward) so they appear in the taginfo registry.Tests
Added
features/car/priority.featurewith two Cucumber scenarios:Note: priority_penalty is applied multiplicatively to per-direction rate (speed). A value <1 reduces the rate for the disadvantaged direction, making that direction less attractive. Because weight is computed as duration / rate, reducing the rate increases weight (roughly 1/priority_penalty). The PR implements the penalty on per-direction rates; the config knob name reflects penalising the disadvantaged direction's rate.\n\nNote: This PR also removes support for leisure=track from the foot profile's routable ways (profiles/foot.lua). This was done to avoid treating leisure=track as an implicit routable channel for pedestrians; if this is undesirable, the change can be split out or documented further.\n\nClarifications and corrections:\n\n- Priority semantics: priority_penalty scales the disadvantaged direction's per-direction rate (speed). A value <1 reduces that direction's rate, which increases its routing weight (weight ≈ duration / rate). The implementation applies the penalty to per-direction rates; WayHandlers.penalties now only sets result.weight when forward and backward penalties are equal to avoid losing a directional penalty when a shared bidirectional weight would be applied.\n\n- Foot profile: Correction — this PR DOES NOT remove 'leisure=track' from profiles/foot.lua. An earlier note incorrectly stated that; the PR only renames a Cucumber scenario in features/foot/way.feature. No functional change to profiles/foot.lua is included here.\n\n- Tests: Added Cucumber scenarios in features/car/priority.feature that validate per-direction rates and that a shared bidirectional weight is not used when penalties differ.\n