Sha256: fca5d374d70fe079f2ee024f80655a5474a996bdba1d67bf025118c5455be618
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# encoding: utf-8 class GeoCoder def self.search( q = "", language = "de" ) if q.present? log "GeoCode (#{language}): #{q}" attempts = 0 begin search_via_google results = Geocoder.search( q, language: language ) log "google Geocoded: #{results.to_yaml}" return results rescue Exception => e log "Google -- #{e}" sleep 0.3 attempts += 1 end while attempts < 3 unless results search_via_nominatim results = Geocoder.search( q, language: language ) log "nominatim Geocoded: #{results.to_yaml}" end else results = [] end return results end def self.search_via_google Geocoder.configure( :lookup => :google ) end def self.search_via_nominatim Geocoder.configure( :lookup => :nominatim ) end def self.log( stuff = "+ geo + geo + geo + geo + geo + geo + " ) if Rails.env.development? Rails.logger.info "+ geo + geo + geo + geo + geo + geo + " Rails.logger.info stuff Rails.logger.info "+ geo + geo + geo + geo + geo + geo + " end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
magic_addresses-0.0.1 | app/services/geo_coder.rb |