Skip to content

Commit c77add5

Browse files
author
Moritz Kobitzsch
committed
cherry-pick #3555
1 parent 37e36fd commit c77add5

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

include/util/debug.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ inline void print(const engine::guidance::RouteStep &step)
2929
<< " "
3030
<< " Duration: " << step.duration << " Distance: " << step.distance
3131
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end
32+
<< " Exit: " << step.maneuver.exit << " Mode: " << (int)step.mode
3233
<< "\n\tIntersections: " << step.intersections.size() << " [";
3334

3435
for (const auto &intersection : step.intersections)

src/extractor/guidance/intersection_handler.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
167167
node_based_graph.GetEdgeData(left.eid).road_classification.IsLowPriorityRoadClass();
168168
const bool low_priority_right =
169169
node_based_graph.GetEdgeData(right.eid).road_classification.IsLowPriorityRoadClass();
170+
const auto same_mode_left =
171+
in_data.travel_mode == node_based_graph.GetEdgeData(left.eid).travel_mode;
172+
const auto same_mode_right =
173+
in_data.travel_mode == node_based_graph.GetEdgeData(right.eid).travel_mode;
174+
const auto suppressed_left_type =
175+
same_mode_left ? TurnType::Suppressed : TurnType::Notification;
176+
const auto suppressed_right_type =
177+
same_mode_right ? TurnType::Suppressed : TurnType::Notification;
170178
if ((angularDeviation(left.angle, STRAIGHT_ANGLE) < MAXIMAL_ALLOWED_NO_TURN_DEVIATION &&
171179
angularDeviation(right.angle, STRAIGHT_ANGLE) > FUZZY_ANGLE_DIFFERENCE))
172180
{
@@ -198,7 +206,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
198206
}
199207
else
200208
{
201-
left.instruction = {TurnType::Suppressed, DirectionModifier::Straight};
209+
left.instruction = {suppressed_left_type, DirectionModifier::Straight};
202210
right.instruction = {findBasicTurnType(via_edge, right),
203211
DirectionModifier::SlightRight};
204212
}
@@ -237,15 +245,15 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
237245
}
238246
else
239247
{
240-
right.instruction = {TurnType::Suppressed, DirectionModifier::Straight};
248+
right.instruction = {suppressed_right_type, DirectionModifier::Straight};
241249
left.instruction = {findBasicTurnType(via_edge, left),
242250
DirectionModifier::SlightLeft};
243251
}
244252
}
245253
}
246254
// left side of fork
247255
if (low_priority_right && !low_priority_left)
248-
left.instruction = {TurnType::Suppressed, DirectionModifier::SlightLeft};
256+
left.instruction = {suppressed_left_type, DirectionModifier::SlightLeft};
249257
else
250258
{
251259
if (low_priority_left && !low_priority_right)
@@ -256,7 +264,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
256264

257265
// right side of fork
258266
if (low_priority_left && !low_priority_right)
259-
right.instruction = {TurnType::Suppressed, DirectionModifier::SlightLeft};
267+
right.instruction = {suppressed_right_type, DirectionModifier::SlightLeft};
260268
else
261269
{
262270
if (low_priority_right && !low_priority_left)
@@ -272,6 +280,12 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
272280
ConnectedRoad &right) const
273281
{
274282
// TODO handle low priority road classes in a reasonable way
283+
const auto suppressed_type = [&](const ConnectedRoad &road) {
284+
const auto in_mode = node_based_graph.GetEdgeData(via_edge).travel_mode;
285+
const auto out_mode = node_based_graph.GetEdgeData(road.eid).travel_mode;
286+
return in_mode == out_mode ? TurnType::Suppressed : TurnType::Notification;
287+
};
288+
275289
if (left.entry_allowed && center.entry_allowed && right.entry_allowed)
276290
{
277291
left.instruction = {TurnType::Fork, DirectionModifier::SlightLeft};
@@ -285,7 +299,7 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
285299
}
286300
else
287301
{
288-
center.instruction = {TurnType::Suppressed, DirectionModifier::Straight};
302+
center.instruction = {suppressed_type(center), DirectionModifier::Straight};
289303
}
290304
}
291305
else

src/extractor/guidance/turn_handler.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ std::pair<std::size_t, std::size_t> TurnHandler::findFork(const EdgeID via_edge,
566566
return true;
567567
}();
568568

569+
const auto has_compatible_modes = std::all_of(
570+
intersection.begin() + right, intersection.begin() + left + 1, [&](const auto &road) {
571+
return node_based_graph.GetEdgeData(road.eid).travel_mode ==
572+
node_based_graph.GetEdgeData(via_edge).travel_mode;
573+
});
574+
569575
// check if all entries in the fork range allow entry
570576
const bool only_valid_entries = [&]() {
571577
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,
585591

586592
// TODO check whether 2*NARROW_TURN is too large
587593
if (valid_indices && separated_at_left_side && separated_at_right_side &&
588-
not_more_than_three && !has_obvious && has_compatible_classes && only_valid_entries)
594+
not_more_than_three && !has_obvious && has_compatible_classes && only_valid_entries &&
595+
has_compatible_modes)
589596
return std::make_pair(right, left);
590597
}
591598
return std::make_pair(std::size_t{0}, std::size_t{0});

0 commit comments

Comments
 (0)