Open
Description
I'm trying to perform a Nominatim lookup by passing the address via the street
/city
/country
/state
/postalcode
query parameters, which is what Nominatim calls a structured lookup.
Geocoder.search(nil, params: {
street: "...",
city: "...",
country: "...",
state: "...",
postalcode: "...",
})
Unfortunately, since Geocoder always passes the q
query parameter, regardless of whether it's blank, I get an error from Nominatim:
Structured query parameters(amenity, street, city, county, state, postalcode, country) cannot be used together with 'q' parameter.
I was considering opening a PR with this change:
diff --git a/lib/geocoder/lookups/nominatim.rb b/lib/geocoder/lookups/nominatim.rb
index f7e119a..b15c089 100644
--- a/lib/geocoder/lookups/nominatim.rb
+++ b/lib/geocoder/lookups/nominatim.rb
@@ -55,7 +55,7 @@ module Geocoder::Lookup
lat,lon = query.coordinates
params[:lat] = lat
params[:lon] = lon
- else
+ elsif !query.params_given?
params[:q] = query.sanitized_text
end
params
diff --git a/lib/geocoder/query.rb b/lib/geocoder/query.rb
index c509a7b..3dc15c2 100644
--- a/lib/geocoder/query.rb
+++ b/lib/geocoder/query.rb
@@ -116,8 +116,6 @@ module Geocoder
options[:language]
end
- private # ----------------------------------------------------------------
-
def params_given?
!!(options[:params].is_a?(Hash) and options[:params].keys.size > 0)
end
But I realized that maybe not all :params
apply to structured lookup, some could be valid together with the q
parameter.
Any idea how to solve / work around this?
Metadata
Metadata
Assignees
Labels
No labels