2 extend ActionView::Helpers::NumberHelper
4 def self.describe_location(lat, lon, zoom = nil, language = nil)
6 language ||= http_accept_language.user_preferred_languages.join(',')
8 Rails.cache.fetch "/nominatim/location/#{lat}/#{lon}/#{zoom}/#{language}" do
9 url = "http://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}"
12 response = OSM::Timer.timeout(4) do
13 REXML::Document.new(Net::HTTP.get(URI.parse(url)))
19 if response && result = response.get_text("reversegeocode/result")
22 "#{number_with_precision(lat, :precision => 3)}, #{number_with_precision(lon, :precision => 3)}"