]> git.openstreetmap.org Git - rails.git/blob - app/helpers/geocoder_helper.rb
Merge branch 'redesign' of github.com:osmlab/openstreetmap-website into redesign
[rails.git] / app / helpers / geocoder_helper.rb
1 module GeocoderHelper
2   def result_to_html(result)
3     html_options = { :class => "set_position", :data => {} }
4
5     if result[:type] and result[:id]
6       url = url_for(:controller => :browse, :action => result[:type], :id => result[:id])
7     elsif result[:min_lon] and result[:min_lat] and result[:max_lon] and result[:max_lat]
8       url = "?minlon=#{result[:min_lon]}&minlat=#{result[:min_lat]}&maxlon=#{result[:max_lon]}&maxlat=#{result[:max_lat]}"
9     else
10       url = "?mlat=#{result[:lat]}&mlon=#{result[:lon]}&zoom=#{result[:zoom]}"
11     end
12
13     result.each do |key,value|
14       html_options[:data][key.to_s.tr('_', '-')] = value
15     end
16
17     html = ""
18     html << result[:prefix] if result[:prefix]
19     html << " " if result[:prefix] and result[:name]
20     html << link_to(result[:name], url, html_options) if result[:name]
21     html << result[:suffix] if result[:suffix]
22     html.html_safe
23   end
24
25   def describe_location(lat, lon, zoom = nil, language = nil)
26     Nominatim.describe_location(lat, lon, zoom, language)
27   end
28 end