diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-05-26 14:23:53 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-05-27 14:17:14 +0300 |
commit | 9d393d2b51224681a090c76399db3e1f6b8bd10b (patch) | |
tree | c24bbac5a2e2cd76bc53e7902d85891a91ef4da9 | |
parent | e060fd2fa6898a41d8f849b8d575dd17cd1d2bb4 (diff) |
Creating routing mode intead of using onewayAsBidirectional flag.
-rw-r--r-- | map/framework.cpp | 2 | ||||
-rw-r--r-- | pedestrian_routing_tests/pedestrian_routing_tests.cpp | 6 | ||||
-rw-r--r-- | routing/features_road_graph.cpp | 8 | ||||
-rw-r--r-- | routing/features_road_graph.hpp | 6 | ||||
-rw-r--r-- | routing/road_graph.cpp | 4 | ||||
-rw-r--r-- | routing/road_graph.hpp | 22 | ||||
-rw-r--r-- | routing/road_graph_router.cpp | 11 | ||||
-rw-r--r-- | routing/road_graph_router.hpp | 2 | ||||
-rw-r--r-- | routing/routing_tests/road_graph_builder.cpp | 5 | ||||
-rw-r--r-- | routing/routing_tests/road_graph_builder.hpp | 2 |
10 files changed, 38 insertions, 30 deletions
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<routing::IRouter> CreatePedestrianAStarTestRouter(Index & index, stor unique_ptr<routing::IVehicleModelFactory> vehicleModelFactory(new SimplifiedPedestrianModelFactory()); unique_ptr<routing::IRoutingAlgorithm> algorithm(new routing::AStarRoutingAlgorithm()); unique_ptr<routing::IRouter> 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<routing::IRouter> CreatePedestrianAStarBidirectionalTestRouter(Index unique_ptr<routing::IVehicleModelFactory> vehicleModelFactory(new SimplifiedPedestrianModelFactory()); unique_ptr<routing::IRoutingAlgorithm> algorithm(new routing::AStarBidirectionalRoutingAlgorithm()); unique_ptr<routing::IRouter> 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<pair<routing::Edge, m2::PointD>> & edges) { unique_ptr<routing::IVehicleModelFactory> 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<IVehicleModelFactory> && 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<IVehicleModelFactory> && vehicleModelFactory); static uint32_t GetStreetReadScale(); @@ -71,7 +71,7 @@ public: vector<pair<Edge, m2::PointD>> & 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<MwmSet::MwmId, MwmSet::MwmHandle> 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<Junction> TJunctionVector; typedef vector<Edge> 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<IVehicleModelFactory> && vehicleModelFactory, unique_ptr<IRoutingAlgorithm> && algorithm, unique_ptr<IDirectionsEngine> && 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<FeaturesRoadGraph>(index, onewayAsBidirectional, move(vehicleModelFactory))) + , m_roadGraph(make_unique<FeaturesRoadGraph>(index, mode, move(vehicleModelFactory))) , m_directionsEngine(move(directionsEngine)) { } @@ -260,7 +259,7 @@ unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn co unique_ptr<IRoutingAlgorithm> algorithm(new AStarRoutingAlgorithm()); unique_ptr<IDirectionsEngine> directionsEngine(new PedestrianDirectionsEngine()); unique_ptr<IRouter> 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<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index, TCou unique_ptr<IRoutingAlgorithm> algorithm(new AStarBidirectionalRoutingAlgorithm()); unique_ptr<IDirectionsEngine> directionsEngine(new PedestrianDirectionsEngine()); unique_ptr<IRouter> 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<IRouter> CreateBicycleAStarBidirectionalRouter(Index & index, TCountr unique_ptr<IRoutingAlgorithm> algorithm(new AStarBidirectionalRoutingAlgorithm()); unique_ptr<IDirectionsEngine> directionsEngine(new BicycleDirectionsEngine(index)); unique_ptr<IRouter> 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<IVehicleModelFactory> && vehicleModelFactory, unique_ptr<IRoutingAlgorithm> && algorithm, unique_ptr<IDirectionsEngine> && 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<pair<routing::Edge, m2::PointD>> & 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<RoadInfo> m_roads; |