Skip to content

Commit

Permalink
Merge ec5bc52 into c718f14
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Oct 16, 2017
2 parents c718f14 + ec5bc52 commit 4a4c4ac
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
29 changes: 29 additions & 0 deletions features/guidance/collapse-detail.feature
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,32 @@ Feature: Collapse
| waypoints | route | turns |
| a,d | road,left,left | depart,turn left,arrive |
| a,e | road,right,right | depart,turn right,arrive |

# https://www.openstreetmap.org/#map=18/53.89755/27.54306
Scenario: Wide turn into invalid u-turn
Given the node map
"""
g
|
|
f - - - - e
|
|
|
h - - d
|
|
|
a - - - - b - - - - c
"""

And the ways
| nodes | highway | name |
| abc | secondary | road |
| bdfg | service | |
| hd | service | |
| fe | service | |

When I route I should get
| waypoints | route | turns |
| c,e | road,,, | depart,turn right,turn right,arrive |
22 changes: 22 additions & 0 deletions include/engine/guidance/collapsing_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/guidance/route_step.hpp"
#include "util/attributes.hpp"
#include "util/bearing.hpp"
#include "util/guidance/name_announcements.hpp"

#include <boost/range/algorithm_ext/erase.hpp>
Expand Down Expand Up @@ -189,6 +190,27 @@ inline std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> st
return steps;
}

inline double totalTurnAngle(const RouteStep &entry_step, const RouteStep &exit_step)
{
if (entry_step.geometry_begin > exit_step.geometry_begin)
return totalTurnAngle(exit_step, entry_step);

const auto exit_intersection = exit_step.intersections.front();
const auto entry_intersection = entry_step.intersections.front();
if ((exit_intersection.out >= exit_intersection.bearings.size()) ||
(entry_intersection.in >= entry_intersection.bearings.size()))
return entry_intersection.bearings[entry_intersection.out];

const auto exit_step_exit_bearing = exit_intersection.bearings[exit_intersection.out];
const auto entry_step_entry_bearing =
util::bearing::reverse(entry_intersection.bearings[entry_intersection.in]);

const double total_angle =
util::bearing::angleBetween(entry_step_entry_bearing, exit_step_exit_bearing);

return total_angle;
}

} /* namespace guidance */
} /* namespace engine */
} /* namespace osrm */
Expand Down
7 changes: 6 additions & 1 deletion src/engine/guidance/collapse_scenario_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,12 @@ bool suppressedStraightBetweenTurns(const RouteStepIterator step_entering_inters
hasTurnType(*step_leaving_intersection, TurnType::Continue) ||
hasTurnType(*step_leaving_intersection, TurnType::OnRamp));

return both_short_enough && similar_length && correct_types;
const auto total_angle =
totalTurnAngle(*step_entering_intersection, *step_leaving_intersection);
const auto total_angle_is_not_uturn =
(total_angle > NARROW_TURN_ANGLE) && (total_angle < 360 - NARROW_TURN_ANGLE);

return both_short_enough && similar_length && correct_types && total_angle_is_not_uturn;
}

bool maneuverSucceededByNameChange(const RouteStepIterator step_entering_intersection,
Expand Down

0 comments on commit 4a4c4ac

Please sign in to comment.