Skip to content
Snippets Groups Projects
Commit 30f8a700 authored by Chris Myers's avatar Chris Myers
Browse files

fixed a couple bugs

parent d1f036f1
No related branches found
No related tags found
No related merge requests found
......@@ -10,23 +10,36 @@ module Geocoder::Lookup
def results(query, reverse = false)
return [] unless doc = fetch_data(query, reverse)
if doc.any?
return doc[0]['place_id'] != "" ? doc : []
else
warn "Nominatim Geocoding Adress not founr or API error."
return []
end
if doc.kind_of?(Array)
if doc.any?
return doc[0]['place_id'] != "" ? doc : []
else
warn "Address not found or Nominatim Geocoding API error."
return []
end
else
return doc['place_id'] != "" ? doc = [] << doc : []
end
end
def query_url(query, reverse = false)
params = {
:q => query,
:format => "json",
:polygon => "1",
:addressdetails => "1",
# :locale => "#{Geocoder::Configuration.language}_US",
}
"http://nominatim.openstreetmap.org/search?" + hash_to_query(params)
if (reverse)
method = 'reverse'
parts = query.split(/\s*,\s*/);
params[:lat] = parts[0]
params[:lon] = parts[1]
else
method = 'search'
params[:q] = query
end
"http://nominatim.openstreetmap.org/#{method}?" + hash_to_query(params)
end
end
end
\ No newline at end of file
......@@ -31,12 +31,12 @@ module Geocoder::Result
@data['address']['state']
end
alias_method :state_code, :state
def postal_code
@data['address']['postcode']
end
alias_method :state, :state_code
def county
@data['address']['county']
end
......
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