From 5faa35e12ad8bb2deebae27c0220cc16d7efee1a Mon Sep 17 00:00:00 2001 From: alex-osm Date: Thu, 8 Feb 2024 17:18:52 +0300 Subject: [PATCH] Added debug logs to my location animation --- Sources/Controllers/Map/OAMapViewController.h | 1 + .../Map/OAMapViewTrackingUtilities.mm | 22 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Sources/Controllers/Map/OAMapViewController.h b/Sources/Controllers/Map/OAMapViewController.h index 5a5f29334e..4663c27eaa 100644 --- a/Sources/Controllers/Map/OAMapViewController.h +++ b/Sources/Controllers/Map/OAMapViewController.h @@ -45,6 +45,7 @@ #define kScreensToFlyWithAnimation 400000.0 #define kUserInteractionAnimationKey reinterpret_cast(1) #define kLocationServicesAnimationKey reinterpret_cast(2) +#define kNavAnimatonTime 1.0f #define CENTER_CONSTANT 0 #define BOTTOM_CONSTANT 1 diff --git a/Sources/Controllers/Map/OAMapViewTrackingUtilities.mm b/Sources/Controllers/Map/OAMapViewTrackingUtilities.mm index 2b8b0dc492..588b636edb 100644 --- a/Sources/Controllers/Map/OAMapViewTrackingUtilities.mm +++ b/Sources/Controllers/Map/OAMapViewTrackingUtilities.mm @@ -334,18 +334,20 @@ - (void) onLocationServicesUpdate // Update target if (!sameLocation && !freeMapCenterMode) { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"]; + NSLog(@"DEBUG NAV: new = %@ %f, %f (%f km/h) %@", [dateFormatter stringFromDate: newLocation.timestamp], newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.speed * 3.6, (![self.class isSmallSpeedForAnimation:newLocation] ? @"ANIMATION" : @"")); + if (prevLocation) + { + NSLog(@"DEBUG NAV: prev = %@ %f, %f (%f km/h) %f", [dateFormatter stringFromDate: prevLocation.timestamp], prevLocation.coordinate.latitude, prevLocation.coordinate.longitude, prevLocation.speed * 3.6, [newLocation.timestamp timeIntervalSinceDate:prevLocation.timestamp]); + } if (![self.class isSmallSpeedForAnimation:newLocation] && _settings.animateMyLocation.get) { + double duration = prevLocation ? [newLocation.timestamp timeIntervalSinceDate:prevLocation.timestamp] : 0; + duration = MAX(duration, kNavAnimatonTime / 4); if (targetAnimation) { _mapView.mapAnimator->cancelAnimation(targetAnimation); - - double duration; - if (prevLocation) - duration = [newLocation.timestamp timeIntervalSinceDate:prevLocation.timestamp]; - else - duration = targetAnimation->getDuration() - targetAnimation->getTimePassed(); - _mapView.mapAnimator->animateTargetTo(newTarget31, duration, OsmAnd::MapAnimator::TimingFunction::Linear, @@ -353,12 +355,6 @@ - (void) onLocationServicesUpdate } else { - double duration; - if (prevLocation) - duration = MAX(1.0, [newLocation.timestamp timeIntervalSinceDate:prevLocation.timestamp]); - else - duration = kHalfSecondAnimatonTime; - _mapView.mapAnimator->animateTargetTo(newTarget31, duration, OsmAnd::MapAnimator::TimingFunction::Linear,