2

I'm currently measuring the distance how far the user walked/runned/etc. When I'm comparing my results with results from other apps my result is not that accurate as the others (i.e 100m which are correct and my result is around 50m). So how can I improve my accuracy to get more accurate results?

What I'm doing so far is:

Init the CLLocationManager:

locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
locationManager.distanceFilter = 10;

and:

- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    CLLocation *lastLocation = [locations lastObject];

    NSTimeInterval age = -[lastLocation.timestamp timeIntervalSinceNow];

    if (age > 30.0) return;

    if (lastLocation.horizontalAccuracy < 0) return; // ignore invalid updates

    if (previousLocation == nil || previousLocation.horizontalAccuracy < 0)
    {
        previousLocation = lastLocation;
        return;
    }

    CLLocationDistance distance = [lastLocation distanceFromLocation:previousLocation];

    if ([delegate respondsToSelector:@selector(currentDistance:)])
    {
        [delegate currentDistance:distance];
    }

    previousLocation = lastLocation;  

}

Cheers!

gpichler
  • 2,181
  • 2
  • 27
  • 52

1 Answers1

3

Usually geolocation is made in 3 ways depending on the settings and devices hardware:

  • cellular radio
  • wifi mapping
  • GPS

The -desiredAccuracy property sets which of those three modes should be on. On the other hand the most accuracy you require the latest response is. First you will get radio (only for cell devices), if WiFI is on and cell data are on you will get WiFi geolocation, generally around +- 100m, and a lot after GPS (if available). The delay on GPS is due two search of satellite and battery optimization. For running I would suggest you to use as desired accuracy kCLLocationAccuracyBestForNavigation you should get values near +-10m as soon as GPS come into play.
Another thing is set -distanceFilter to 5 meters, if CoreLocation Manager get a new measurements with a delta >= 5 meters it will call the delegate method.
If you want to exclude location with horizontal accuracy bigger than a value just add another logical condition.
I recommend you also to read these answer link

Community
  • 1
  • 1
Andrea
  • 26,120
  • 10
  • 85
  • 131