JuliaGeo / Proj.jl

Julia wrapper for the PROJ cartographic projections library
MIT License
48 stars 9 forks source link

Invalid order of arguments passed to geod_inverse() #105

Closed himotoyoshi closed 2 months ago

himotoyoshi commented 4 months ago

The definition of the function Proj.geod_inverse() in geod.jl is as follows.

function geod_inverse(g::geod_geodesic, lat1::Real, lon1::Real, lat2::Real, lon2::Real)
    s12 = Ref{Cdouble}(NaN)
    azi1 = Ref{Cdouble}(NaN)
    azi2 = Ref{Cdouble}(NaN)

    geod_inverse(Ref(g), lat1, lat2, lon1, lon2, s12, azi1, azi2)

    return s12[], azi1[], azi2[]
end

However, I think the correct order of arguments passed to the (inner) geod_inverse() function should be

    geod_inverse(Ref(g), lat1, lon1, lat2, lon2, s12, azi1, azi2)
visr commented 4 months ago

Yes, it looks like you're right, thanks for the report. We should fix and add some tests for this function.

https://github.com/OSGeo/PROJ/blob/3c47abf8fd1175dc6ccd00b725e60e75897de90a/src/geodesic.h#L271