Sha256: ed91dd0c3f22457716dbc87c8f34ec6d1689c9cbc3e0afaaea941eac20c9c04c

Contents?: true

Size: 1006 Bytes

Versions: 10

Compression:

Stored size: 1006 Bytes

Contents

require 'geocoder/lookups/base'
require "geocoder/results/yahoo"

module Geocoder::Lookup
  class Yahoo < Base

    def map_link_url(coordinates)
      "http://maps.yahoo.com/#lat=#{coordinates[0]}&lon=#{coordinates[1]}"
    end

    private # ---------------------------------------------------------------

    def results(query, reverse = false)
      return [] unless doc = fetch_data(query, reverse)
      if doc = doc['ResultSet'] and doc['Error'] == 0
        return doc['Found'] > 0 ? doc['Results'] : []
      else
        warn "Yahoo Geocoding API error: #{doc['Error']} (#{doc['ErrorMessage']})."
        return []
      end
    end

    def query_url(query, reverse = false)
      params = {
        :location => query,
        :flags => "JXTSR",
        :gflags => "AC#{'R' if reverse}",
        :locale => "#{Geocoder::Configuration.language}_US",
        :appid => Geocoder::Configuration.api_key
      }
      "http://where.yahooapis.com/geocode?" + hash_to_query(params)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
geocoder-1.1.3 lib/geocoder/lookups/yahoo.rb
geocoder-1.1.2 lib/geocoder/lookups/yahoo.rb
geocoder-1.1.1 lib/geocoder/lookups/yahoo.rb
geocoder-1.1.0 lib/geocoder/lookups/yahoo.rb
geocoder-1.0.5 lib/geocoder/lookups/yahoo.rb
geocoder-1.0.4 lib/geocoder/lookups/yahoo.rb
geocoder-1.0.3 lib/geocoder/lookups/yahoo.rb
geocoder-1.0.2 lib/geocoder/lookups/yahoo.rb
geocoder-1.0.1 lib/geocoder/lookups/yahoo.rb
geocoder-1.0.0 lib/geocoder/lookups/yahoo.rb