Hey all,
I have a table containing a number of records with their long / lat coordinates. I'm trying to do the common "Show all within X miles" type search where my point of origin is the user's current long / lat pulled using geolocation in the browser.
Does anyone know an efficient away to calculate the distance between my point of origin and the various potential destinations without retrieving all of them from the database and looping through them to calculate the distance? That seems like itll be really inefficient as we get more and more records in the potential destination table.
If there's a ruby/rails orient solution awesome, otherwise any suggestions would be appreciated.