class Msewage::Importer::Geolocator

Attributes

config[R]

Public Class Methods

new(config = Config.new) click to toggle source
# 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

Public Instance Methods

geolocate(location) click to toggle source
# 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