more docs
This commit is contained in:
+15
-11
@@ -101,6 +101,8 @@ MBTiles.prototype._exists = function(table, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// DB integrity check.
|
// DB integrity check.
|
||||||
|
//
|
||||||
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype._integrity = function(callback) {
|
MBTiles.prototype._integrity = function(callback) {
|
||||||
if (typeof callback !== 'function') callback = noop;
|
if (typeof callback !== 'function') callback = noop;
|
||||||
|
|
||||||
@@ -108,12 +110,13 @@ MBTiles.prototype._integrity = function(callback) {
|
|||||||
if (!(row && row.integrity_check && row.integrity_check === 'ok')) {
|
if (!(row && row.integrity_check && row.integrity_check === 'ok')) {
|
||||||
return callback(new Error('Corrupted database.'));
|
return callback(new Error('Corrupted database.'));
|
||||||
} else {
|
} else {
|
||||||
return callback(null, true);
|
return callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup schema, indices, views for a new mbtiles database.
|
// Setup schema, indices, views for a new mbtiles database.
|
||||||
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype._setup = function(callback) {
|
MBTiles.prototype._setup = function(callback) {
|
||||||
var mbtiles = this;
|
var mbtiles = this;
|
||||||
mbtiles._exists('tiles', function(err, exists) {
|
mbtiles._exists('tiles', function(err, exists) {
|
||||||
@@ -130,7 +133,7 @@ MBTiles.prototype._setup = function(callback) {
|
|||||||
// - @param {Number} z tile z coordinate.
|
// - @param {Number} z tile z coordinate.
|
||||||
// - @param {Number} x tile x coordinate.
|
// - @param {Number} x tile x coordinate.
|
||||||
// - @param {Number} y tile y coordinate.
|
// - @param {Number} y tile y coordinate.
|
||||||
// - @param {Function} callback
|
// - @param {Function(err, grid, headers)} callback
|
||||||
MBTiles.prototype.getTile = function(z, x, y, callback) {
|
MBTiles.prototype.getTile = function(z, x, y, 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'));
|
||||||
@@ -163,7 +166,7 @@ MBTiles.prototype.getTile = function(z, x, y, callback) {
|
|||||||
// - @param {Number} z tile z coordinate
|
// - @param {Number} z tile z coordinate
|
||||||
// - @param {Number} x tile x coordinate
|
// - @param {Number} x tile x coordinate
|
||||||
// - @param {Number} y tile y coordinate
|
// - @param {Number} y tile y coordinate
|
||||||
// - @param {Function} callback
|
// - @param {Function(err, grid)} callback
|
||||||
MBTiles.prototype.getGrid = function(z, x, y, callback) {
|
MBTiles.prototype.getGrid = function(z, x, y, 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'));
|
||||||
@@ -226,9 +229,10 @@ MBTiles.prototype._metadata = function(key, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend `MBTiles` class with an `info` method for retrieving metadata and
|
// Obtain metadata from the database. Performing fallback queries if certain
|
||||||
// performing fallback queries if certain keys (like `bounds`, `minzoom`,
|
// keys(like `bounds`, `minzoom`, `maxzoom`) have not been provided.
|
||||||
// `maxzoom`) have not been provided.
|
//
|
||||||
|
// - @param {Function(err, data)} callback
|
||||||
MBTiles.prototype.getInfo = function(callback) {
|
MBTiles.prototype.getInfo = 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'));
|
||||||
@@ -338,7 +342,7 @@ MBTiles.prototype.getInfo = function(callback) {
|
|||||||
|
|
||||||
// Puts the MBTiles tilestore into write mode.
|
// Puts the MBTiles tilestore into write mode.
|
||||||
//
|
//
|
||||||
// - @param {Function} callback
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype.startWriting = function(callback) {
|
MBTiles.prototype.startWriting = 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'));
|
||||||
@@ -364,7 +368,7 @@ MBTiles.prototype.startWriting = function(callback) {
|
|||||||
|
|
||||||
// (private) Commits the cached changes to the database.
|
// (private) Commits the cached changes to the database.
|
||||||
//
|
//
|
||||||
// - @param {Function} callback
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype._commit = function(callback) {
|
MBTiles.prototype._commit = function(callback) {
|
||||||
var mbtiles = this;
|
var mbtiles = this;
|
||||||
mbtiles._db.serialize(function() {
|
mbtiles._db.serialize(function() {
|
||||||
@@ -453,7 +457,7 @@ MBTiles.prototype._commit = function(callback) {
|
|||||||
|
|
||||||
// Leaves write mode.
|
// Leaves write mode.
|
||||||
//
|
//
|
||||||
// - @param {Function} callback
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype.stopWriting = function(callback) {
|
MBTiles.prototype.stopWriting = 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'));
|
||||||
@@ -476,7 +480,7 @@ MBTiles.prototype.stopWriting = function(callback) {
|
|||||||
// - @param {Number} x tile x coordinate
|
// - @param {Number} x tile x coordinate
|
||||||
// - @param {Number} y tile y coordinate
|
// - @param {Number} y tile y coordinate
|
||||||
// - @param {Buffer} buffer tile image data
|
// - @param {Buffer} buffer tile image data
|
||||||
// - @param {Function} callback
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype.putTile = function(z, x, y, data, callback) {
|
MBTiles.prototype.putTile = function(z, x, y, data, 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'));
|
||||||
@@ -509,7 +513,7 @@ MBTiles.prototype.putTile = function(z, x, y, data, callback) {
|
|||||||
// - @param {Number} x grid x coordinate
|
// - @param {Number} x grid x coordinate
|
||||||
// - @param {Number} y grid y coordinate
|
// - @param {Number} y grid y coordinate
|
||||||
// - @param {Object} data grid object
|
// - @param {Object} data grid object
|
||||||
// - @param {Function} callback
|
// - @param {Function(err)} callback
|
||||||
MBTiles.prototype.putGrid = function(z, x, y, data, callback) {
|
MBTiles.prototype.putGrid = function(z, x, y, data, 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'));
|
||||||
|
|||||||
Reference in New Issue
Block a user