<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:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.Section1
        {page:Section1;}
-->
</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=PT link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Hi All,<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span lang=EN-US>In the sequence of my last email with the
same subject this is the query I tried (only for the localities layer)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>select min(distance(u.curr_location,
(select geometry from toponimia where name='Se' limit 1))) as dist <o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>from units as u <o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>where u.id=XXXXXXXX;<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>the results aren’t quite the expected
as:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>unit 11111111 is almost over the point with
the name ‘Se’<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>unit 80000135 is the second on the list<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>unit 99999999 is the farthest….<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>These are the result that I got:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>80000135 = 3665.52978684708<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>11111111 = 3666.92134092059<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>99999999 = 3665.79245878804<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>To my surprise unit 11111111’s
distance is the greatest….<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>What is distance() returning anyway?<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Btw: both tables have srid=4326<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Any help would be greatly appreciated since
I really have to finish this task (please see last email with the same subject)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Thank you.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Pedro Doria Meunier<o:p></o:p></span></p>

</div>

</body>

</html>