<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">It might be worth mentioning the</div><div class="gmail_default" style="font-family:monospace,monospace">"Standards Of Fundamental Astronomy" (SOFA)</div><div class="gmail_default" style="font-family:monospace,monospace">library:</div><div class="gmail_default" style="font-family:monospace,monospace"><a href="https://www.iausofa.org/current_C.html">https://www.iausofa.org/current_C.html</a></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 29 Nov 2020 at 08:10, Joa Gre <<a href="mailto:joagre@gmail.com">joagre@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"><div>This might come in handy:<div dir="auto"><br></div><div dir="auto"><pre style="white-space:pre-wrap">%% <a href="https://en.m.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates" target="_blank">https://en.m.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates</a>
%% <a href="https://en.m.wikipedia.org/wiki/Geodetic_datum#World_Geodetic_System_1984_(WGS_84)" target="_blank">https://en.m.wikipedia.org/wiki/Geodetic_datum#World_Geodetic_System_1984_(WGS_84)</a>
geodetic_to_ecef_coordinates(Latitude, Longitude, H) ->
CLatitude = math:cos(Latitude * ?RADIANS_PER_DEGREE),
SLatitude = math:sin(Latitude * ?RADIANS_PER_DEGREE),
CLongitude = math:cos(Longitude * ?RADIANS_PER_DEGREE),
SLongitude = math:sin(Longitude * ?RADIANS_PER_DEGREE),
%% Semi-major axis
A = 6378137.0,
A2 = math:pow(A, 2),
%% Semi-minor axis
B = 6356752.3142,
B2 = math:pow(B, 2),
%% Prime vertical radius of curvature
N = A2 / math:sqrt(
math:pow(CLatitude, 2) * A2 + math:pow(SLatitude, 2) * B2),
X = (N + H) * CLatitude * CLongitude,
Y = (N + H) * CLatitude * SLongitude,
Z = (B2 / A2 * N + H) * SLatitude,
{X, Y, Z}.</pre><pre style="white-space:pre-wrap"><br></pre></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Den ons 25 nov. 2020 22:39Frank Muller <<a href="mailto:frank.muller.erl@gmail.com" target="_blank">frank.muller.erl@gmail.com</a>> skrev:<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></div></div>
</blockquote></div>