port to >= node-v6
This commit is contained in:
@@ -215,26 +215,25 @@ MBTiles.prototype.getGrid = function(z, x, y, callback) {
|
||||
}
|
||||
if (err) return callback(err);
|
||||
|
||||
try {
|
||||
var grid = zlib.inflate(
|
||||
!Buffer.isBuffer(row.grid)
|
||||
zlib.inflate(!Buffer.isBuffer(row.grid)
|
||||
? new Buffer(row.grid, 'binary')
|
||||
: row.grid
|
||||
).toString();
|
||||
var data = rows.reduce(function(memo, r) {
|
||||
memo[r.key_name] = JSON.parse(r.key_json);
|
||||
return memo;
|
||||
}, {});
|
||||
var result = _(JSON.parse(grid)).extend({ data: data });
|
||||
} catch (err) {
|
||||
return callback(new Error('Grid is invalid'));
|
||||
}
|
||||
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);
|
||||
, function(err,buffer) {
|
||||
if (err) {
|
||||
return callback(new Error('Grid is invalid:' + err.message));
|
||||
}
|
||||
var data = rows.reduce(function(memo, r) {
|
||||
memo[r.key_name] = JSON.parse(r.key_json);
|
||||
return memo;
|
||||
}, {});
|
||||
var result = _(JSON.parse(buffer.toString())).extend({ data: data });
|
||||
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);
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -582,13 +581,19 @@ MBTiles.prototype.putGrid = function(z, x, y, data, callback) {
|
||||
var id = data.id || crypto.createHash('md5').update(json).digest('hex');
|
||||
if (!this._gridCache[id]) {
|
||||
// This corresponds to the grid_utfgrid table.
|
||||
this._gridCache[id] = zlib.deflate(new Buffer(json, 'utf8'));
|
||||
var that = this;
|
||||
Step(function() {
|
||||
zlib.deflate(new Buffer(json, 'utf8'),this);
|
||||
}, function(err,buffer) {
|
||||
if (err) return callback(err);
|
||||
that._gridCache[id] = buffer;
|
||||
// This corresponds to the grid_key table.
|
||||
that._keyCache[id] = Object.keys(data.data || {});
|
||||
|
||||
// This corresponds to the grid_key table.
|
||||
this._keyCache[id] = Object.keys(data.data || {});
|
||||
|
||||
// This corresponds to the keymap table.
|
||||
_(this._dataCache).extend(data.data || {});
|
||||
// This corresponds to the keymap table.
|
||||
_(that._dataCache).extend(data.data || {});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// This corresponds to the map table.
|
||||
|
||||
@@ -30,14 +30,13 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"optimist": "0.2.x",
|
||||
"sqlite3": "~2.0.17",
|
||||
"sqlite3": "~2.1.1",
|
||||
"step": "0.0.x",
|
||||
"sphericalmercator": "1.0.x",
|
||||
"underscore": "1.1.x",
|
||||
"zlib": "1.0.x"
|
||||
"underscore": "1.1.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
"node": ">= 0.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "expresso"
|
||||
|
||||
Reference in New Issue
Block a user