Class: Geokit::Geocoders::Geocoder

Inherits:
Object
  • Object
show all
Defined in:
lib/geokit/geocoders.rb

Overview

The Geocoder base class which defines the interface to be used by all other geocoders.

Class Method Summary collapse

Class Method Details

.geocode(address, *args) ⇒ Object

Main method which calls the do_geocode template method which subclasses are responsible for implementing. Returns a populated GeoLoc or an empty one with a failed success code.


90
91
92
93
94
95
96
97
98
99
# File 'lib/geokit/geocoders.rb', line 90

def self.geocode(address, *args)
  logger.debug "#{provider_name} geocoding. address: #{address}, args #{args}"
  do_geocode(address, *args) || GeoLoc.new
rescue TooManyQueriesError, GeocodeError, AccessDeniedError
  raise
rescue => e
  logger.error "Caught an error during #{provider_name} geocoding call: #{$!}"
  logger.error e.backtrace.join("\n")
  GeoLoc.new
end

.reverse_geocode(latlng, *args) ⇒ Object

Main method which calls the do_reverse_geocode template method which subclasses are responsible for implementing. Returns a populated GeoLoc or an empty one with a failed success code.


103
104
105
106
# File 'lib/geokit/geocoders.rb', line 103

def self.reverse_geocode(latlng, *args)
  logger.debug "#{provider_name} geocoding. latlng: #{latlng}, args #{args}"
  do_reverse_geocode(latlng, *args) || GeoLoc.new
end