ActsAsLocateable released 9
Introducing my 2nd adventure into Rails plugins: ActsAsLocateable!
ActsAsLocateable is an easy way to give any model the ability to be found by location. For instance, say you have a model Store which is associated with a zip code indicating where that Store is located. To find all the stores within a specific radius of another ZipCode, you can do a
Store.find_within_radius(10, 12345) # Find all stores within 10 miles of zip code 12345
Install ActsAsLocateable in the normal way
script/plugin install http://svn.baconbear.com/rails_plugins/acts_as_locateable/trunk/
Be sure to read the associated README file after the install for details on installation, setup, and usage.
ActsAsLocateable is based heavily on the ZipCodeSearch plugin by Doug Fales and utilizes much of the same code and data. Special thanks to Doug for making his code freely available!
Comments
-
Neat plugin. Couple of questions. Why are latitude and longitude stored in the DB as strings as opposed to floats? I redid the migration with floats and it seems to work well. I also added an index to speed things up. add_index :zip_codes, [:latitude, :longitude] And to help folks using MySQL, here's the faster load syntax: LOAD DATA INFILE '[your filename]' INTO TABLE zip_codes FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (zip, latitude, longitude, city, state, zip_class);
-
Good suggestions. I originally didn't make those changes simply because that's the way ZipCodeSearch did things. I'll make the changes and post an update when I get a chance.
-
It would be nice to be able to pass in standard AR conditions and have them applied to the query too. That way I could, say, search for all events within a given radius and on a certain day. I've patched my copy and can email a diff if you'd like. Pasting it in here seems to lose all the formatting.
-
I've actually posted the patch over on my blog. You can find it at: http://jystewart.net/process/archives/2007/02/extending-acts_as_locateable/
-
Qui vi insegniamo a giocare ai migliori giochi del casinò di internet per meglio vincere un sacco di soldi.
-
Auf punenet.com können Sie alle Spielregeln für das Spielen im Online Casino nachlesen!
-
Das Casinoland entführt Sie in die Welt der Online Casinos und zeigt Ihnen, wo Sie sicher spielen können.
-
Backgammon online is easy to play and enjoyable, check out our backgammon guide to find out how and where to play.
-
Hey, thanks for sharing this information. I see that I am not the only one with problems in this field.
