X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/ee458b6ee25b9a34ca0cb9841b17b6e155ebcc87..0264b865e36c6ed25cb48e833653461aab3e5a00:/lib/gpx.rb?ds=sidebyside diff --git a/lib/gpx.rb b/lib/gpx.rb index 068b84815..1212db642 100644 --- a/lib/gpx.rb +++ b/lib/gpx.rb @@ -51,7 +51,7 @@ module GPX rescue Archive::Error io = ::File.open(@file) - case MimeMagic.by_magic(io).type + case MimeMagic.by_magic(io)&.type when "application/gzip" then io = Zlib::GzipReader.open(@file) when "application/x-bzip" then io = Bzip2::FFI::Reader.open(@file) end @@ -66,7 +66,7 @@ module GPX height = 250 delay = 50 - points_per_frame = num_points / nframes + points_per_frame = (num_points.to_f / nframes).ceil proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height) @@ -114,6 +114,7 @@ module GPX end image = GD2::AnimatedGif.new + image.add(frames.first) frames.each do |frame| image.add(frame, :delay => delay) end