diff options
author | Constantin Shalnev <c.shalnev@corp.mail.ru> | 2015-08-28 12:47:53 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:02:59 +0300 |
commit | b6e03fef95818878a016dabbb3081009eba8a8e6 (patch) | |
tree | b9bfe698ba21d134697b38d8d274896a617bdaf2 /routing | |
parent | ac88e25dd2a8c4d0516486e2785bbc0a3192bc1b (diff) |
Code cleanup: removed extra class
Diffstat (limited to 'routing')
-rw-r--r-- | routing/routing_algorithm.cpp | 29 | ||||
-rw-r--r-- | routing/routing_algorithm.hpp | 15 |
2 files changed, 16 insertions, 28 deletions
diff --git a/routing/routing_algorithm.cpp b/routing/routing_algorithm.cpp index 57121753bd..df4cf9d6a9 100644 --- a/routing/routing_algorithm.cpp +++ b/routing/routing_algorithm.cpp @@ -1,6 +1,7 @@ #include "routing/road_graph.hpp" #include "routing/routing_algorithm.hpp" #include "routing/base/astar_algorithm.hpp" +#include "routing/base/astar_progress.hpp" #include "base/assert.hpp" @@ -121,13 +122,6 @@ string DebugPrint(IRoutingAlgorithm::Result const & value) return string(); } -// *************************** Base class for AStar based routing algorithms ****************************** - -AStarRoutingAlgorithmBase::AStarRoutingAlgorithmBase() - : m_progress(0, 100) -{ -} - // *************************** AStar routing algorithm implementation ************************************* IRoutingAlgorithm::Result AStarRoutingAlgorithm::CalculateRoute(IRoadGraph const & graph, @@ -136,18 +130,21 @@ IRoutingAlgorithm::Result AStarRoutingAlgorithm::CalculateRoute(IRoadGraph const RouterDelegate const & delegate, vector<Junction> & path) { + AStarProgress progress(0, 100); + function<void(Junction const &, Junction const &)> onVisitJunctionFn = - [&delegate, this](Junction const & junction, Junction const & /* target */) + [&delegate, &progress](Junction const & junction, Junction const & /* target */) { delegate.OnPointCheck(junction.GetPoint()); - auto const lastValue = m_progress.GetLastValue(); - auto const newValue = m_progress.GetProgressForDirectedAlgo(junction.GetPoint()); + auto const lastValue = progress.GetLastValue(); + auto const newValue = progress.GetProgressForDirectedAlgo(junction.GetPoint()); if (newValue - lastValue > kProgressInterval) delegate.OnProgress(newValue); }; + my::Cancellable const & cancellable = delegate; - m_progress.Initialize(startPos.GetPoint(), finalPos.GetPoint()); + progress.Initialize(startPos.GetPoint(), finalPos.GetPoint()); TAlgorithmImpl::Result const res = TAlgorithmImpl().FindPath( RoadGraph(graph), startPos, finalPos, path, cancellable, onVisitJunctionFn); return Convert(res); @@ -159,19 +156,21 @@ IRoutingAlgorithm::Result AStarBidirectionalRoutingAlgorithm::CalculateRoute( IRoadGraph const & graph, Junction const & startPos, Junction const & finalPos, RouterDelegate const & delegate, vector<Junction> & path) { + AStarProgress progress(0, 100); + function<void(Junction const &, Junction const &)> onVisitJunctionFn = - [&delegate, this](Junction const & junction, Junction const & target) + [&delegate, &progress](Junction const & junction, Junction const & target) { delegate.OnPointCheck(junction.GetPoint()); - auto const lastValue = m_progress.GetLastValue(); + auto const lastValue = progress.GetLastValue(); auto const newValue = - m_progress.GetProgressForBidirectedAlgo(junction.GetPoint(), target.GetPoint()); + progress.GetProgressForBidirectedAlgo(junction.GetPoint(), target.GetPoint()); if (newValue - lastValue > kProgressInterval) delegate.OnProgress(newValue); }; my::Cancellable const & cancellable = delegate; - m_progress.Initialize(startPos.GetPoint(), finalPos.GetPoint()); + progress.Initialize(startPos.GetPoint(), finalPos.GetPoint()); TAlgorithmImpl::Result const res = TAlgorithmImpl().FindPathBidirectional( RoadGraph(graph), startPos, finalPos, path, cancellable, onVisitJunctionFn); return Convert(res); diff --git a/routing/routing_algorithm.hpp b/routing/routing_algorithm.hpp index 5df6010dfc..2330a6c96b 100644 --- a/routing/routing_algorithm.hpp +++ b/routing/routing_algorithm.hpp @@ -5,8 +5,6 @@ #include "routing/road_graph.hpp" #include "routing/router.hpp" -#include "routing/base/astar_progress.hpp" - #include "std/functional.hpp" #include "std/string.hpp" #include "std/vector.hpp" @@ -33,17 +31,8 @@ public: string DebugPrint(IRoutingAlgorithm::Result const & result); -// Base class for AStar-based routing algorithms -class AStarRoutingAlgorithmBase : public IRoutingAlgorithm -{ -protected: - AStarRoutingAlgorithmBase(); - - AStarProgress m_progress; -}; - // AStar routing algorithm implementation -class AStarRoutingAlgorithm : public AStarRoutingAlgorithmBase +class AStarRoutingAlgorithm : public IRoutingAlgorithm { public: // IRoutingAlgorithm overrides: @@ -53,7 +42,7 @@ public: }; // AStar-bidirectional routing algorithm implementation -class AStarBidirectionalRoutingAlgorithm : public AStarRoutingAlgorithmBase +class AStarBidirectionalRoutingAlgorithm : public IRoutingAlgorithm { public: // IRoutingAlgorithm overrides: |