]> git.openstreetmap.org Git - rails.git/commitdiff
Cope with results from the OSM Namefinder that have no name.
authorTom Hughes <tom@compton.nu>
Wed, 8 Aug 2007 17:05:28 +0000 (17:05 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 8 Aug 2007 17:05:28 +0000 (17:05 +0000)
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
       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
       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
       else
-        results.push({:lat => lat, :lon => lon, :zoom => zoom,
-                      :prefix => "#{type} ", :name => name,
-                      :description => description})
+        suffix = ""
       end
       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 }
     end
 
     return { :source => "OpenStreetMap Namefinder", :url => "http://www.frankieandshadow.com/osm/", :results => results }