<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">When I had something similar to do, I found the simplest</div><div class="gmail_default" style="font-family:monospace,monospace">thing was to convert latitude and longitude to (x,y,z)</div><div class="gmail_default" style="font-family:monospace,monospace">points on the unit sphere. I then took advantage of the</div><div class="gmail_default" style="font-family:monospace,monospace">fact that great-circle distance on the surface of the</div><div class="gmail_default" style="font-family:monospace,monospace">sphere and chordal distance going through it are monotonically</div><div class="gmail_default" style="font-family:monospace,monospace">related, so the closest in 3-space is also the closest on the</div><div class="gmail_default" style="font-family:monospace,monospace">2-sphere. See</div><div class="gmail_default" style="font-family:monospace,monospace"><a href="https://en.wikipedia.org/wiki/Great-circle_distance">https://en.wikipedia.org/wiki/Great-circle_distance</a><br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">The obvious question is SCALE:</div><div class="gmail_default" style="font-family:monospace,monospace">how many points will there be?</div><div class="gmail_default" style="font-family:monospace,monospace">how many queries will there be?</div><div class="gmail_default" style="font-family:monospace,monospace">For my application, storing the 3d points in a k-d-tree</div><div class="gmail_default" style="font-family:monospace,monospace">with k=3 worked OK, but it was hundreds of points,</div><div class="gmail_default" style="font-family:monospace,monospace">not millions.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 26 Nov 2020 at 10:39, Frank Muller <<a href="mailto:frank.muller.erl@gmail.com">frank.muller.erl@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Hi guys,</div><div dir="auto"><br></div><div dir="auto">I've a list of geographic coordinates: </div><div dir="auto"><br></div><div dir="auto">L = [ {{<<"longitude">>,6.1457}, {<<"latitude">>,46.2022}},</div><div dir="auto"> {{<<"longitude">>,2.3387}, {<<"latitude">>,48.8582}},</div><div dir="auto"> ... ]</div><div dir="auto"><br></div><div dir="auto">and a specific coordinate X = {{<<"longitude">>,-73.5848}, {<<"latitude">>,45.4995}}.</div><div dir="auto"><br></div><div dir="auto">Question: how can i find the nearest coordinates to X from L (sorted from the nearest to the farest)?</div><div dir="auto"><br></div><div dir="auto">/Frank</div>
</blockquote></div>