2016-04-08 06:49:14 -04:00
|
|
|
#include "extractor/guidance/intersection.hpp"
|
2016-05-13 13:18:00 -04:00
|
|
|
#include "extractor/guidance/toolkit.hpp"
|
2016-04-08 06:49:14 -04:00
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
|
|
|
|
ConnectedRoad::ConnectedRoad(const TurnOperation turn, const bool entry_allowed)
|
|
|
|
: entry_allowed(entry_allowed), turn(turn)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString(const ConnectedRoad &road)
|
|
|
|
{
|
|
|
|
std::string result = "[connection] ";
|
|
|
|
result += std::to_string(road.turn.eid);
|
|
|
|
result += " allows entry: ";
|
|
|
|
result += std::to_string(road.entry_allowed);
|
|
|
|
result += " angle: ";
|
|
|
|
result += std::to_string(road.turn.angle);
|
|
|
|
result += " instruction: ";
|
2016-06-15 08:38:24 -04:00
|
|
|
result += std::to_string(static_cast<std::int32_t>(road.turn.instruction.type)) + " " +
|
|
|
|
std::to_string(static_cast<std::int32_t>(road.turn.instruction.direction_modifier)) +
|
|
|
|
" " + std::to_string(static_cast<std::int32_t>(road.turn.lane_data_id));
|
2016-04-08 06:49:14 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-13 13:18:00 -04:00
|
|
|
Intersection::iterator findClosestTurn(Intersection &intersection, const double angle)
|
|
|
|
{
|
|
|
|
return std::min_element(intersection.begin(),
|
|
|
|
intersection.end(),
|
|
|
|
[angle](const ConnectedRoad &lhs, const ConnectedRoad &rhs) {
|
|
|
|
return angularDeviation(lhs.turn.angle, angle) <
|
|
|
|
angularDeviation(rhs.turn.angle, angle);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
Intersection::const_iterator findClosestTurn(const Intersection &intersection, const double angle)
|
|
|
|
{
|
|
|
|
return std::min_element(intersection.cbegin(),
|
|
|
|
intersection.cend(),
|
|
|
|
[angle](const ConnectedRoad &lhs, const ConnectedRoad &rhs) {
|
|
|
|
return angularDeviation(lhs.turn.angle, angle) <
|
|
|
|
angularDeviation(rhs.turn.angle, angle);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-08 06:49:14 -04:00
|
|
|
} // namespace guidance
|
|
|
|
} // namespace extractor
|
|
|
|
} // namespace osrm
|