2016-03-03 09:34:13 -05:00
|
|
|
#include "engine/guidance/assemble_steps.hpp"
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
2017-08-28 12:03:51 -04:00
|
|
|
#include "util/bearing.hpp"
|
|
|
|
#include "util/log.hpp"
|
|
|
|
|
2016-05-10 02:37:45 -04:00
|
|
|
#include <cmath>
|
2016-03-03 09:34:13 -05:00
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
namespace detail
|
|
|
|
{
|
2016-05-10 02:37:45 -04:00
|
|
|
|
2017-08-28 12:03:51 -04:00
|
|
|
std::pair<short, short> getDepartBearings(const LegGeometry &leg_geometry,
|
|
|
|
const PhantomNode &source_node,
|
|
|
|
const bool traversed_in_reverse)
|
2016-05-10 02:37:45 -04:00
|
|
|
{
|
|
|
|
BOOST_ASSERT(leg_geometry.locations.size() >= 2);
|
|
|
|
const auto turn_coordinate = leg_geometry.locations.front();
|
|
|
|
const auto post_turn_coordinate = *(leg_geometry.locations.begin() + 1);
|
2017-08-28 12:03:51 -04:00
|
|
|
|
|
|
|
if (turn_coordinate == post_turn_coordinate)
|
|
|
|
{
|
|
|
|
return std::make_pair<short, short>(0, source_node.GetBearing(traversed_in_reverse));
|
|
|
|
}
|
2016-05-18 11:53:05 -04:00
|
|
|
return std::make_pair<short, short>(
|
2016-05-27 15:05:04 -04:00
|
|
|
0,
|
|
|
|
std::round(util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate)));
|
2016-05-10 02:37:45 -04:00
|
|
|
}
|
2016-03-03 09:34:13 -05:00
|
|
|
|
2017-08-28 12:03:51 -04:00
|
|
|
std::pair<short, short> getArriveBearings(const LegGeometry &leg_geometry,
|
|
|
|
const PhantomNode &target_node,
|
|
|
|
const bool traversed_in_reverse)
|
2016-05-10 02:37:45 -04:00
|
|
|
{
|
|
|
|
BOOST_ASSERT(leg_geometry.locations.size() >= 2);
|
|
|
|
const auto turn_coordinate = leg_geometry.locations.back();
|
|
|
|
const auto pre_turn_coordinate = *(leg_geometry.locations.end() - 2);
|
2017-08-28 12:03:51 -04:00
|
|
|
if (turn_coordinate == pre_turn_coordinate)
|
|
|
|
{
|
|
|
|
return std::make_pair<short, short>(target_node.GetBearing(traversed_in_reverse), 0);
|
|
|
|
}
|
2016-05-18 11:53:05 -04:00
|
|
|
return std::make_pair<short, short>(
|
|
|
|
std::round(util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate)), 0);
|
2016-03-03 09:34:13 -05:00
|
|
|
}
|
|
|
|
} // ns detail
|
|
|
|
} // ns engine
|
|
|
|
} // ns guidance
|
|
|
|
} // ns detail
|