diff --git a/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo+Core.h b/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo+Core.h index 969b4c2374..a7565ae24d 100644 --- a/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo+Core.h +++ b/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo+Core.h @@ -2,9 +2,13 @@ #include #include "map/gps_track_collection.hpp" +#include "map/elevation_info.hpp" @interface TrackRecordingInfo (Core) - (instancetype)initWithGpsTrackInfo:(GpsTrackInfo const &)info; +- (instancetype)initWithDistance:(double)distance duration:(double)duration; + +- (void)setElevationInfo:(ElevationInfo const &)elevationInfo; @end diff --git a/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.h b/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.h index eaf1adb902..01dc643202 100644 --- a/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.h +++ b/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.h @@ -4,12 +4,14 @@ NS_ASSUME_NONNULL_BEGIN @interface TrackRecordingInfo : NSObject -@property (nonatomic, readonly) NSString * distance; -@property (nonatomic, readonly) NSString * duration; -@property (nonatomic, readonly) NSString * ascent; -@property (nonatomic, readonly) NSString * descent; -@property (nonatomic, readonly) NSString * maxElevation; -@property (nonatomic, readonly) NSString * minElevation; +@property (nonatomic, readonly) double distance; +@property (nonatomic, readonly) double duration; +@property (nonatomic, readonly) NSUInteger ascent; +@property (nonatomic, readonly) NSUInteger descent; +@property (nonatomic, readonly) NSUInteger maxElevation; +@property (nonatomic, readonly) NSUInteger minElevation; + +- (BOOL)hasElevationInfo; + (TrackRecordingInfo *)emptyInfo; diff --git a/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.mm b/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.mm index 88fb0a2c4e..0533fab2c0 100644 --- a/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.mm +++ b/iphone/CoreApi/CoreApi/TrackRecorder/TrackRecordingInfo.mm @@ -3,10 +3,12 @@ #import "DistanceFormatter.h" #import "DurationFormatter.h" +#include "map/elevation_info.hpp" + @implementation TrackRecordingInfo -+ (TrackRecordingInfo *)emptyInfo { - return [[TrackRecordingInfo alloc] initWithGpsTrackInfo:GpsTrackInfo()]; +- (BOOL)hasElevationInfo { + return _ascent != 0 || _descent != 0 || _maxElevation != 0 || _minElevation != 0; } @end @@ -15,14 +17,29 @@ - (instancetype)initWithGpsTrackInfo:(GpsTrackInfo const &)trackInfo { if (self = [super init]) { - _distance = [DistanceFormatter distanceStringFromMeters:trackInfo.m_length]; - _duration = [DurationFormatter durationStringFromTimeInterval:trackInfo.m_duration]; - _ascent = [AltitudeFormatter altitudeStringFromMeters:trackInfo.m_ascent]; - _descent = [AltitudeFormatter altitudeStringFromMeters:trackInfo.m_descent]; - _maxElevation = [AltitudeFormatter altitudeStringFromMeters:trackInfo.m_maxElevation]; - _minElevation = [AltitudeFormatter altitudeStringFromMeters:trackInfo.m_minElevation]; + _distance = trackInfo.m_length; + _duration = trackInfo.m_duration; + _ascent = trackInfo.m_ascent; + _descent = trackInfo.m_descent; + _maxElevation = trackInfo.m_maxElevation; + _minElevation = trackInfo.m_minElevation; } return self; } +- (instancetype)initWithDistance:(double)distance duration:(double)duration { + if (self = [super init]) { + _distance = distance; + _duration = duration; + } + return self; +} + +- (void)setElevationInfo:(ElevationInfo const &)elevationInfo { + _ascent = elevationInfo.GetAscent(); + _descent = elevationInfo.GetDescent(); + _maxElevation = elevationInfo.GetMaxAltitude(); + _minElevation = elevationInfo.GetMinAltitude(); +} + @end diff --git a/iphone/Maps/Core/TrackRecorder/TrackRecordingActivityManager.swift b/iphone/Maps/Core/TrackRecorder/TrackRecordingActivityManager.swift index 954bf78c8e..0a6c83ee18 100644 --- a/iphone/Maps/Core/TrackRecorder/TrackRecordingActivityManager.swift +++ b/iphone/Maps/Core/TrackRecorder/TrackRecordingActivityManager.swift @@ -48,12 +48,19 @@ extension TrackRecordingLiveActivityManager: TrackRecordingActivityManager { private extension TrackRecordingLiveActivityAttributes.ContentState { init(trackInfo: TrackRecordingInfo) { - self.distance = StatisticsViewModel(key: "", value: trackInfo.distance) - self.duration = StatisticsViewModel(key: "", value: trackInfo.duration) - self.maxElevation = StatisticsViewModel(key: L("elevation_profile_max_elevation"), value: trackInfo.maxElevation) - self.minElevation = StatisticsViewModel(key: L("elevation_profile_min_elevation"), value: trackInfo.minElevation) - self.ascent = StatisticsViewModel(key: L("elevation_profile_ascent"), value: trackInfo.ascent) - self.descent = StatisticsViewModel(key: L("elevation_profile_descent"), value: trackInfo.descent) + let distance = DistanceFormatter.distanceString(fromMeters: trackInfo.distance) + let duration = DurationFormatter.durationString(from: trackInfo.duration) + let maxElevation = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.maxElevation)) + let minElevation = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.minElevation)) + let ascent = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.ascent)) + let descent = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.descent)) + + self.distance = StatisticsViewModel(key: "", value: distance) + self.duration = StatisticsViewModel(key: "", value: duration) + self.maxElevation = StatisticsViewModel(key: L("elevation_profile_max_elevation"), value: maxElevation) + self.minElevation = StatisticsViewModel(key: L("elevation_profile_min_elevation"), value: minElevation) + self.ascent = StatisticsViewModel(key: L("elevation_profile_ascent"), value: ascent) + self.descent = StatisticsViewModel(key: L("elevation_profile_descent"), value: descent) } }