Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ if(MSVC)
message(STATUS "MSVC warning configuration applied - suppressed informational warnings, kept bug-indicating warnings")
endif()

if(APPLE)
if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
no_warning(unused-command-line-argument)
message(STATUS "Apple Clang detected - disabled unused-command-line-argument warning")
message(STATUS "Clang/AppleClang detected - disabled unused-command-line-argument warning")
endif()
30 changes: 30 additions & 0 deletions features/car/priority.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@routing @priority @car
Feature: Car - Priority tag handling
The priority tag indicates traffic right-of-way direction on a way.
priority=forward means forward traffic has right-of-way, penalizing backward.
priority=backward means backward traffic has right-of-way, penalizing forward.

Background: Use specific speeds
Given the profile "car"
Given a grid size of 1000 meters

Scenario: Car - Priority tag applies directional penalty
Then routability should be
| highway | maxspeed | priority | forw | backw | forw_rate | backw_rate |
| primary | 60 | | 48 km/h | 48 km/h | 13.3 | 13.3 |
| 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 |

Scenario: Car - Priority penalty affects permitted direction on oneways
Then routability should be
| highway | maxspeed | priority | oneway | forw | backw | forw_rate | backw_rate |
| primary | 60 | forward | yes | 48 km/h | | 13.3 | |
| primary | 60 | backward | yes | 48 km/h | | 9.3 | |
| primary | 60 | forward | -1 | | 48 km/h | | 9.3 |
| primary | 60 | backward | -1 | | 48 km/h | | 13.3 |

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 |
Comment on lines +25 to +30
Comment on lines +26 to +30
2 changes: 1 addition & 1 deletion features/foot/way.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Feature: Foot - Accessability of different way types
| cycleway | |
| bridleway | |

Scenario: Foot - Basic access
Scenario: Foot - Leisure track handling
Then routability should be
| highway | leisure | forw |
| (nil) | track | |
Comment on lines +34 to 37
Expand Down
7 changes: 7 additions & 0 deletions profiles/car.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ function setup()
-- Applied to bidirectional roads to prefer roads with clear lane markings
lane_markings_penalty = 0.75,

-- 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,
Comment on lines +45 to +50

-- Size of the vehicle, to be limited by physical restriction of the way
vehicle_height = 2.0, -- in meters, 2.0m is the height slightly above biggest SUVs
vehicle_width = 1.9, -- in meters, ways with narrow tag are considered narrower than 2.2m
Expand Down
25 changes: 22 additions & 3 deletions profiles/lib/way_handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,22 @@ function WayHandlers.penalties(profile,way,result,data)
sideroad_penalty = profile.side_road_multiplier
end

local forward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty)
local backward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty)
local priority_forward_penalty = 1.0
local priority_backward_penalty = 1.0
if profile.priority_penalty then
-- priority_penalty scales the disadvantaged direction's per-direction rate (speed).
-- A value < 1 reduces that direction's rate, which increases its routing weight
-- because weight is computed as duration / rate.
local priority = way:get_value_by_key("priority")
if priority == "forward" then
priority_backward_penalty = profile.priority_penalty
elseif priority == "backward" then
priority_forward_penalty = profile.priority_penalty
end
end

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 +454 to 458
Expand All @@ -448,7 +462,12 @@ function WayHandlers.penalties(profile,way,result,data)
result.backward_rate = (result.backward_speed * backward_penalty) / 3.6
end
if result.duration > 0 then
result.weight = result.duration / forward_penalty
-- Only set a bidirectional weight when penalties are equal.
-- When forward/backward penalties differ (directional penalty), avoid setting result.weight,
-- so the extractor uses per-direction rates (forward_rate/backward_rate) to compute weights.
if forward_penalty == backward_penalty then
result.weight = result.duration / forward_penalty
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions taginfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@
{"key": "lanes:forward", "description": "Lanes in forward direction"},
{"key": "lanes:backward", "description": "Lanes in backward direction"},
{"key": "lane_markings", "value": "no", "description": "Penalty for roads without lane markings on bidirectional streets"},
{"key": "priority", "value": "forward", "object_types": ["way"], "description": "Traffic priority in forward direction; non-priority direction gets a penalty"},
{"key": "priority", "value": "backward", "object_types": ["way"], "description": "Traffic priority in backward direction; non-priority direction gets a penalty"},
{"key": "surface", "value": "asphalt"},
{"key": "surface", "value": "concrete"},
{"key": "surface", "value": "concrete:plates"},
Expand Down
Loading