diff --git a/map/framework.cpp b/map/framework.cpp index 928f090264..9858b0a500 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1035,7 +1035,7 @@ void Framework::StartInteractiveSearch(search::SearchParams const & params) m_lastInteractiveSearchParams = params; m_lastInteractiveSearchParams.SetForceSearch(false); - m_lastInteractiveSearchParams.SetMode(Mode::Viewport); + m_lastInteractiveSearchParams.SetMode(search::Mode::Viewport); m_lastInteractiveSearchParams.SetSuggestsEnabled(false); m_lastInteractiveSearchParams.m_onResults = [this](Results const & results) { diff --git a/pedestrian_routing_tests/pedestrian_routing_tests.cpp b/pedestrian_routing_tests/pedestrian_routing_tests.cpp index d7733240f7..3c7598eb07 100644 --- a/pedestrian_routing_tests/pedestrian_routing_tests.cpp +++ b/pedestrian_routing_tests/pedestrian_routing_tests.cpp @@ -95,7 +95,7 @@ unique_ptr CreatePedestrianAStarTestRouter(Index & index, stor unique_ptr vehicleModelFactory(new SimplifiedPedestrianModelFactory()); unique_ptr algorithm(new routing::AStarRoutingAlgorithm()); unique_ptr router(new routing::RoadGraphRouter( - "test-astar-pedestrian", index, UKGetter, true /* onewayAsBidirectional */, + "test-astar-pedestrian", index, UKGetter, routing::IRoadGraph::Mode::IgnoreOnewayTag, move(vehicleModelFactory), move(algorithm), nullptr)); return router; } @@ -106,7 +106,7 @@ unique_ptr CreatePedestrianAStarBidirectionalTestRouter(Index unique_ptr vehicleModelFactory(new SimplifiedPedestrianModelFactory()); unique_ptr algorithm(new routing::AStarBidirectionalRoutingAlgorithm()); unique_ptr router(new routing::RoadGraphRouter( - "test-astar-bidirectional-pedestrian", index, UKGetter, true /* onewayAsBidirectional */, + "test-astar-bidirectional-pedestrian", index, UKGetter, routing::IRoadGraph::Mode::IgnoreOnewayTag, move(vehicleModelFactory), move(algorithm), nullptr)); return router; } @@ -124,7 +124,7 @@ m2::PointD GetPointOnEdge(routing::Edge & e, double posAlong) void GetNearestPedestrianEdges(Index & index, m2::PointD const & pt, vector> & edges) { unique_ptr vehicleModelFactory(new SimplifiedPedestrianModelFactory()); - routing::FeaturesRoadGraph roadGraph(index, true /* onewayAsBidirectional */, + routing::FeaturesRoadGraph roadGraph(index, routing::IRoadGraph::Mode::IgnoreOnewayTag, move(vehicleModelFactory)); roadGraph.FindClosestEdges(pt, 1 /*count*/, edges); diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 8b3f2a17c2..f04a0049f5 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -101,10 +101,10 @@ void FeaturesRoadGraph::RoadInfoCache::Clear() m_cache.clear(); } -FeaturesRoadGraph::FeaturesRoadGraph(Index const & index, bool onewayAsBidirectional, +FeaturesRoadGraph::FeaturesRoadGraph(Index const & index, IRoadGraph::Mode mode, unique_ptr && vehicleModelFactory) : m_index(index) - , m_onewayAsBidirectional(onewayAsBidirectional) + , m_mode(mode) , m_vehicleModel(move(vehicleModelFactory)) { } @@ -230,9 +230,9 @@ void FeaturesRoadGraph::GetJunctionTypes(Junction const & junction, feature::Typ m_index.ForEachInRect(f, rect, GetStreetReadScale()); } -bool FeaturesRoadGraph::ConsiderOnewayFeaturesAsBidirectional() const +IRoadGraph::Mode FeaturesRoadGraph::ConsiderOnewayFeaturesAsBidirectional() const { - return m_onewayAsBidirectional; + return m_mode; }; void FeaturesRoadGraph::ClearState() diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp index 016358e1db..28ed0c54f8 100644 --- a/routing/features_road_graph.hpp +++ b/routing/features_road_graph.hpp @@ -56,7 +56,7 @@ private: }; public: - FeaturesRoadGraph(Index const & index, bool onewayAsBidirectional, + FeaturesRoadGraph(Index const & index, IRoadGraph::Mode mode, unique_ptr && vehicleModelFactory); static uint32_t GetStreetReadScale(); @@ -71,7 +71,7 @@ public: vector> & vicinities) const override; void GetFeatureTypes(FeatureID const & featureId, feature::TypesHolder & types) const override; void GetJunctionTypes(Junction const & junction, feature::TypesHolder & types) const override; - bool ConsiderOnewayFeaturesAsBidirectional() const override; + IRoadGraph::Mode ConsiderOnewayFeaturesAsBidirectional() const override; void ClearState() override; private: @@ -92,7 +92,7 @@ private: void LockFeatureMwm(FeatureID const & featureId) const; Index const & m_index; - bool const m_onewayAsBidirectional; + IRoadGraph::Mode const m_mode; mutable RoadInfoCache m_cache; mutable CrossCountryVehicleModel m_vehicleModel; mutable map m_mwmLocks; diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp index 73dbf8953a..9ba1d9a99a 100644 --- a/routing/road_graph.cpp +++ b/routing/road_graph.cpp @@ -179,7 +179,7 @@ void IRoadGraph::CrossOutgoingLoader::LoadEdge(FeatureID const & featureId, if (!PointsAlmostEqualAbs(m_cross, p)) continue; - if (i > 0 && (roadInfo.m_bidirectional || m_onewayAsBidirectional)) + if (i > 0 && (roadInfo.m_bidirectional || m_mode == IRoadGraph::Mode::IgnoreOnewayTag)) { // p // o------------>o @@ -218,7 +218,7 @@ void IRoadGraph::CrossIngoingLoader::LoadEdge(FeatureID const & featureId, m_edges.emplace_back(featureId, true /* forward */, i - 1, roadInfo.m_points[i - 1], p); } - if (i < numPoints - 1 && (roadInfo.m_bidirectional || m_onewayAsBidirectional)) + if (i < numPoints - 1 && (roadInfo.m_bidirectional || m_mode == IRoadGraph::Mode::IgnoreOnewayTag)) { // p // o------------>o diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 916706fba2..143c7a75e3 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -83,6 +83,12 @@ public: typedef vector TJunctionVector; typedef vector TEdgeVector; + enum class Mode + { + ObeyOnewayTag, + IgnoreOnewayTag, + }; + /// This struct contains the part of a feature's metadata that is /// relevant for routing. struct RoadInfo @@ -102,8 +108,8 @@ public: class ICrossEdgesLoader { public: - ICrossEdgesLoader(m2::PointD const & cross, bool onewayAsBidirectional, TEdgeVector & edges) - : m_cross(cross), m_onewayAsBidirectional(onewayAsBidirectional), m_edges(edges) + ICrossEdgesLoader(m2::PointD const & cross, IRoadGraph::Mode mode, TEdgeVector & edges) + : m_cross(cross), m_mode(mode), m_edges(edges) { } virtual ~ICrossEdgesLoader() = default; @@ -118,15 +124,15 @@ public: protected: m2::PointD const m_cross; - bool const m_onewayAsBidirectional; + IRoadGraph::Mode const m_mode; TEdgeVector & m_edges; }; class CrossOutgoingLoader : public ICrossEdgesLoader { public: - CrossOutgoingLoader(m2::PointD const & cross, bool onewayAsBidirectional, TEdgeVector & edges) - : ICrossEdgesLoader(cross, onewayAsBidirectional, edges) + CrossOutgoingLoader(m2::PointD const & cross, IRoadGraph::Mode mode, TEdgeVector & edges) + : ICrossEdgesLoader(cross, mode, edges) { } @@ -137,8 +143,8 @@ public: class CrossIngoingLoader : public ICrossEdgesLoader { public: - CrossIngoingLoader(m2::PointD const & cross, bool onewayAsBidirectional, TEdgeVector & edges) - : ICrossEdgesLoader(cross, onewayAsBidirectional, edges) + CrossIngoingLoader(m2::PointD const & cross, IRoadGraph::Mode mode, TEdgeVector & edges) + : ICrossEdgesLoader(cross, mode, edges) { } // ICrossEdgesLoader overrides: @@ -191,7 +197,7 @@ public: /// @return Types for specified junction virtual void GetJunctionTypes(Junction const & junction, feature::TypesHolder & types) const = 0; - virtual bool ConsiderOnewayFeaturesAsBidirectional() const = 0; + virtual IRoadGraph::Mode ConsiderOnewayFeaturesAsBidirectional() const = 0; /// Clear all temporary buffers. virtual void ClearState() {} diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp index 7e75f58396..83934557e8 100644 --- a/routing/road_graph_router.cpp +++ b/routing/road_graph_router.cpp @@ -131,7 +131,7 @@ void FindClosestEdges(IRoadGraph const & graph, m2::PointD const & point, RoadGraphRouter::~RoadGraphRouter() {} RoadGraphRouter::RoadGraphRouter(string const & name, Index const & index, - TCountryFileFn const & countryFileFn, bool onewayAsBidirectional, + TCountryFileFn const & countryFileFn, IRoadGraph::Mode mode, unique_ptr && vehicleModelFactory, unique_ptr && algorithm, unique_ptr && directionsEngine) @@ -139,8 +139,7 @@ RoadGraphRouter::RoadGraphRouter(string const & name, Index const & index, , m_countryFileFn(countryFileFn) , m_index(index) , m_algorithm(move(algorithm)) - , m_roadGraph( - make_unique(index, onewayAsBidirectional, move(vehicleModelFactory))) + , m_roadGraph(make_unique(index, mode, move(vehicleModelFactory))) , m_directionsEngine(move(directionsEngine)) { } @@ -260,7 +259,7 @@ unique_ptr CreatePedestrianAStarRouter(Index & index, TCountryFileFn co unique_ptr algorithm(new AStarRoutingAlgorithm()); unique_ptr directionsEngine(new PedestrianDirectionsEngine()); unique_ptr router(new RoadGraphRouter( - "astar-pedestrian", index, countryFileFn, true /* onewayAsBidirectional */, + "astar-pedestrian", index, countryFileFn, IRoadGraph::Mode::IgnoreOnewayTag, move(vehicleModelFactory), move(algorithm), move(directionsEngine))); return router; } @@ -271,7 +270,7 @@ unique_ptr CreatePedestrianAStarBidirectionalRouter(Index & index, TCou unique_ptr algorithm(new AStarBidirectionalRoutingAlgorithm()); unique_ptr directionsEngine(new PedestrianDirectionsEngine()); unique_ptr router(new RoadGraphRouter( - "astar-bidirectional-pedestrian", index, countryFileFn, true /* onewayAsBidirectional */, + "astar-bidirectional-pedestrian", index, countryFileFn, IRoadGraph::Mode::IgnoreOnewayTag, move(vehicleModelFactory), move(algorithm), move(directionsEngine))); return router; } @@ -282,7 +281,7 @@ unique_ptr CreateBicycleAStarBidirectionalRouter(Index & index, TCountr unique_ptr algorithm(new AStarBidirectionalRoutingAlgorithm()); unique_ptr directionsEngine(new BicycleDirectionsEngine(index)); unique_ptr router(new RoadGraphRouter( - "astar-bidirectional-bicycle", index, countryFileFn, false /* onewayAsBidirectional */, + "astar-bidirectional-bicycle", index, countryFileFn, IRoadGraph::Mode::ObeyOnewayTag, move(vehicleModelFactory), move(algorithm), move(directionsEngine))); return router; } diff --git a/routing/road_graph_router.hpp b/routing/road_graph_router.hpp index c9894d3107..17701bdc7a 100644 --- a/routing/road_graph_router.hpp +++ b/routing/road_graph_router.hpp @@ -24,7 +24,7 @@ class RoadGraphRouter : public IRouter { public: RoadGraphRouter(string const & name, Index const & index, TCountryFileFn const & countryFileFn, - bool onewayAsBidirectional, + IRoadGraph::Mode mode, unique_ptr && vehicleModelFactory, unique_ptr && algorithm, unique_ptr && directionsEngine); diff --git a/routing/routing_tests/road_graph_builder.cpp b/routing/routing_tests/road_graph_builder.cpp index 2de44978ca..b7308da201 100644 --- a/routing/routing_tests/road_graph_builder.cpp +++ b/routing/routing_tests/road_graph_builder.cpp @@ -110,7 +110,10 @@ void RoadGraphMockSource::GetJunctionTypes(Junction const & junction, feature::T UNUSED_VALUE(types); } -bool RoadGraphMockSource::ConsiderOnewayFeaturesAsBidirectional() const { return true; } +IRoadGraph::Mode RoadGraphMockSource::ConsiderOnewayFeaturesAsBidirectional() const +{ + return IRoadGraph::Mode::IgnoreOnewayTag; +} FeatureID MakeTestFeatureID(uint32_t offset) { diff --git a/routing/routing_tests/road_graph_builder.hpp b/routing/routing_tests/road_graph_builder.hpp index 4fbad32f70..de68330a33 100644 --- a/routing/routing_tests/road_graph_builder.hpp +++ b/routing/routing_tests/road_graph_builder.hpp @@ -22,7 +22,7 @@ public: vector> & vicinities) const override; void GetFeatureTypes(FeatureID const & featureId, feature::TypesHolder & types) const override; void GetJunctionTypes(routing::Junction const & junction, feature::TypesHolder & types) const override; - bool ConsiderOnewayFeaturesAsBidirectional() const override; + routing::IRoadGraph::Mode ConsiderOnewayFeaturesAsBidirectional() const override; private: vector m_roads;