From c487d1307e3b3e6f4a0f1c4ee5a89c9d54a61f8b Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 31 Mar 2017 11:29:48 +0200 Subject: [PATCH] enable map matching in MLD --- include/engine/algorithm.hpp | 3 ++ include/engine/routing_algorithms.hpp | 12 ------ .../routing_algorithms/routing_base_mld.hpp | 40 +++++++++++++++---- .../routing_algorithms/map_matching.cpp | 10 +++++ 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/include/engine/algorithm.hpp b/include/engine/algorithm.hpp index 0ea02663a..7fe1a71e2 100644 --- a/include/engine/algorithm.hpp +++ b/include/engine/algorithm.hpp @@ -99,6 +99,9 @@ template <> struct HasDirectShortestPathSearch final : std::true template <> struct HasShortestPathSearch final : std::true_type { }; +template <> struct HasMapMatching final : std::true_type +{ +}; } } } diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index fccfaebff..900a7d89b 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -221,18 +221,6 @@ RoutingAlgorithms::ManyToManySearch( throw util::exception("ManyToManySearch is not implemented"); } -template <> -inline routing_algorithms::SubMatchingList -RoutingAlgorithms::MapMatching( - const routing_algorithms::CandidateLists &, - const std::vector &, - const std::vector &, - const std::vector> &, - const bool) const -{ - throw util::exception("MapMatching is not implemented"); -} - template <> inline std::vector RoutingAlgorithms::GetTileTurns( diff --git a/include/engine/routing_algorithms/routing_base_mld.hpp b/include/engine/routing_algorithms/routing_base_mld.hpp index f5152f449..4b00afedf 100644 --- a/include/engine/routing_algorithms/routing_base_mld.hpp +++ b/include/engine/routing_algorithms/routing_base_mld.hpp @@ -24,9 +24,9 @@ namespace // Unrestricted search (Args is const PhantomNodes &): // * use partition.GetQueryLevel to find the node query level based on source and target phantoms // * allow to traverse all cells -LevelID getNodeQureyLevel(const partition::MultiLevelPartitionView &partition, - NodeID node, - const PhantomNodes &phantom_nodes) +inline LevelID getNodeQureyLevel(const partition::MultiLevelPartitionView &partition, + NodeID node, + const PhantomNodes &phantom_nodes) { auto level = [&partition, node](const SegmentID &source, const SegmentID &target) { if (source.enabled && target.enabled) @@ -43,17 +43,21 @@ LevelID getNodeQureyLevel(const partition::MultiLevelPartitionView &partition, phantom_nodes.target_phantom.reverse_segment_id))); } -bool checkParentCellRestriction(CellID, const PhantomNodes &) { return true; } +inline bool checkParentCellRestriction(CellID, const PhantomNodes &) { return true; } // Restricted search (Args is LevelID, CellID): // * use the fixed level for queries // * check if the node cell is the same as the specified parent onr -LevelID getNodeQureyLevel(const partition::MultiLevelPartitionView &, NodeID, LevelID level, CellID) +inline LevelID +getNodeQureyLevel(const partition::MultiLevelPartitionView &, NodeID, LevelID level, CellID) { return level; } -bool checkParentCellRestriction(CellID cell, LevelID, CellID parent) { return cell == parent; } +inline bool checkParentCellRestriction(CellID cell, LevelID, CellID parent) +{ + return cell == parent; +} } template @@ -305,7 +309,7 @@ search(const datafacade::ContiguousInternalMemoryDataFacade &facade, return std::make_tuple(weight, source_node, target_node, std::move(unpacked_path)); } -// Alias to be compatible with the overload for CoreCH that needs 4 heaps +// Alias to be compatible with the overload for CoreCH that needs 4 heaps for shortest path search inline void search(const datafacade::ContiguousInternalMemoryDataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, @@ -362,6 +366,28 @@ void unpackPath(const FacadeT &facade, annotatePath(facade, source_node, target_node, unpacked_edges, phantom_nodes, unpacked_path); } +inline double +getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade &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) +{ + (void)facade; + (void)forward_heap; + (void)reverse_heap; + (void)forward_core_heap; + (void)reverse_core_heap; + (void)source_phantom; + (void)target_phantom; + (void)duration_upper_bound; + + return 0.; // TODO: unimplemented +} + } // namespace mld } // namespace routing_algorithms } // namespace engine diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index 992bc0006..29ff68f2b 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -1,5 +1,6 @@ #include "engine/routing_algorithms/map_matching.hpp" #include "engine/routing_algorithms/routing_base_ch.hpp" +#include "engine/routing_algorithms/routing_base_mld.hpp" #include "engine/map_matching/hidden_markov_model.hpp" #include "engine/map_matching/matching_confidence.hpp" @@ -437,6 +438,15 @@ mapMatching(SearchEngineData &engine_working_data, const std::vector> &trace_gps_precision, const bool allow_splitting); +template SubMatchingList +mapMatching(SearchEngineData &engine_working_data, + const datafacade::ContiguousInternalMemoryDataFacade &facade, + const CandidateLists &candidates_list, + const std::vector &trace_coordinates, + const std::vector &trace_timestamps, + const std::vector> &trace_gps_precision, + const bool allow_splitting); + } // namespace routing_algorithms } // namespace engine } // namespace osrm