Module: Geokit::Geocoders

Defined in:
lib/geokit/geocoders.rb,
lib/geokit/services/ip.rb,
lib/geokit/services/fcc.rb,
lib/geokit/services/ripe.rb,
lib/geokit/multi_geocoder.rb,
lib/geokit/services/yahoo.rb,
lib/geokit/services/google.rb,
lib/geokit/services/yandex.rb,
lib/geokit/services/google3.rb,
lib/geokit/services/maxmind.rb,
lib/geokit/services/geonames.rb,
lib/geokit/services/geo_plugin.rb,
lib/geokit/services/ca_geocoder.rb,
lib/geokit/services/us_geocoder.rb,
lib/geokit/services/openstreetmap.rb

Overview

Contains a range of geocoders:

### “regular” address geocoders

  • Yahoo Geocoder - requires an API key.

  • Geocoder.us - may require authentication if performing more than the free request limit.

  • Geocoder.ca - for Canada; may require authentication as well.

  • Geonames - a free geocoder

### address geocoders that also provide reverse geocoding

  • Google Geocoder - requires an API key.

### IP address geocoders

  • IP Geocoder - geocodes an IP address using hostip.info's web service.

  • Geoplugin.net – another IP address geocoder

### The Multigeocoder

  • Multi Geocoder - provides failover for the physical location geocoders.

Some of these geocoders require configuration. You don't have to provide it here. See the README.

Defined Under Namespace

Classes: CaGeocoder, FCCGeocoder, GeoPluginGeocoder, GeocodeError, Geocoder, GeonamesGeocoder, GoogleGeocoder, GoogleGeocoder3, IpGeocoder, MaxmindGeocoder, MultiGeocoder, OSMGeocoder, RipeGeocoder, UsGeocoder, YahooGeocoder, YandexGeocoder

Constant Summary collapse

Google3Geocoder =
GoogleGeocoder3
@@proxy_addr =
nil
@@proxy_port =
nil
@@proxy_user =
nil
@@proxy_pass =
nil
@@request_timeout =
nil
@@yahoo_consumer_key =
'REPLACE_WITH_YOUR_YAHOO_BOSS_OAUTH_CONSUMER_KEY'
@@yahoo_consumer_secret =
'REPLACE_WITH_YOUR_YAHOO_BOSS_OAUTH_CONSUMER_SECRET'
@@yandex =
'REPLACE_WITH_YOUR_YANDEX_KEY'
@@google =
'REPLACE_WITH_YOUR_GOOGLE_KEY'
@@google_client_id =
nil
@@google_cryptographic_key =
nil
@@google_channel =
nil
@@geocoder_us =
false
@@geocoder_ca =
false
@@geonames =
false
@@provider_order =
[:google,:us]
@@ip_provider_order =
[:geo_plugin,:ip]
@@logger =
Logger.new(STDOUT)
@@domain =
nil
@@osm =

if needed

'REPLACE_WITH_YOUR_OSM_KEY'
@@geoip_data_path =
File.expand_path(File.join(File.dirname(__FILE__),'../../..','data','GeoLiteCity.dat'))

Class Method Summary collapse

Class Method Details

.__define_accessorsObject


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/geokit/geocoders.rb', line 58

def self.__define_accessors
  class_variables.each do |v|
    sym = v.to_s.delete("@").to_sym
    unless self.respond_to? sym
      module_eval <<-EOS, __FILE__, __LINE__
        def self.#{sym}
          value = if defined?(#{sym.to_s.upcase})
            #{sym.to_s.upcase}
          else
            @@#{sym}
          end
          if value.is_a?(Hash)
            value = (self.domain.nil? ? nil : value[self.domain]) || value.values.first
          end
          value
        end

        def self.#{sym}=(obj)
          @@#{sym} = obj
        end
      EOS
    end
  end
end