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:
@@ -285,11 +285,41 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
return get_location_tag(context, node.location(), key);
|
||||
});
|
||||
|
||||
context.state.new_usertype<ExtractionNode>("ResultNode",
|
||||
"traffic_lights",
|
||||
&ExtractionNode::traffic_lights,
|
||||
"barrier",
|
||||
&ExtractionNode::barrier);
|
||||
context.state.new_enum("traffic_lights",
|
||||
"none",
|
||||
extractor::TrafficLightClass::NONE,
|
||||
"direction_all",
|
||||
extractor::TrafficLightClass::DIRECTION_ALL,
|
||||
"direction_forward",
|
||||
extractor::TrafficLightClass::DIRECTION_FORWARD,
|
||||
"direction_reverse",
|
||||
extractor::TrafficLightClass::DIRECTION_REVERSE);
|
||||
|
||||
context.state.new_usertype<ExtractionNode>(
|
||||
"ResultNode",
|
||||
"traffic_lights",
|
||||
sol::property([](const ExtractionNode &node) { return node.traffic_lights; },
|
||||
[](ExtractionNode &node, const sol::object &obj) {
|
||||
if (obj.is<bool>())
|
||||
{
|
||||
// The old approach of assigning a boolean traffic light
|
||||
// state to the node is converted to the class enum
|
||||
// TODO: Make a breaking API change and remove this option.
|
||||
bool val = obj.as<bool>();
|
||||
node.traffic_lights = (val) ? TrafficLightClass::DIRECTION_ALL
|
||||
: TrafficLightClass::NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(obj.is<TrafficLightClass::Direction>());
|
||||
{
|
||||
TrafficLightClass::Direction val =
|
||||
obj.as<TrafficLightClass::Direction>();
|
||||
node.traffic_lights = val;
|
||||
}
|
||||
}),
|
||||
"barrier",
|
||||
&ExtractionNode::barrier);
|
||||
|
||||
context.state.new_usertype<RoadClassification>(
|
||||
"RoadClassification",
|
||||
|
||||
Reference in New Issue
Block a user