Fix ingestion fixed duration values from UnpackPath
This commit is contained in:
parent
7091331b55
commit
082eac68f7
@ -40,17 +40,13 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
const bool source_traversed_in_reverse,
|
||||
const bool target_traversed_in_reverse)
|
||||
{
|
||||
const auto source_duration =
|
||||
(source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset()
|
||||
: source_node.GetForwardWeightPlusOffset()) /
|
||||
10.;
|
||||
const EdgeWeight source_duration =
|
||||
source_traversed_in_reverse ? source_node.forward_weight : source_node.reverse_weight;
|
||||
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
|
||||
: source_node.forward_travel_mode;
|
||||
|
||||
const auto target_duration =
|
||||
(target_traversed_in_reverse ? target_node.GetReverseWeightPlusOffset()
|
||||
: target_node.GetForwardWeightPlusOffset()) /
|
||||
10.;
|
||||
const EdgeWeight target_duration =
|
||||
target_traversed_in_reverse ? target_node.forward_weight : target_node.reverse_weight;
|
||||
const auto target_mode = target_traversed_in_reverse ? target_node.backward_travel_mode
|
||||
: target_node.forward_travel_mode;
|
||||
|
||||
@ -63,9 +59,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
const auto initial_modifier =
|
||||
leg_geometry.locations.size() >= 3
|
||||
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
leg_geometry.locations[0],
|
||||
leg_geometry.locations[1],
|
||||
leg_geometry.locations[2]))
|
||||
leg_geometry.locations[0], leg_geometry.locations[1], leg_geometry.locations[2]))
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
|
||||
if (leg_data.size() > 0)
|
||||
@ -74,50 +68,59 @@ 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, INVALID_EXIT_NR);
|
||||
WaypointType::Depart, leg_geometry, segment_index, INVALID_EXIT_NR);
|
||||
|
||||
// PathData saves the information we need of the segment _before_ the turn,
|
||||
// but a RouteStep is with regard to the segment after the turn.
|
||||
// We need to skip the first segment because it is already covered by the
|
||||
// initial start of a route
|
||||
int segment_duration = 0;
|
||||
for (const auto &path_point : leg_data)
|
||||
{
|
||||
segment_duration += path_point.duration_until_turn;
|
||||
|
||||
if (path_point.turn_instruction != extractor::guidance::TurnInstruction::NO_TURN())
|
||||
{
|
||||
BOOST_ASSERT(segment_duration >= 0);
|
||||
const auto name = facade.get_name_for_id(path_point.name_id);
|
||||
const auto distance = leg_geometry.segment_distances[segment_index];
|
||||
steps.push_back(RouteStep{
|
||||
path_point.name_id, name, path_point.duration_until_turn / 10.0, distance,
|
||||
path_point.travel_mode, maneuver, leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
maneuver = detail::stepManeuverFromGeometry(
|
||||
path_point.turn_instruction, WaypointType::None, leg_geometry, segment_index, path_point.exit);
|
||||
steps.push_back(RouteStep{path_point.name_id, name, segment_duration / 10.0,
|
||||
distance, path_point.travel_mode, maneuver,
|
||||
leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
maneuver = detail::stepManeuverFromGeometry(path_point.turn_instruction,
|
||||
WaypointType::None, leg_geometry,
|
||||
segment_index, path_point.exit);
|
||||
segment_index++;
|
||||
segment_duration = 0;
|
||||
}
|
||||
}
|
||||
const auto distance = leg_geometry.segment_distances[segment_index];
|
||||
const int duration = segment_duration + target_duration;
|
||||
BOOST_ASSERT(duration >= 0);
|
||||
steps.push_back(RouteStep{target_node.name_id, facade.get_name_for_id(target_node.name_id),
|
||||
target_duration, distance, target_mode, maneuver,
|
||||
duration / 10., distance, target_mode, maneuver,
|
||||
leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
}
|
||||
// In this case the source + target are on the same edge segment
|
||||
else
|
||||
{
|
||||
//
|
||||
// |-----s source_duration
|
||||
// |-------------t target_duration
|
||||
// x---*---*---*---z compressed edge
|
||||
// |-------| duration
|
||||
BOOST_ASSERT(source_node.fwd_segment_position == target_node.fwd_segment_position);
|
||||
// s t
|
||||
// u-------------v
|
||||
// |---| source_duration
|
||||
// |---------| target_duration
|
||||
|
||||
StepManeuver maneuver = {source_node.location, 0., 0.,
|
||||
extractor::guidance::TurnInstruction{
|
||||
extractor::guidance::TurnType::NoTurn, initial_modifier},
|
||||
WaypointType::Depart,
|
||||
INVALID_EXIT_NR};
|
||||
WaypointType::Depart, INVALID_EXIT_NR};
|
||||
int duration = target_duration - source_duration;
|
||||
BOOST_ASSERT(duration >= 0);
|
||||
|
||||
steps.push_back(RouteStep{source_node.name_id, facade.get_name_for_id(source_node.name_id),
|
||||
target_duration - source_duration,
|
||||
leg_geometry.segment_distances[segment_index], source_mode,
|
||||
duration / 10., leg_geometry.segment_distances[segment_index], source_mode,
|
||||
std::move(maneuver), leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
}
|
||||
@ -136,8 +139,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
StepManeuver{target_node.location, 0., 0.,
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::NoTurn,
|
||||
final_modifier},
|
||||
WaypointType::Arrive,
|
||||
INVALID_EXIT_NR},
|
||||
WaypointType::Arrive, INVALID_EXIT_NR},
|
||||
leg_geometry.locations.size(), leg_geometry.locations.size()});
|
||||
|
||||
return steps;
|
||||
|
@ -204,7 +204,6 @@ std::vector<std::vector<PathData>> postProcess(std::vector<std::vector<PathData>
|
||||
!entersRoundabout(data.turn_instruction)))
|
||||
{
|
||||
data.turn_instruction = TurnInstruction::NO_TURN();
|
||||
data.duration_until_turn = 0;
|
||||
data.exit = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user