Update resume to only return coords. Tilelive API no longer requires copied count.
This commit is contained in:
+5
-10
@@ -620,17 +620,12 @@ MBTiles.prototype.copyResume = function(callback) {
|
|||||||
if (typeof callback !== 'function') throw new Error('Callback needed');
|
if (typeof callback !== 'function') throw new Error('Callback needed');
|
||||||
if (!this.open) return callback(new Error('MBTiles not yet loaded'));
|
if (!this.open) return callback(new Error('MBTiles not yet loaded'));
|
||||||
var mbtiles = this;
|
var mbtiles = this;
|
||||||
Step(function() {
|
// y is ASC here because tilelive.copy uses XYZ when writing/ordering
|
||||||
// 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.
|
||||||
// tiles but y is "flipped" to TMS when stored in an MBTiles database.
|
this._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', function(err, row) {
|
||||||
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);
|
if (err) return callback(err);
|
||||||
// Flip Y coordinate back to XYZ for tilelive API.
|
if (row) row.y = (1 << row.z) - 1 - row.y; // TMS => XYZ
|
||||||
if (coords) coords.y = (1 << coords.z) - 1 - coords.y;
|
return callback(null, row);
|
||||||
if (coords && copied) coords.copied = copied.copied;
|
|
||||||
return callback(null, coords);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user