diff options
-rw-r--r-- | map/framework.cpp | 11 | ||||
-rw-r--r-- | map/framework.hpp | 6 | ||||
-rw-r--r-- | routing/routing_session.cpp | 14 | ||||
-rw-r--r-- | routing/routing_session.hpp | 10 |
4 files changed, 20 insertions, 21 deletions
diff --git a/map/framework.cpp b/map/framework.cpp index 3f1d73a477..10c0168d2b 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2989,13 +2989,12 @@ bool Framework::GenerateRouteAltitudeChart(uint32_t width, uint32_t height, vector<uint8_t> & imageRGBAData) const { feature::TAltitudes altitudes; - if (!m_routingSession.GetRouteAltitudes(altitudes)) - return false; - vector<double> segDistanceM; - if (!m_routingSession.GetSegDistanceM(segDistanceM)) + vector<double> segDistance; + + if (!m_routingSession.GetRouteAltitudesAndDistancesM(segDistance, altitudes)) return false; - segDistanceM.insert(segDistanceM.begin(), 0.0); + segDistance.insert(segDistance.begin(), 0.0); - return maps::GenerateChart(width, height, segDistanceM, altitudes, + return maps::GenerateChart(width, height, segDistance, altitudes, GetMapStyle(), imageRGBAData); } diff --git a/map/framework.hpp b/map/framework.hpp index 3701e342b0..5e181f1b94 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -725,7 +725,13 @@ public: void AllowAutoZoom(bool allowAutoZoom); void SaveAutoZoom(bool allowAutoZoom); + /// \returns true if altitude information along |m_route| is available and + /// false otherwise. bool HasRouteAltitude() const; + /// \brief Generates 4 bytes per point image (RGBA) and put the data to |imageRGBAData|. + /// \returns If there is valid route info and returns true and false otherwise. + /// \note If HasRouteAltitude() method returns true, GenerateRouteAltitudeChart(...) + /// could return false if route was deleted or rebuilt between the calls. bool GenerateRouteAltitudeChart(uint32_t width, uint32_t height, vector<uint8_t> & imageRGBAData) const; diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index affe26a4f0..eee15c3cb4 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -534,21 +534,15 @@ bool RoutingSession::HasRouteAltitude() const return HasRouteAltitudeImpl(); } -bool RoutingSession::GetRouteAltitudes(feature::TAltitudes & routeAltitudes) const +bool RoutingSession::GetRouteAltitudesAndDistancesM(vector<double> & routeSegDistanceM, + feature::TAltitudes & routeAltitudesM) const { threads::MutexGuard guard(m_routeSessionMutex); - if (!HasRouteAltitudeImpl()) + if (!m_route.IsValid() || !HasRouteAltitudeImpl()) return false; - routeAltitudes.assign(m_route.GetAltitudes().begin(), m_route.GetAltitudes().end()); - return true; -} -bool RoutingSession::GetSegDistanceM(vector<double> & routeSegDistanceM) const -{ - threads::MutexGuard guard(m_routeSessionMutex); - if (!m_route.IsValid()) - return false; routeSegDistanceM = m_route.GetSegDistanceM(); + routeAltitudesM.assign(m_route.GetAltitudes().cbegin(), m_route.GetAltitudes().cend()); return true; } diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp index 9156ab53ae..d10d637c01 100644 --- a/routing/routing_session.hpp +++ b/routing/routing_session.hpp @@ -108,12 +108,12 @@ public: /// \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 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(vector<double> & routeSegDistanceM) const; + /// route altitude information to |routeSegDistanceM| and |routeAltitudes|. + /// \returns true if there is valid route information. If the route is not valid returns false. + bool GetRouteAltitudesAndDistancesM(vector<double> & routeSegDistanceM, + feature::TAltitudes & routeAltitudesM) const; State OnLocationPositionChanged(location::GpsInfo const & info, Index const & index); void GetRouteFollowingInfo(location::FollowingInfo & info) const; |