<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:tax="http://schemas.microsoft.com/sharepoint/taxonomy/soap/" xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/recordsrepository/" xmlns:spsup="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">1. What is the overall extent of the points?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">2. Do you need the exact answer?<br>
e.g. will there be many points close together and you <i>have</i> to get the correct one;<br>
can you assume a spherical Earth, not model the exact geoid shape (WGS84,etc.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">3. Does the region include the areas around the poles or crossing the 180 longitude ‘dateline’?<br>
<br>
If (1) is ‘small’ or ‘a few 100 km’, and (2) and (3) are NO, then there are some simple methods …<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If it is a localized region near the equator (e.g. within Singapore) you can use the Euclidean formula directly.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If it is a localized region, you can assume the ‘2D tangent plane projection’ Euclidean approximation.<br>
Take the middle value for the latitude, <i>avlat</i>, and use <i>cos(avlat)</i> to scale the longitudinal differences,<br>
then use the Euclidean formula.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Mike<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> erlang-questions [mailto:erlang-questions-bounces@erlang.org]
<b>On Behalf Of </b>Ivan Uemlianin<br>
<b>Sent:</b> Thursday, November 26, 2020 6:14 AM<br>
<b>To:</b> Frank Muller; Erlang-Questions Questions<br>
<b>Subject:</b> Re: Find nearest geographic coordinates<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Ooh interesting. Well there's your answer, although if you're always using it for `distance(A, X) < distance(B, X)` you could probably simplify the arithmetic.<br>
<br>
Ivan<br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal">On 25/11/2020 22:09, Frank Muller wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div style="border:none white 1.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal">I’m new to GIS field, but this module states that Euclidian distance isn’t accurate compared to “Law of Haversines”:<o:p></o:p></p>
</div>
<div style="border:none white 1.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div style="border:none white 1.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><a href="https://github.com/armon/teles/blob/master/src/teles_geo_query.erl#L87-L102">https://github.com/armon/teles/blob/master/src/teles_geo_query.erl#L87-L102</a><o:p></o:p></p>
</div>
<div style="border:none white 1.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div style="border:none white 1.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div style="border:none white 1.0pt;padding:0in 0in 0in 0in">
<p class="MsoNormal">/Frank<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Wed 25 nov. 2020 à 22:45, Ivan Uemlianin <<a href="mailto:ivan@llaisdy.com">ivan@llaisdy.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Frank<br>
<br>
Do you want to sort the list by Euclidean distance from X? If so, could <br>
you use lists:sort/2?<br>
<br>
Ivan<br>
<br>
<br>
On 25/11/2020 21:38, Frank Muller wrote:<br>
> Hi guys,<br>
><br>
> I've a list of geographic coordinates:<br>
><br>
> L = [ {{<<"longitude">>,6.1457}, {<<"latitude">>,46.2022}},<br>
> {{<<"longitude">>,2.3387}, {<<"latitude">>,48.8582}},<br>
> ... ]<br>
><br>
> and a specific coordinate X = {{<<"longitude">>,-73.5848}, <br>
> {<<"latitude">>,45.4995}}.<br>
><br>
> Question: how can i find the nearest coordinates to X from L (sorted <br>
> from the nearest to the farest)?<br>
><br>
> /Frank<br>
<br>
-- <br>
============================================================<br>
Ivan A. Uemlianin PhD<br>
Llaisdy<br>
<br>
Ymchwil a Datblygu Technoleg Lleferydd<br>
Speech Technology Research and Development<br>
<br>
<a href="mailto:ivan@llaisdy.com" target="_blank">ivan@llaisdy.com</a><br>
@llaisdy<br>
<a href="http://llaisdy.wordpress.com" target="_blank">
llaisdy.wordpress.com</a><br>
<a href="http://github.com/llaisdy" target="_blank">github.com/llaisdy</a><br>
<a href="http://www.linkedin.com/in/ivanuemlianin" target="_blank">
www.linkedin.com/in/ivanuemlianin</a><br>
<br>
festina lente<br>
============================================================<o:p></o:p></p>
</blockquote>
</div>
</div>
</blockquote>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>-- <o:p></o:p></pre>
<pre>============================================================<o:p></o:p></pre>
<pre>Ivan A. Uemlianin PhD<o:p></o:p></pre>
<pre>Llaisdy<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Ymchwil a Datblygu Technoleg Lleferydd<o:p></o:p></pre>
<pre>Speech Technology Research and Development<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> <a href="mailto:ivan@llaisdy.com">ivan@llaisdy.com</a><o:p></o:p></pre>
<pre> @llaisdy<o:p></o:p></pre>
<pre> llaisdy.wordpress.com<o:p></o:p></pre>
<pre> github.com/llaisdy<o:p></o:p></pre>
<pre> <a href="http://www.linkedin.com/in/ivanuemlianin">www.linkedin.com/in/ivanuemlianin</a><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> festina lente<o:p></o:p></pre>
<pre>============================================================<o:p></o:p></pre>
</div>
</body>
</html>