Location accuracy

I am currently working on a location tracking application and am having difficulties with inaccurate location updates from my CLLocationManager. This causes my application to track the distance that is actually caused by inaccurate GPS readings.

Inaccurate location readings

I can even leave my iPhone on the table with the application turned on, and after a few minutes my application tracks hundreds of meters at a distance just because of this shortcoming.

Here is my initialization code:

- (void)initializeTracking { self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; self.locationManager.distanceFilter = 5; [self.locationManager startUpdatingLocation]; } 

Thanks in advance!: -)

+8
ios objective-c core-location gps location
source share
4 answers

One of the ways I solved this in a similar application is to opt out of location updates, where the distance change is slightly less than the horizontal accuracy indicated in this location update.

Given a previousLocation , then for a newLocation calculate the distance from previousLocation . If this distance >= (horizontalAccuracy * 0.5) , we used this location, and this place will become our new previousLocation . If the distance is less, we discard this location update, do not change the previousLocation and wait for the next location update.

This worked well for our purposes, you can try something like this. If you still find too many updates that are noise, increase the ratio to 0.5, maybe try 0.66.

You can also protect against cases where you are just starting to get a fix, where you get a series of location updates that seem to be moving, but in fact it happens that the accuracy improves significantly.

I would avoid running any location tracking or distance measurement with horizontal accuracy> 70 meters. These are substandard positions for GNSS, although this may be all you can get in a city canyon, under a heavy canopy of trees, or in other poor signal conditions.

+14
source share

I used this method to get the desired location accuracy (in SWIFT)

 let TIMEOUT_INTERVAL = 3.0 func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { let newLocation = locations.last as! CLLocation println("didupdateLastLocation \(newLocation)") //The last location must not be capured more then 3 seconds ago if newLocation.timestamp.timeIntervalSinceNow > -3 && newLocation.horizontalAccuracy > 0 { var distance = CLLocationDistance(DBL_MAX) if let location = self.lastLocation { distance = newLocation.distanceFromLocation(location) } if self.lastLocation == nil || self.lastLocation!.horizontalAccuracy > newLocation.horizontalAccuracy { self.lastLocation = newLocation if newLocation.horizontalAccuracy <= self.locationManager.desiredAccuracy { //Desired location Found println("LOCATION FOUND") self.stopLocationManager() } } else if distance < 1 { let timerInterval = newLocation.timestamp.timeIntervalSinceDate(self.lastLocation!.timestamp) if timerInterval >= TIMEOUT_INTERVAL { //Force Stop stopLocationManager() } } } 

Where:

 if newLocation.timestamp.timeIntervalSinceNow > -3 && newLocation.horizontalAccuracy > 0 { 

The last location found should not be recorded more than 3 seconds ago, and the last location must have the correct horizontal accuracy (if less than 1 means that this is not a valid location).

Then we will set the distance with the default value:

  var distance = CLLocationDistance(DBL_MAX) 

Calculate the distance from the last location to a new place:

 if let location = self.lastLocation { distance = newLocation.distanceFromLocation(location) } 

If our local last location has not yet been established, or if the new horizontal location is better than the actual one, then we are going to set the local location to a new location:

 if self.lastLocation == nil || self.lastLocation!.horizontalAccuracy > newLocation.horizontalAccuracy { self.lastLocation = newLocation 

The next step is to check if the accuracy is correctly obtained from the location. To do this, we check to see if the horizontal distance of the location has changed, and then the desired value. If this is the case, we can stop our manager:

 if newLocation.horizontalAccuracy <= self.locationManager.desiredAccuracy { //Desired location Found self.stopLocationManager() } 

With the last if we will check if the distance from the last found location is removed, and the new location is less (this means that 2 locations are very close). If so, then we are going to get the time interval from the last found location and get a new location and check if the interval exceeds more than 3 seconds. If this is the case, it means that for more than 3 seconds we are not getting a location that is more accurate from our local location, and therefore we can stop the location services:

 else if distance < 1 { let timerInterval = newLocation.timestamp.timeIntervalSinceDate(self.lastLocation!.timestamp) if timerInterval >= TIMEOUT_INTERVAL { //Force Stop println("Stop location timeout") stopLocationManager() } } 
+4
source share

This is always a problem with satellites. This rating and ratings may vary. Each new report is a new assessment. You need a position clamp that ignores values ​​when there is no movement.

You can try using sensors to find out if the device is really moving. Look at the accelerometer data, if they do not change, the device does not move, although the GPS says that it is. Of course, there is noise on the accelerometer data, so you should also filter it out.

This is a difficult problem.

+1
source share

In fact, you cannot do more to improve what the operating system and your current trick give you. At first glance, it doesn't seem like something is wrong with your code - when it comes to iOS location updates, you're really at peace with the OS and your service.

What you can do is control where you pay attention. If I were you in my didUpdateLocations function when you receive callbacks from the OS with new locations - can you ignore any locations with horizontal accuracy exceeding a predetermined threshold, possibly 25 m? As a result, you will get fewer location updates, but you will have less noise.

0
source share

All Articles