<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Bacon Bear Blog: ActsAsLocateable released</title>
    <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>ActsAsLocateable released</title>
      <description>&lt;p&gt;Introducing my 2nd adventure into Rails plugins: ActsAsLocateable!&lt;/p&gt;

&lt;p&gt;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&lt;/p&gt;

&lt;pre&gt;
Store.find_within_radius(10, 12345)     # Find all stores within 10 miles of zip code 12345
&lt;/pre&gt;

&lt;p&gt;Install ActsAsLocateable in the normal way&lt;/p&gt;

&lt;pre&gt;
script/plugin install http://svn.baconbear.com/rails_plugins/acts_as_locateable/trunk/
&lt;/pre&gt;

&lt;p&gt;Be sure to read the associated README file after the install for details on installation, setup, and usage.&lt;/p&gt;

&lt;p&gt;ActsAsLocateable is based heavily on the &lt;a href="http://zipcodesearch.rubyforge.org/"&gt;ZipCodeSearch plugin&lt;/a&gt; by Doug Fales and utilizes much of the same code and data.  Special thanks to Doug for making his code freely available!&lt;/p&gt;</description>
      <pubDate>Fri, 29 Dec 2006 17:54:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:5f8ec1d7-fe33-45aa-bf8f-1b8a8658367e</guid>
      <author>Jeff</author>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released</link>
      <category>rails</category>
      <category>ActsAsLocateable</category>
      <category>plugins</category>
    </item>
    <item>
      <title>"ActsAsLocateable released" by Matt</title>
      <description>Thanks!!!  I made a few tweaks to work w/ my app...

# Change data type to float
t.column :latitude, :float
t.column :longitude, :float

# Modify lat/lon floats and index
execute("ALTER TABLE zip_codes MODIFY latitude float(10,7);")
execute("ALTER TABLE zip_codes MODIFY longitude float(10,7);")
add_index :zip_codes, [:latitude, :longitude], :name = 'latlon'

# Removed the + symbol in the .csv file
Search: ","+
Replace: "," 

# Added James Stewart's patch (Thanks James!)</description>
      <pubDate>Sun, 03 Aug 2008 10:26:46 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:d25e6609-6102-4acd-a05c-68adca418dee</guid>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released#comment-1785</link>
    </item>
    <item>
      <title>"ActsAsLocateable released" by casinos</title>
      <description>Hey, thanks for sharing this information. I see that I am not the only one with problems in this field.</description>
      <pubDate>Fri, 25 Jan 2008 05:12:32 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:d0b030f8-e3b5-44fb-af36-1c6e1767431e</guid>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released#comment-1775</link>
    </item>
    <item>
      <title>"ActsAsLocateable released" by James Stewart</title>
      <description>I've actually posted the patch over on my blog. You can find it at:

&lt;a href="http://jystewart.net/process/archives/2007/02/extending-acts_as_locateable/" rel="nofollow"&gt;http://jystewart.net/process/archives/2007/02/extending-acts_as_locateable/&lt;/a&gt;</description>
      <pubDate>Wed, 07 Feb 2007 13:17:45 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:c1d1981e-0c2f-4ac1-9cd0-605509cb2494</guid>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released#comment-1724</link>
    </item>
    <item>
      <title>"ActsAsLocateable released" by James Stewart</title>
      <description>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.</description>
      <pubDate>Wed, 07 Feb 2007 13:06:39 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:a49a1956-2488-49cb-877c-1c59c41d984b</guid>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released#comment-1723</link>
    </item>
    <item>
      <title>"ActsAsLocateable released" by Jeff Lee</title>
      <description>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.</description>
      <pubDate>Thu, 04 Jan 2007 17:32:17 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:e0ec7bf6-07d4-4d20-b95d-1b0fe40cd581</guid>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released#comment-1720</link>
    </item>
    <item>
      <title>"ActsAsLocateable released" by Joshua Warchol</title>
      <description>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); </description>
      <pubDate>Thu, 04 Jan 2007 14:15:13 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:e12cd9a4-a07b-4d83-8fb7-bdf7bea32681</guid>
      <link>http://www.baconbear.com/articles/2006/12/29/actsaslocateable-released#comment-1719</link>
    </item>
  </channel>
</rss>
