2016-02-24 04:29:23 -05:00
|
|
|
#ifndef OSRM_GUIDANCE_TURN_INSTRUCTION_HPP_
|
|
|
|
#define OSRM_GUIDANCE_TURN_INSTRUCTION_HPP_
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
2016-03-01 16:30:31 -05:00
|
|
|
namespace extractor
|
2016-02-24 04:29:23 -05:00
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
// inclusive bounds for turn modifiers
|
|
|
|
const constexpr uint8_t num_direction_modifiers = 8;
|
|
|
|
} // detail
|
|
|
|
|
|
|
|
// direction modifiers based on angle
|
|
|
|
// Would be nice to have
|
|
|
|
// enum class DirectionModifier : unsigned char
|
|
|
|
enum DirectionModifier
|
|
|
|
{
|
|
|
|
UTurn,
|
|
|
|
SharpRight,
|
|
|
|
Right,
|
|
|
|
SlightRight,
|
|
|
|
Straight,
|
|
|
|
SlightLeft,
|
|
|
|
Left,
|
|
|
|
SharpLeft
|
|
|
|
};
|
|
|
|
|
|
|
|
// enum class TurnType : unsigned char
|
|
|
|
enum TurnType // at the moment we can support 32 turn types, without increasing memory consumption
|
|
|
|
{
|
|
|
|
Invalid, // no valid turn instruction
|
2016-03-10 05:22:45 -05:00
|
|
|
NoTurn, // end of segment without turn/middle of a segment
|
2016-02-24 04:29:23 -05:00
|
|
|
Suppressed, // location that suppresses a turn
|
|
|
|
NewName, // no turn, but name changes
|
|
|
|
Continue, // remain on a street
|
|
|
|
Turn, // basic turn
|
|
|
|
Merge, // merge onto a street
|
|
|
|
Ramp, // special turn (highway ramp exits)
|
|
|
|
Fork, // fork road splitting up
|
|
|
|
EndOfRoad, // T intersection
|
|
|
|
EnterRoundabout, // Entering a small Roundabout
|
|
|
|
EnterRoundaboutAtExit, // Entering a small Roundabout at a countable exit
|
2016-02-25 12:31:29 -05:00
|
|
|
EnterAndExitRoundabout, // Touching a roundabout
|
2016-02-24 04:29:23 -05:00
|
|
|
ExitRoundabout, // Exiting a small Roundabout
|
|
|
|
EnterRotary, // Enter a rotary
|
|
|
|
EnterRotaryAtExit, // Enter A Rotary at a countable exit
|
2016-02-25 12:31:29 -05:00
|
|
|
EnterAndExitRotary, // Touching a rotary
|
2016-02-24 04:29:23 -05:00
|
|
|
ExitRotary, // Exit a rotary
|
|
|
|
StayOnRoundabout, // Continue on Either a small or a large Roundabout
|
|
|
|
Restriction, // Cross a Barrier, requires barrier penalties instead of full block
|
|
|
|
Notification // Travel Mode Changes`
|
|
|
|
};
|
|
|
|
|
|
|
|
// turn angle in 1.40625 degree -> 128 == 180 degree
|
|
|
|
struct TurnInstruction
|
|
|
|
{
|
|
|
|
TurnInstruction(const TurnType type = TurnType::Invalid,
|
|
|
|
const DirectionModifier direction_modifier = DirectionModifier::Straight)
|
|
|
|
: type(type), direction_modifier(direction_modifier)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TurnType type : 5;
|
|
|
|
DirectionModifier direction_modifier : 3;
|
|
|
|
|
|
|
|
static TurnInstruction INVALID()
|
|
|
|
{
|
|
|
|
return TurnInstruction(TurnType::Invalid, DirectionModifier::UTurn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static TurnInstruction NO_TURN()
|
|
|
|
{
|
2016-03-01 09:26:13 -05:00
|
|
|
return TurnInstruction(TurnType::NoTurn, DirectionModifier::UTurn);
|
2016-02-24 04:29:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static TurnInstruction REMAIN_ROUNDABOUT(const DirectionModifier modifier)
|
|
|
|
{
|
|
|
|
return TurnInstruction(TurnType::StayOnRoundabout, modifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static TurnInstruction ENTER_ROUNDABOUT(const DirectionModifier modifier)
|
|
|
|
{
|
2016-03-01 16:30:31 -05:00
|
|
|
return TurnInstruction(TurnType::EnterRoundabout, modifier);
|
2016-02-24 04:29:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static TurnInstruction EXIT_ROUNDABOUT(const DirectionModifier modifier)
|
|
|
|
{
|
|
|
|
return TurnInstruction(TurnType::ExitRoundabout, modifier);
|
|
|
|
}
|
2016-03-01 09:26:13 -05:00
|
|
|
|
|
|
|
static TurnInstruction SUPPRESSED(const DirectionModifier modifier)
|
|
|
|
{
|
2016-03-01 16:30:31 -05:00
|
|
|
return TurnInstruction{TurnType::Suppressed, modifier};
|
2016-03-01 09:26:13 -05:00
|
|
|
}
|
2016-02-24 04:29:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator!=(const TurnInstruction lhs, const TurnInstruction rhs)
|
|
|
|
{
|
|
|
|
return lhs.type != rhs.type || lhs.direction_modifier != rhs.direction_modifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator==(const TurnInstruction lhs, const TurnInstruction rhs)
|
|
|
|
{
|
|
|
|
return lhs.type == rhs.type && lhs.direction_modifier == rhs.direction_modifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace guidance
|
2016-03-01 16:30:31 -05:00
|
|
|
} // namespace extractor
|
2016-02-24 04:29:23 -05:00
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif // OSRM_GUIDANCE_TURN_INSTRUCTION_HPP_
|