diff --git a/routing/CMakeLists.txt b/routing/CMakeLists.txt index b557d90956..d24ea004a8 100644 --- a/routing/CMakeLists.txt +++ b/routing/CMakeLists.txt @@ -22,9 +22,8 @@ set( car_model.hpp car_router.cpp car_router.hpp + cross_mwm_index_graph.cpp cross_mwm_index_graph.hpp - cross_mwm_index_graph_osrm.cpp - cross_mwm_index_graph_osrm.hpp cross_mwm_road_graph.cpp cross_mwm_road_graph.hpp cross_mwm_router.cpp diff --git a/routing/cross_mwm_index_graph_osrm.cpp b/routing/cross_mwm_index_graph.cpp similarity index 72% rename from routing/cross_mwm_index_graph_osrm.cpp rename to routing/cross_mwm_index_graph.cpp index 4fd2f99c19..eabe09ccc7 100644 --- a/routing/cross_mwm_index_graph_osrm.cpp +++ b/routing/cross_mwm_index_graph.cpp @@ -1,4 +1,4 @@ -#include "routing/cross_mwm_index_graph_osrm.hpp" +#include "routing/cross_mwm_index_graph.hpp" #include "platform/country_file.hpp" @@ -25,14 +25,19 @@ void FillTransitionSegments(routing::OsrmFtSegMapping const & segMapping, routin transitionSegments.emplace(seg.m_fid, min(seg.m_pointStart, seg.m_pointEnd), mwmId, seg.IsForward()); return; } - LOG(LERROR, ("No valid segments in the range returned by OsrmFtSegMapping::GetSegmentsRange(", nodeId, ")")); + LOG(LERROR, ("No valid segments in the range returned by OsrmFtSegMapping::GetSegmentsRange(", nodeId, + "). Num mwm id:", mwmId)); } } // namespace namespace routing { -bool CrossMwmIndexGraphOsrm::IsTransition(Segment const & s, bool isOutgoing) +bool CrossMwmIndexGraph::IsTransition(Segment const & s, bool isOutgoing) { + // @TODO(bykoianko) It's necessary to check if mwm of |s| contains an A* cross mwm section + // and if so to use it. If not, osrm cross mwm sections should be used. + + // Checking if a segment |s| is a transition segment by osrm cross mwm sections. auto it = m_transitionCache.find(s.GetMwmId()); if (it == m_transitionCache.cend()) { @@ -63,14 +68,18 @@ bool CrossMwmIndexGraphOsrm::IsTransition(Segment const & s, bool isOutgoing) return it->second.m_ingoing.count(s) != 0; } -void CrossMwmIndexGraphOsrm::GetTwin(Segment const & /* s */, std::vector & /* twins */) const +void CrossMwmIndexGraph::GetTwins(Segment const & /* s */, std::vector & /* twins */) const { + // @TODO(bykoianko) It's necessary to check if mwm of |s| contains an A* cross mwm section + // and if so to use it. If not, osrm cross mwm sections should be used. NOTIMPLEMENTED(); } -void CrossMwmIndexGraphOsrm::GetEdgeList(Segment const & /* s */, +void CrossMwmIndexGraph::GetEdgeList(Segment const & /* s */, bool /* isOutgoing */, std::vector & /* edges */) const { + // @TODO(bykoianko) It's necessary to check if mwm of |s| contains an A* cross mwm section + // and if so to use it. If not, osrm cross mwm sections should be used. NOTIMPLEMENTED(); } } // namespace routing diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index c3ec20f21a..8bf9c88312 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -1,19 +1,27 @@ #pragma once +#include "routing/cross_mwm_index_graph.hpp" +#include "routing/num_mwm_id.hpp" +#include "routing/routing_mapping.hpp" #include "routing/segment.hpp" +#include "base/math.hpp" + +#include +#include +#include #include namespace routing { -/// \brief This is an interface for cross mwm routing. -// @TODO(bykoianko) This interface will have two implementations. -// * For orsm cross mwm section. -// * For A* cross mwm section -class CrossMwmIndexGraph +/// \brief Getting information for cross mwm routing. +class CrossMwmIndexGraph final { public: - virtual ~CrossMwmIndexGraph() = default; + CrossMwmIndexGraph(std::shared_ptr numMwmIds, RoutingIndexManager & indexManager) + : m_indexManager(indexManager), m_numMwmIds(numMwmIds) + { + } /// \brief Transition segment is a segment which is crossed by mwm border. That means /// start and finsh of such segment have to lie in different mwms. If a segment is @@ -40,14 +48,14 @@ public: /// * exit transition segments are exits from their mwms; /// \returns true if |s| is an exit (|isOutgoing| == true) or an enter (|isOutgoing| == false) /// transition segment. - virtual bool IsTransition(Segment const & s, bool isOutgoing) = 0; + bool IsTransition(Segment const & s, bool isOutgoing); /// \brief Fills |twins| with duplicates of |s| transition segment in neighbouring mwm. /// For most cases there is only one twin for |s|. /// If |s| is an enter transition segment fills |twins| with appropriate exit transition segments. /// If |s| is an exit transition segment fills |twins| with appropriate enter transition segments. - /// \note GetTwin(...) shall be called only if IsTransition(s, ...) returns true. - virtual void GetTwin(Segment const & s, std::vector & twins) const = 0; + /// \note GetTwins(...) shall be called only if IsTransition(s, ...) returns true. + void GetTwins(Segment const & s, std::vector & twins) const; /// \brief Fills |edges| with edges outgoing from |s| (ingoing to |s|). /// If |isOutgoing| == true then |s| should be an enter transition segment. @@ -58,6 +66,18 @@ public: /// enter transition segments of the mwm of |s| and ending at |s|. /// Weight of each edge is equal to weight of the route form |s| to |SegmentEdge::m_target| /// if |isOutgoing| == true and from |SegmentEdge::m_target| to |s| otherwise. - virtual void GetEdgeList(Segment const & s, bool isOutgoing, std::vector & edges) const = 0; + void GetEdgeList(Segment const & s, bool isOutgoing, std::vector & edges) const; + +private: + struct TransitionSegments + { + std::set m_ingoing; + std::set m_outgoing; + }; + + RoutingIndexManager & m_indexManager; + std::shared_ptr m_numMwmIds; + + std::map m_transitionCache; }; } // routing diff --git a/routing/cross_mwm_index_graph_osrm.hpp b/routing/cross_mwm_index_graph_osrm.hpp deleted file mode 100644 index 986ba3c0e2..0000000000 --- a/routing/cross_mwm_index_graph_osrm.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "routing/cross_mwm_index_graph.hpp" -#include "routing/num_mwm_id.hpp" -#include "routing/routing_mapping.hpp" - -#include "base/math.hpp" - -#include -#include -#include - -namespace routing -{ -class CrossMwmIndexGraphOsrm : public CrossMwmIndexGraph -{ -public: - CrossMwmIndexGraphOsrm(std::shared_ptr numMwmIds, RoutingIndexManager & indexManager) - : m_indexManager(indexManager), m_numMwmIds(numMwmIds) - { - } - - // CrossMwmIndexGraph overrides: - bool IsTransition(Segment const & s, bool isOutgoing) override; - void GetTwin(Segment const & s, std::vector & twins) const override; - void GetEdgeList(Segment const & s, bool isOutgoing, std::vector & edges) const override; - -private: - struct TransitionSegments - { - std::set m_ingoing; - std::set m_outgoing; - }; - - RoutingIndexManager & m_indexManager; - std::shared_ptr m_numMwmIds; - - std::map m_transitionCache; -}; -} // namespace routing diff --git a/routing/routing.pro b/routing/routing.pro index 9d7a6d4515..dc332ec950 100644 --- a/routing/routing.pro +++ b/routing/routing.pro @@ -19,7 +19,7 @@ SOURCES += \ bicycle_model.cpp \ car_model.cpp \ car_router.cpp \ - cross_mwm_index_graph_osrm.cpp \ + cross_mwm_index_graph.cpp \ cross_mwm_road_graph.cpp \ cross_mwm_router.cpp \ cross_routing_context.cpp \ @@ -73,7 +73,6 @@ HEADERS += \ car_model.hpp \ car_router.hpp \ cross_mwm_index_graph.hpp \ - cross_mwm_index_graph_osrm.hpp \ cross_mwm_road_graph.hpp \ cross_mwm_router.hpp \ cross_routing_context.hpp \ diff --git a/xcode/routing/routing.xcodeproj/project.pbxproj b/xcode/routing/routing.xcodeproj/project.pbxproj index ccb14d8aba..dd68a25428 100644 --- a/xcode/routing/routing.xcodeproj/project.pbxproj +++ b/xcode/routing/routing.xcodeproj/project.pbxproj @@ -60,8 +60,7 @@ 56CA09E71E30E73B00D05C9A /* restriction_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56CA09E21E30E73B00D05C9A /* restriction_test.cpp */; }; 56CA09E91E30F19800D05C9A /* libtraffic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56CA09E81E30F19800D05C9A /* libtraffic.a */; }; 56CC5A371E3884960016AC46 /* cross_mwm_index_graph.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 56CC5A361E3884960016AC46 /* cross_mwm_index_graph.hpp */; }; - 56D637D31E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56D637D11E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.cpp */; }; - 56D637D41E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 56D637D21E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.hpp */; }; + 56D637D61E4B12AA00B86D7B /* cross_mwm_index_graph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56D637D51E4B12AA00B86D7B /* cross_mwm_index_graph.cpp */; }; 56EA2FD51D8FD8590083F01A /* routing_helpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 56EA2FD41D8FD8590083F01A /* routing_helpers.hpp */; }; 56F0D7341D896A5300045886 /* libmap.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 67BD35DE1C69F198003AA26F /* libmap.a */; }; 56F0D7391D896A5300045886 /* libstorage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 67BD35D41C69F155003AA26F /* libstorage.a */; }; @@ -311,8 +310,7 @@ 56CA09E21E30E73B00D05C9A /* restriction_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = restriction_test.cpp; sourceTree = ""; }; 56CA09E81E30F19800D05C9A /* libtraffic.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtraffic.a; path = "/Users/vladimirbykoyanko/src_github_master/omim/xcode/traffic/../../../omim-build/xcode/Debug/libtraffic.a"; sourceTree = ""; }; 56CC5A361E3884960016AC46 /* cross_mwm_index_graph.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cross_mwm_index_graph.hpp; sourceTree = ""; }; - 56D637D11E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cross_mwm_index_graph_osrm.cpp; sourceTree = ""; }; - 56D637D21E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cross_mwm_index_graph_osrm.hpp; sourceTree = ""; }; + 56D637D51E4B12AA00B86D7B /* cross_mwm_index_graph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cross_mwm_index_graph.cpp; sourceTree = ""; }; 56EA2FD41D8FD8590083F01A /* routing_helpers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = routing_helpers.hpp; sourceTree = ""; }; 56F0D75F1D896A5300045886 /* routing_benchmarks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = routing_benchmarks.app; sourceTree = BUILT_PRODUCTS_DIR; }; 670B84BE1A9381D900CE4492 /* cross_routing_context.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cross_routing_context.cpp; sourceTree = ""; }; @@ -711,8 +709,7 @@ 675343FA1A3F640D00A0A8C3 /* routing */ = { isa = PBXGroup; children = ( - 56D637D11E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.cpp */, - 56D637D21E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.hpp */, + 56D637D51E4B12AA00B86D7B /* cross_mwm_index_graph.cpp */, 674F9BBA1B0A580E00704FFA /* async_router.cpp */, 674F9BBB1B0A580E00704FFA /* async_router.hpp */, 671F58BA1B874EA20032311E /* base */, @@ -901,7 +898,6 @@ 670D049F1B0B4A970013A7AC /* nearest_edge_finder.hpp in Headers */, A120B34F1B4A7C0A002F3808 /* online_absent_fetcher.hpp in Headers */, 674F9BD51B0A580E00704FFA /* road_graph.hpp in Headers */, - 56D637D41E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.hpp in Headers */, 56826BD11DB51C4E00807C62 /* car_router.hpp in Headers */, A120B3511B4A7C0A002F3808 /* routing_algorithm.hpp in Headers */, 0C5FEC6B1DDE193F0017688C /* road_point.hpp in Headers */, @@ -1138,10 +1134,10 @@ 6741AA9C1BF35331002C974C /* turns_notification_manager.cpp in Sources */, 67C7D42B1B4EB48F00FE41AA /* pedestrian_model.cpp in Sources */, 0C0DF9251DE898CF0055A22F /* single_mwm_router.cpp in Sources */, + 56D637D61E4B12AA00B86D7B /* cross_mwm_index_graph.cpp in Sources */, 0C0DF9211DE898B70055A22F /* index_graph_starter.cpp in Sources */, A120B3471B4A7BE5002F3808 /* cross_mwm_router.cpp in Sources */, 670EE5731B664796001E8064 /* pedestrian_directions.cpp in Sources */, - 56D637D31E49F8DA00B86D7B /* cross_mwm_index_graph_osrm.cpp in Sources */, 6753441B1A3F644F00A0A8C3 /* route.cpp in Sources */, 674F9BCA1B0A580E00704FFA /* async_router.cpp in Sources */, 675344191A3F644F00A0A8C3 /* osrm2feature_map.cpp in Sources */,