fix collapsing into uturns, that aren't u-turns
This commit is contained in:
parent
8719821363
commit
37774a331a
@ -174,5 +174,5 @@ Feature: Collapse
|
|||||||
| fe | service | |
|
| fe | service | |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| waypoints | route | turns |
|
| waypoints | route | turns |
|
||||||
| c,e | road,, | depart,turn uturn,arrive |
|
| c,e | road,,, | depart,turn right,turn right,arrive |
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "extractor/guidance/turn_instruction.hpp"
|
#include "extractor/guidance/turn_instruction.hpp"
|
||||||
#include "engine/guidance/route_step.hpp"
|
#include "engine/guidance/route_step.hpp"
|
||||||
#include "util/attributes.hpp"
|
#include "util/attributes.hpp"
|
||||||
|
#include "util/bearing.hpp"
|
||||||
#include "util/guidance/name_announcements.hpp"
|
#include "util/guidance/name_announcements.hpp"
|
||||||
|
|
||||||
#include <boost/range/algorithm_ext/erase.hpp>
|
#include <boost/range/algorithm_ext/erase.hpp>
|
||||||
@ -189,6 +190,27 @@ inline std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> st
|
|||||||
return steps;
|
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 guidance */
|
||||||
} /* namespace engine */
|
} /* namespace engine */
|
||||||
} /* namespace osrm */
|
} /* namespace osrm */
|
||||||
|
@ -306,7 +306,12 @@ bool suppressedStraightBetweenTurns(const RouteStepIterator step_entering_inters
|
|||||||
hasTurnType(*step_leaving_intersection, TurnType::Continue) ||
|
hasTurnType(*step_leaving_intersection, TurnType::Continue) ||
|
||||||
hasTurnType(*step_leaving_intersection, TurnType::OnRamp));
|
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,
|
bool maneuverSucceededByNameChange(const RouteStepIterator step_entering_intersection,
|
||||||
|
Loading…
Reference in New Issue
Block a user