]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/geocoder_controller.rb
Cope with results from the OSM Namefinder that have no name.
[rails.git] / app / controllers / geocoder_controller.rb
index 1b9ca05b558659a1e038f8b123554fc3e1201a46..69c35e0e3c23e2fc36ba254946d69bb2dbb79f8d 100644 (file)
@@ -93,19 +93,23 @@ private
       type = named.attributes["info"].to_s.capitalize
       name = named.attributes["name"].to_s
       description = named.elements["description"].to_s
+      if name.empty?
+        prefix = ""
+        name = type
+      else
+        prefix = "#{type} "
+      end
       if place
         distance = format_distance(place.attributes["approxdistance"].to_i)
         direction = format_direction(place.attributes["direction"].to_i)
         placename = place.attributes["name"].to_s
-        results.push({:lat => lat, :lon => lon, :zoom => zoom,
-                      :prefix => "#{type} ", :name => name,
-                      :suffix => ", #{distance} #{direction} of #{placename}",
-                      :description => description})
+        suffix = ", #{distance} #{direction} of #{placename}"
       else
-        results.push({:lat => lat, :lon => lon, :zoom => zoom,
-                      :prefix => "#{type} ", :name => name,
-                      :description => description})
+        suffix = ""
       end
+      results.push({:lat => lat, :lon => lon, :zoom => zoom,
+                    :prefix => prefix, :name => name, :suffix => suffix,
+                    :description => description})
     end
 
     return { :source => "OpenStreetMap Namefinder", :url => "http://www.frankieandshadow.com/osm/", :results => results }