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