2017-01-09 15:40:33 -05:00
|
|
|
#ifndef OSRM_ENGINE_ROUTING_ALGORITHM_HPP
|
|
|
|
#define OSRM_ENGINE_ROUTING_ALGORITHM_HPP
|
|
|
|
|
|
|
|
#include "engine/algorithm.hpp"
|
|
|
|
#include "engine/internal_route_result.hpp"
|
|
|
|
#include "engine/phantom_node.hpp"
|
|
|
|
#include "engine/routing_algorithms/alternative_path.hpp"
|
|
|
|
#include "engine/routing_algorithms/direct_shortest_path.hpp"
|
|
|
|
#include "engine/routing_algorithms/many_to_many.hpp"
|
|
|
|
#include "engine/routing_algorithms/map_matching.hpp"
|
|
|
|
#include "engine/routing_algorithms/shortest_path.hpp"
|
|
|
|
#include "engine/routing_algorithms/tile_turns.hpp"
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
|
|
|
|
class RoutingAlgorithmsInterface
|
|
|
|
{
|
|
|
|
public:
|
2017-05-11 12:44:48 -04:00
|
|
|
virtual InternalManyRoutesResult
|
2017-04-06 08:28:43 -04:00
|
|
|
AlternativePathSearch(const PhantomNodes &phantom_node_pair,
|
|
|
|
unsigned number_of_alternatives) const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-02-24 20:24:21 -05:00
|
|
|
virtual InternalRouteResult
|
2017-02-24 21:22:17 -05:00
|
|
|
ShortestPathSearch(const std::vector<PhantomNodes> &phantom_node_pair,
|
2017-02-25 00:13:38 -05:00
|
|
|
const boost::optional<bool> continue_straight_at_waypoint) const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-02-24 20:24:21 -05:00
|
|
|
virtual InternalRouteResult
|
2017-02-25 00:13:38 -05:00
|
|
|
DirectShortestPathSearch(const PhantomNodes &phantom_node_pair) const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
virtual std::vector<EdgeWeight>
|
2017-02-24 21:22:17 -05:00
|
|
|
ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
|
2017-02-25 00:13:38 -05:00
|
|
|
const std::vector<std::size_t> &source_indices,
|
|
|
|
const std::vector<std::size_t> &target_indices) const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
virtual routing_algorithms::SubMatchingList
|
|
|
|
MapMatching(const routing_algorithms::CandidateLists &candidates_list,
|
|
|
|
const std::vector<util::Coordinate> &trace_coordinates,
|
|
|
|
const std::vector<unsigned> &trace_timestamps,
|
2017-03-06 08:11:38 -05:00
|
|
|
const std::vector<boost::optional<double>> &trace_gps_precision,
|
2017-03-20 06:30:24 -04:00
|
|
|
const bool allow_splitting) const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
virtual std::vector<routing_algorithms::TurnData>
|
2017-02-24 21:22:17 -05:00
|
|
|
GetTileTurns(const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &edges,
|
2017-02-25 00:13:38 -05:00
|
|
|
const std::vector<std::size_t> &sorted_edge_indexes) const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-02-24 21:22:17 -05:00
|
|
|
virtual bool HasAlternativePathSearch() const = 0;
|
|
|
|
virtual bool HasShortestPathSearch() const = 0;
|
|
|
|
virtual bool HasDirectShortestPathSearch() const = 0;
|
|
|
|
virtual bool HasMapMatching() const = 0;
|
|
|
|
virtual bool HasManyToManySearch() const = 0;
|
|
|
|
virtual bool HasGetTileTurns() const = 0;
|
2017-01-09 15:40:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Short-lived object passed to each plugin in request to wrap routing algorithms
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgorithmsInterface
|
2017-01-09 15:40:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2017-04-12 02:22:28 -04:00
|
|
|
RoutingAlgorithms(SearchEngineData<Algorithm> &heaps,
|
2017-04-03 13:15:58 -04:00
|
|
|
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade)
|
2017-02-24 20:24:21 -05:00
|
|
|
: heaps(heaps), facade(facade)
|
2017-01-09 15:40:33 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-28 18:43:11 -05:00
|
|
|
virtual ~RoutingAlgorithms() = default;
|
|
|
|
|
2017-05-11 12:44:48 -04:00
|
|
|
InternalManyRoutesResult
|
2017-04-06 08:28:43 -04:00
|
|
|
AlternativePathSearch(const PhantomNodes &phantom_node_pair,
|
|
|
|
unsigned number_of_alternatives) const final override;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-02-25 00:13:38 -05:00
|
|
|
InternalRouteResult ShortestPathSearch(
|
|
|
|
const std::vector<PhantomNodes> &phantom_node_pair,
|
2017-03-01 17:55:18 -05:00
|
|
|
const boost::optional<bool> continue_straight_at_waypoint) const final override;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-02-25 00:13:38 -05:00
|
|
|
InternalRouteResult
|
2017-03-01 17:55:18 -05:00
|
|
|
DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const final override;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
std::vector<EdgeWeight>
|
2017-02-24 21:22:17 -05:00
|
|
|
ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
|
2017-02-25 00:13:38 -05:00
|
|
|
const std::vector<std::size_t> &source_indices,
|
2017-03-01 17:55:18 -05:00
|
|
|
const std::vector<std::size_t> &target_indices) const final override;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-03-14 07:35:56 -04:00
|
|
|
routing_algorithms::SubMatchingList
|
|
|
|
MapMatching(const routing_algorithms::CandidateLists &candidates_list,
|
|
|
|
const std::vector<util::Coordinate> &trace_coordinates,
|
|
|
|
const std::vector<unsigned> &trace_timestamps,
|
|
|
|
const std::vector<boost::optional<double>> &trace_gps_precision,
|
2017-03-20 06:30:24 -04:00
|
|
|
const bool allow_splitting) const final override;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
std::vector<routing_algorithms::TurnData>
|
2017-02-24 21:22:17 -05:00
|
|
|
GetTileTurns(const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &edges,
|
2017-03-01 17:55:18 -05:00
|
|
|
const std::vector<std::size_t> &sorted_edge_indexes) const final override;
|
2017-01-09 15:40:33 -05:00
|
|
|
|
2017-02-24 21:22:17 -05:00
|
|
|
bool HasAlternativePathSearch() const final override
|
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::HasAlternativePathSearch<Algorithm>::value;
|
2017-02-24 21:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasShortestPathSearch() const final override
|
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::HasShortestPathSearch<Algorithm>::value;
|
2017-02-24 21:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasDirectShortestPathSearch() const final override
|
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::HasDirectShortestPathSearch<Algorithm>::value;
|
2017-02-24 21:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasMapMatching() const final override
|
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::HasMapMatching<Algorithm>::value;
|
2017-02-24 21:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasManyToManySearch() const final override
|
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::HasManyToManySearch<Algorithm>::value;
|
2017-02-24 21:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasGetTileTurns() const final override
|
2017-01-09 15:40:33 -05:00
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::HasGetTileTurns<Algorithm>::value;
|
2017-02-24 20:24:21 -05:00
|
|
|
}
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
private:
|
2017-04-12 02:22:28 -04:00
|
|
|
SearchEngineData<Algorithm> &heaps;
|
2017-04-11 15:22:07 -04:00
|
|
|
|
2017-01-09 15:40:33 -05:00
|
|
|
// Owned by shared-ptr passed to the query
|
2017-04-03 13:15:58 -04:00
|
|
|
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade;
|
2017-01-09 15:40:33 -05:00
|
|
|
};
|
2017-03-01 17:55:18 -05:00
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm>
|
2017-05-11 12:44:48 -04:00
|
|
|
InternalManyRoutesResult
|
2017-04-06 08:28:43 -04:00
|
|
|
RoutingAlgorithms<Algorithm>::AlternativePathSearch(const PhantomNodes &phantom_node_pair,
|
|
|
|
unsigned number_of_alternatives) const
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
2017-04-06 08:28:43 -04:00
|
|
|
return routing_algorithms::alternativePathSearch(
|
|
|
|
heaps, facade, phantom_node_pair, number_of_alternatives);
|
2017-03-01 17:55:18 -05:00
|
|
|
}
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm>
|
|
|
|
InternalRouteResult RoutingAlgorithms<Algorithm>::ShortestPathSearch(
|
2017-03-01 17:55:18 -05:00
|
|
|
const std::vector<PhantomNodes> &phantom_node_pair,
|
|
|
|
const boost::optional<bool> continue_straight_at_waypoint) const
|
|
|
|
{
|
|
|
|
return routing_algorithms::shortestPathSearch(
|
|
|
|
heaps, facade, phantom_node_pair, continue_straight_at_waypoint);
|
|
|
|
}
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm>
|
2017-03-01 17:55:18 -05:00
|
|
|
InternalRouteResult
|
2017-04-03 13:15:58 -04:00
|
|
|
RoutingAlgorithms<Algorithm>::DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
|
|
|
return routing_algorithms::directShortestPathSearch(heaps, facade, phantom_nodes);
|
|
|
|
}
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm>
|
|
|
|
std::vector<EdgeWeight>
|
|
|
|
RoutingAlgorithms<Algorithm>::ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
|
|
|
|
const std::vector<std::size_t> &source_indices,
|
|
|
|
const std::vector<std::size_t> &target_indices) const
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
2017-06-30 17:45:00 -04:00
|
|
|
return routing_algorithms::manyToManySearch(
|
|
|
|
heaps, facade, phantom_nodes, source_indices, target_indices);
|
2017-03-01 17:55:18 -05:00
|
|
|
}
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm>
|
|
|
|
inline routing_algorithms::SubMatchingList RoutingAlgorithms<Algorithm>::MapMatching(
|
2017-03-01 17:55:18 -05:00
|
|
|
const routing_algorithms::CandidateLists &candidates_list,
|
|
|
|
const std::vector<util::Coordinate> &trace_coordinates,
|
|
|
|
const std::vector<unsigned> &trace_timestamps,
|
2017-03-06 08:11:38 -05:00
|
|
|
const std::vector<boost::optional<double>> &trace_gps_precision,
|
2017-03-20 06:30:24 -04:00
|
|
|
const bool allow_splitting) const
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
2017-04-03 13:15:58 -04:00
|
|
|
return routing_algorithms::mapMatching(heaps,
|
|
|
|
facade,
|
|
|
|
candidates_list,
|
|
|
|
trace_coordinates,
|
|
|
|
trace_timestamps,
|
|
|
|
trace_gps_precision,
|
|
|
|
allow_splitting);
|
2017-03-01 17:55:18 -05:00
|
|
|
}
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <typename Algorithm>
|
|
|
|
inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<Algorithm>::GetTileTurns(
|
2017-03-01 17:55:18 -05:00
|
|
|
const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &edges,
|
|
|
|
const std::vector<std::size_t> &sorted_edge_indexes) const
|
|
|
|
{
|
|
|
|
return routing_algorithms::getTileTurns(facade, edges, sorted_edge_indexes);
|
|
|
|
}
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
// CoreCH overrides
|
|
|
|
template <>
|
2017-05-11 12:44:48 -04:00
|
|
|
InternalManyRoutesResult inline RoutingAlgorithms<
|
2017-04-06 08:28:43 -04:00
|
|
|
routing_algorithms::corech::Algorithm>::AlternativePathSearch(const PhantomNodes &,
|
|
|
|
unsigned) const
|
2017-04-03 13:15:58 -04:00
|
|
|
{
|
|
|
|
throw util::exception("AlternativePathSearch is disabled due to performance reasons");
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline std::vector<EdgeWeight>
|
|
|
|
RoutingAlgorithms<routing_algorithms::corech::Algorithm>::ManyToManySearch(
|
|
|
|
const std::vector<PhantomNode> &,
|
|
|
|
const std::vector<std::size_t> &,
|
|
|
|
const std::vector<std::size_t> &) const
|
|
|
|
{
|
|
|
|
throw util::exception("ManyToManySearch is disabled due to performance reasons");
|
|
|
|
}
|
2017-04-06 08:28:43 -04:00
|
|
|
} // ns engine
|
|
|
|
} // ns osrm
|
2017-01-09 15:40:33 -05:00
|
|
|
|
|
|
|
#endif
|