title: MongoDB Bound Queries: How do I convert mile to radian?
body: <p>I have a collection of stores with a geospacial index on the location propery.</p>
  
  <p>What I am trying to do is given the user's latitude, latitude and a search radius (mi), I want to return the list of stores that are within those parameters.</p>
  
  <p>I saw the following example on the MongoDB documentation (<a href="http://www.mongodb.org/display/DOCS/Geospatial+Indexing" rel="noreferrer">http://www.mongodb.org/display/DOCS/Geospatial+Indexing</a>), but it looks like the distance is in radians.</p>
  
  <pre><code>center = [50, 50]
  radius = 10
  db.places.find({"loc" : {"$within" : {"$center" : [center, radius]}}})
  </code></pre>
  
  <p>So, what is the formula to convert miles to radians?</p>
  
  <p><strong>Solution</strong>
  The awesome people at mongodb-user helped me find the answer.
  Basically, what I was really looking for was a way to limit the distance.</p>
  
  <p>Per, the updated documentation, there is a 3rd parameter to the $near query:
  You can also use $near with a maximum distance</p>
  
  <pre><code>db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } ).limit(20)
  </code></pre>
  
  <p>The value for $maxDistance is in radians; so, I had to take my distance in miles and divide it by 69.</p>
  
  <p>Thank you!</p>