- lat = place.attributes["lat"].to_s
- lon = place.attributes["lon"].to_s
- klass = place.attributes["class"].to_s
- type = place.attributes["type"].to_s
- name = place.attributes["display_name"].to_s
- min_lat,max_lat,min_lon,max_lon = place.attributes["boundingbox"].to_s.split(",")
- prefix_name = t "geocoder.search_osm_nominatim.prefix.#{klass}.#{type}", :default => type.gsub("_", " ").capitalize
- prefix = t "geocoder.search_osm_nominatim.prefix_format", :name => prefix_name
-
- @results.push({:lat => lat, :lon => lon,
- :min_lat => min_lat, :max_lat => max_lat,
- :min_lon => min_lon, :max_lon => max_lon,
- :prefix => prefix, :name => name})
- @more_params[:exclude].push(place.attributes["place_id"].to_s)
+ lat = place.attributes["lat"]
+ lon = place.attributes["lon"]
+ klass = place.attributes["class"]
+ type = place.attributes["type"]
+ name = place.attributes["display_name"]
+ min_lat, max_lat, min_lon, max_lon = place.attributes["boundingbox"].split(",")
+ prefix_name = if type.empty?
+ ""
+ else
+ t "geocoder.search_osm_nominatim.prefix.#{klass}.#{type}", :default => type.tr("_", " ").capitalize
+ end
+ if klass == "boundary" && type == "administrative"
+ rank = (place.attributes["address_rank"].to_i + 1) / 2
+ prefix_name = t "geocoder.search_osm_nominatim.admin_levels.level#{rank}", :default => prefix_name
+ place.elements["extratags"].elements.each("tag") do |extratag|
+ prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "linked_place" || extratag.attributes["key"] == "place"
+ end
+ end
+ prefix = t ".prefix_format", :name => prefix_name
+ object_type = place.attributes["osm_type"]
+ object_id = place.attributes["osm_id"]
+
+ @results.push(:lat => lat, :lon => lon,
+ :min_lat => min_lat, :max_lat => max_lat,
+ :min_lon => min_lon, :max_lon => max_lon,
+ :prefix => prefix, :name => name,
+ :type => object_type, :id => object_id)