Parent

Geokit::Geocoders::MultiGeocoder

Provides methods to geocode with a variety of geocoding service providers, plus failover among providers in the order you configure. When 2nd parameter is set ‘true’, perform ip location lookup with ‘address’ as the ip address.

Goal:

Limitations:

Private Class Methods

do_geocode(address, options = {}) click to toggle source

This method will call one or more geocoders in the order specified in the configuration until one of the geocoders work.

The failover approach is crucial for production-grade apps, but is rarely used. 98% of your geocoding calls will be successful with the first call

     # File /Users/andre/projects/rails/geokit/lib/geokit/geocoders.rb, line 652
652:       def self.do_geocode(address, options = {})
653:         geocode_ip = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.match(address)
654:         provider_order = geocode_ip ? Geokit::Geocoders::ip_provider_order : Geokit::Geocoders::provider_order
655:         
656:         provider_order.each do |provider|
657:           begin
658:             klass = Geokit::Geocoders.const_get "#{Geokit::Inflector::camelize(provider.to_s)}Geocoder"
659:             res = klass.send :geocode, address, options
660:             return res if res.success?
661:           rescue
662:             logger.error("Something has gone very wrong during geocoding, OR you have configured an invalid class name in Geokit::Geocoders::provider_order. Address: #{address}. Provider: #{provider}")
663:           end
664:         end
665:         # If we get here, we failed completely.
666:         GeoLoc.new
667:       end
do_reverse_geocode(latlng) click to toggle source

This method will call one or more geocoders in the order specified in the configuration until one of the geocoders work, only this time it’s going to try to reverse geocode a geographical point.

     # File /Users/andre/projects/rails/geokit/lib/geokit/geocoders.rb, line 672
672:       def self.do_reverse_geocode(latlng)
673:         Geokit::Geocoders::provider_order.each do |provider|
674:           begin
675:             klass = Geokit::Geocoders.const_get "#{Geokit::Inflector::camelize(provider.to_s)}Geocoder"
676:             res = klass.send :reverse_geocode, latlng
677:             return res if res.success?
678:           rescue
679:             logger.error("Something has gone very wrong during reverse geocoding, OR you have configured an invalid class name in Geokit::Geocoders::provider_order. LatLng: #{latlng}. Provider: #{provider}")
680:           end
681:         end
682:         # If we get here, we failed completely.
683:         GeoLoc.new
684:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.