From 69ef69126de0bf9223ada5454ff655a07c0f4d9f Mon Sep 17 00:00:00 2001 From: Dmitry Svetlichny Date: Tue, 5 Nov 2024 22:10:58 +0200 Subject: [PATCH 1/2] Fixed dif stat --- .../OABaseTrackMenuHudViewController.mm | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm b/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm index 0b96d695ba..8a3aedd244 100644 --- a/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm +++ b/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm @@ -284,22 +284,24 @@ - (void)updateGpxData:(BOOL)replaceGPX updateDocument:(BOOL)updateDocument } } - -- (OASGpxTrackAnalysis *)getAnalysisFor:(OASTrkSegment *)segment -{ - OASGpxTrackAnalysis *analysis = [[OASGpxTrackAnalysis alloc] init]; - auto splitSegments = [ArraySplitSegmentConverter toKotlinArrayFrom:@[[[OASSplitSegment alloc] initWithSegment:segment]]]; - [analysis prepareInformationFileTimeStamp:0 pointsAnalyser:nil splitSegments:splitSegments]; - return analysis; -} - - (void)updateAnalysis { if (_doc) { - _analysis = !_isCurrentTrack && [_doc getGeneralTrack] && [_doc getGeneralSegment] - ? [self getAnalysisFor:[_doc getGeneralSegment]] - : [_doc getAnalysisFileTimestamp:0 fromDistance:nil toDistance:nil pointsAnalyzer:OASPlatformUtil.shared.getTrackPointsAnalyser]; + NSString *gpxFilePath = _doc.path; + NSTimeInterval fileTimestamp; + if (gpxFilePath.length == 0) + { + fileTimestamp = [[NSDate date] timeIntervalSince1970] * 1000; + } + else + { + OASKFile *file = [[OASKFile alloc] initWithFilePath:gpxFilePath]; + fileTimestamp = file.lastModified; + } + _analysis = [_doc getAnalysisFileTimestamp:fileTimestamp fromDistance:nil toDistance:nil pointsAnalyzer:OASPlatformUtil.shared.getTrackPointsAnalyser]; + if (_analysis.totalDistanceWithoutGaps == 0 && _analysis.totalDistance != 0) + _analysis.totalDistanceWithoutGaps = _analysis.totalDistance; } else { From 396922aa69e9546bfd53aad0c65f9ad11f09e40a Mon Sep 17 00:00:00 2001 From: Dmitry Svetlichny Date: Wed, 6 Nov 2024 15:53:59 +0200 Subject: [PATCH 2/2] add comment --- .../TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm b/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm index 8a3aedd244..6fcde8ebbf 100644 --- a/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm +++ b/Sources/Controllers/TargetMenu/GPX/TrackMenu/OABaseTrackMenuHudViewController.mm @@ -301,6 +301,7 @@ - (void)updateAnalysis } _analysis = [_doc getAnalysisFileTimestamp:fileTimestamp fromDistance:nil toDistance:nil pointsAnalyzer:OASPlatformUtil.shared.getTrackPointsAnalyser]; if (_analysis.totalDistanceWithoutGaps == 0 && _analysis.totalDistance != 0) + // Set _analysis.totalDistanceWithoutGaps to _analysis.totalDistance because the initial analysis does not compute totalDistanceWithoutGaps for tracks with multiple segments during this initialization. _analysis.totalDistanceWithoutGaps = _analysis.totalDistance; } else