4

I decompiled System.Device.Location.GeoCoordinate.GetDistanceTo(...), and found it uses the Haversine formula, which should specify the Earth's radius as one of the steps of calculation.

The radius specified in the decompiled code is 6376500.0 (meters).

In MSDN, the documentation for GetDistanceTo has a remark:

The Haversine formula accounts for the curvature of the earth, but assumes a spherical earth rather than an ellipsoid.

Wikipedia states that

Several different ways of modeling the Earth as a sphere each yield a mean radius of 6,371 kilometers

Also everywhere I search, I find cannot find anyone very few specifying the radius as 6,376.5 km.

So, even though they're pretty close, GetDistanceTo uses 6,376.5 km, but the widely accepted radius is 6,371 km. Why the difference? Did the creators of GetDistanceTo figure out a better way to approximate the radius of the Earth?

David S.
  • 5,965
  • 2
  • 40
  • 77
  • After a quick Google, looks like they're using the radius at the equator (well close to it anyway!) – Surfbutler Oct 02 '13 at 13:11
  • @Surfbutler but why? When the Haversine formula assumes spherical earth, why not use the mean radius instead of the max radius? Why would it be better in any way to use the max radius? – David S. Oct 02 '13 at 13:14
  • I suspect that only the Microsoft dev that wrote the function knows the answer to that. – Surfbutler Oct 02 '13 at 13:16
  • @Surfbutler could be.. maybe it's wishful thinking, but I'd like to think that such a widely used library goes through more than one person to decide constants and formulas. – David S. Oct 02 '13 at 13:21

1 Answers1

1

Unless my maths are out, this could lead to a difference of up to 34 km.

Sounds a lot, but only an additional 0.17% error.

Perhaps you could only use/display the results to 2 significant places then it won't really matter.

weston
  • 54,145
  • 21
  • 145
  • 203