Skip to content

Commit

Permalink
Allow GeoLoc object to be used in CaGeocoder
Browse files Browse the repository at this point in the history
  • Loading branch information
siannopollo committed Sep 26, 2018
1 parent 3b4b5ee commit 37355a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/geokit/geocoders/ca_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def self.parse_xml(xml, loc)

# Formats the request in the format acceptable by the CA geocoder.
def self.submit_url(loc)
args = ["locate=#{Geokit::Inflector.url_escape(loc)}"]
loc_str = loc.is_a?(GeoLoc) ? loc.to_geocodeable_s : loc
args = ["locate=#{Geokit::Inflector.url_escape(loc_str)}"]
args << "auth=#{key}" if key
args << 'geoit=xml'
'http://geocoder.ca/?' + args.join('&')
Expand Down
8 changes: 8 additions & 0 deletions test/test_ca_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def test_service_unavailable
assert !geocode(@ca_full_txt).success
end

def test_geocoder_with_geo_loc_object
response = MockSuccess.new
response.expects(:body).returns(CA_SUCCESS)
url = 'http://geocoder.ca/?locate=2105+West+32nd+Avenue%2C+Vancouver%2C+BC&auth=SOMEKEYVALUE&geoit=xml'
geocoder_class.expects(:call_geocoder_service).with(url).returns(response)
verify(geocode(Geokit::GeoLoc.new(@ca_full_hash)))
end

private

def verify(location)
Expand Down

0 comments on commit 37355a0

Please sign in to comment.