Use faraday http client for nominatim lookups
This commit is contained in:
parent
3c00ed8dc3
commit
f2ca25b75c
1 changed files with 6 additions and 4 deletions
|
@ -11,14 +11,16 @@ module Nominatim
|
||||||
url = "#{Settings.nominatim_url}reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
|
url = "#{Settings.nominatim_url}reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = Timeout.timeout(4) do
|
response = OSM.http_client.get(URI.parse(url)) do |request|
|
||||||
REXML::Document.new(Net::HTTP.get(URI.parse(url)))
|
request.options.timeout = 4
|
||||||
end
|
|
||||||
rescue StandardError
|
|
||||||
response = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if response && result = response.get_text("reversegeocode/result")
|
results = REXML::Document.new(response.body) if response.success?
|
||||||
|
rescue StandardError
|
||||||
|
results = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if results && result = results.get_text("reversegeocode/result")
|
||||||
result.value
|
result.value
|
||||||
else
|
else
|
||||||
"#{number_with_precision(lat, :precision => 3)}, #{number_with_precision(lon, :precision => 3)}"
|
"#{number_with_precision(lat, :precision => 3)}, #{number_with_precision(lon, :precision => 3)}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue