diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-09-07 15:53:41 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-09-08 12:49:56 +0300 |
commit | f29e63de51933e526c5a4cfc41945180ee11c961 (patch) | |
tree | 2f779ef1aabd5b6a1e490fd7de8a2bb0ea542876 /routing | |
parent | af4c0e975c2a942c82841be4e3a43e8bc7ccc581 (diff) |
Review fixes.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/bicycle_directions.cpp | 4 | ||||
-rw-r--r-- | routing/osrm_path_segment_factory.cpp | 4 | ||||
-rw-r--r-- | routing/osrm_router.cpp | 16 | ||||
-rw-r--r-- | routing/road_graph_router.cpp | 8 | ||||
-rw-r--r-- | routing/route.hpp | 8 | ||||
-rw-r--r-- | routing/routing_result_graph.hpp | 4 | ||||
-rw-r--r-- | routing/routing_session.cpp | 11 | ||||
-rw-r--r-- | routing/routing_session.hpp | 10 | ||||
-rw-r--r-- | routing/routing_tests/route_tests.cpp | 10 |
9 files changed, 40 insertions, 35 deletions
diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index 965bbe5173..19f3ab28b0 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -56,13 +56,13 @@ public: double GetPathLength() const override { return m_routeLength; } - Junction const & GetStartPoint() const override + Junction GetStartPoint() const override { CHECK(!m_routeEdges.empty(), ()); return m_routeEdges.front().GetStartJunction(); } - Junction const & GetEndPoint() const override + Junction GetEndPoint() const override { CHECK(!m_routeEdges.empty(), ()); return m_routeEdges.back().GetEndJunction(); diff --git a/routing/osrm_path_segment_factory.cpp b/routing/osrm_path_segment_factory.cpp index c861707003..3005d8ec19 100644 --- a/routing/osrm_path_segment_factory.cpp +++ b/routing/osrm_path_segment_factory.cpp @@ -57,13 +57,13 @@ void LoadPathGeometry(buffer_vector<TSeg, 8> const & buffer, size_t startIndex, if (startIdx < endIdx) { for (auto idx = startIdx; idx <= endIdx; ++idx) - loadPathGeometry.m_path.push_back(routing::Junction(ft.GetPoint(idx), feature::kDefaultAltitudeMeters)); + loadPathGeometry.m_path.emplace_back(ft.GetPoint(idx), feature::kDefaultAltitudeMeters); } else { // I use big signed type because endIdx can be 0. for (int64_t idx = startIdx; idx >= static_cast<int64_t>(endIdx); --idx) - loadPathGeometry.m_path.push_back(routing::Junction(ft.GetPoint(idx), feature::kDefaultAltitudeMeters)); + loadPathGeometry.m_path.emplace_back(ft.GetPoint(idx), feature::kDefaultAltitudeMeters); } // Load lanes if it is a last segment before junction. diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index 402853ffc7..3ce50d4db3 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -153,12 +153,12 @@ public: double GetPathLength() const override { return m_rawResult.shortestPathLength; } - Junction const & GetStartPoint() const override + Junction GetStartPoint() const override { return Junction(m_rawResult.sourceEdge.segmentPoint, feature::kDefaultAltitudeMeters); } - Junction const & GetEndPoint() const override + Junction GetEndPoint() const override { return Junction(m_rawResult.targetEdge.segmentPoint, feature::kDefaultAltitudeMeters); } @@ -377,9 +377,9 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const & } route.SetGeometry(points.begin(), points.end()); - route.SwapTurnInstructions(turnsDir); - route.SwapSectionTimes(times); - route.SwapStreetNames(streets); + route.SetTurnInstructions(move(turnsDir)); + route.SetSectionTimes(move(times)); + route.SetStreetNames(move(streets)); return NoError; } @@ -518,9 +518,9 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint, JunctionsToPoints(junctions, points); route.SetGeometry(points.begin(), points.end()); - route.SwapTurnInstructions(turnsDir); - route.SwapSectionTimes(times); - route.SwapStreetNames(streets); + route.SetTurnInstructions(move(turnsDir)); + route.SetSectionTimes(move(times)); + route.SetStreetNames(move(streets)); return NoError; } diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp index f449e70531..2ce3321978 100644 --- a/routing/road_graph_router.cpp +++ b/routing/road_graph_router.cpp @@ -255,10 +255,10 @@ void RoadGraphRouter::ReconstructRoute(vector<Junction> && path, Route & route, JunctionsToAltitudes(junctions, altitudes); route.SetGeometry(routeGeometry.begin(), routeGeometry.end()); - route.SwapSectionTimes(times); - route.SwapTurnInstructions(turnsDir); - route.SwapStreetNames(streetNames); - route.SwapAltitudes(altitudes); + route.SetSectionTimes(move(times)); + route.SetTurnInstructions(move(turnsDir)); + route.SetStreetNames(move(streetNames)); + route.SetAltitudes(move(altitudes)); } unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn const & countryFileFn) diff --git a/routing/route.hpp b/routing/route.hpp index 7c1fdb294a..6e729b855c 100644 --- a/routing/route.hpp +++ b/routing/route.hpp @@ -55,10 +55,10 @@ public: Update(); } - inline void SwapTurnInstructions(TTurns & v) { swap(m_turns, v); } - inline void SwapSectionTimes(TTimes & v) { swap(m_times, v); } - inline void SwapStreetNames(TStreets & v) { swap(m_streets, v); } - inline void SwapAltitudes(feature::TAltitudes & v) { swap(m_altitudes, v); } + inline void SetTurnInstructions(TTurns &&v) { m_turns = move(v); } + inline void SetSectionTimes(TTimes && v) { m_times = move(v); } + inline void SetStreetNames(TStreets && v) { m_streets = move(v); } + inline void SetAltitudes(feature::TAltitudes && v) { m_altitudes = move(v); } uint32_t GetTotalTimeSec() const; uint32_t GetCurrentTimeToEndSec() const; diff --git a/routing/routing_result_graph.hpp b/routing/routing_result_graph.hpp index d815b228ec..2fac67733d 100644 --- a/routing/routing_result_graph.hpp +++ b/routing/routing_result_graph.hpp @@ -25,8 +25,8 @@ public: m2::PointD const & junctionPoint, size_t & ingoingCount, TurnCandidates & outgoingTurns) const = 0; virtual double GetPathLength() const = 0; - virtual Junction const & GetStartPoint() const = 0; - virtual Junction const & GetEndPoint() const = 0; + virtual Junction GetStartPoint() const = 0; + virtual Junction GetEndPoint() const = 0; virtual ~IRoutingResult() = default; }; diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index dbdb08c515..2f918a2079 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -523,7 +523,12 @@ void RoutingSession::EmitCloseRoutingEvent() const alohalytics::Location::FromLatLon(lastGoodPoint.lat, lastGoodPoint.lon)); } -bool RoutingSession::HasRouteAltitudeImpl() const { return !m_route.GetAltitudes().empty(); } +bool RoutingSession::HasRouteAltitudeImpl() const +{ + return !m_route.GetAltitudes().empty() + && m_route.GetAltitudes().size() == m_route.GetSegDistanceM().size() + 1; +} + bool RoutingSession::HasRouteAltitude() const { threads::MutexGuard guard(m_routeSessionMutex); @@ -539,12 +544,12 @@ bool RoutingSession::GetRouteAltitudes(feature::TAltitudes & routeAltitudes) con return true; } -bool RoutingSession::GetSegDistanceM(deque<double> & routeSegDistanceM) const +bool RoutingSession::GetSegDistanceM(vector<double> & routeSegDistanceM) const { threads::MutexGuard guard(m_routeSessionMutex); if (!m_route.IsValid()) return false; - routeSegDistanceM.assign(m_route.GetSegDistanceM().begin(), m_route.GetSegDistanceM().end()); + routeSegDistanceM = m_route.GetSegDistanceM(); return true; } diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp index a15b50a6f0..9156ab53ae 100644 --- a/routing/routing_session.hpp +++ b/routing/routing_session.hpp @@ -15,7 +15,6 @@ #include "base/mutex.hpp" #include "std/atomic.hpp" -#include "std/deque.hpp" #include "std/limits.hpp" #include "std/unique_ptr.hpp" @@ -106,15 +105,15 @@ public: inline void SetState(State state) { m_state = state; } Route const & GetRoute() const { return m_route; } - /// \returns true if any altitude information along |m_route| is available and + /// \returns true if altitude information along |m_route| is available and /// false otherwise. bool HasRouteAltitude() const; /// \brief copies route altitude information to |routeAltitudes| if any is available and - /// returns true. If no route altitude information is available returns false. + /// returns true. If there's no navigation route, the method returns false. bool GetRouteAltitudes(feature::TAltitudes & routeAltitudes) const; /// \brief copies distance from route beginning to ends of route segments in meters and /// returns true. If the route is not valid returns false. - bool GetSegDistanceM(deque<double> & routeSegDistanceM) const; + bool GetSegDistanceM(vector<double> & routeSegDistanceM) const; State OnLocationPositionChanged(location::GpsInfo const & info, Index const & index); void GetRouteFollowingInfo(location::FollowingInfo & info) const; @@ -148,7 +147,6 @@ public: double GetCompletionPercent() const; void EmitCloseRoutingEvent() const; - bool HasRouteAltitudeImpl() const; private: struct DoReadyCallback @@ -176,6 +174,8 @@ private: void RemoveRoute(); void RemoveRouteImpl(); + bool HasRouteAltitudeImpl() const; + private: unique_ptr<AsyncRouter> m_router; Route m_route; diff --git a/routing/routing_tests/route_tests.cpp b/routing/routing_tests/route_tests.cpp index 821e4a59ac..985d270935 100644 --- a/routing/routing_tests/route_tests.cpp +++ b/routing/routing_tests/route_tests.cpp @@ -50,7 +50,7 @@ UNIT_TEST(DistanceToCurrentTurnTest) Route route("TestRouter"); route.SetGeometry(kTestGeometry.begin(), kTestGeometry.end()); vector<turns::TurnItem> turns(kTestTurns); - route.SwapTurnInstructions(turns); + route.SetTurnInstructions(move(turns)); double distance; turns::TurnItem turn; @@ -85,7 +85,7 @@ UNIT_TEST(NextTurnTest) Route route("TestRouter"); route.SetGeometry(kTestGeometry.begin(), kTestGeometry.end()); vector<turns::TurnItem> turns(kTestTurns); - route.SwapTurnInstructions(turns); + route.SetTurnInstructions(move(turns)); double distance, nextDistance; turns::TurnItem turn; @@ -114,7 +114,7 @@ UNIT_TEST(NextTurnsTest) Route route("TestRouter"); route.SetGeometry(kTestGeometry.begin(), kTestGeometry.end()); vector<turns::TurnItem> turns(kTestTurns); - route.SwapTurnInstructions(turns); + route.SetTurnInstructions(move(turns)); vector<turns::TurnItemDist> turnsDist; { @@ -165,9 +165,9 @@ UNIT_TEST(RouteNameTest) route.SetGeometry(kTestGeometry.begin(), kTestGeometry.end()); vector<turns::TurnItem> turns(kTestTurns); - route.SwapTurnInstructions(turns); + route.SetTurnInstructions(move(turns)); Route::TStreets names(kTestNames); - route.SwapStreetNames(names); + route.SetStreetNames(move(names)); string name; route.GetCurrentStreetName(name); |