Currently OSRM parses traffic signal nodes without consideration for the direction in which the signal applies. This can lead to duplicated routing penalties, especially when a forward and backward signal are in close proximity on a way. This commit adds support for directed signals to the extraction and graph creation. Signal penalties are only applied in the direction specified by the OSM tag. We add the assignment of traffic directions to the lua scripts, maintaining backwards compatibility with the existing boolean traffic states. As part of the changes to the internal structures used for tracking traffic signals during extraction, we stop serialising/deserialising signals to the `.osrm` file. The traffic signals are only used by `osrm-extract` so whilst this is a data format change, it will not break any existing user processes.
27 lines
744 B
Lua
27 lines
744 B
Lua
-- Assigns traffic light value to node as defined by
|
|
-- include/extractor/traffic_lights.hpp
|
|
|
|
local TrafficSignal = {}
|
|
|
|
function TrafficSignal.get_value(node)
|
|
local tag = node:get_value_by_key("highway")
|
|
if "traffic_signals" == tag then
|
|
local direction = node:get_value_by_key("traffic_signals:direction")
|
|
if direction then
|
|
if "forward" == direction then
|
|
return traffic_lights.direction_forward
|
|
end
|
|
if "backward" == direction then
|
|
return traffic_lights.direction_reverse
|
|
end
|
|
end
|
|
-- return traffic_lights.direction_all
|
|
return true
|
|
end
|
|
-- return traffic_lights.none
|
|
return false
|
|
end
|
|
|
|
return TrafficSignal
|
|
|