]> git.openstreetmap.org Git - rails.git/blobdiff - lib/gpx.rb
Fix importing of GPX traces with a leading byte order marker
[rails.git] / lib / gpx.rb
index cfc82eedb2445fd0d081872d3d89eb1b7629853a..1212db6423deadeaa62fca89cfd674b8b5a39646 100644 (file)
@@ -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)