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

[Bug] Incorrect distance when longitude close to antimeridian #2

Closed
johnp-4dvanalytics opened this issue May 26, 2021 · 2 comments
Closed

Comments

@johnp-4dvanalytics
Copy link

johnp-4dvanalytics commented May 26, 2021

inverse(lats1=[0], lons1=[179.9999999], 
        lats2=[0], 
        lons2=[180])["s12"]
        
#array([20003931.4586233])

the below code fixes it:

def fix_lon(x, dtype=np.float64):
    min_lon = -180 + np.finfo(dtype).eps
    max_lon = 180 - np.finfo(dtype).eps 
    
    x = np.where(x > max_lon, max_lon, x)
    x = np.where(x < min_lon, min_lon, x)
    return x

inverse(lats1=[0], lons1=fix_lon([179.9999999]), 
        lats2=[0], 
        lons2=fix_lon([180]))["s12"]

#array([0.])
@omdv
Copy link
Owner

omdv commented May 27, 2021

Thanks for finding this. I checked your proposed fix and I don't think it will work, first of all it does not solve the issue for me as-is if I do proper comparison vs geographiclib (non-vectorized benchmark) and also there are some further test issues.

Looking into it. The problem goes away if you increase the separation between points. So just want to mention that you are pushing accuracy of WGS84 geod model if you want to go to centimeters.

@omdv
Copy link
Owner

omdv commented Jun 4, 2021

I introduced the fix and added new tests. Please check the new version from pip (==1.3).

@omdv omdv closed this as completed Jun 4, 2021
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