Reputation: 1232
I need to calculate the distance between two points (Lat/Lng). In android I can achieve this in two ways :
1)
location1.distanceTo(location2);
2)
SphericalUtil.computeDistanceBetween(location1, location2);
Which one should I use to get the most accurate distance between the two points ?
Upvotes: 0
Views: 229
Reputation: 62189
SphericalUtil.computeDistanceBetween() returns double
, whereas Location.distanceTo() returns float
.
From documentation of distanceTo
Returns the approximate distance in meters between this location and the given location.
From documentation of computeDistanceBetween
Returns the distance between two LatLngs, in meters.
SphericalUtil
tends to be more precise.
Upvotes: 1