From 9c9fcdfaf91956cd0097992c074e6f24a3de0a47 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Fri, 27 Jan 2012 18:08:24 -0500 Subject: [PATCH] Fix resume start point. --- lib/mbtiles.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mbtiles.js b/lib/mbtiles.js index ddd1a40..7828ba8 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -621,7 +621,9 @@ MBTiles.prototype.copyResume = function(callback) { if (!this.open) return callback(new Error('MBTiles not yet loaded')); var mbtiles = this; Step(function() { - mbtiles._db.get('SELECT zoom_level AS z, tile_column AS x, tile_row AS y FROM tiles ORDER BY z DESC, y DESC, x DESC LIMIT 1', this.parallel()); + // y is ASC here because tilelive.copy uses XYZ when writing/ordering + // tiles but y is "flipped" to TMS when stored in an MBTiles database. + mbtiles._db.get('SELECT zoom_level AS z, tile_column AS x, tile_row AS y FROM tiles ORDER BY z DESC, y ASC, x DESC LIMIT 1', this.parallel()); mbtiles._db.get('SELECT COUNT(*) AS copied FROM tiles WHERE tile_data IS NOT NULL', this.parallel()); }, function(err, coords, copied) { if (err) return callback(err);