<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>opensoul.org - Announcing Graticule geocoding API Comments</title>
  <id>tag:opensoul.org,2008:/2006/10/31/announcing-graticule-geocoding-api/comments</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://opensoul.org/2006/10/31/announcing-graticule-geocoding-api/comments.xml" rel="self" type="application/atom+xml"/>
  <link href="/2006/10/31/announcing-graticule-geocoding-api" rel="alternate" type="text/html"/>
  <updated>2007-06-22T15:15:12Z</updated>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Andy Nahapetian</name>
    </author>
    <id>tag:opensoul.org,2006-10-31:648:3120</id>
    <published>2007-06-22T15:15:12Z</published>
    <updated>2007-06-22T15:15:12Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2006/10/31/announcing-graticule-geocoding-api" rel="alternate" type="text/html"/>
    <title>Comment on 'Announcing Graticule geocoding API' by Andy Nahapetian</title>
<content type="html">First of all, Thanks for this great plugin! in cleans up a lot of my code!
I found a small bug in the way geocoder.locate works. It calls Graticule::Location.to_s to get the formatted string to send to the geocoding service (I only tested the google service). 
The problem is that the to_s method insert a \n into the string, which makes the google geocoder hiccup with certain geocoding queries and give you geodata (my example was :street =&amp;gt; &#8216;Kampstraße 4&#8217; , :zipcode =&amp;gt; &#8216;20357&#8217;, :locality =&amp;gt; &#8216;Hamburg&#8217;, :country =&amp;gt; &#8216;DE&#8217;). Changeing the to_s method to the following solves  the problem:
&lt;pre&gt;
module Graticule
class Location
  def to_s(options = {})
    options = {:coordinates =&amp;gt; false, :country =&amp;gt; true}.merge(options)
    result = &quot;&quot; 
    result &amp;lt;&amp;lt; &quot;#{street},&quot; if street
    result &amp;lt;&amp;lt; [locality, [region, postal_code].compact.join(&quot; &quot;)].compact.join(&quot;, &quot;)
    result &amp;lt;&amp;lt; &quot; #{country}&quot; if options[:country] &#38;&#38; country
    result &amp;lt;&amp;lt; &quot;\nlatitude: #{latitude}, longitude: #{longitude}&quot; if options[:coordinates] &#38;&#38; [latitude, longitude].any?
    result
  end
end
end
&lt;/pre&gt;
Kind regards,
Andy Nahapetian
link: nahapetian.com</content>  </entry>
</feed>
