Different distance between two points on iOS and Android

I am trying to measure the distance between two points (longitude, latitude). My problem is that I get different results on iOS and then on Android.

I checked it with this site and the result was that the Android values ​​are correct.

I use this MapKit method to get the distance in iOS: distanceFromLocation:

Here are my test locations:

P1 : 48.643798, 9.453735 P2 : 49.495150, 9.782150

IOS distance : 97717 m; Android distance : 97673 m

How is this possible and how can I fix it?

+7
source share
3 answers

So I had another problem and came across an answer to both of our questions:

In iOS, you can do the following:

  meters1 = [P1 distanceFromLocation:P2] // meters1 is 97,717 meters2 = [P2 distanceFromLocation:P1] // meters2 is 97,630 

I searched and searched, but could not find the reason for the difference. Since they are exact points, they should show the same distance no matter how you travel. I sent it to Apple as an error and they closed it as a duplicate, but still haven't fixed it. I suggest to everyone who wants this to be fixed in order to also present it as a mistake.

At the same time, the average of the two values ​​is actually correct:

  meters = (meters1 + meters2)/2 // meters (the average of the first two) is 97,673 

Android obviously does not have this problem.

+9
source

Longitude and latitude are not all you need. You must use the same comparison model as WGS84 or ETRS89. Earth is not an exact ellipsoid, so you need models, none of the models is completely accurate, and the distances are somewhat different depending on the model used.

Please make sure that you use the same link for iOS and Android.

+3
source

There are several ways to calculate the distance between long / lat chords based on how you compensate for the curvature of the earth, and there is no right or wrong approach. Most likely, the two platforms use a slightly different model.

Here are some formulas to calculate it. http://www.movable-type.co.uk/scripts/latlong.html

If you absolutely need them to be the same, just do your own calculation using one of these formulas, then you can guarantee that you will get the same result on both platforms.

+3
source

All Articles