Correctly handle compressed traffic signals (#6724)
Unidirectional traffic signal segments are currently not compressed. This means traffic signals which are not on turns can be missed and not applied the correct penalty. This commit changes this behaviour to correctly handle the graph compression. Additional tests are added to ensure there is no regression for other cases (turns, restrictions). Co-authored-by: Michael Bell <michael@mjjbell.com>
This commit is contained in:
@@ -24,7 +24,7 @@ class GraphCompressor
|
||||
|
||||
public:
|
||||
void Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const TrafficSignals &traffic_signals,
|
||||
TrafficSignals &traffic_signals,
|
||||
ScriptingEnvironment &scripting_environment,
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
|
||||
@@ -39,7 +39,7 @@ class NodeBasedGraphFactory
|
||||
NodeBasedGraphFactory(ScriptingEnvironment &scripting_environment,
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
const TrafficSignals &traffic_signals,
|
||||
TrafficSignals &traffic_signals,
|
||||
std::unordered_set<NodeID> &&barriers,
|
||||
std::vector<util::Coordinate> &&coordinates,
|
||||
extractor::PackedOSMIDs &&osm_node_ids,
|
||||
@@ -71,7 +71,7 @@ class NodeBasedGraphFactory
|
||||
void Compress(ScriptingEnvironment &scripting_environment,
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
const TrafficSignals &traffic_signals);
|
||||
TrafficSignals &traffic_signals);
|
||||
|
||||
// Most ways are bidirectional, making the geometry in forward and backward direction the same,
|
||||
// except for reversal. We make use of this fact by keeping only one representation of the
|
||||
|
||||
@@ -19,6 +19,21 @@ struct TrafficSignals
|
||||
{
|
||||
return bidirectional_nodes.count(to) > 0 || unidirectional_segments.count({from, to}) > 0;
|
||||
}
|
||||
|
||||
void Compress(NodeID from, NodeID via, NodeID to)
|
||||
{
|
||||
bidirectional_nodes.erase(via);
|
||||
if (unidirectional_segments.count({via, to}))
|
||||
{
|
||||
unidirectional_segments.erase({via, to});
|
||||
unidirectional_segments.insert({from, to});
|
||||
}
|
||||
if (unidirectional_segments.count({via, from}))
|
||||
{
|
||||
unidirectional_segments.erase({via, from});
|
||||
unidirectional_segments.insert({to, from});
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace osrm::extractor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user