]> git.openstreetmap.org Git - rails.git/commitdiff
Ignore unknown countries when doing geolocation
authorTom Hughes <tom@compton.nu>
Thu, 13 May 2010 14:32:46 +0000 (15:32 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 13 May 2010 14:32:46 +0000 (15:32 +0100)
lib/osm.rb

index c92655aeea207b48393645e6bb9aeb4bcf478c4c..704bc099ce23d8ae1ff2c1abdc51e422c57869ee 100644 (file)
@@ -471,9 +471,7 @@ module OSM
   def self.IPLocation(ip_address)
     code = OSM.IPToCountry(ip_address)
 
-    unless code.nil?
-      country = Country.find_by_code(code)
-
+    if code and country = Country.find_by_code(code)
       return { :minlon => country.min_lon, :minlat => country.min_lat, :maxlon => country.max_lon, :maxlat => country.max_lat }
     end