fix initial maneuvers
This commit is contained in:
parent
f3de53c363
commit
f3ea86b611
@ -51,6 +51,7 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
|
|||||||
current_distance +=
|
current_distance +=
|
||||||
util::coordinate_calculation::haversineDistance(prev_coordinate, coordinate);
|
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)
|
if (path_point.turn_instruction.type != extractor::guidance::TurnType::NoTurn)
|
||||||
{
|
{
|
||||||
geometry.segment_distances.push_back(current_distance);
|
geometry.segment_distances.push_back(current_distance);
|
||||||
|
@ -25,9 +25,13 @@ namespace guidance
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||||
const WaypointType waypoint_type,
|
|
||||||
const LegGeometry &leg_geometry,
|
const LegGeometry &leg_geometry,
|
||||||
const std::size_t segment_index);
|
const std::size_t segment_index);
|
||||||
|
|
||||||
|
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||||
|
const WaypointType waypoint_type,
|
||||||
|
const LegGeometry &leg_geometry);
|
||||||
|
|
||||||
} // ns detail
|
} // ns detail
|
||||||
|
|
||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
@ -39,7 +43,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
const bool source_traversed_in_reverse,
|
const bool source_traversed_in_reverse,
|
||||||
const bool target_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 =
|
const EdgeWeight source_duration =
|
||||||
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
|
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
|
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 >= MINIMAL_RELATIVE_DISTANCE &&
|
||||||
distance_to_start <= MAXIMAL_RELATIVE_DISTANCE
|
distance_to_start <= MAXIMAL_RELATIVE_DISTANCE
|
||||||
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||||
source_node.input_location, leg_geometry.locations[0],
|
source_node.input_location, leg_geometry.locations[0], leg_geometry.locations[1]))
|
||||||
leg_geometry.locations[1]))
|
|
||||||
: extractor::guidance::DirectionModifier::UTurn;
|
: extractor::guidance::DirectionModifier::UTurn;
|
||||||
|
|
||||||
if (leg_data.size() > 0)
|
if (leg_data.size() > 0)
|
||||||
@ -77,7 +80,8 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
||||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn,
|
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn,
|
||||||
initial_modifier},
|
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,
|
// PathData saves the information we need of the segment _before_ the turn,
|
||||||
// but a RouteStep is with regard to the segment after 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;
|
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)
|
if (path_point.turn_instruction.type != extractor::guidance::TurnType::NoTurn)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(segment_duration >= 0);
|
BOOST_ASSERT(segment_duration >= 0);
|
||||||
@ -102,8 +107,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
leg_geometry.FrontIndex(segment_index),
|
leg_geometry.FrontIndex(segment_index),
|
||||||
leg_geometry.BackIndex(segment_index) + 1});
|
leg_geometry.BackIndex(segment_index) + 1});
|
||||||
maneuver = detail::stepManeuverFromGeometry(path_point.turn_instruction,
|
maneuver = detail::stepManeuverFromGeometry(path_point.turn_instruction,
|
||||||
WaypointType::None, leg_geometry,
|
leg_geometry, segment_index);
|
||||||
segment_index);
|
|
||||||
segment_index++;
|
segment_index++;
|
||||||
segment_duration = 0;
|
segment_duration = 0;
|
||||||
}
|
}
|
||||||
@ -129,14 +133,10 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
// |---| source_duration
|
// |---| source_duration
|
||||||
// |---------| target_duration
|
// |---------| target_duration
|
||||||
|
|
||||||
StepManeuver maneuver = {source_node.location,
|
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
||||||
NO_BEARING,
|
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn,
|
||||||
NO_BEARING,
|
initial_modifier},
|
||||||
extractor::guidance::TurnInstruction{
|
WaypointType::Depart, leg_geometry);
|
||||||
extractor::guidance::TurnType::NoTurn, initial_modifier},
|
|
||||||
WaypointType::Depart,
|
|
||||||
INVALID_EXIT_NR,
|
|
||||||
INVALID_EXIT_NR};
|
|
||||||
int duration = target_duration - source_duration;
|
int duration = target_duration - source_duration;
|
||||||
BOOST_ASSERT(duration >= 0);
|
BOOST_ASSERT(duration >= 0);
|
||||||
|
|
||||||
@ -162,20 +162,15 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
target_node.input_location))
|
target_node.input_location))
|
||||||
: extractor::guidance::DirectionModifier::UTurn;
|
: extractor::guidance::DirectionModifier::UTurn;
|
||||||
// This step has length zero, the only reason we need it is the target location
|
// This step has length zero, the only reason we need it is the target location
|
||||||
steps.push_back(
|
auto final_maneuver = detail::stepManeuverFromGeometry(
|
||||||
RouteStep{target_node.name_id,
|
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),
|
facade.GetNameForID(target_node.name_id),
|
||||||
ZERO_DURACTION,
|
ZERO_DURACTION,
|
||||||
ZERO_DISTANCE,
|
ZERO_DISTANCE,
|
||||||
target_mode,
|
target_mode,
|
||||||
StepManeuver{target_node.location,
|
final_maneuver,
|
||||||
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(),
|
||||||
leg_geometry.locations.size()});
|
leg_geometry.locations.size()});
|
||||||
|
|
||||||
|
@ -12,8 +12,41 @@ namespace guidance
|
|||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||||
const WaypointType waypoint_type,
|
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 LegGeometry &leg_geometry,
|
||||||
const std::size_t segment_index)
|
const std::size_t segment_index)
|
||||||
{
|
{
|
||||||
@ -35,7 +68,7 @@ StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instr
|
|||||||
pre_turn_bearing,
|
pre_turn_bearing,
|
||||||
post_turn_bearing,
|
post_turn_bearing,
|
||||||
instruction,
|
instruction,
|
||||||
waypoint_type,
|
WaypointType::None,
|
||||||
INVALID_EXIT_NR,
|
INVALID_EXIT_NR,
|
||||||
INVALID_EXIT_NR};
|
INVALID_EXIT_NR};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user