maurycyp / vincenty

Calculate the geographical distance between 2 points with extreme accuracy.
The Unlicense
62 stars 13 forks source link

Failing cases on sets of co-ordinates. #5

Closed harrison0083 closed 6 years ago

harrison0083 commented 6 years ago

Recently discovered some failing cases in a project I'm working on. I'm not sure what the cause of the problem is but no distance is returned. The co-ordinates are real places on Earth.

Geopoint locations used: (3.44, -76.52), (-3.94, 103.8)
Geopoint locations used: (3.44, -76.52), (-3.29, 102.86)
Geopoint locations used: (3.44, -76.52), (-4.02, 103.25)
Geopoint locations used: (11.56, 104.92), (-12.07, -75.2)
Geopoint locations used: (11.56, 104.92), (-11.42, -75.69)
Geopoint locations used: (-6.23, 106.99), (5.82, -73.03)
Geopoint locations used: (-6.23, 106.99), (5.71, -72.93)
Geopoint locations used: (31.77, 119.95), (-31.73, -60.52)
Geopoint locations used: (3.03, 101.45), (-2.9, -79.0)
Geopoint locations used: (3.04, 101.58), (-2.9, -79.0)

A console Python example would be:

>>> loc1 = (3.44, -76.52)
>>> loc2 = (-3.79, 103.54)
>>> loc3 = (11.56, 104.92)
>>> loc4 = (-11.42, -75.69)
>>> vincenty(loc1,loc2)
>>> vincenty(loc3,loc4)
>>> vincenty(loc1,loc4)
1645.873288
>>>

Interestingly these cases fail even on http://www.gpsvisualizer.com/calculators which makes me think the problem is one inherent to the formula or something I'm doing.

harrison0083 commented 6 years ago

My apologies, I just realised those are near anti-podal sets of co-ordinates. That's what's causing the formula to fail to converge on a distance.