]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Convert some URLs to https
[rails.git] / lib / osm.rb
index 80b68c2a95bdbeeb4d8201614994865638c321aa..841cce17b8f49dba022de129d7d50b04aba63335 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
@@ -510,13 +510,13 @@ module OSM
     if ipinfo
       country = ipinfo.country_code2
     else
-      country = http_client.get("http://api.hostip.info/country.php?ip=#{ip_address}").body
+      country = http_client.get("https://api.hostip.info/country.php?ip=#{ip_address}").body
       country = "GB" if country == "UK"
     end
 
-    return country
+    country
   rescue StandardError
-    return nil
+    nil
   end
 
   def self.ip_location(ip_address)
@@ -532,7 +532,7 @@ module OSM
   # Parse a float, raising a specified exception on failure
   def self.parse_float(str, klass, *args)
     Float(str)
-  rescue
+  rescue StandardError
     raise klass.new(*args)
   end
 
@@ -553,7 +553,7 @@ module OSM
     tilesql = QuadTile.sql_for_area(bbox, prefix)
     bbox = bbox.to_scaled
 
-    "#{tilesql} AND #{prefix}latitude BETWEEN #{bbox.min_lat} AND #{bbox.max_lat} " +
+    "#{tilesql} AND #{prefix}latitude BETWEEN #{bbox.min_lat} AND #{bbox.max_lat} " \
       "AND #{prefix}longitude BETWEEN #{bbox.min_lon} AND #{bbox.max_lon}"
   end