Sha256: 2b59c7cb184b0fb48f83f5b7eb817ff7805e994dcf0f5c8407d763afd39a21c6

Contents?: true

Size: 717 Bytes

Versions: 1

Compression:

Stored size: 717 Bytes

Contents

module Barometer
  #
  # Web Service: Geocode
  #
  # uses Google Maps Geocoding service
  #
  class WebService::Geocode < WebService
    
    def self.fetch(query)
      raise ArgumentError unless _is_a_query?(query)
      puts "geocoding: #{query.q}" if Barometer::debug?
      location = self.get(
        "http://maps.google.com/maps/geo",
        :query => {
          :gl => query.country_code,
          :output => "json",
          :q => query.q,
          :sensor => "false"
        },
        :format => :json, :timeout => Barometer.timeout
      )
      location = location['kml']['Response'] if (location && location['kml'])
      location ? (geo = Data::Geo.new(location)) : nil
    end
    
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
barometer-0.7.2 lib/barometer/web_services/geocode.rb