Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pass username to Geonames

According to the documentation, usernames is a required parameter.

http://www.geonames.org/export/web-services.html
  • Loading branch information...
commit de11bf3d5eaa92986c96c687ac17ae9c1214d5f3 1 parent 663013c
@bryckbost bryckbost authored
View
11 lib/graticule/geocoder/geonames.rb
@@ -3,12 +3,17 @@ module Graticule #:nodoc:
module Geocoder #:nodoc:
class Geonames < Base
- def initialize
- @url = URI.parse 'http://ws.geonames.org/timezone'
+ def initialize(username)
+ @url = URI.parse('http://ws.geonames.org/timezone')
+ @username = URI.encode(username)
end
def time_zone(location)
- get :formatted => 'true', :style => 'full', :lat => location.latitude, :lng => location.longitude
+ get :formatted => 'true',
+ :style => 'full',
+ :lat => location.latitude,
+ :lng => location.longitude,
+ :username => @username
end
private
View
9 test/graticule/geocoder/geonames_test.rb
@@ -7,14 +7,7 @@ class GeonamesTest < Test::Unit::TestCase
def setup
URI::HTTP.responses = []
URI::HTTP.uris = []
- @geocoder = Geonames.new
- end
-
- def test_time_zone
- return unless prepare_response(:success)
-
- chicago = Location.new(:latitude => 41.85, :longitude => -87.65)
- assert_equal 'America/Chicago', @geocoder.time_zone(chicago)
+ @geocoder = Geonames.new("demo")
end
def test_time_zone
Please sign in to comment.
Something went wrong with that request. Please try again.