I’ve been using GeoKit for Rails and it works great. However, I noticed that when pulling alot of listings it is VERY slow in loading.
I’m wondering if it is because it is querying google or some external source before returning the results. If thats the case, is there a way to use raw lat lng coordinates (which I have) to simply calculate distance internally?
Or a simply ruby formula that will do this for me?
Distance-wise:
Geokit-gem provides a method to calculate the distance between two points:
Finder-wise:
Geokit-rails (a plugin) has a finder that generates SQL (for mysql, postgres, and SQL server) to calculate distances, letting you find rows within a certain distance:
It calculates distances for all rows, but doesn’t need to query external resources. If your table is truly huge it might help (but I’m not so sure that it would) to narrow it down by pre-calculating lat/lng ranges first:
If that still doesn’t help you’re gonna have to write some customised SQL. The sql distance calculations for geokit-rails are here:
https://github.com/andre/geokit-rails/tree/master/lib/geokit-rails/adapters