X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/162ffd9acccc844ab37b4f60b1ff9d5465f43686..43c09d8062fc4aef4f1e0e5d3598e526a02bb288:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index 40027991a..1951e3c31 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -480,7 +480,7 @@ module OSM 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 @@ -494,14 +494,20 @@ module OSM doc = XML::Document.new doc.encoding = XML::Encoding::UTF_8 root = XML::Node.new "osm" - root["version"] = API_VERSION.to_s - root["generator"] = GENERATOR - root["copyright"] = COPYRIGHT_OWNER - root["attribution"] = ATTRIBUTION_URL - root["license"] = LICENSE_URL + xml_root_attributes.each do |k, v| + root[k] = v + end doc.root = root doc end + + def xml_root_attributes + { "version" => API_VERSION.to_s, + "generator" => GENERATOR, + "copyright" => COPYRIGHT_OWNER, + "attribution" => ATTRIBUTION_URL, + "license" => LICENSE_URL } + end end def self.ip_to_country(ip_address) @@ -510,13 +516,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)