add putDuplicateTile function
This commit is contained in:
@@ -562,6 +562,31 @@ MBTiles.prototype.putTile = function(z, x, y, data, callback) {
|
|||||||
else return callback(null);
|
else return callback(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Inserts a duplicate tile into the MBTiles store. Scheme is XYZ.
|
||||||
|
//
|
||||||
|
// - @param {Number} z tile z coordinate
|
||||||
|
// - @param {Number} x tile x coordinate
|
||||||
|
// - @param {Number} y tile y coordinate
|
||||||
|
// - @param {Number} duplicate tile ID
|
||||||
|
// - @param {Function(err)} callback
|
||||||
|
MBTiles.prototype.putDuplicateTile = function(z, x, y, id, callback) {
|
||||||
|
if (typeof callback !== 'function') throw new Error('Callback needed');
|
||||||
|
if (!this.open) return callback(new Error('MBTiles not yet loaded'));
|
||||||
|
if (!this._isWritable) return callback(new Error('MBTiles not in write mode'));
|
||||||
|
|
||||||
|
// Flip Y coordinate because MBTiles files are TMS.
|
||||||
|
y = (1 << z) - 1 - y;
|
||||||
|
|
||||||
|
// This corresponds to the map table.
|
||||||
|
var coords = hash(z, x, y);
|
||||||
|
if (!this._mapCache[coords]) this._mapCache[coords] = { z: z, x: x, y: y };
|
||||||
|
this._mapCache[coords].tile_id = id;
|
||||||
|
|
||||||
|
// Only commit when we can insert at least batchSize rows.
|
||||||
|
if (++this._pending >= this._batchSize) return this._commit(callback);
|
||||||
|
else return callback(null);
|
||||||
|
};
|
||||||
|
|
||||||
// Inserts a grid into the MBTiles store. Scheme is XYZ.
|
// Inserts a grid into the MBTiles store. Scheme is XYZ.
|
||||||
//
|
//
|
||||||
// - @param {Number} z grid z coordinate
|
// - @param {Number} z grid z coordinate
|
||||||
|
|||||||
Reference in New Issue
Block a user