Resolving iPhone apps GPS accuracy problems

November 19th, 2014

We have been creating mobile solutions for our customers for almost a decade. But with each project's experience come interesting challenges. Recently, we developed an iPhone application that is now available in the Apple Store. It required us to determine a user's location at various points using GPS. It turned out that in developing GPS-based mobile applications, the accuracy of the coordinates can vary. These inaccuracies appear on the screen as sudden jumps in a user's location on the map and are especially visible if the application is trying to plot a route that the user is traveling. These inaccuracies are the result of not discarding bad coordinate points and not detecting fluctuation of points in a route.

In certain situations the CoreLocation framework can return points with incorrect coordinates. To deal with this issue, we developed the following criteria to determine that a point is invalid:

  • Object's location is null
  • horizontalAccuracy < 0
  • Temporary marker of the new location has a value less than the value of the temporary marker of the previous location. This indicates that the LocationManager has returned locations in the wrong order.
  • New location's temporary marker indicates that it was returned prior to starting the application because the CoreLocation framework caches points from the last time the GPS was used. This can create an undesirable result. For example, the user exits the GPS application, drives 40 miles, re-launches the GPS application, and the LocationManager returns the coordinate point that is off by 40 miles from the user's current location.

In a situation where the signal is weak or the mobile device is on standby, the CoreLocation manager can return coordinate points that greatly vary from one another. To address this problem, we have applied specific filters (Kalman filter) and interpolation algorithms for detecting these false coordinates and smoothing out the points on the route. However, if you are building an application that requires you to know a user's precise location without performing the additional analysis, you can use a shortcut that can significantly decrease the amount of inaccurate points - discard all points where horizontalAccuracy > 150 m.

Until next time, when we continue to share our experience in the mobile world!