Skip to content

Commit

Permalink
cherry-pick #3555
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Jan 17, 2017
1 parent 37e36fd commit c77add5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/util/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ inline void print(const engine::guidance::RouteStep &step)
<< " "
<< " Duration: " << step.duration << " Distance: " << step.distance
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end
<< " Exit: " << step.maneuver.exit << " Mode: " << (int)step.mode
<< "\n\tIntersections: " << step.intersections.size() << " [";

for (const auto &intersection : step.intersections)
Expand Down
24 changes: 19 additions & 5 deletions src/extractor/guidance/intersection_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
node_based_graph.GetEdgeData(left.eid).road_classification.IsLowPriorityRoadClass();
const bool low_priority_right =
node_based_graph.GetEdgeData(right.eid).road_classification.IsLowPriorityRoadClass();
const auto same_mode_left =
in_data.travel_mode == node_based_graph.GetEdgeData(left.eid).travel_mode;
const auto same_mode_right =
in_data.travel_mode == node_based_graph.GetEdgeData(right.eid).travel_mode;
const auto suppressed_left_type =
same_mode_left ? TurnType::Suppressed : TurnType::Notification;
const auto suppressed_right_type =
same_mode_right ? TurnType::Suppressed : TurnType::Notification;
if ((angularDeviation(left.angle, STRAIGHT_ANGLE) < MAXIMAL_ALLOWED_NO_TURN_DEVIATION &&
angularDeviation(right.angle, STRAIGHT_ANGLE) > FUZZY_ANGLE_DIFFERENCE))
{
Expand Down Expand Up @@ -198,7 +206,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
}
else
{
left.instruction = {TurnType::Suppressed, DirectionModifier::Straight};
left.instruction = {suppressed_left_type, DirectionModifier::Straight};
right.instruction = {findBasicTurnType(via_edge, right),
DirectionModifier::SlightRight};
}
Expand Down Expand Up @@ -237,15 +245,15 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
}
else
{
right.instruction = {TurnType::Suppressed, DirectionModifier::Straight};
right.instruction = {suppressed_right_type, DirectionModifier::Straight};
left.instruction = {findBasicTurnType(via_edge, left),
DirectionModifier::SlightLeft};
}
}
}
// left side of fork
if (low_priority_right && !low_priority_left)
left.instruction = {TurnType::Suppressed, DirectionModifier::SlightLeft};
left.instruction = {suppressed_left_type, DirectionModifier::SlightLeft};
else
{
if (low_priority_left && !low_priority_right)
Expand All @@ -256,7 +264,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,

// right side of fork
if (low_priority_left && !low_priority_right)
right.instruction = {TurnType::Suppressed, DirectionModifier::SlightLeft};
right.instruction = {suppressed_right_type, DirectionModifier::SlightLeft};
else
{
if (low_priority_right && !low_priority_left)
Expand All @@ -272,6 +280,12 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
ConnectedRoad &right) const
{
// TODO handle low priority road classes in a reasonable way
const auto suppressed_type = [&](const ConnectedRoad &road) {
const auto in_mode = node_based_graph.GetEdgeData(via_edge).travel_mode;
const auto out_mode = node_based_graph.GetEdgeData(road.eid).travel_mode;
return in_mode == out_mode ? TurnType::Suppressed : TurnType::Notification;
};

if (left.entry_allowed && center.entry_allowed && right.entry_allowed)
{
left.instruction = {TurnType::Fork, DirectionModifier::SlightLeft};
Expand All @@ -285,7 +299,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
}
else
{
center.instruction = {TurnType::Suppressed, DirectionModifier::Straight};
center.instruction = {suppressed_type(center), DirectionModifier::Straight};
}
}
else
Expand Down
9 changes: 8 additions & 1 deletion src/extractor/guidance/turn_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,12 @@ std::pair<std::size_t, std::size_t> TurnHandler::findFork(const EdgeID via_edge,
return true;
}();

const auto has_compatible_modes = std::all_of(
intersection.begin() + right, intersection.begin() + left + 1, [&](const auto &road) {
return node_based_graph.GetEdgeData(road.eid).travel_mode ==
node_based_graph.GetEdgeData(via_edge).travel_mode;
});

// check if all entries in the fork range allow entry
const bool only_valid_entries = [&]() {
BOOST_ASSERT(right <= left && left < intersection.size());
Expand All @@ -585,7 +591,8 @@ std::pair<std::size_t, std::size_t> TurnHandler::findFork(const EdgeID via_edge,

// TODO check whether 2*NARROW_TURN is too large
if (valid_indices && separated_at_left_side && separated_at_right_side &&
not_more_than_three && !has_obvious && has_compatible_classes && only_valid_entries)
not_more_than_three && !has_obvious && has_compatible_classes && only_valid_entries &&
has_compatible_modes)
return std::make_pair(right, left);
}
return std::make_pair(std::size_t{0}, std::size_t{0});
Expand Down

0 comments on commit c77add5

Please sign in to comment.