2016-03-03 09:34:13 -05:00
|
|
|
#include "engine/guidance/assemble_steps.hpp"
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
namespace detail
|
|
|
|
{
|
2016-03-22 08:40:13 -04:00
|
|
|
|
2016-03-03 09:34:13 -05:00
|
|
|
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
2016-03-10 05:22:45 -05:00
|
|
|
const WaypointType waypoint_type,
|
2016-03-22 08:40:13 -04:00
|
|
|
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,
|
2016-03-03 09:34:13 -05:00
|
|
|
const LegGeometry &leg_geometry,
|
2016-03-21 13:07:28 -04:00
|
|
|
const std::size_t segment_index)
|
2016-03-03 09:34:13 -05:00
|
|
|
{
|
|
|
|
auto turn_index = leg_geometry.BackIndex(segment_index);
|
|
|
|
BOOST_ASSERT(turn_index > 0);
|
2016-03-21 13:07:28 -04:00
|
|
|
BOOST_ASSERT(turn_index + 1 < leg_geometry.locations.size());
|
2016-03-03 09:34:13 -05:00
|
|
|
|
|
|
|
// TODO chose a bigger look-a-head to smooth complex geometry
|
|
|
|
const auto pre_turn_coordinate = leg_geometry.locations[turn_index - 1];
|
|
|
|
const auto turn_coordinate = leg_geometry.locations[turn_index];
|
|
|
|
const auto post_turn_coordinate = leg_geometry.locations[turn_index + 1];
|
|
|
|
|
|
|
|
const double pre_turn_bearing =
|
|
|
|
util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate);
|
|
|
|
const double post_turn_bearing =
|
|
|
|
util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate);
|
|
|
|
|
2016-03-21 13:07:28 -04:00
|
|
|
return StepManeuver{turn_coordinate,
|
|
|
|
pre_turn_bearing,
|
|
|
|
post_turn_bearing,
|
|
|
|
instruction,
|
2016-03-22 08:40:13 -04:00
|
|
|
WaypointType::None,
|
2016-03-21 13:07:28 -04:00
|
|
|
INVALID_EXIT_NR,
|
|
|
|
INVALID_EXIT_NR};
|
2016-03-03 09:34:13 -05:00
|
|
|
}
|
|
|
|
} // ns detail
|
|
|
|
} // ns engine
|
|
|
|
} // ns guidance
|
|
|
|
} // ns detail
|