Merge branch 'master' of github.com:mapbox/node-mbtiles into skipblank
This commit is contained in:
@@ -174,7 +174,7 @@ MBTiles.prototype.getTile = function(z, x, y, callback) {
|
||||
} else {
|
||||
var options = {
|
||||
'Content-Type': MBTiles.utils.getMimeType(row.tile_data),
|
||||
'Last-Modified': mbtiles._stat.mtime,
|
||||
'Last-Modified': new Date(mbtiles._stat.mtime).toUTCString(),
|
||||
'ETag': mbtiles._stat.size + '-' + Number(mbtiles._stat.mtime)
|
||||
};
|
||||
return callback(null, row.tile_data, options);
|
||||
@@ -229,8 +229,12 @@ MBTiles.prototype.getGrid = function(z, x, y, callback) {
|
||||
} catch (err) {
|
||||
return callback(new Error('Grid is invalid'));
|
||||
}
|
||||
|
||||
callback(null, result);
|
||||
var options = {
|
||||
'Content-Type': 'text/javascript',
|
||||
'Last-Modified': new Date(that._stat.mtime).toUTCString(),
|
||||
'ETag': that._stat.size + '-' + Number(that._stat.mtime)
|
||||
};
|
||||
callback(null, result, options);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mbtiles",
|
||||
"version": "0.1.17",
|
||||
"version": "0.1.18",
|
||||
"description": "Utilities and tilelive integration for the MBTiles format.",
|
||||
"url": "http://github.com/mapbox/node-mbtiles",
|
||||
"author": {
|
||||
|
||||
@@ -37,9 +37,12 @@ exports['get tiles'] = function(beforeExit) {
|
||||
if (coords) {
|
||||
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
|
||||
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2];
|
||||
mbtiles.getTile(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, tile) {
|
||||
mbtiles.getTile(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, tile, headers) {
|
||||
if (err) throw err;
|
||||
assert.deepEqual(tile, fs.readFileSync(__dirname + '/fixtures/images/' + file));
|
||||
assert.equal(headers['Content-Type'], 'image/png');
|
||||
assert.ok(!isNaN(Date.parse(headers['Last-Modified'])));
|
||||
assert.ok(/\d+-\d+/.test(headers['ETag']));
|
||||
status.success++;
|
||||
});
|
||||
}
|
||||
@@ -74,9 +77,12 @@ exports['get grids'] = function(beforeExit) {
|
||||
if (coords) {
|
||||
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
|
||||
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2];
|
||||
mbtiles.getGrid(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, grid) {
|
||||
mbtiles.getGrid(coords[3] | 0, coords[1] | 0, coords[2] | 0, function(err, grid, headers) {
|
||||
if (err) throw err;
|
||||
assert.deepEqual(JSON.stringify(grid), fs.readFileSync(__dirname + '/fixtures/grids/' + file, 'utf8'));
|
||||
assert.equal(headers['Content-Type'], 'text/javascript');
|
||||
assert.ok(!isNaN(Date.parse(headers['Last-Modified'])));
|
||||
assert.ok(/\d+-\d+/.test(headers['ETag']));
|
||||
status.success++;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user