Extract getStaticImageOptions middleware from controller's context
This commit is contained in:
@@ -80,7 +80,7 @@ NamedMapsController.prototype.register = function(app) {
|
||||
getAffectedTables(),
|
||||
getTemplate(staticOptions),
|
||||
prepareLayerFilterFromPreviewLayers(staticOptions),
|
||||
this.getStaticImageOptions(),
|
||||
getStaticImageOptions({ tablesExtentApi: this.tablesExtentApi }),
|
||||
this.getImage(staticOptions),
|
||||
this.incrementMapViews(),
|
||||
this.setSurrogateKey(),
|
||||
@@ -116,7 +116,7 @@ function getNamedMapProvider ({ namedMapProviderCache, label, forcedFormat = nul
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function getAffectedTables () {
|
||||
return function getAffectedTables (req, res, next) {
|
||||
@@ -134,7 +134,7 @@ function getAffectedTables () {
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function getTemplate ({ label }) {
|
||||
return function getTemplateMiddleware (req, res, next) {
|
||||
@@ -151,7 +151,7 @@ function getTemplate ({ label }) {
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label }) {
|
||||
return function prepareLayerFilterFromPreviewLayersMiddleware (req, res, next) {
|
||||
@@ -193,7 +193,7 @@ function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label })
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function getTile ({ tileBackend, label }) {
|
||||
return function getTileMiddleware (req, res, next) {
|
||||
@@ -214,9 +214,9 @@ function getTile ({ tileBackend, label }) {
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
NamedMapsController.prototype.getStaticImageOptions = function () {
|
||||
function getStaticImageOptions ({ tablesExtentApi }) {
|
||||
return function getStaticImageOptionsMiddleware(req, res, next) {
|
||||
const { user, namedMapProvider, template } = res.locals;
|
||||
|
||||
@@ -240,7 +240,7 @@ NamedMapsController.prototype.getStaticImageOptions = function () {
|
||||
return next();
|
||||
}
|
||||
|
||||
this.tablesExtentApi.getBounds(user, affectedTables, (err, bounds) => {
|
||||
tablesExtentApi.getBounds(user, affectedTables, (err, bounds) => {
|
||||
if (err) {
|
||||
return next();
|
||||
}
|
||||
@@ -250,8 +250,8 @@ NamedMapsController.prototype.getStaticImageOptions = function () {
|
||||
return next();
|
||||
});
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function getImageOptions (params, template) {
|
||||
const { zoom, lon, lat, bbox } = params;
|
||||
|
||||
Reference in New Issue
Block a user