Skip to content
Snippets Groups Projects
Commit 820bb1f7 authored by Simon Stemplinger's avatar Simon Stemplinger Committed by Alex Reisner
Browse files

support for opencagedata optional parameters (#1122)

support for opencagedata optional parameters
parent fdb04acd
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,12 @@ module Geocoder::Lookup ...@@ -47,6 +47,12 @@ module Geocoder::Lookup
:language => (query.language || configuration.language) :language => (query.language || configuration.language)
}.merge(super) }.merge(super)
[:countrycode, :min_confidence, :no_dedupe, :no_annotations, :no_record, :limit].each do |option|
unless (option_value = query.options[option]).nil?
params[option] = option_value
end
end
unless (bounds = query.options[:bounds]).nil? unless (bounds = query.options[:bounds]).nil?
params[:bounds] = bounds.map{ |point| "%f,%f" % point }.join(',') params[:bounds] = bounds.map{ |point| "%f,%f" % point }.join(',')
end end
......
...@@ -30,6 +30,24 @@ class OpencagedataTest < GeocoderTestCase ...@@ -30,6 +30,24 @@ class OpencagedataTest < GeocoderTestCase
assert_match(/bounds=40.0+%2C-120.0+%2C39.0+%2C-121.0+/, url) assert_match(/bounds=40.0+%2C-120.0+%2C39.0+%2C-121.0+/, url)
end end
def test_opencagedata_query_url_contains_optional_params
lookup = Geocoder::Lookup::Opencagedata.new
url = lookup.query_url(Geocoder::Query.new(
"Some street",
:countrycode => 'fr',
:min_confidence => 5,
:no_dedupe => 1,
:no_annotations => 1,
:no_record => 1,
:limit => 2
))
assert_match(/countrycode=fr/, url)
assert_match(/min_confidence=5/, url)
assert_match(/no_dedupe=1/, url)
assert_match(/no_annotations=1/, url)
assert_match(/no_record=1/, url)
assert_match(/limit=2/, url)
end
def test_no_results def test_no_results
results = Geocoder.search("no results") results = Geocoder.search("no results")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment