refactor guidance

This commit is contained in:
Moritz Kobitzsch
2016-04-11 12:51:06 +02:00
committed by Patrick Niklaus
parent e04baef3bb
commit d770c35245
16 changed files with 257 additions and 502 deletions
@@ -2,6 +2,8 @@
#include "extractor/guidance/intersection_handler.hpp"
#include "extractor/guidance/toolkit.hpp"
#include "util/simple_logger.hpp"
#include <algorithm>
using EdgeData = osrm::util::NodeBasedDynamicGraph::EdgeData;
@@ -283,6 +285,47 @@ void IntersectionHandler::assignFork(const EdgeID via_edge,
}
}
void IntersectionHandler::assignTrivialTurns(const EdgeID via_eid,
Intersection &intersection,
const std::size_t begin,
const std::size_t end) const
{
for (std::size_t index = begin; index != end; ++index)
if (intersection[index].entry_allowed)
intersection[index].turn.instruction = {
findBasicTurnType(via_eid, intersection[index]),
getTurnDirection(intersection[index].turn.angle)};
}
void IntersectionHandler::assignCountingTurns(const EdgeID via_eid,
Intersection &intersection,
const std::size_t begin,
const std::size_t end,
const DirectionModifier modifier) const
{
const constexpr TurnType turns[] = {TurnType::FirstTurn, TurnType::SecondTurn,
TurnType::ThirdTurn, TurnType::FourthTurn};
const constexpr TurnType ramps[] = {TurnType::FirstRamp, TurnType::SecondRamp,
TurnType::ThirdRamp, TurnType::FourthRamp};
const std::size_t length = end > begin ? end - begin : begin - end;
if (length > 4)
{
util::SimpleLogger().Write(logDEBUG) << "Counting Turn assignment called for " << length
<< " turns. Supports at most four turns.";
}
// counting turns varies whether we consider left/right turns
for (std::size_t index = begin, count = 0; index != end;
count++, begin < end ? ++index : --index)
{
if (TurnType::Ramp == findBasicTurnType(via_eid, intersection[index]))
intersection[index].turn.instruction = {ramps[count], modifier};
else
intersection[index].turn.instruction = {turns[count], modifier};
}
}
bool IntersectionHandler::isThroughStreet(const std::size_t index,
const Intersection &intersection) const
{