Make TurnInstructionsClass functions free standing functions
This commit is contained in:
parent
03f64a6c20
commit
f65dd63210
@ -254,7 +254,7 @@ ApiResponseGenerator<DataFacadeT>::BuildRouteSegments(const Segments &segment_li
|
||||
for (const auto &segment : segment_list.Get())
|
||||
{
|
||||
const auto current_turn = segment.turn_instruction;
|
||||
if (extractor::TurnInstructionsClass::TurnIsNecessary(current_turn) &&
|
||||
if (extractor::isTurnNecessary(current_turn) &&
|
||||
(extractor::TurnInstruction::EnterRoundAbout != current_turn))
|
||||
{
|
||||
|
||||
|
@ -47,7 +47,7 @@ inline util::json::Array AnnotateRoute(const std::vector<SegmentInformation> &ro
|
||||
{
|
||||
util::json::Array json_instruction_row;
|
||||
extractor::TurnInstruction current_instruction = segment.turn_instruction;
|
||||
if (extractor::TurnInstructionsClass::TurnIsNecessary(current_instruction))
|
||||
if (extractor::isTurnNecessary(current_instruction))
|
||||
{
|
||||
if (extractor::TurnInstruction::EnterRoundAbout == current_instruction)
|
||||
{
|
||||
|
@ -31,54 +31,50 @@ enum class TurnInstruction : unsigned char
|
||||
AccessRestrictionPenalty = 129
|
||||
};
|
||||
|
||||
struct TurnInstructionsClass
|
||||
// Translates between angles and their human-friendly directional representation
|
||||
inline TurnInstruction getTurnDirection(const double angle)
|
||||
{
|
||||
TurnInstructionsClass() = delete;
|
||||
TurnInstructionsClass(const TurnInstructionsClass &) = delete;
|
||||
|
||||
static inline TurnInstruction GetTurnDirectionOfInstruction(const double angle)
|
||||
if (angle >= 23 && angle < 67)
|
||||
{
|
||||
if (angle >= 23 && angle < 67)
|
||||
{
|
||||
return TurnInstruction::TurnSharpRight;
|
||||
}
|
||||
if (angle >= 67 && angle < 113)
|
||||
{
|
||||
return TurnInstruction::TurnRight;
|
||||
}
|
||||
if (angle >= 113 && angle < 158)
|
||||
{
|
||||
return TurnInstruction::TurnSlightRight;
|
||||
}
|
||||
if (angle >= 158 && angle < 202)
|
||||
{
|
||||
return TurnInstruction::GoStraight;
|
||||
}
|
||||
if (angle >= 202 && angle < 248)
|
||||
{
|
||||
return TurnInstruction::TurnSlightLeft;
|
||||
}
|
||||
if (angle >= 248 && angle < 292)
|
||||
{
|
||||
return TurnInstruction::TurnLeft;
|
||||
}
|
||||
if (angle >= 292 && angle < 336)
|
||||
{
|
||||
return TurnInstruction::TurnSharpLeft;
|
||||
}
|
||||
return TurnInstruction::UTurn;
|
||||
return TurnInstruction::TurnSharpRight;
|
||||
}
|
||||
|
||||
static inline bool TurnIsNecessary(const TurnInstruction turn_instruction)
|
||||
if (angle >= 67 && angle < 113)
|
||||
{
|
||||
if (TurnInstruction::NoTurn == turn_instruction ||
|
||||
TurnInstruction::StayOnRoundAbout == turn_instruction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return TurnInstruction::TurnRight;
|
||||
}
|
||||
};
|
||||
if (angle >= 113 && angle < 158)
|
||||
{
|
||||
return TurnInstruction::TurnSlightRight;
|
||||
}
|
||||
if (angle >= 158 && angle < 202)
|
||||
{
|
||||
return TurnInstruction::GoStraight;
|
||||
}
|
||||
if (angle >= 202 && angle < 248)
|
||||
{
|
||||
return TurnInstruction::TurnSlightLeft;
|
||||
}
|
||||
if (angle >= 248 && angle < 292)
|
||||
{
|
||||
return TurnInstruction::TurnLeft;
|
||||
}
|
||||
if (angle >= 292 && angle < 336)
|
||||
{
|
||||
return TurnInstruction::TurnSharpLeft;
|
||||
}
|
||||
return TurnInstruction::UTurn;
|
||||
}
|
||||
|
||||
// Decides if a turn is needed to be done for the current instruction
|
||||
inline bool isTurnNecessary(const TurnInstruction turn_instruction)
|
||||
{
|
||||
if (TurnInstruction::NoTurn == turn_instruction ||
|
||||
TurnInstruction::StayOnRoundAbout == turn_instruction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u,
|
||||
}
|
||||
}
|
||||
|
||||
return TurnInstructionsClass::GetTurnDirectionOfInstruction(angle);
|
||||
return getTurnDirection(angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user