public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation) { var currentLocation = EdisonLocationFromCLLocation(newLocation); OnLocationChanged?.Invoke(this, new LocationChangedEventArgs { CurrentLocation = currentLocation, LastLocation = oldLocation != null ? EdisonLocationFromCLLocation(oldLocation) : null, }); LastKnownLocation = currentLocation; }
public const float LocationThresholdPercent = 0.1f; // % as fraction public static bool RemoveLocationJitter(EdisonLocation oldLocation, EdisonLocation newLocation, int jitterThresholdMeters = UserLocationJitterThreshold) { if (newLocation == null) { return(false); } if (oldLocation == null) { return(true); } var latDelta = Math.Abs(newLocation.Latitude - oldLocation.Latitude); var longDelta = Math.Abs(newLocation.Longitude - oldLocation.Longitude); // Check for user location jitter check the user has moved more than the threshold to update map var latDistanceDelta = latDelta * 111111; var longDistanceDelta = longDelta * 111111 * Math.Cos(newLocation.Latitude); var deltaDist = Math.Sqrt(latDistanceDelta * latDistanceDelta + longDistanceDelta * longDistanceDelta); return(deltaDist >= jitterThresholdMeters); }