]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Merge remote-tracking branch 'upstream/pull/1804'
[rails.git] / lib / osm.rb
index e4835a76b57745a86ce83b1205bf05243af74894..71e12534ffe57c348d4802d81aeb40f9a4b31cbf 100644 (file)
@@ -475,12 +475,12 @@ module OSM
         lonradius = PI
       end
 
-      minlat = (@lat - latradius) * 180 / PI
-      maxlat = (@lat + latradius) * 180 / PI
-      minlon = (@lon - lonradius) * 180 / PI
-      maxlon = (@lon + lonradius) * 180 / PI
+      minlat = [(@lat - latradius) * 180 / PI, -90].max
+      maxlat = [(@lat + latradius) * 180 / PI, 90].min
+      minlon = [(@lon - lonradius) * 180 / PI, -180].max
+      maxlon = [(@lon + lonradius) * 180 / PI, 180].min
 
-      { :minlat => minlat, :maxlat => maxlat, :minlon => minlon, :maxlon => maxlon }
+      BoundingBox.new(minlon, minlat, maxlon, maxlat)
     end
 
     # get the SQL to use to calculate distance
@@ -514,9 +514,9 @@ module OSM
       country = "GB" if country == "UK"
     end
 
-    return country
+    country
   rescue StandardError
-    return nil
+    nil
   end
 
   def self.ip_location(ip_address)