catch infinite loops

This commit is contained in:
Moritz Kobitzsch
2016-09-05 10:06:50 +02:00
parent 47a6cd5462
commit 5d79e0ac2f
3 changed files with 42 additions and 1 deletions
@@ -574,6 +574,9 @@ IntersectionGenerator::GetActualNextIntersection(const NodeID starting_node,
NodeID node_at_intersection = starting_node;
EdgeID incoming_edge = via_edge;
// to prevent endless loops
const auto termination_node = node_based_graph.GetTarget(via_edge);
while (result.size() == 2 &&
node_based_graph.GetEdgeData(via_edge).IsCompatibleTo(
node_based_graph.GetEdgeData(result[1].turn.eid)))
@@ -581,6 +584,10 @@ IntersectionGenerator::GetActualNextIntersection(const NodeID starting_node,
node_at_intersection = node_based_graph.GetTarget(incoming_edge);
incoming_edge = result[1].turn.eid;
result = GetConnectedRoads(node_at_intersection, incoming_edge);
// When looping back to the original node, we obviously are in a loop. Stop there.
if (termination_node == node_based_graph.GetTarget(incoming_edge))
break;
}
// return output if requested