Skip to content

Allow structured Nominatim lookup #1690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ group :test do
gem 'webmock'

platforms :ruby do
gem 'pg', '~> 1.1.4'
gem 'pg', '~> 1.1'
gem 'mysql2', '~> 0.5.4'
end

Expand Down
2 changes: 1 addition & 1 deletion lib/geocoder/lookups/nominatim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def query_url_params(query)
lat,lon = query.coordinates
params[:lat] = lat
params[:lon] = lon
else
elsif !query.params_given? || !query.sanitized_text.empty?
params[:q] = query.sanitized_text
end
params
Expand Down
2 changes: 0 additions & 2 deletions lib/geocoder/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ def language
options[:language]
end

private # ----------------------------------------------------------------

def params_given?
!!(options[:params].is_a?(Hash) and options[:params].keys.size > 0)
end
Expand Down
5 changes: 5 additions & 0 deletions test/unit/lookups/nominatim_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def test_host_configuration
assert_match %r(http://local\.com), query.url
end

def test_structured_lookup
result = Geocoder.search("", params: { street: "Madison Square Garden" }).first
assert_equal "Madison Square Garden", result.data["address"]["stadium"]
end

def test_raises_exception_when_over_query_limit
Geocoder.configure(:always_raise => [Geocoder::OverQueryLimitError])
l = Geocoder::Lookup.get(:nominatim)
Expand Down