Class: Msewage::Importer::Geolocator

Inherits:
Object
  • Object
show all
Defined in:
lib/msewage-importer/geolocator.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = Config.new) ⇒ Geolocator

Returns a new instance of Geolocator.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/msewage-importer/geolocator.rb', line 7

def initialize(config = Config.new)
  #Geocoder.configure do |c|
  #  #c.lookup = :bing
  #  #c.api_key = config.geocoder.bing_key
  #  c.lookup = :google
  #  #c.lookup = :nominatim
  #  #c.lookup = :yandex
  #  #c.lookup = :mapquest
  #  #c.lookup = :freegeoip
  #end

  @config = config
end

Instance Method Details

#geolocate(location) ⇒ Object



21
22
23
24
25
# File 'lib/msewage-importer/geolocator.rb', line 21

def geolocate(location)
  result = Geocoder.search(location)
  result = result.first if result.is_a?(Array)
  result.nil? ? nil : result.coordinates
end