Windshaft-cartodb/lib/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js

28 lines
847 B
JavaScript
Raw Normal View History

'use strict';
2019-10-22 01:07:24 +08:00
function MapConfigBufferSizeAdapter () {
this.formats = ['png', 'png32', 'mvt', 'grid.json'];
}
module.exports = MapConfigBufferSizeAdapter;
MapConfigBufferSizeAdapter.prototype.getMapConfig = function (user, requestMapConfig, params, context, callback) {
if (!context.templateParams || !context.templateParams.buffersize) {
return callback(null, requestMapConfig);
}
this.formats.forEach(function (format) {
if (Number.isFinite(context.templateParams.buffersize[format])) {
if (requestMapConfig.buffersize === undefined) {
requestMapConfig.buffersize = {};
}
requestMapConfig.buffersize[format] = context.templateParams.buffersize[format];
}
});
2017-05-17 18:55:05 +08:00
setImmediate(function () {
callback(null, requestMapConfig);
});
};