If you can, best bet is to use postgis but it sounds like you are on shared hosting so unlikely.
Postgis will give you a much better method to get all points within a radius. From the faq (http://postgis.refractions.net/documentation/ manual-1.5/ch03.html)... SELECT * FROM geotable WHERE ST_DWithin(geocolumn, 'POINT(1000 1000)', 100.0); This is get all from the geotable within 100 m of the point(1000 1000) The advantage of postgis is you don't query every record in your db and calc the distance. You use one of those handy db tricks called indexes. Angus On Jun 3, 4:31 pm, Nathan de Vries <[email protected]> wrote: > On 03/06/2010, at 1:45 PM, Keith Pitt wrote: > > > We wrote a plpgsql function that made it easier for us to find locations > > within a certain radius. > > This functionality is available via the PostgreSQL "earthdistance" module. > Your "km_between_lat_long" function can be replaced with: > > earth_distance(ll_to_earth(lat1, lon1), ll_to_earth(lat2, lon2)) > > I'm unsure whether that would be faster or more accurate than what you're > doing, so you'd need to test it. > > Cheers, > > Nathan -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
