Commit 7f486ca9 authored by theopolisme's avatar theopolisme
Browse files

Display how much of the file has been processed...and how much remains!

parent 3b7bcd40
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
( function ( $, L, oboe, FileReadStream ) {
( function ( $, L, oboe, FileReadStream, prettySize ) {
	var map;

	// Start at the beginning
@@ -56,16 +56,17 @@

		function processFile ( file ) {
			var pointNo = 0,
				fileSize = prettySize( file.size ),
				filestream = new FileReadStream( file );

			status( 'Reading file...' );
			status( 'Preparing to import file (' + fileSize + ')...' );

			oboe( filestream )
				.on( 'node', {
					'locations.*': function ( location ) {
						// Add the new point... prevent lots of redraws by writing to _latlngs
						pointNo += 1;
						status( 'Adding point #' + pointNo.toLocaleString() + '...' );
						status( 'Adding point #' + pointNo.toLocaleString() + ' (' + prettySize( filestream._offset ) + ' / ' + fileSize + ')' );
						heat._latlngs.push( [ location.latitudeE7 * SCALAR_E7, location.longitudeE7 * SCALAR_E7 ] );
					},
					'locations': function () {
@@ -107,4 +108,4 @@
		} );
	}

}( jQuery, L, oboe, FileReadStream ) );
}( jQuery, L, oboe, FileReadStream, prettySize ) );
+3 −0
Original line number Diff line number Diff line
/* https://github.com/davglass/prettysize */
(function(){var sizes=["Bytes","kB","MB","GB","TB","PB","EB"];window.prettySize=function(e,s,i){var t,n;return sizes.forEach(function(n,o){i&&(n=n.slice(0,1));var r,B=Math.pow(1024,o);B>e||(r=(e/B).toFixed(1)+"",r.indexOf(".0")===r.length-2&&(r=r.slice(0,-2)),t=r+(s?"":" ")+n)}),t||(n=i?sizes[0].slice(0,1):sizes[0],t="0"+(s?"":" ")+n),t};}());

/**
 * browserification of
 *  - https://github.com/jimhigson/oboe.js