X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/effb1b7f4170bb7244c4dfffcbe6134fe00e2bc4..1a0ed716f7ec8e873966566cde50af2630203cb8:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index e4835a76b..841cce17b 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -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)