Permalink
Browse files

merged in drogus' changes

  • Loading branch information...
Andre Lewis
Andre Lewis committed Sep 21, 2009
2 parents 0fed9d9 + 4e30492 commit 80b51120b556c846d1b19d5236f0a6e4770b9f01
Showing with 93 additions and 22 deletions.
  1. +2 −2 geokit.gemspec
  2. +12 −4 lib/geokit/geocoders.rb
  3. +79 −16 test/test_google_geocoder.rb
View
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Andre Lewis and Bill Eisenhauer"]
- s.date = %q{2009-06-15}
+ s.date = %q{2009-08-02}
s.description = %q{Geokit Gem}
s.email = ["andre@earthcode.com / bill_eisenhauer@yahoo.com"]
s.extra_rdoc_files = ["Manifest.txt", "README.markdown"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--main", "README.markdown"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{geokit}
- s.rubygems_version = %q{1.3.1}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{none}
s.test_files = ["test/test_base_geocoder.rb", "test/test_bounds.rb", "test/test_ca_geocoder.rb", "test/test_geoloc.rb",
"test/test_geoplugin_geocoder.rb", "test/test_google_geocoder.rb", "test/test_google_reverse_geocoder.rb",
View
@@ -5,6 +5,9 @@
require 'logger'
module Geokit
+
+ class TooManyQueriesError < StandardError; end
+
module Inflector
extend self
@@ -462,14 +465,19 @@ def self.xml2GeoLoc(xml, address="")
end
end
return geoloc
- else
+ elsif doc.elements['//kml/Response/Status/code'].text == '620'
+ raise Geokit::TooManyQueriesError
+ else
logger.info "Google was unable to geocode address: "+address
return GeoLoc.new
end
- rescue
- logger.error "Caught an error during Google geocoding call: "+$!
- return GeoLoc.new
+ rescue Geokit::TooManyQueriesError
+ # re-raise because of other rescue
+ raise Geokit::TooManyQueriesError, "Google returned a 620 status, too many queries. The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time. If you're sending multiple requests in parallel or in a tight loop, use a timer or pause in your code to make sure you don't send the requests too quickly."
+ rescue
+ logger.error "Caught an error during Google geocoding call: "+$!
+ return GeoLoc.new
end
# extracts a single geoloc from a //placemark element in the google results xml
Oops, something went wrong.

0 comments on commit 80b5112

Please sign in to comment.