Middlewarify attributes endpoint

This commit is contained in:
Daniel García Aubert 2018-03-05 18:28:52 +01:00
parent d8a4209768
commit ca56df5cfe

View File

@ -79,7 +79,8 @@ LayergroupController.prototype.register = function(app) {
cors(), cors(),
userMiddleware, userMiddleware,
this.prepareContext, this.prepareContext,
this.attributes.bind(this) this.getMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
this.attributes(this.attributesBackend)
); );
app.get( app.get(
@ -229,30 +230,23 @@ LayergroupController.prototype.dataviewSearch = function (dataviewBackend) {
}.bind(this); }.bind(this);
}; };
LayergroupController.prototype.attributes = function(req, res, next) { LayergroupController.prototype.attributes = function (attributesBackend) {
var self = this; return function attributesMiddleware (req, res, next) {
req.profiler.start('windshaft.maplayer_attribute');
req.profiler.start('windshaft.maplayer_attribute'); const { mapConfigProvider } = res.locals;
step( attributesBackend.getFeatureAttributes(mapConfigProvider, res.locals, false, (err, tile, stats) => {
function retrieveFeatureAttributes() {
var mapConfigProvider = new MapStoreMapConfigProvider(
self.mapStore, res.locals.user, self.userLimitsApi, res.locals
);
self.attributesBackend.getFeatureAttributes(mapConfigProvider, res.locals, false, this);
},
function finish(err, tile, stats) {
req.profiler.add(stats || {}); req.profiler.add(stats || {});
if (err) { if (err) {
err.label = 'GET ATTRIBUTES'; err.label = 'GET ATTRIBUTES';
next(err); return next(err);
} else {
self.sendResponse(req, res, tile, 200);
} }
}
);
this.sendResponse(req, res, tile, 200);
});
}.bind(this);
}; };
// Gets a tile for a given token and set of tile ZXY coords. (OSM style) // Gets a tile for a given token and set of tile ZXY coords. (OSM style)