feat(profiles): handle priority=forward/backward way tag in car profile#7541
Open
DennisOSRM wants to merge 2 commits intomasterfrom
Open
feat(profiles): handle priority=forward/backward way tag in car profile#7541DennisOSRM wants to merge 2 commits intomasterfrom
DennisOSRM wants to merge 2 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>
Comment on lines
+451
to
455
| local forward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty, priority_forward_penalty) | ||
| local backward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty, priority_backward_penalty) | ||
|
|
||
| if profile.properties.weight_name == 'routability' then | ||
| if result.forward_speed > 0 then |
Comment on lines
+45
to
+46
| -- Penalty multiplier for the non-priority direction on ways tagged priority=forward/backward | ||
| priority_penalty = 0.7, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: