fix initial maneuvers
This commit is contained in:
parent
e82bc20422
commit
59fbb289b9
@ -51,6 +51,7 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
|
||||
current_distance +=
|
||||
util::coordinate_calculation::haversineDistance(prev_coordinate, coordinate);
|
||||
|
||||
//all changes to this check have to be matched with assemble_steps
|
||||
if (path_point.turn_instruction.type != extractor::guidance::TurnType::NoTurn)
|
||||
{
|
||||
geometry.segment_distances.push_back(current_distance);
|
||||
|
@ -25,9 +25,13 @@ namespace guidance
|
||||
namespace detail
|
||||
{
|
||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||
const WaypointType waypoint_type,
|
||||
const LegGeometry &leg_geometry,
|
||||
const std::size_t segment_index);
|
||||
|
||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||
const WaypointType waypoint_type,
|
||||
const LegGeometry &leg_geometry);
|
||||
|
||||
} // ns detail
|
||||
|
||||
template <typename DataFacadeT>
|
||||
@ -39,7 +43,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
const bool source_traversed_in_reverse,
|
||||
const bool target_traversed_in_reverse)
|
||||
{
|
||||
const double constexpr ZERO_DURACTION = 0., ZERO_DISTANCE = 0., NO_BEARING = 0.;
|
||||
const double constexpr ZERO_DURACTION = 0., ZERO_DISTANCE = 0.;
|
||||
const EdgeWeight source_duration =
|
||||
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
|
||||
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
|
||||
@ -67,8 +71,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
distance_to_start >= MINIMAL_RELATIVE_DISTANCE &&
|
||||
distance_to_start <= MAXIMAL_RELATIVE_DISTANCE
|
||||
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
source_node.input_location, leg_geometry.locations[0],
|
||||
leg_geometry.locations[1]))
|
||||
source_node.input_location, leg_geometry.locations[0], leg_geometry.locations[1]))
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
|
||||
if (leg_data.size() > 0)
|
||||
@ -77,7 +80,8 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn,
|
||||
initial_modifier},
|
||||
WaypointType::Depart, leg_geometry, segment_index);
|
||||
WaypointType::Depart, leg_geometry);
|
||||
maneuver.location = source_node.location;
|
||||
|
||||
// PathData saves the information we need of the segment _before_ the turn,
|
||||
// but a RouteStep is with regard to the segment after the turn.
|
||||
@ -88,6 +92,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
{
|
||||
segment_duration += path_point.duration_until_turn;
|
||||
|
||||
// all changes to this check have to be matched with assemble_geometry
|
||||
if (path_point.turn_instruction.type != extractor::guidance::TurnType::NoTurn)
|
||||
{
|
||||
BOOST_ASSERT(segment_duration >= 0);
|
||||
@ -102,8 +107,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
maneuver = detail::stepManeuverFromGeometry(path_point.turn_instruction,
|
||||
WaypointType::None, leg_geometry,
|
||||
segment_index);
|
||||
leg_geometry, segment_index);
|
||||
segment_index++;
|
||||
segment_duration = 0;
|
||||
}
|
||||
@ -129,14 +133,10 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
// |---| source_duration
|
||||
// |---------| target_duration
|
||||
|
||||
StepManeuver maneuver = {source_node.location,
|
||||
NO_BEARING,
|
||||
NO_BEARING,
|
||||
extractor::guidance::TurnInstruction{
|
||||
extractor::guidance::TurnType::NoTurn, initial_modifier},
|
||||
WaypointType::Depart,
|
||||
INVALID_EXIT_NR,
|
||||
INVALID_EXIT_NR};
|
||||
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn,
|
||||
initial_modifier},
|
||||
WaypointType::Depart, leg_geometry);
|
||||
int duration = target_duration - source_duration;
|
||||
BOOST_ASSERT(duration >= 0);
|
||||
|
||||
@ -162,22 +162,17 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
target_node.input_location))
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
// This step has length zero, the only reason we need it is the target location
|
||||
steps.push_back(
|
||||
RouteStep{target_node.name_id,
|
||||
facade.GetNameForID(target_node.name_id),
|
||||
ZERO_DURACTION,
|
||||
ZERO_DISTANCE,
|
||||
target_mode,
|
||||
StepManeuver{target_node.location,
|
||||
NO_BEARING,
|
||||
NO_BEARING,
|
||||
extractor::guidance::TurnInstruction{
|
||||
extractor::guidance::TurnType::NoTurn, final_modifier},
|
||||
WaypointType::Arrive,
|
||||
INVALID_EXIT_NR,
|
||||
INVALID_EXIT_NR},
|
||||
leg_geometry.locations.size(),
|
||||
leg_geometry.locations.size()});
|
||||
auto final_maneuver = detail::stepManeuverFromGeometry(
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn, final_modifier},
|
||||
WaypointType::Arrive, leg_geometry);
|
||||
steps.push_back(RouteStep{target_node.name_id,
|
||||
facade.GetNameForID(target_node.name_id),
|
||||
ZERO_DURACTION,
|
||||
ZERO_DISTANCE,
|
||||
target_mode,
|
||||
final_maneuver,
|
||||
leg_geometry.locations.size(),
|
||||
leg_geometry.locations.size()});
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
@ -12,8 +12,41 @@ namespace guidance
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||
const WaypointType waypoint_type,
|
||||
const LegGeometry &leg_geometry)
|
||||
{
|
||||
BOOST_ASSERT(waypoint_type != WaypointType::None);
|
||||
BOOST_ASSERT(leg_geometry.locations.size() >= 2);
|
||||
|
||||
double pre_turn_bearing = 0, post_turn_bearing = 0;
|
||||
Coordinate turn_coordinate;
|
||||
if (waypoint_type == WaypointType::Arrive)
|
||||
{
|
||||
turn_coordinate = leg_geometry.locations.front();
|
||||
const auto post_turn_coordinate = *(leg_geometry.locations.begin() + 1);
|
||||
post_turn_bearing =
|
||||
util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(waypoint_type == WaypointType::Depart);
|
||||
turn_coordinate = leg_geometry.locations.back();
|
||||
const auto pre_turn_coordinate = *(leg_geometry.locations.end() - 2);
|
||||
pre_turn_bearing =
|
||||
util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate);
|
||||
}
|
||||
return StepManeuver{turn_coordinate,
|
||||
pre_turn_bearing,
|
||||
post_turn_bearing,
|
||||
instruction,
|
||||
waypoint_type,
|
||||
INVALID_EXIT_NR,
|
||||
INVALID_EXIT_NR};
|
||||
}
|
||||
|
||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||
const LegGeometry &leg_geometry,
|
||||
const std::size_t segment_index)
|
||||
{
|
||||
@ -35,7 +68,7 @@ StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instr
|
||||
pre_turn_bearing,
|
||||
post_turn_bearing,
|
||||
instruction,
|
||||
waypoint_type,
|
||||
WaypointType::None,
|
||||
INVALID_EXIT_NR,
|
||||
INVALID_EXIT_NR};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user