Support OSM traffic signal directions (#6153)
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.
This commit is contained in:
@@ -5,6 +5,7 @@ api_version = 4
|
||||
Set = require('lib/set')
|
||||
Sequence = require('lib/sequence')
|
||||
Handlers = require("lib/way_handlers")
|
||||
TrafficSignal = require("lib/traffic_signal")
|
||||
find_access_tag = require("lib/access").find_access_tag
|
||||
limit = require("lib/maxspeed").limit
|
||||
Measure = require("lib/measure")
|
||||
@@ -235,10 +236,7 @@ function process_node(profile, node, result)
|
||||
end
|
||||
|
||||
-- check if node is a traffic light
|
||||
local tag = node:get_value_by_key("highway")
|
||||
if tag and "traffic_signals" == tag then
|
||||
result.traffic_lights = true
|
||||
end
|
||||
result.traffic_lights = TrafficSignal.get_value(node)
|
||||
end
|
||||
|
||||
function handle_bicycle_tags(profile,way,result,data)
|
||||
|
||||
+2
-4
@@ -6,6 +6,7 @@ Set = require('lib/set')
|
||||
Sequence = require('lib/sequence')
|
||||
Handlers = require("lib/way_handlers")
|
||||
Relations = require("lib/relations")
|
||||
TrafficSignal = require("lib/traffic_signal")
|
||||
find_access_tag = require("lib/access").find_access_tag
|
||||
limit = require("lib/maxspeed").limit
|
||||
Utils = require("lib/utils")
|
||||
@@ -360,10 +361,7 @@ function process_node(profile, node, result, relations)
|
||||
end
|
||||
|
||||
-- check if node is a traffic light
|
||||
local tag = node:get_value_by_key("highway")
|
||||
if "traffic_signals" == tag then
|
||||
result.traffic_lights = true
|
||||
end
|
||||
result.traffic_lights = TrafficSignal.get_value(node)
|
||||
end
|
||||
|
||||
function process_way(profile, way, result, relations)
|
||||
|
||||
@@ -157,6 +157,7 @@ function process_node(profile, node, result)
|
||||
-- check if node is a traffic light
|
||||
local tag = node:get_value_by_key("highway")
|
||||
if "traffic_signals" == tag then
|
||||
-- Direction should only apply to vehicles
|
||||
result.traffic_lights = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
-- 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
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
-- Primary road: 36km/h = 36000m/3600s = 100m/10s
|
||||
-- Secondary road: 18km/h = 18000m/3600s = 100m/20s
|
||||
-- Tertiary road: 12km/h = 12000m/3600s = 100m/30s
|
||||
TrafficSignal = require("lib/traffic_signal")
|
||||
|
||||
api_version = 4
|
||||
|
||||
@@ -38,12 +39,9 @@ function setup()
|
||||
end
|
||||
|
||||
function process_node (profile, node, result)
|
||||
local traffic_signal = node:get_value_by_key("highway")
|
||||
|
||||
if traffic_signal and traffic_signal == "traffic_signals" then
|
||||
result.traffic_lights = true
|
||||
-- TODO: a way to set the penalty value
|
||||
end
|
||||
-- check if node is a traffic light
|
||||
result.traffic_lights = TrafficSignal.get_value(node)
|
||||
-- TODO: a way to set the penalty value
|
||||
end
|
||||
|
||||
function process_way (profile, way, result)
|
||||
|
||||
Reference in New Issue
Block a user