2016-03-01 16:30:31 -05:00
|
|
|
#ifndef OSRM_UTIL_GUIDANCE_TOOLKIT_HPP_
|
|
|
|
#define OSRM_UTIL_GUIDANCE_TOOLKIT_HPP_
|
|
|
|
|
|
|
|
#include "extractor/guidance/turn_instruction.hpp"
|
|
|
|
#include "util/bearing.hpp"
|
|
|
|
|
2016-04-14 04:41:56 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
2016-03-01 16:30:31 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
|
|
|
|
// Silent Turn Instructions are not to be mentioned to the outside world but
|
|
|
|
inline bool isSilent(const extractor::guidance::TurnInstruction instruction)
|
|
|
|
{
|
2016-03-03 09:36:03 -05:00
|
|
|
return instruction.type == extractor::guidance::TurnType::NoTurn ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::Suppressed ||
|
2016-03-01 16:30:31 -05:00
|
|
|
instruction.type == extractor::guidance::TurnType::StayOnRoundabout;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool entersRoundabout(const extractor::guidance::TurnInstruction instruction)
|
|
|
|
{
|
|
|
|
return (instruction.type == extractor::guidance::TurnType::EnterRoundabout ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterRotary ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterRoundaboutAtExit ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterRotaryAtExit ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool leavesRoundabout(const extractor::guidance::TurnInstruction instruction)
|
|
|
|
{
|
|
|
|
return (instruction.type == extractor::guidance::TurnType::ExitRoundabout ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::ExitRotary ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
|
|
|
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool staysOnRoundabout(const extractor::guidance::TurnInstruction instruction)
|
|
|
|
{
|
|
|
|
return instruction.type == extractor::guidance::TurnType::StayOnRoundabout;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline extractor::guidance::DirectionModifier angleToDirectionModifier(const double bearing)
|
|
|
|
{
|
|
|
|
if (bearing < 135)
|
|
|
|
{
|
|
|
|
return extractor::guidance::DirectionModifier::Right;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bearing <= 225)
|
|
|
|
{
|
|
|
|
return extractor::guidance::DirectionModifier::Straight;
|
|
|
|
}
|
|
|
|
return extractor::guidance::DirectionModifier::Left;
|
|
|
|
}
|
|
|
|
|
2016-04-14 04:41:56 -04:00
|
|
|
inline double angularDeviation(const double angle, const double from)
|
|
|
|
{
|
|
|
|
const double deviation = std::abs(angle - from);
|
|
|
|
return std::min(360 - deviation, deviation);
|
|
|
|
}
|
|
|
|
|
2016-03-01 16:30:31 -05:00
|
|
|
} // namespace guidance
|
|
|
|
} // namespace engine
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif /* OSRM_UTIL_GUIDANCE_TOOLKIT_HPP_ */
|