Commit 8949787b authored by Chris Scott's avatar Chris Scott

Vary distanceFilter exponentially with speed, capped to 1000

parent cff6468f
...@@ -235,11 +235,12 @@ ...@@ -235,11 +235,12 @@
-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations -(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{ {
NSLog(@"- CDVBackgroundGeoLocation didUpdateLocations (isMoving: %hhd)", isMoving); NSLog(@"- CDVBackgroundGeoLocation didUpdateLocations (isMoving: %hhd)", isMoving);
CLLocation *newLocation = [locations lastObject];
if (!isMoving && !isAcquiringStationaryLocation && !stationaryLocation) { if (!isMoving && !isAcquiringStationaryLocation && !stationaryLocation) {
// Perhaps our GPS signal was interupted, re-acquire a stationaryLocation now. // Perhaps our GPS signal was interupted, re-acquire a stationaryLocation now.
[self setPace: NO]; [self setPace: NO];
} }
CLLocation *newLocation = [locations lastObject];
// Handle location updates as normal, code omitted for brevity. // Handle location updates as normal, code omitted for brevity.
// The omitted code should determine whether to reject the location update for being too // The omitted code should determine whether to reject the location update for being too
...@@ -362,10 +363,12 @@ ...@@ -362,10 +363,12 @@
{ {
float newDistanceFilter = distanceFilter; float newDistanceFilter = distanceFilter;
if (velocity > 5.0 && velocity < 100) { if (velocity > 3.0 && velocity < 100) {
newDistanceFilter = (5.0 * floorf(velocity / 5.0 + 0.5f)) * 10; // (rounded-velocity-to-nearest-5) / 2)^2
// eg 5.2 becomes (5/2)^2
newDistanceFilter = pow((5.0 * floorf(velocity / 5.0 + 0.5f)), 2) + distanceFilter;
} }
return newDistanceFilter; return (newDistanceFilter < 1000) ? newDistanceFilter : 1000;
} }
- (void) stopBackgroundTask - (void) stopBackgroundTask
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment