2018-04-09 22:18:30 +08:00
|
|
|
const MapStoreMapConfigProvider = require('../../models/mapconfig/provider/map-store-provider');
|
2018-03-24 04:20:37 +08:00
|
|
|
|
|
|
|
module.exports = function createMapStoreMapConfigProvider (
|
|
|
|
mapStore,
|
|
|
|
userLimitsApi,
|
|
|
|
pgConnection,
|
|
|
|
affectedTablesCache,
|
|
|
|
forcedFormat = null
|
|
|
|
) {
|
|
|
|
return function createMapStoreMapConfigProviderMiddleware (req, res, next) {
|
|
|
|
const { user, token, cache_buster, api_key } = res.locals;
|
|
|
|
const { dbuser, dbname, dbpassword, dbhost, dbport } = res.locals;
|
|
|
|
const { layer, z, x, y, scale_factor, format } = req.params;
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
user, token, cache_buster, api_key,
|
|
|
|
dbuser, dbname, dbpassword, dbhost, dbport,
|
|
|
|
layer, z, x, y, scale_factor, format
|
|
|
|
};
|
|
|
|
|
|
|
|
if (forcedFormat) {
|
|
|
|
params.format = forcedFormat;
|
|
|
|
params.layer = params.layer || 'all';
|
|
|
|
}
|
|
|
|
|
|
|
|
res.locals.mapConfigProvider = new MapStoreMapConfigProvider(
|
|
|
|
mapStore,
|
|
|
|
user,
|
|
|
|
userLimitsApi,
|
|
|
|
pgConnection,
|
|
|
|
affectedTablesCache,
|
|
|
|
params
|
|
|
|
);
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|