Find nearest geographic coordinates

Richard O'Keefe raoknz@REDACTED
Fri Nov 27 03:57:40 CET 2020


When I had something similar to do, I found the simplest
thing was to convert latitude and longitude to (x,y,z)
points on the unit sphere.  I then took advantage of the
fact that great-circle distance on the surface of the
sphere and chordal distance going through it are monotonically
related, so the closest in 3-space is also the closest on the
2-sphere.  See
https://en.wikipedia.org/wiki/Great-circle_distance

The obvious question is SCALE:
how many points will there be?
how many queries will there be?
For my application, storing the 3d points in a k-d-tree
with k=3 worked OK, but it was hundreds of points,
not millions.

On Thu, 26 Nov 2020 at 10:39, Frank Muller <frank.muller.erl@REDACTED>
wrote:

> Hi guys,
>
> I've a list of geographic coordinates:
>
> L = [ {{<<"longitude">>,6.1457}, {<<"latitude">>,46.2022}},
>       {{<<"longitude">>,2.3387}, {<<"latitude">>,48.8582}},
>       ... ]
>
> and a specific coordinate X = {{<<"longitude">>,-73.5848},
> {<<"latitude">>,45.4995}}.
>
> Question: how can i find the nearest coordinates to X from L (sorted from
> the nearest to the farest)?
>
> /Frank
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20201127/0f1cecb3/attachment.htm>


More information about the erlang-questions mailing list