anowacki / Geodesics.jl

Calculate great circles on a flattened sphere in Julia
Other
11 stars 5 forks source link

shortest distance between two points #7

Open lazarusA opened 3 years ago

lazarusA commented 3 years ago

Probably a very naive question.

But, is it possible to obtain the shortest distance between two points (geodesic) with this package and if so, how?

Geodesics.inverse ? [with this right?]

But, more importantly: How do I get the corresponding geodesic line data?

anowacki commented 3 years ago

The shorted distance between two points defines the geodesic, and as you suspect, this is given using inverse(lon1, lat1, lon2, lat2). See the Geodesics.inverse section in the README file, or examine the inverse docstring in the REPL.

I think by 'geodesic line data', you mean points along the geodesic. This package doesn't have a function to compute those for you, but it is quite easy to find these using the angular_step function (see docstring for details). You would first call inverse to obtain the azimuth from the starting point and geodesic distance, then call angular_step multiple times with that azimuth and different distances to obtain several points along the geodesic.

Whilst this package does what it needs to, I suggest instead using GeographicLib.jl, because that package uses a more accurate (but just as fast) algorithm to compute geodesics, and also exposes the waypoints function. There are examples of its use in the documentation—another reason to prefer that package.