fix looping in sliproad handler for lanes

This commit is contained in:
Moritz Kobitzsch 2016-09-12 10:08:01 +02:00
parent e3c1b133bf
commit b3c5a9c010
3 changed files with 17 additions and 4 deletions

View File

@ -235,7 +235,8 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo
route_step.values["distance"] = std::round(step.distance * 10) / 10.;
route_step.values["duration"] = std::round(step.duration * 10) / 10.;
route_step.values["name"] = std::move(step.name);
if (!step.ref.empty()) route_step.values["ref"] = std::move(step.ref);
if (!step.ref.empty())
route_step.values["ref"] = std::move(step.ref);
if (!step.pronunciation.empty())
route_step.values["pronunciation"] = std::move(step.pronunciation);
if (!step.destinations.empty())

View File

@ -37,9 +37,9 @@ SliproadHandler::SliproadHandler(const IntersectionGenerator &intersection_gener
// included for interface reasons only
bool SliproadHandler::canProcess(const NodeID /*nid*/,
const EdgeID /*via_eid*/,
const Intersection & /*intersection*/) const
const Intersection &intersection) const
{
return true;
return intersection.size() > 2;
}
Intersection SliproadHandler::
@ -59,6 +59,13 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
while (intersection.size() == 2)
{
const auto node = node_based_graph.GetTarget(in_edge);
if (node == at_node)
{
// we ended up in a loop without exit
output_node = SPECIAL_NODEID;
intersection.clear();
return intersection;
}
in_edge = intersection[1].turn.eid;
output_node = node_based_graph.GetTarget(in_edge);
intersection = intersection_generator(node, in_edge);
@ -82,6 +89,10 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
intersection_node_id, intersection[1], intersection_node_one);
const auto intersection_following_index_two = findNextIntersectionForRoad(
intersection_node_id, intersection[2], intersection_node_two);
// in case of broken roads, we return
if (intersection_following_index_one.empty() ||
intersection_following_index_two.empty())
return 0;
// In case of loops at the end of the road, we will arrive back at the intersection
// itself. If that is the case, the road is obviously not a sliproad.

View File

@ -94,6 +94,7 @@ Intersection TurnAnalysis::assignTurnTypes(const NodeID from_nid,
}
}
// Handle sliproads
if (sliproad_handler.canProcess(from_nid, via_eid, intersection))
intersection = sliproad_handler(from_nid, via_eid, std::move(intersection));
// Turn On Ramps Into Off Ramps, if we come from a motorway-like road