Merge branch 'master' of github.com:mapbox/node-mbtiles into skipblank

This commit is contained in:
Dane Springmeyer
2012-03-06 17:56:23 -08:00
3 changed files with 16 additions and 6 deletions
+7 -3
View File
@@ -174,7 +174,7 @@ MBTiles.prototype.getTile = function(z, x, y, callback) {
} else { } else {
var options = { var options = {
'Content-Type': MBTiles.utils.getMimeType(row.tile_data), '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) 'ETag': mbtiles._stat.size + '-' + Number(mbtiles._stat.mtime)
}; };
return callback(null, row.tile_data, options); return callback(null, row.tile_data, options);
@@ -229,8 +229,12 @@ MBTiles.prototype.getGrid = function(z, x, y, callback) {
} catch (err) { } catch (err) {
return callback(new Error('Grid is invalid')); return callback(new Error('Grid is invalid'));
} }
var options = {
callback(null, result); '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 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "mbtiles", "name": "mbtiles",
"version": "0.1.17", "version": "0.1.18",
"description": "Utilities and tilelive integration for the MBTiles format.", "description": "Utilities and tilelive integration for the MBTiles format.",
"url": "http://github.com/mapbox/node-mbtiles", "url": "http://github.com/mapbox/node-mbtiles",
"author": { "author": {
+8 -2
View File
@@ -37,9 +37,12 @@ exports['get tiles'] = function(beforeExit) {
if (coords) { if (coords) {
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ. // Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2]; 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; if (err) throw err;
assert.deepEqual(tile, fs.readFileSync(__dirname + '/fixtures/images/' + file)); 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++; status.success++;
}); });
} }
@@ -74,9 +77,12 @@ exports['get grids'] = function(beforeExit) {
if (coords) { if (coords) {
// Flip Y coordinate because file names are TMS, but .getTile() expects XYZ. // Flip Y coordinate because file names are TMS, but .getTile() expects XYZ.
coords[2] = Math.pow(2, coords[3]) - 1 - coords[2]; 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; if (err) throw err;
assert.deepEqual(JSON.stringify(grid), fs.readFileSync(__dirname + '/fixtures/grids/' + file, 'utf8')); 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++; status.success++;
}); });
} }