Port OSRM, Engine and Datafacades to be algorithm aware

This commit is contained in:
Patrick Niklaus
2017-01-09 20:40:33 +00:00
committed by Patrick Niklaus
parent 71e95c92b6
commit 2fa8d0f534
47 changed files with 1384 additions and 1047 deletions
@@ -3,6 +3,8 @@
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/search_engine_data.hpp"
#include "util/integer_range.hpp"
@@ -27,9 +29,12 @@ const double constexpr VIAPATH_ALPHA = 0.10;
const double constexpr VIAPATH_EPSILON = 0.15; // alternative at most 15% longer
const double constexpr VIAPATH_GAMMA = 0.75; // alternative shares at most 75% with the shortest.
class AlternativeRouting final : private BasicRoutingInterface
template <typename AlgorithmT> class AlternativeRouting;
template <> class AlternativeRouting<algorithm::CH> final : private BasicRouting<algorithm::CH>
{
using super = BasicRoutingInterface;
using super = BasicRouting<algorithm::CH>;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using QueryHeap = SearchEngineData::QueryHeap;
using SearchSpaceEdge = std::pair<NodeID, NodeID>;
@@ -59,7 +64,7 @@ class AlternativeRouting final : private BasicRoutingInterface
virtual ~AlternativeRouting() {}
void operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void operator()(const FacadeT &facade,
const PhantomNodes &phantom_node_pair,
InternalRouteResult &raw_route_data);
@@ -77,17 +82,16 @@ class AlternativeRouting final : private BasicRoutingInterface
// compute and unpack <s,..,v> and <v,..,t> by exploring search spaces
// from v and intersecting against queues. only half-searches have to be
// done at this stage
void
ComputeLengthAndSharingOfViaPath(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
const NodeID via_node,
int *real_length_of_via_path,
int *sharing_of_via_path,
const std::vector<NodeID> &packed_shortest_path,
const EdgeWeight min_edge_offset);
void ComputeLengthAndSharingOfViaPath(const FacadeT &facade,
const NodeID via_node,
int *real_length_of_via_path,
int *sharing_of_via_path,
const std::vector<NodeID> &packed_shortest_path,
const EdgeWeight min_edge_offset);
// todo: reorder parameters
template <bool is_forward_directed>
void AlternativeRoutingStep(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void AlternativeRoutingStep(const FacadeT &facade,
QueryHeap &heap1,
QueryHeap &heap2,
NodeID *middle_node,
@@ -150,14 +154,14 @@ class AlternativeRouting final : private BasicRoutingInterface
}
}
for (auto edge : facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
const bool edge_is_forward_directed =
(is_forward_directed ? data.forward : data.backward);
if (edge_is_forward_directed)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
BOOST_ASSERT(edge_weight > 0);
@@ -181,7 +185,7 @@ class AlternativeRouting final : private BasicRoutingInterface
}
// conduct T-Test
bool ViaNodeCandidatePassesTTest(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
bool ViaNodeCandidatePassesTTest(const FacadeT &facade,
QueryHeap &existing_forward_heap,
QueryHeap &existing_reverse_heap,
QueryHeap &new_forward_heap,
@@ -1,15 +1,10 @@
#ifndef DIRECT_SHORTEST_PATH_HPP
#define DIRECT_SHORTEST_PATH_HPP
#include <boost/assert.hpp>
#include <iterator>
#include <memory>
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/search_engine_data.hpp"
#include "util/integer_range.hpp"
#include "util/timing_util.hpp"
#include "util/typedefs.hpp"
namespace osrm
@@ -19,15 +14,19 @@ namespace engine
namespace routing_algorithms
{
template <typename AlgorithmT> class DirectShortestPathRouting;
/// This is a striped down version of the general shortest path algorithm.
/// The general algorithm always computes two queries for each leg. This is only
/// necessary in case of vias, where the directions of the start node is constrainted
/// by the previous route.
/// This variation is only an optimazation for graphs with slow queries, for example
/// not fully contracted graphs.
class DirectShortestPathRouting final : public BasicRoutingInterface
template <>
class DirectShortestPathRouting<algorithm::CH> final : public BasicRouting<algorithm::CH>
{
using super = BasicRoutingInterface;
using super = BasicRouting<algorithm::CH>;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using QueryHeap = SearchEngineData::QueryHeap;
SearchEngineData &engine_working_data;
@@ -39,7 +38,7 @@ class DirectShortestPathRouting final : public BasicRoutingInterface
~DirectShortestPathRouting() {}
void operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void operator()(const FacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
InternalRouteResult &raw_route_data) const;
};
@@ -1,8 +1,9 @@
#ifndef MANY_TO_MANY_ROUTING_HPP
#define MANY_TO_MANY_ROUTING_HPP
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/search_engine_data.hpp"
#include "util/typedefs.hpp"
@@ -20,9 +21,12 @@ namespace engine
namespace routing_algorithms
{
class ManyToManyRouting final : public BasicRoutingInterface
template <typename AlgorithmT> class ManyToManyRouting;
template <> class ManyToManyRouting<algorithm::CH> final : public BasicRouting<algorithm::CH>
{
using super = BasicRoutingInterface;
using super = BasicRouting<algorithm::CH>;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using QueryHeap = SearchEngineData::ManyToManyQueryHeap;
SearchEngineData &engine_working_data;
@@ -46,13 +50,12 @@ class ManyToManyRouting final : public BasicRoutingInterface
{
}
std::vector<EdgeWeight>
operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices) const;
std::vector<EdgeWeight> operator()(const FacadeT &facade,
const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices) const;
void ForwardRoutingStep(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void ForwardRoutingStep(const FacadeT &facade,
const unsigned row_idx,
const unsigned number_of_targets,
QueryHeap &query_heap,
@@ -60,25 +63,25 @@ class ManyToManyRouting final : public BasicRoutingInterface
std::vector<EdgeWeight> &weights_table,
std::vector<EdgeWeight> &durations_table) const;
void BackwardRoutingStep(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void BackwardRoutingStep(const FacadeT &facade,
const unsigned column_idx,
QueryHeap &query_heap,
SearchSpaceWithBuckets &search_space_with_buckets) const;
template <bool forward_direction>
inline void RelaxOutgoingEdges(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
inline void RelaxOutgoingEdges(const FacadeT &facade,
const NodeID node,
const EdgeWeight weight,
const EdgeWeight duration,
QueryHeap &query_heap) const
{
for (auto edge : facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
const bool direction_flag = (forward_direction ? data.forward : data.backward);
if (direction_flag)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
const EdgeWeight edge_duration = data.duration;
@@ -104,18 +107,18 @@ class ManyToManyRouting final : public BasicRoutingInterface
// Stalling
template <bool forward_direction>
inline bool StallAtNode(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
inline bool StallAtNode(const FacadeT &facade,
const NodeID node,
const EdgeWeight weight,
QueryHeap &query_heap) const
{
for (auto edge : facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
const bool reverse_flag = ((!forward_direction) ? data.forward : data.backward);
if (reverse_flag)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
if (query_heap.WasInserted(to))
@@ -1,9 +1,9 @@
#ifndef MAP_MATCHING_HPP
#define MAP_MATCHING_HPP
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/map_matching/hidden_markov_model.hpp"
#include "engine/map_matching/matching_confidence.hpp"
#include "engine/map_matching/sub_matching.hpp"
@@ -37,11 +37,15 @@ using SubMatchingList = std::vector<map_matching::SubMatching>;
constexpr static const unsigned MAX_BROKEN_STATES = 10;
static const constexpr double MATCHING_BETA = 10;
constexpr static const double MAX_DISTANCE_DELTA = 2000.;
static const constexpr double DEFAULT_GPS_PRECISION = 5;
template <typename AlgorithmT> class MapMatching;
// implements a hidden markov model map matching algorithm
class MapMatching final : public BasicRoutingInterface
template <> class MapMatching<algorithm::CH> final : public BasicRouting<algorithm::CH>
{
using super = BasicRoutingInterface;
using super = BasicRouting<algorithm::CH>;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using QueryHeap = SearchEngineData::QueryHeap;
SearchEngineData &engine_working_data;
map_matching::EmissionLogProbability default_emission_log_probability;
@@ -52,15 +56,15 @@ class MapMatching final : public BasicRoutingInterface
unsigned GetMedianSampleTime(const std::vector<unsigned> &timestamps) const;
public:
MapMatching(SearchEngineData &engine_working_data, const double default_gps_precision)
MapMatching(SearchEngineData &engine_working_data)
: engine_working_data(engine_working_data),
default_emission_log_probability(default_gps_precision),
default_emission_log_probability(DEFAULT_GPS_PRECISION),
transition_log_probability(MATCHING_BETA)
{
}
SubMatchingList
operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
operator()(const FacadeT &facade,
const CandidateLists &candidates_list,
const std::vector<util::Coordinate> &trace_coordinates,
const std::vector<unsigned> &trace_timestamps,
@@ -2,10 +2,13 @@
#define ROUTING_BASE_HPP
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/datafacade/contiguous_internalmem_datafacade.hpp"
#include "engine/edge_unpacker.hpp"
#include "engine/internal_route_result.hpp"
#include "engine/search_engine_data.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/guidance/turn_bearing.hpp"
#include "util/typedefs.hpp"
@@ -32,10 +35,15 @@ namespace engine
namespace routing_algorithms
{
class BasicRoutingInterface
template <typename AlgorithmT> class BasicRouting;
// TODO: There is no reason these functions are contained in a class other then for namespace
// purposes. This should be a namespace with free functions.
template <> class BasicRouting<algorithm::CH>
{
protected:
using EdgeData = datafacade::BaseDataFacade::EdgeData;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using EdgeData = typename FacadeT::EdgeData;
public:
/*
@@ -67,7 +75,7 @@ class BasicRoutingInterface
Since we are dealing with a graph that contains _negative_ edges,
we need to add an offset to the termination criterion.
*/
void RoutingStep(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void RoutingStep(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
NodeID &middle_node_id,
@@ -78,17 +86,15 @@ class BasicRoutingInterface
const bool force_loop_forward,
const bool force_loop_reverse) const;
template <bool UseDuration>
EdgeWeight GetLoopWeight(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
NodeID node) const
template <bool UseDuration> EdgeWeight GetLoopWeight(const FacadeT &facade, NodeID node) const
{
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
for (auto edge : facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
if (data.forward)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
if (to == node)
{
const auto value = UseDuration ? data.duration : data.weight;
@@ -100,7 +106,7 @@ class BasicRoutingInterface
}
template <typename RandomIter>
void UnpackPath(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void UnpackPath(const FacadeT &facade,
RandomIter packed_path_begin,
RandomIter packed_path_end,
const PhantomNodes &phantom_node_pair,
@@ -120,7 +126,7 @@ class BasicRoutingInterface
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id);
UnpackCHPath(
*facade,
facade,
packed_path_begin,
packed_path_end,
[this,
@@ -132,14 +138,14 @@ class BasicRoutingInterface
const EdgeData &edge_data) {
BOOST_ASSERT_MSG(!edge_data.shortcut, "original edge flagged as shortcut");
const auto name_index = facade->GetNameIndexFromEdgeID(edge_data.id);
const auto turn_instruction = facade->GetTurnInstructionForEdgeID(edge_data.id);
const auto name_index = facade.GetNameIndexFromEdgeID(edge_data.id);
const auto turn_instruction = facade.GetTurnInstructionForEdgeID(edge_data.id);
const extractor::TravelMode travel_mode =
(unpacked_path.empty() && start_traversed_in_reverse)
? phantom_node_pair.source_phantom.backward_travel_mode
: facade->GetTravelModeForEdgeID(edge_data.id);
: facade.GetTravelModeForEdgeID(edge_data.id);
const auto geometry_index = facade->GetGeometryIndexForEdgeID(edge_data.id);
const auto geometry_index = facade.GetGeometryIndexForEdgeID(edge_data.id);
std::vector<NodeID> id_vector;
std::vector<EdgeWeight> weight_vector;
@@ -147,19 +153,17 @@ class BasicRoutingInterface
std::vector<DatasourceID> datasource_vector;
if (geometry_index.forward)
{
id_vector = facade->GetUncompressedForwardGeometry(geometry_index.id);
weight_vector = facade->GetUncompressedForwardWeights(geometry_index.id);
duration_vector = facade->GetUncompressedForwardDurations(geometry_index.id);
datasource_vector =
facade->GetUncompressedForwardDatasources(geometry_index.id);
id_vector = facade.GetUncompressedForwardGeometry(geometry_index.id);
weight_vector = facade.GetUncompressedForwardWeights(geometry_index.id);
duration_vector = facade.GetUncompressedForwardDurations(geometry_index.id);
datasource_vector = facade.GetUncompressedForwardDatasources(geometry_index.id);
}
else
{
id_vector = facade->GetUncompressedReverseGeometry(geometry_index.id);
weight_vector = facade->GetUncompressedReverseWeights(geometry_index.id);
duration_vector = facade->GetUncompressedReverseDurations(geometry_index.id);
datasource_vector =
facade->GetUncompressedReverseDatasources(geometry_index.id);
id_vector = facade.GetUncompressedReverseGeometry(geometry_index.id);
weight_vector = facade.GetUncompressedReverseWeights(geometry_index.id);
duration_vector = facade.GetUncompressedReverseDurations(geometry_index.id);
datasource_vector = facade.GetUncompressedReverseDatasources(geometry_index.id);
}
BOOST_ASSERT(id_vector.size() > 0);
BOOST_ASSERT(datasource_vector.size() > 0);
@@ -194,17 +198,17 @@ class BasicRoutingInterface
util::guidance::TurnBearing(0)});
}
BOOST_ASSERT(unpacked_path.size() > 0);
if (facade->hasLaneData(edge_data.id))
unpacked_path.back().lane_data = facade->GetLaneData(edge_data.id);
if (facade.hasLaneData(edge_data.id))
unpacked_path.back().lane_data = facade.GetLaneData(edge_data.id);
unpacked_path.back().entry_classid = facade->GetEntryClassID(edge_data.id);
unpacked_path.back().entry_classid = facade.GetEntryClassID(edge_data.id);
unpacked_path.back().turn_instruction = turn_instruction;
unpacked_path.back().duration_until_turn +=
facade->GetDurationPenaltyForEdgeID(edge_data.id);
facade.GetDurationPenaltyForEdgeID(edge_data.id);
unpacked_path.back().weight_until_turn +=
facade->GetWeightPenaltyForEdgeID(edge_data.id);
unpacked_path.back().pre_turn_bearing = facade->PreTurnBearing(edge_data.id);
unpacked_path.back().post_turn_bearing = facade->PostTurnBearing(edge_data.id);
facade.GetWeightPenaltyForEdgeID(edge_data.id);
unpacked_path.back().pre_turn_bearing = facade.PreTurnBearing(edge_data.id);
unpacked_path.back().post_turn_bearing = facade.PostTurnBearing(edge_data.id);
});
std::size_t start_index = 0, end_index = 0;
@@ -218,16 +222,16 @@ class BasicRoutingInterface
if (target_traversed_in_reverse)
{
id_vector = facade->GetUncompressedReverseGeometry(
id_vector = facade.GetUncompressedReverseGeometry(
phantom_node_pair.target_phantom.packed_geometry_id);
weight_vector = facade->GetUncompressedReverseWeights(
weight_vector = facade.GetUncompressedReverseWeights(
phantom_node_pair.target_phantom.packed_geometry_id);
duration_vector = facade->GetUncompressedReverseDurations(
duration_vector = facade.GetUncompressedReverseDurations(
phantom_node_pair.target_phantom.packed_geometry_id);
datasource_vector = facade->GetUncompressedReverseDatasources(
datasource_vector = facade.GetUncompressedReverseDatasources(
phantom_node_pair.target_phantom.packed_geometry_id);
if (is_local_path)
@@ -246,16 +250,16 @@ class BasicRoutingInterface
}
end_index = phantom_node_pair.target_phantom.fwd_segment_position;
id_vector = facade->GetUncompressedForwardGeometry(
id_vector = facade.GetUncompressedForwardGeometry(
phantom_node_pair.target_phantom.packed_geometry_id);
weight_vector = facade->GetUncompressedForwardWeights(
weight_vector = facade.GetUncompressedForwardWeights(
phantom_node_pair.target_phantom.packed_geometry_id);
duration_vector = facade->GetUncompressedForwardDurations(
duration_vector = facade.GetUncompressedForwardDurations(
phantom_node_pair.target_phantom.packed_geometry_id);
datasource_vector = facade->GetUncompressedForwardDatasources(
datasource_vector = facade.GetUncompressedForwardDatasources(
phantom_node_pair.target_phantom.packed_geometry_id);
}
@@ -339,7 +343,7 @@ class BasicRoutingInterface
* @param to the node the CH edge finishes at
* @param unpacked_path the sequence of original NodeIDs that make up the expanded CH edge
*/
void UnpackEdge(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void UnpackEdge(const FacadeT &facade,
const NodeID from,
const NodeID to,
std::vector<NodeID> &unpacked_path) const;
@@ -365,7 +369,7 @@ class BasicRoutingInterface
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void Search(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void Search(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
std::int32_t &weight,
@@ -383,7 +387,7 @@ class BasicRoutingInterface
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void SearchWithCore(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void SearchWithCore(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
@@ -400,7 +404,7 @@ class BasicRoutingInterface
bool NeedsLoopBackwards(const PhantomNode &source_phantom,
const PhantomNode &target_phantom) const;
double GetPathDistance(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
double GetPathDistance(const FacadeT &facade,
const std::vector<NodeID> &packed_path,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom) const;
@@ -408,20 +412,19 @@ class BasicRoutingInterface
// Requires the heaps for be empty
// If heaps should be adjusted to be initialized outside of this function,
// the addition of force_loop parameters might be required
double
GetNetworkDistanceWithCore(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
int duration_upper_bound = INVALID_EDGE_WEIGHT) const;
double GetNetworkDistanceWithCore(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
int duration_upper_bound = INVALID_EDGE_WEIGHT) const;
// Requires the heaps for be empty
// If heaps should be adjusted to be initialized outside of this function,
// the addition of force_loop parameters might be required
double GetNetworkDistance(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
double GetNetworkDistance(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
const PhantomNode &source_phantom,
@@ -1,13 +1,11 @@
#ifndef SHORTEST_PATH_HPP
#define SHORTEST_PATH_HPP
#include "util/typedefs.hpp"
#include "engine/algorithm.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/search_engine_data.hpp"
#include "util/integer_range.hpp"
#include "util/typedefs.hpp"
#include <boost/assert.hpp>
#include <boost/optional.hpp>
@@ -20,9 +18,12 @@ namespace engine
namespace routing_algorithms
{
class ShortestPathRouting final : public BasicRoutingInterface
template <typename AlgorithmT> class ShortestPathRouting;
template <> class ShortestPathRouting<algorithm::CH> final : public BasicRouting<algorithm::CH>
{
using super = BasicRoutingInterface;
using super = BasicRouting<algorithm::CH>;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using QueryHeap = SearchEngineData::QueryHeap;
SearchEngineData &engine_working_data;
const static constexpr bool DO_NOT_FORCE_LOOP = false;
@@ -37,7 +38,7 @@ class ShortestPathRouting final : public BasicRoutingInterface
// allows a uturn at the target_phantom
// searches source forward/reverse -> target forward/reverse
void SearchWithUTurn(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void SearchWithUTurn(const FacadeT &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
@@ -56,7 +57,7 @@ class ShortestPathRouting final : public BasicRoutingInterface
// searches shortest path between:
// source forward/reverse -> target forward
// source forward/reverse -> target reverse
void Search(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void Search(const FacadeT &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
@@ -74,14 +75,14 @@ class ShortestPathRouting final : public BasicRoutingInterface
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse) const;
void UnpackLegs(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void UnpackLegs(const FacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const std::vector<NodeID> &total_packed_path,
const std::vector<std::size_t> &packed_leg_begin,
const int shortest_path_length,
InternalRouteResult &raw_route_data) const;
void operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
void operator()(const FacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const boost::optional<bool> continue_straight_at_waypoint,
InternalRouteResult &raw_route_data) const;
@@ -0,0 +1,46 @@
#ifndef OSRM_ENGINE_ROUTING_ALGORITHMS_TILE_TURNS_HPP
#define OSRM_ENGINE_ROUTING_ALGORITHMS_TILE_TURNS_HPP
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/search_engine_data.hpp"
#include "util/typedefs.hpp"
namespace osrm
{
namespace engine
{
namespace routing_algorithms
{
template <typename AlgorithmT> class TileTurns;
// Used to accumulate all the information we want in the tile about a turn.
struct TurnData final
{
const util::Coordinate coordinate;
const int in_angle;
const int turn_angle;
const int weight;
};
/// This class is used to extract turn information for the tile plugin from a CH graph
template <> class TileTurns<algorithm::CH> final : public BasicRouting<algorithm::CH>
{
using super = BasicRouting<algorithm::CH>;
using FacadeT = datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH>;
using RTreeLeaf = datafacade::BaseDataFacade::RTreeLeaf;
public:
std::vector<TurnData> operator()(const FacadeT &facade,
const std::vector<RTreeLeaf> &edges,
const std::vector<std::size_t> &sorted_edge_indexes) const;
};
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
#endif