2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2017-05-11 00:16:22 +08:00
|
|
|
function MapConfigBufferSizeAdapter() {
|
2017-05-17 18:33:41 +08:00
|
|
|
this.formats = ['png', 'png32', 'mvt', 'grid.json'];
|
2017-04-28 20:46:36 +08:00
|
|
|
}
|
|
|
|
|
2017-05-11 00:16:22 +08:00
|
|
|
module.exports = MapConfigBufferSizeAdapter;
|
2017-04-28 20:46:36 +08:00
|
|
|
|
2017-05-11 00:16:22 +08:00
|
|
|
MapConfigBufferSizeAdapter.prototype.getMapConfig = function (user, requestMapConfig, params, context, callback) {
|
2017-05-10 23:49:28 +08:00
|
|
|
if (!context.templateParams || !context.templateParams.buffersize) {
|
|
|
|
return callback(null, requestMapConfig);
|
2017-04-28 20:46:36 +08:00
|
|
|
}
|
|
|
|
|
2017-05-17 18:33:41 +08:00
|
|
|
this.formats.forEach(function (format) {
|
2017-05-10 23:49:28 +08:00
|
|
|
if (Number.isFinite(context.templateParams.buffersize[format])) {
|
2017-05-18 21:49:57 +08:00
|
|
|
if (requestMapConfig.buffersize === undefined) {
|
|
|
|
requestMapConfig.buffersize = {};
|
|
|
|
}
|
|
|
|
|
2017-05-10 23:49:28 +08:00
|
|
|
requestMapConfig.buffersize[format] = context.templateParams.buffersize[format];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-05-17 18:55:05 +08:00
|
|
|
setImmediate(function () {
|
2017-04-28 20:46:36 +08:00
|
|
|
callback(null, requestMapConfig);
|
|
|
|
});
|
|
|
|
};
|