relative waypoint locations
This commit is contained in:
committed by
Patrick Niklaus
parent
482e18ccdb
commit
6605f293b4
@@ -14,6 +14,7 @@
|
||||
#include "extractor/travel_mode.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -45,10 +46,8 @@ inline StepManeuver stepManeuverFromGeometry(TurnInstruction instruction,
|
||||
|
||||
return StepManeuver{turn_coordinate, pre_turn_bearing, post_turn_bearing, instruction, exit};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename DataFacadeT>
|
||||
std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
const std::vector<PathData> &leg_data,
|
||||
@@ -56,7 +55,9 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
const PhantomNode &source_node,
|
||||
const PhantomNode &target_node,
|
||||
const bool source_traversed_in_reverse,
|
||||
const bool target_traversed_in_reverse)
|
||||
const bool target_traversed_in_reverse,
|
||||
boost::optional<util::Coordinate> source_location,
|
||||
boost::optional<util::Coordinate> target_location)
|
||||
{
|
||||
const auto source_duration =
|
||||
(source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset()
|
||||
@@ -77,12 +78,21 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
std::vector<RouteStep> steps;
|
||||
steps.reserve(number_of_segments);
|
||||
|
||||
// TODO do computation based on distance and choose better next vertex
|
||||
BOOST_ASSERT(leg_geometry.size() >= 4); // source, phantom, closest positions on way
|
||||
const auto initial_modifier =
|
||||
source_location
|
||||
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
source_location.get(), leg_geometry.locations[0], leg_geometry.locations[1]))
|
||||
: DirectionModifier::UTurn;
|
||||
|
||||
auto segment_index = 0;
|
||||
if (leg_data.size() > 0)
|
||||
{
|
||||
StepManeuver maneuver = detail::stepManeuverFromGeometry(
|
||||
TurnInstruction{TurnType::Location, DirectionModifier::Straight}, leg_geometry,
|
||||
segment_index, INVALID_EXIT_NR);
|
||||
|
||||
StepManeuver maneuver =
|
||||
detail::stepManeuverFromGeometry(TurnInstruction{TurnType::Location, initial_modifier},
|
||||
leg_geometry, segment_index, INVALID_EXIT_NR);
|
||||
|
||||
// TODO fix this: it makes no sense
|
||||
// PathData saves the information we need of the segment _before_ the turn,
|
||||
@@ -119,23 +129,27 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
// x---*---*---*---z compressed edge
|
||||
// |-------| duration
|
||||
StepManeuver maneuver = {source_node.location, 0., 0.,
|
||||
TurnInstruction{TurnType::Location, DirectionModifier::Straight},
|
||||
TurnInstruction{TurnType::Location, initial_modifier},
|
||||
INVALID_EXIT_NR};
|
||||
|
||||
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, std::move(maneuver), leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
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,
|
||||
std::move(maneuver), leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
}
|
||||
|
||||
BOOST_ASSERT(segment_index == number_of_segments - 1);
|
||||
const auto final_modifier =
|
||||
target_location ? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
|
||||
*(leg_geometry.locations.end() - 3),
|
||||
*(leg_geometry.locations.end() - 1), target_location.get()))
|
||||
: 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.get_name_for_id(target_node.name_id), 0., 0., target_mode,
|
||||
StepManeuver{target_node.location, 0., 0.,
|
||||
TurnInstruction{TurnType::Location, DirectionModifier::Straight},
|
||||
INVALID_EXIT_NR},
|
||||
TurnInstruction{TurnType::Location, final_modifier}, INVALID_EXIT_NR},
|
||||
leg_geometry.locations.size(), leg_geometry.locations.size()});
|
||||
|
||||
return steps;
|
||||
|
||||
@@ -69,6 +69,16 @@ enum TurnType // at the moment we can support 32 turn types, without increasing
|
||||
Notification // Travel Mode Changes`
|
||||
};
|
||||
|
||||
inline bool isValidModifier( const TurnType type, const DirectionModifier modifier )
|
||||
{
|
||||
if( type == TurnType::Location &&
|
||||
modifier != DirectionModifier::Left
|
||||
&& modifier != DirectionModifier::Straight
|
||||
&& modifier != DirectionModifier::Right )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const constexpr char *turn_type_names[] = {"invalid",
|
||||
"no turn",
|
||||
"waypoint",
|
||||
|
||||
Reference in New Issue
Block a user