Skip to content

Commit

Permalink
Adds unicode compliance for URL escaping and Net:HTTP fetching for Go…
Browse files Browse the repository at this point in the history
…ogle Geocode
  • Loading branch information
evenwestvang committed Oct 16, 2010
1 parent b67a046 commit 0d70f0e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/geokit/geocoders.rb
Expand Up @@ -37,9 +37,7 @@ def snake_case(s)
end

def url_escape(s)
s.gsub(/([^ a-zA-Z0-9_.-]+)/nu) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase
end.tr(' ', '+')
CGI.escape(s)
end

def camelize(str)
Expand Down Expand Up @@ -433,6 +431,7 @@ def self.do_geocode(address, options = {})
res = self.call_geocoder_service("http://maps.google.com/maps/geo?q=#{Geokit::Inflector::url_escape(address_str)}&output=xml#{bias_str}&key=#{Geokit::Geocoders::google}&oe=utf-8")
return GeoLoc.new if !res.is_a?(Net::HTTPSuccess)
xml = res.body
xml = xml.force_encoding(Encoding::UTF_8)
logger.debug "Google geocoding. Address: #{address}. Result: #{xml}"
return self.xml2GeoLoc(xml, address)
end
Expand Down

0 comments on commit 0d70f0e

Please sign in to comment.