Re: Find nearest geographic coordinates
Frank Muller <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAFA6GnAGVv0ky7JnTo-oM++Y3gUWqCyy1UHmBoGuKG4Tc1eH6A@mail.gmail.com> |
Thanks Richard. Happy to see you are still around and didn’t left the Erlang community. /Frank Fri . 27 nov. 2020 03:57, Richard O'Keefe <[email protected]> wrote : > 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 <[email protected]> > 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 >> >