Skip to content

Commit

Permalink
Added debug logs to my location animation
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-osm committed Feb 8, 2024
1 parent 3004015 commit 5faa35e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions Sources/Controllers/Map/OAMapViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define kScreensToFlyWithAnimation 400000.0
#define kUserInteractionAnimationKey reinterpret_cast<OsmAnd::MapAnimator::Key>(1)
#define kLocationServicesAnimationKey reinterpret_cast<OsmAnd::MapAnimator::Key>(2)
#define kNavAnimatonTime 1.0f

#define CENTER_CONSTANT 0
#define BOTTOM_CONSTANT 1
Expand Down
22 changes: 9 additions & 13 deletions Sources/Controllers/Map/OAMapViewTrackingUtilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -334,31 +334,27 @@ - (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,
kLocationServicesAnimationKey);
}
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,
Expand Down

0 comments on commit 5faa35e

Please sign in to comment.