Class: Geokit::Geocoders::Geocoder
- Inherits:
-
Object
- Object
- Geokit::Geocoders::Geocoder
- Defined in:
- lib/geokit/geocoders.rb
Overview
The Geocoder base class which defines the interface to be used by all other geocoders.
Direct Known Subclasses
CaGeocoder, GeoPluginGeocoder, GeonamesGeocoder, GoogleGeocoder, IpGeocoder, MultiGeocoder, UsGeocoder, YahooGeocoder
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) ⇒ 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.
120 121 122 123 124 125 |
# File 'lib/geokit/geocoders.rb', line 120 def self.call_geocoder_service(url) timeout(Geokit::Geocoders::timeout) { return self.do_get(url) } if Geokit::Geocoders::timeout return self.do_get(url) rescue TimeoutError return 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.
130 131 132 |
# File 'lib/geokit/geocoders.rb', line 130 def self.do_reverse_geocode(latlng) return GeoLoc.new end |
.geocode(address) ⇒ 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.
106 107 108 109 |
# File 'lib/geokit/geocoders.rb', line 106 def self.geocode(address) res = do_geocode(address) return res.success ? res : 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.
114 115 116 117 |
# File 'lib/geokit/geocoders.rb', line 114 def self.reverse_geocode(latlng) res = do_reverse_geocode(latlng) return res.success ? res : GeoLoc.new end |