Make TurnInstructionsClass functions free standing functions

This commit is contained in:
Daniel J. Hofmann 2016-01-08 22:37:25 +01:00 committed by Patrick Niklaus
parent 03f64a6c20
commit f65dd63210
4 changed files with 42 additions and 46 deletions

View File

@ -254,7 +254,7 @@ ApiResponseGenerator<DataFacadeT>::BuildRouteSegments(const Segments &segment_li
for (const auto &segment : segment_list.Get()) for (const auto &segment : segment_list.Get())
{ {
const auto current_turn = segment.turn_instruction; const auto current_turn = segment.turn_instruction;
if (extractor::TurnInstructionsClass::TurnIsNecessary(current_turn) && if (extractor::isTurnNecessary(current_turn) &&
(extractor::TurnInstruction::EnterRoundAbout != current_turn)) (extractor::TurnInstruction::EnterRoundAbout != current_turn))
{ {

View File

@ -47,7 +47,7 @@ inline util::json::Array AnnotateRoute(const std::vector<SegmentInformation> &ro
{ {
util::json::Array json_instruction_row; util::json::Array json_instruction_row;
extractor::TurnInstruction current_instruction = segment.turn_instruction; extractor::TurnInstruction current_instruction = segment.turn_instruction;
if (extractor::TurnInstructionsClass::TurnIsNecessary(current_instruction)) if (extractor::isTurnNecessary(current_instruction))
{ {
if (extractor::TurnInstruction::EnterRoundAbout == current_instruction) if (extractor::TurnInstruction::EnterRoundAbout == current_instruction)
{ {

View File

@ -31,13 +31,9 @@ enum class TurnInstruction : unsigned char
AccessRestrictionPenalty = 129 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; return TurnInstruction::TurnSharpRight;
@ -67,18 +63,18 @@ struct TurnInstructionsClass
return TurnInstruction::TurnSharpLeft; return TurnInstruction::TurnSharpLeft;
} }
return TurnInstruction::UTurn; return TurnInstruction::UTurn;
} }
static inline bool TurnIsNecessary(const TurnInstruction turn_instruction) // 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 || if (TurnInstruction::NoTurn == turn_instruction ||
TurnInstruction::StayOnRoundAbout == turn_instruction) TurnInstruction::StayOnRoundAbout == turn_instruction)
{ {
return false; return false;
} }
return true; return true;
} }
};
} }
} }

View File

@ -683,7 +683,7 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u,
} }
} }
return TurnInstructionsClass::GetTurnDirectionOfInstruction(angle); return getTurnDirection(angle);
} }
} }
} }