Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VincentyGeodesy.distanceInMeters can result in NaN for valid input coordinates #52

Open
satorg opened this issue Mar 2, 2021 · 2 comments

Comments

@satorg
Copy link
Contributor

satorg commented Mar 2, 2021

Sometimes VincentyGeodesy.distanceInMeters produces NaN for pretty valid input points.
There are examples (not a complete list!) of arguments for distanceInMeters below that result it to generate NaN:

foo=(0.0,0.0), bar=(0.0,-180.0)
foo=(1.0,180.0), bar=(0.0,1.0)
foo=(0.0,0.0), bar=(0.0,180.0)
foo=(-1.0,1.0), bar=(0.0,-180.0)
foo=(-1.0,-103.0), bar=(0.0,78.0)
foo=(-1.0,-106.0), bar=(0.0,75.0)
foo=(-1.0,-142.0), bar=(0.0,39.0)
foo=(-1.0,-155.0), bar=(0.0,26.0)
foo=(-1.0,-161.0), bar=(0.0,18.0)
foo=(-1.0,-164.0), bar=(0.0,17.0)
foo=(-1.0,-176.0), bar=(1.0,4.0)
foo=(-1.0,-178.0), bar=(0.0,1.0)
foo=(-1.0,-179.0), bar=(0.0,0.0)
foo=(-1.0,-30.0), bar=(0.0,149.0)
foo=(-1.0,-33.0), bar=(0.0,148.0)
foo=(-1.0,-50.0), bar=(1.0,130.0)
foo=(-1.0,-74.0), bar=(0.0,105.0)
foo=(-1.0,-79.0), bar=(1.0,101.0)
foo=(-1.0,-93.0), bar=(0.0,86.0)
foo=(-1.0,0.0), bar=(0.0,-179.0)
foo=(-1.0,0.0), bar=(0.0,179.0)
foo=(-1.0,1.0), bar=(0.0,-178.0)
foo=(-1.0,1.0), bar=(1.0,-179.0)
foo=(-1.0,110.0), bar=(0.0,-69.0)
foo=(-1.0,144.0), bar=(0.0,-35.0)
foo=(-1.0,158.0), bar=(1.0,-22.0)
foo=(-1.0,167.0), bar=(1.0,-13.0)
foo=(-1.0,174.0), bar=(0.0,-5.0)
foo=(-1.0,176.0), bar=(0.0,-3.0)
foo=(-1.0,179.0), bar=(0.0,0.0)
foo=(-1.0,33.0), bar=(0.0,-148.0)
foo=(-1.0,46.0), bar=(0.0,-135.0)
foo=(-1.0,47.0), bar=(0.0,-134.0)
foo=(-1.0,5.0), bar=(1.0,-175.0)

The list above is generated with help of ScalaCheck.

Version: 1.4.0

@mrjonjonjon
Copy link

This probably happens because "Between two nearly antipodal points, the iterative formula may fail to converge". Perhaps in such cases, half the circumference of earth should be used.

@satorg
Copy link
Contributor Author

satorg commented Jul 11, 2022

@mrjonjonjon yes, looks like so... But seems there's no clear and ready-to-use solution yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants