pull in intersection finder accumulator

This commit is contained in:
Moritz Kobitzsch
2016-11-04 12:04:07 +01:00
committed by Daniel J. H
parent b108d8ea21
commit 2fb40944bf
2 changed files with 59 additions and 1 deletions
@@ -11,6 +11,7 @@
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <cstdint>
#include <utility>
namespace osrm
@@ -89,7 +90,7 @@ struct LengthLimitedCoordinateAccumulator
};
/*
* The FollowRoadNameSelector tries to follow a given name along a route. We offer methods to skip
* The SelectRoadByNameOnlyChoiceAndStraightness tries to follow a given name along a route. We offer methods to skip
* over bridges/similar situations if desired, following narrow turns
* This struct offers an example implementation of a possible road selector for traversing the
* node-based graph using the NodeBasedGraphWalker
@@ -114,6 +115,32 @@ struct SelectRoadByNameOnlyChoiceAndStraightness
const bool requires_entry;
};
// find the next intersection given a hop limit
struct IntersectionFinderAccumulator
{
IntersectionFinderAccumulator(const std::uint8_t hop_limit, const IntersectionGenerator &intersection_generator);
// true if the path has traversed enough distance
bool terminate();
// update the accumulator
void update(const NodeID from_node,
const EdgeID via_edge,
const NodeID to_node);
std::uint8_t hops;
const std::uint8_t hop_limit;
// we need to be able to look-up the intersection
const IntersectionGenerator &intersection_generator;
// the result we are looking for
NodeID nid;
EdgeID via_edge_id;
Intersection intersection;
};
template <class accumulator_type, class selector_type>
boost::optional<std::pair<NodeID, EdgeID>>
NodeBasedGraphWalker::TraverseRoad(NodeID current_node_id,