Things you should know while working with GPS

Distance calculation using geo coordinates is very useful in mobile applications. Before starting to look into distance calculation methods, it is necessary to mention that these methods does not take into account of the ellipsoidal effects of the earth. Instead, the method assumes that the earth is spherical in nature which can lead to 0.3% of error. Hence it will tend to overestimate transpolar distances and under-estimate the trans-equatorial distances.

One of the widely used approach in distance calculation is regarded as the Haversine formula, which calculates the shortest distance on the earth’s surface i.e. (straight line distance between two points).

Following are the challenges that needs to be taken into consideration in order to avoid inaccurate distance measurements.

The time interval for each consecutive location readings should be properly configured. A long interval could result into an underestimation of the distance whereas a small interval will result in an overestimation of distance measurement. In addition, a geographical plane having a zigzag route is the best case to test the interval between subsequent location updates.

In my personal experience, a better way of dealing this situation in Android is to consider two parameters while periodical location updates i.e. minimum time and distance. Below is the reference code for location updates:

requestLocationUpdates(LocationManager.GPS_PROVIDER, minTimeInMillis, minimumDistanceInMeters, locationListener);

The values of time and distance varies according to the theme of application. However, considering an application that requires highest accuracy; for instance an application that precisely calculates the distance covered in a route should consider to have a minimum time in between 3ms to 5ms and distance equals to 50 meters.