title: Calculating distance between point and circle in PostgreSQL, what units are used for circle radius and distance?
body: <p>I'm using geometric functions and operators: <a href="http://www.postgresql.org/docs/9.3/static/functions-geometry.html" rel="nofollow">http://www.postgresql.org/docs/9.3/static/functions-geometry.html</a></p>
  
  <p>Table 'bank' Containing a geofence the type of which is <code>circle</code> with a 0.5 Radius.</p>
  
  <pre><code>id       name   geofence  
  "ID123";"FAR";"&lt;(-122.31562661719,49.051595254425),0.5&gt;"
  "ID456";"NEAR";"&lt;(-83.110566270539,42.102925914015),0.5&gt;"
  </code></pre>
  
  <p>Table 'points' Containing lat_lon as a <code>point</code></p>
  
  <pre><code>id    url              lat_lon              device
  "455";"www.google.com";"(-83.0163,42.2733)";"48ddb459104986c1860eaa048ad72525ac881651"
  </code></pre>
  
  <p>I am trying to find all the points that are within a geofence.</p>
  
  <p>I tried:</p>
  
  <pre><code>SELECT *
  FROM 
    points, bank
  WHERE lat_lon &lt;@ bank.geofence;
  </code></pre>
  
  <p>The results I get are close to the point I am checking for, but they are not within the 0.5KM radius when I check them on the map.</p>
  
  <p>For the above two points, if I print out the distance as a column</p>
  
  <pre><code>SELECT *, lat_lon &lt;-&gt; bank.geofence
  FROM 
    points, bank;
  </code></pre>
  
  <p>Gives me a value of 39.3795 for the FAR point, and a 0 for the NEAR point. I know that both aren't within the geofence, but I am trying to figure out the units used for Radius and for Distance.</p>
  
  <p>So, what unit is the radius field in a circle?
  If I want 500m what should I use?</p>