]> git.openstreetmap.org Git - rails.git/commitdiff
Use a lower zoom level for partial postcode matches.
authorTom Hughes <tom@compton.nu>
Tue, 5 Feb 2008 19:14:33 +0000 (19:14 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 5 Feb 2008 19:14:33 +0000 (19:14 +0000)
app/controllers/geocoder_controller.rb

index d997be614b7f02ccef03370b8fab68b4ead1bf80..d055fe8a9adb2bf315b8baa692506e44acc4f826 100644 (file)
@@ -84,8 +84,10 @@ private
     unless response.match(/Error/)
       dataline = response.split(/\n/)[1]
       data = dataline.split(/,/) # easting,northing,postcode,lat,long
-      results.push({:lat => data[3], :lon => data[4], :zoom => POSTCODE_ZOOM,
-                    :name => data[2].gsub(/'/, "")})
+      postcode = data[2].gsub(/'/, "")
+      zoom = POSTCODE_ZOOM - postcode.count("#")
+      results.push({:lat => data[3], :lon => data[4], :zoom => zoom,
+                    :name => postcode})
     end
 
     return { :source => "NPEMap / FreeThePostcode", :url => "http://www.npemap.org.uk/", :results => results }