title: Trying to calculate distance between two lat-lng points in PostgreSQL - what is the unit of PostgreSQL earth_box(ll_to_earth) return value?
body: <p>I have a query like so:</p>
  
  <pre><code>SELECT * FROM chat_rooms 
  WHERE earth_box(ll_to_earth(5, 5), 111000) @&gt; ll_to_earth(lat, lng);
  </code></pre>
  
  <p>Essentially, I have <code>lat = lng = 5</code> in the query, and in my <code>chat_rooms</code> table I have two entries, one with <code>lat=lng=5</code>, the other with <code>lat=lng=4</code>. Using an online calculator, the distance between these two entries is 157 miles = 252.667km (i.e. entry <code>lat=lng=4</code> should be returned when radius >= 157 miles. However, the query only returns the entry with <code>lat=lng=4</code> when the radius is specified as ~111,000+. My question is, what unit is the radius in, and am I conducting this query correctly?</p>