kungfoo / geohash-java

Implementation of GeoHashes in java. We try to be/stay compliant to the spec, as far as possible.
Other
985 stars 309 forks source link

`VincentyGeodesy.distanceInMeters` works incorrectly if one of the points is either South or North pole #66

Open satorg opened 1 year ago

satorg commented 1 year ago

Example (all results in meters are converted into kilometers for convenience):

VincentyGeodesy.distanceInMeters(new WGS84Point(90, 0), new WGS84Point(89, 0)) / 1000.0
  results to 19892.237593638412

whereas

VincentyGeodesy.distanceInMeters(new WGS84Point(-90, 0), new WGS84Point(89, 0)) / 1000.0
  results to 111.69386491426172

which is apparently incorrect.

Note that for a point that is off the pole just a fraction of a degree, the algorithm seems working correctly (or at least plausible):

VincentyGeodesy.distanceInMeters(new WGS84Point(89.9999, 0), new WGS84Point(89, 0)) / 1000.0
  results to 111.6826955163081

VincentyGeodesy.distanceInMeters(new WGS84Point(-89.9999, 0), new WGS84Point(89, 0)) / 1000.0
  results to 19892.22642424046