<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jordan Brock &#187; ruby</title>
	<atom:link href="http://jordanbrock.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://jordanbrock.com</link>
	<description>Pith</description>
	<lastBuildDate>Tue, 17 Apr 2012 11:05:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Maps, Geocoding and Great Timing</title>
		<link>http://jordanbrock.com/2007/02/10/maps-geocoding-and-great-timing/</link>
		<comments>http://jordanbrock.com/2007/02/10/maps-geocoding-and-great-timing/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 19:17:00 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http:///2007/02/10/maps-geocoding-and-great-timing</guid>
		<description><![CDATA[On one of the sites I&#8217;ve been working on for quite a while (SchoolSeek) we&#8217;ve been wanting to add the ability for users to find out how far a school is from their current location. There are services that have been able to geocode addresses for a while, but they were either based in the [...]]]></description>
			<content:encoded><![CDATA[<p>On one of the sites I&#8217;ve been working on for quite a while (<a href="http://www.schoolseek.com.au">SchoolSeek</a>) we&#8217;ve been wanting to add the ability for users to find out how far a school is from their current location. There are services that have been able to <a href="http://en.wikipedia.org/wiki/Geocode">geocode</a> addresses for a while, but they were either based in the US, or cost money. Not a lot of money, but free is always good.</p>
<p>A couple of years ago, <a href="http://maps.google.com">Google Maps</a> launched in the US and opened up a massive range of possibilities for programmers to develop cool &#8220;mashups&#8221;, which took information from one site, mashed it together with maps from google, and created a whole new website. They were all really cool, but unfortunately (at least for the non-US based of us) it was nothing more than something we could sit back and watch &#8211; which was kind of weird because the team of developers that built Google Maps was based in Sydney.</p>
<p>But <a href="http://googleblog.blogspot.com/2006/05/on-map-down-under.html">finally</a> the Australian version of google maps was released, and then recently integrated with Local Search, which means you can search on Pizza shotps near a particular address. Which is cool.</p>
<p>What is even cooler (if you&#8217;re a ruby developer), though, is the release of this: <a href="http://geokit.rubyforge.org/">GeoKit</a>. It integrates with all of the major geocoding/mapping services and provides a huge range of options and services. So now you can do stuff like this:</p>
<pre>
add_1=GeoKit::Geocoders::GoogleGeocoder.geocode("1 St Georges Terrace, Perth, Western Australia")
add_2=GeoKit::Geocoders::GoogleGeocoder.geocode("1 York St, Albany, Western Australia")

distance = add_1.distance_from(add_2, :units =&gt; :kms)
</pre>
<p>Which returns</p>
<p><code><br />
389.248018478531<br />
</code></p>
<p>which is, of course, how far it is between the main streets of Perth and Albany in Western Australia.</p>
<p>Sawwweeeeeet.</p>
<h3>Update</h3>
<p>Well, that didn&#8217;t take long at all. A quick loop over the existing schools in the <a href="http://www.schoolseek.com.au">SchoolSeek</a> database got the lat/long information for all the addresses. Then adding this line</p>
<pre>acts_as_mappable default_units =&gt; :kms</pre>
<p>to my Address model allows you to do this</p>
<pre>
@addresses = Address.find(:all, <img src='http://jordanbrock.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rigin =&gt; "18 Bland St, Ashfield, New South Wales", :conditions =&gt; "distance &lt; 10")
</pre>
<p>which gives me all of the addresses within 10Kms of 18 Bland St, Ashfield. Nice.</p>
<p>So, basically GeoKit let me add distance searching to the site within about 45 minutes (allowing 25 minutes for me to read through the examples and such!)</p>
]]></content:encoded>
			<wfw:commentRss>http://jordanbrock.com/2007/02/10/maps-geocoding-and-great-timing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

