This commit is contained in:
Moritz Kobitzsch 2017-01-17 10:27:33 +01:00
parent 37e36fd165
commit c77add50e2
3 changed files with 28 additions and 6 deletions

View File

@ -29,6 +29,7 @@ inline void print(const engine::guidance::RouteStep &step)
<< " " << " "
<< " Duration: " << step.duration << " Distance: " << step.distance << " Duration: " << step.duration << " Distance: " << step.distance
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end << " Geometry: " << step.geometry_begin << " " << step.geometry_end
<< " Exit: " << step.maneuver.exit << " Mode: " << (int)step.mode
<< "\n\tIntersections: " << step.intersections.size() << " ["; << "\n\tIntersections: " << step.intersections.size() << " [";
for (const auto &intersection : step.intersections) for (const auto &intersection : step.intersections)

View File

@ -167,6 +167,14 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
node_based_graph.GetEdgeData(left.eid).road_classification.IsLowPriorityRoadClass(); node_based_graph.GetEdgeData(left.eid).road_classification.IsLowPriorityRoadClass();
const bool low_priority_right = const bool low_priority_right =
node_based_graph.GetEdgeData(right.eid).road_classification.IsLowPriorityRoadClass(); 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 && if ((angularDeviation(left.angle, STRAIGHT_ANGLE) < MAXIMAL_ALLOWED_NO_TURN_DEVIATION &&
angularDeviation(right.angle, STRAIGHT_ANGLE) > FUZZY_ANGLE_DIFFERENCE)) angularDeviation(right.angle, STRAIGHT_ANGLE) > FUZZY_ANGLE_DIFFERENCE))
{ {
@ -198,7 +206,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
} }
else else
{ {
left.instruction = {TurnType::Suppressed, DirectionModifier::Straight}; left.instruction = {suppressed_left_type, DirectionModifier::Straight};
right.instruction = {findBasicTurnType(via_edge, right), right.instruction = {findBasicTurnType(via_edge, right),
DirectionModifier::SlightRight}; DirectionModifier::SlightRight};
} }
@ -237,7 +245,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
} }
else else
{ {
right.instruction = {TurnType::Suppressed, DirectionModifier::Straight}; right.instruction = {suppressed_right_type, DirectionModifier::Straight};
left.instruction = {findBasicTurnType(via_edge, left), left.instruction = {findBasicTurnType(via_edge, left),
DirectionModifier::SlightLeft}; DirectionModifier::SlightLeft};
} }
@ -245,7 +253,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
} }
// left side of fork // left side of fork
if (low_priority_right && !low_priority_left) if (low_priority_right && !low_priority_left)
left.instruction = {TurnType::Suppressed, DirectionModifier::SlightLeft}; left.instruction = {suppressed_left_type, DirectionModifier::SlightLeft};
else else
{ {
if (low_priority_left && !low_priority_right) if (low_priority_left && !low_priority_right)
@ -256,7 +264,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
// right side of fork // right side of fork
if (low_priority_left && !low_priority_right) if (low_priority_left && !low_priority_right)
right.instruction = {TurnType::Suppressed, DirectionModifier::SlightLeft}; right.instruction = {suppressed_right_type, DirectionModifier::SlightLeft};
else else
{ {
if (low_priority_right && !low_priority_left) if (low_priority_right && !low_priority_left)
@ -272,6 +280,12 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
ConnectedRoad &right) const ConnectedRoad &right) const
{ {
// TODO handle low priority road classes in a reasonable way // 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) if (left.entry_allowed && center.entry_allowed && right.entry_allowed)
{ {
left.instruction = {TurnType::Fork, DirectionModifier::SlightLeft}; left.instruction = {TurnType::Fork, DirectionModifier::SlightLeft};
@ -285,7 +299,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
} }
else else
{ {
center.instruction = {TurnType::Suppressed, DirectionModifier::Straight}; center.instruction = {suppressed_type(center), DirectionModifier::Straight};
} }
} }
else else

View File

@ -566,6 +566,12 @@ std::pair<std::size_t, std::size_t> TurnHandler::findFork(const EdgeID via_edge,
return true; 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 // check if all entries in the fork range allow entry
const bool only_valid_entries = [&]() { const bool only_valid_entries = [&]() {
BOOST_ASSERT(right <= left && left < intersection.size()); BOOST_ASSERT(right <= left && left < intersection.size());
@ -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 // TODO check whether 2*NARROW_TURN is too large
if (valid_indices && separated_at_left_side && separated_at_right_side && 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(right, left);
} }
return std::make_pair(std::size_t{0}, std::size_t{0}); return std::make_pair(std::size_t{0}, std::size_t{0});