4 extend ActionView::Helpers::NumberHelper
6 def self.describe_location(lat, lon, zoom = nil, language = nil)
8 language ||= http_accept_language.user_preferred_languages.join(",")
10 Rails.cache.fetch "/nominatim/location/#{lat}/#{lon}/#{zoom}/#{language}" do
11 url = "#{Settings.nominatim_url}reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
14 response = OSM.http_client.get(URI.parse(url)) do |request|
15 request.options.timeout = 4
18 results = REXML::Document.new(response.body) if response.success?
23 if results && result = results.get_text("reversegeocode/result")
26 "#{number_with_precision(lat, :precision => 3)}, #{number_with_precision(lon, :precision => 3)}"