From: Tom Hughes Date: Wed, 8 Aug 2007 17:05:28 +0000 (+0000) Subject: Cope with results from the OSM Namefinder that have no name. X-Git-Tag: live~8242 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/4ac48d2cb5cd2197d8f2702bdc7b17072b2fdc85?hp=5ffb6950cc3a688552290f9616c142e285b465b6;ds=sidebyside Cope with results from the OSM Namefinder that have no name. --- diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 1b9ca05b5..69c35e0e3 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -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 }