1

I'm trying to retrieve data from GPS, but it's not so accurate. Here is a screenshot :

gpssc

It worked great with GPS emulation on the simulator. I want to know how to improve this.

Here is the code I tried :

    UserLocation = [[CLLocationManager alloc] init];
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
    [UserLocation setPausesLocationUpdatesAutomatically:NO];
    [UserLocation setActivityType:CLActivityTypeFitness];
#endif
   UserLocation.delegate = self;
    [UserLocation setDistanceFilter:kCLDistanceFilterNone];
    [UserLocation setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];
    [UserLocation startUpdatingLocation];

and then I retrieve data every second and check if it's different than the previous one.

Mehdi
  • 974
  • 1
  • 10
  • 24
  • where is screenshot?????? – SachinVsSachin Jul 23 '13 at 14:25
  • 2
    This is to be expected at times. GPS data in general will rarely be anywhere near 100% accurate. There are reflections from nearby buildings and other issues to deal with when reading raw GPS data. You'll want to look into a smoothing algorithm that can take the raw GPS data and intelligently interpret the results. Also, make sure that you toss away any data that does not meet the level of accuracy that you need. – Ric Perrott Jul 23 '13 at 14:25
  • then how to deal with these issues – Mehdi Jul 23 '13 at 14:26
  • Take a look at [this question](http://stackoverflow.com/questions/1134579/smooth-gps-data) and see if it helps – Ric Perrott Jul 23 '13 at 14:27
  • can u add some code to explain your problem – Xcode Jul 23 '13 at 14:28
  • hi user2381789, code added – Mehdi Jul 23 '13 at 14:32
  • [locationManager setDesiredAccuracy: kCLLocationAccuracyBestForNavigation]; try this code – Xcode Jul 23 '13 at 14:49

1 Answers1

2

Ric Perrott is right about the GPS data never being 100% accurate all the time. I suggest you set your accuracy to kCLLocationAccuracyBest which according to Apple is the right setting for what you are trying to do.

To try and filter out some of the 'jumping' you are getting, I suggest taking an average reading. For example, take X number of GPS readings (5 or 10 or...) and then average out. This will eliminate the occasional incorrect reading your device might get.

I wrote a fitness walking app a while back and had similar issues. Averaging did not completely resolve the issue but it did smooth it out a lot.

sangony
  • 11,636
  • 4
  • 39
  • 55