<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>opensoul.org - Graticule and acts_as_geocodable go international Changes</title>
  <id>tag:opensoul.org,2009:/2007/3/27/graticule-and-acts_as_geocodable-go-international/changes</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://opensoul.org/2007/3/27/graticule-and-acts_as_geocodable-go-international/changes.xml" rel="self" type="application/atom+xml"/>
  <link href="/2007/3/27/graticule-and-acts_as_geocodable-go-international" rel="alternate" type="text/html"/>
  <updated>2007-03-27T00:57:33Z</updated>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>brandon</name>
    </author>
    <id>tag:opensoul.org,2007-03-27:267:1</id>
    <updated>2007-03-27T00:57:33Z</updated>
    <link href="http://opensoul.org/2009/3/12/graticule-and-acts_as_geocodable-go-international" rel="alternate" type="text/html"/>
    <title>Graticule and acts_as_geocodable go international</title>
<content type="html">&lt;p&gt;The single biggest request that I&#8217;ve gotten for &lt;a href=&quot;http://opensoul.org/2006/10/31/announcing-graticule-geocoding-api&quot;&gt;Graticule&lt;/a&gt; and &lt;a href=&quot;http://opensoul.org/2007/2/13/geocoding-as-easy-as-1-2&quot;&gt;acts_as_geocodable&lt;/a&gt; has been for international support. So, for those outside the US (50% that read this blog according to google analytics), I have a present for you.&lt;/p&gt;


	&lt;p&gt;Last weekend I committed support for &lt;a href=&quot;http://emad.fano.us/blog/?p=277&quot;&gt;Local Search Maps&lt;/a&gt; (thanks to &lt;a href=&quot;http://jystewart.net/&quot;&gt;James Stewart&lt;/a&gt;), and &lt;a href=&quot;http://jystewart.net/&quot;&gt;PostcodeAnywhere&lt;/a&gt;, both of which have some international support, at least for Canada and Europe.  I also added &lt;a href=&quot;http://geocoder.ca/&quot;&gt;geocoder.ca&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Most of the international geocoding services seem to require a little more structured parameters, so with Graticule 0.2, all of the geocoders can take a hash (and some require it). As a result of gaining international support, the field names that Graticule uses have been changed to be more international-friendly: street, locality, region, postal_code, and country.&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;g = Graticule.service(:local_search_maps).new
location = g.locate :street =&amp;gt; '48 Leicester Square', :locality =&amp;gt; 'London', :country =&amp;gt; 'UK'
location.coordinates  #=&amp;gt; [51.510036, -0.130427]&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;Geocoding IP Addresses&lt;/h3&gt;


	&lt;p&gt;Several people mentioned that they would rather use acts_as_geocodable, but chose to use &lt;a href=&quot;http://geokit.rubyforge.org/&quot;&gt;GeoKit&lt;/a&gt;, another good geocoding library (but with a little different philosophy), because it had support for geocoding IP addresses.  So, with a flick of the wrist and a twitch of the nose, Graticule now supports &lt;a href=&quot;http://hostip.info&quot;&gt;HostIP&lt;/a&gt; for geocoding IP addresses:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;g = Graitucle.service(:host_ip).new
location = g.locate &amp;quot;64.233.167.99&amp;quot;

location.coordinates  #=&amp;gt; [37.402, -122.078]
location.locality     #=&amp;gt; &amp;quot;Mountain View&amp;quot;
location.country      #=&amp;gt; &amp;quot;US&amp;quot;
location.region       #=&amp;gt; &amp;quot;CA&amp;quot;&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Along with this, acts_as_geocodable has a helper method, &lt;code&gt;remote_location&lt;/code&gt;:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@nearest_store = Store.find(:nearest, :origin =&amp;gt; remote_location) if remote_location&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Be careful not to rely too heavily on remote_location because the location of many IP addresses cannot be determined through HostIP.&lt;/p&gt;


	&lt;h3&gt;Feedback&lt;/h3&gt;


	&lt;p&gt;I&#8217;m just an ignorant North-American, so I would love some feedback from people using Graticule and acts_as_geocodable outside the US.&lt;/p&gt;</content>  </entry>
</feed>
