From 4ac48d2cb5cd2197d8f2702bdc7b17072b2fdc85 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 8 Aug 2007 17:05:28 +0000 Subject: [PATCH 1/1] Cope with results from the OSM Namefinder that have no name. --- app/controllers/geocoder_controller.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 } -- 2.43.2