1 # frozen_string_literal: true
4 class NominatimReverseQueriesController < QueriesController
5 include NominatimMethods
15 response = fetch_xml(nominatim_reverse_query_url(:format => "xml"))
18 response.elements.each("reversegeocode/result") do |result|
19 lat = result.attributes["lat"]
20 lon = result.attributes["lon"]
21 object_type = result.attributes["osm_type"]
22 object_id = result.attributes["osm_id"]
23 description = result.text
25 @results.push(:lat => lat, :lon => lon,
28 :type => object_type, :id => object_id)
30 respond_to do |format|
32 format.json { render :json => @results }
35 rescue StandardError => e
36 host = URI(Settings.nominatim_url).host
37 @error = "Error contacting #{host}: #{e}"
38 render :action => "error"