alexreisner/geocoder — pull request #286 by mlandauer (2012-09-03 00:47:39+00:00)
Title: Add bounding box optimisation to distance query

Added a bounding box to sql query for points within a certain distance. On a table where the latitude and longitude are indexed this can massively improve the performance of this query by stopping a whole table scan from being necessary.

This same trick is used in geokit-rails https://github.com/imajes/geokit-rails

Please view this pull request as a proof-of-concept!

I don't know if the implementation suits because I did a little refactoring of the existing code base so that I could add a simple regression test and so that the change to add this feature was minimal.

Please let me know what I can do to help get this optimisation merged. I'll happily rewrite this patch in whatever way you want!