maurycyp / vincenty

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

Returns None #8

Open macleginn opened 2 years ago

macleginn commented 2 years ago

Like this:

>>> a = (-22.6559, -58.9053)
>>> b = (23.0917, 121.348)
>>> vincenty(a, b)                 # None!
>>> b = (23.0917, 122.348)  # Increase the longitude by a little bit.
>>> vincenty(a, b)
19889.79461
muhammedsirajudeen commented 1 year ago

Vincenty formula will fail to converge in points that are anti poidal in nature in debugging the source code i observed that.The return value is None because the points failed to converge. These points are anti poidal in nature that is they are in opposite sides of earth even vincenty was aware of this limitation.This is not a problem of implementation .Inverse implementation of vincenty formula will fail to converge for points that are anti poidal

macleginn commented 1 year ago

Thanks! This makes me wonder, what is the tolerance threshold here? These points are not exactly antipodal, neither in terms of latitude nor in terms of longitude (the "true" antipode to point a is (22.6559, 121.0947)). If the model is likely to fail given approximately antipodal points, I would say it makes sense to check for that in advance and raise some kind of AntipodalPointsError.