Class: Geokit::Geocoders::Geocoder
Overview
The Geocoder base class which defines the interface to be used by all other geocoders.
Direct Known Subclasses
BaseIpGeocoder, BingGeocoder, CaGeocoder, FCCGeocoder, GeonamesGeocoder, GoogleGeocoder, MapQuestGeocoder, MaxmindGeocoder, MultiGeocoder, OSMGeocoder, UsGeocoder, YahooGeocoder, YandexGeocoder
Class Method Summary collapse
-
.call_geocoder_service(url) ⇒ Object
Call the geocoder service using the timeout if configured.
-
.do_reverse_geocode(latlng) ⇒ Object
Not all geocoders can do reverse geocoding.
-
.geocode(address, *args) ⇒ Object
Main method which calls the do_geocode template method which subclasses are responsible for implementing.
-
.reverse_geocode(latlng) ⇒ Object
Main method which calls the do_reverse_geocode template method which subclasses are responsible for implementing.
Class Method Details
.call_geocoder_service(url) ⇒ Object
Call the geocoder service using the timeout if configured.
111 112 113 114 115 116 |
# File 'lib/geokit/geocoders.rb', line 111 def self.call_geocoder_service(url) Timeout::timeout(Geokit::Geocoders::request_timeout) { return self.do_get(url) } if Geokit::Geocoders::request_timeout self.do_get(url) rescue TimeoutError nil end |
.do_reverse_geocode(latlng) ⇒ Object
Not all geocoders can do reverse geocoding. So, unless the subclass explicitly overrides this method, a call to reverse_geocode will return an empty GeoLoc. If you happen to be using MultiGeocoder, this will cause it to failover to the next geocoder, which will hopefully be one which supports reverse geocoding.
121 122 123 |
# File 'lib/geokit/geocoders.rb', line 121 def self.do_reverse_geocode(latlng) GeoLoc.new end |
.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.
95 96 97 98 99 100 101 102 |
# File 'lib/geokit/geocoders.rb', line 95 def self.geocode(address, *args) do_geocode(address, *args) || GeoLoc.new rescue TooManyQueriesError, GeocodeError raise rescue logger.error "Caught an error during #{self.class} geocoding call: #{$!}" GeoLoc.new end |
.reverse_geocode(latlng) ⇒ 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.
106 107 108 |
# File 'lib/geokit/geocoders.rb', line 106 def self.reverse_geocode(latlng) do_reverse_geocode(latlng) || GeoLoc.new end |