6

There is an Android as well as iOS application that I am working on. Both the applications use google's PlaceAutocomplete controller to get a location's lat-long. In iOS we get lat-long upto 6 decimal places sometimes 5 also. Where as in android we get more than 6 decimal places. The precision of the same location coordinate for Android and iOS differs.

For example consider location Pune
             Android Latlng: 18.520431,73.856744
                 iOS Latlng: 18.52043,73.856744

So as you can see there is difference between the precision of latitudes of the same location.

Is there a way to avoid this as my application needs comparison of these lat-longs?

Pritam Kadam
  • 3,203
  • 4
  • 19
  • 41

2 Answers2

8

You should not rely on the precision of the coordinates to compare them because they can change or, as you experiment, vary between platforms.

Instead, you can set a tolerance to determine if two locations are the same. For example:

float YOUR_TOLERANCE = 1; // 1 meter
if (location.distanceTo(otherLocation) < YOUR_TOLERANCE) {
    // Both locations are considered the same
}
antonio
  • 18,044
  • 4
  • 45
  • 61
4

In android also there is three type of location :

  1. GPS_PROVIDER
  2. NETWORK_PROVIDER
  3. PASSIVE_PROVIDER

So, as per my coding experience i come to know that if you use :

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, new MyLocationListener());

you will get long precision of decimal like more then 14+ and if you will you use fusion of them with this :

LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, my_google_listener);

then you will get 6 to 7 digit of precision. try it !!!

Dharvik shah
  • 1,969
  • 12
  • 27