Named maps adapter with getMapConfig interface

This commit is contained in:
Raul Ochoa
2016-05-23 15:39:11 +02:00
parent 3e35604df0
commit 9f6ce64a31
5 changed files with 39 additions and 37 deletions
+2 -5
View File
@@ -175,15 +175,12 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
assert.ifError(err);
var next = this;
analysesResults = _analysesResults;
self.namedLayersAdapter.getLayers(req.context.user, requestMapConfig.layers, self.pgConnection,
function(err, layers, datasource) {
self.namedLayersAdapter.getMapConfig(req.context.user, requestMapConfig, self.pgConnection,
function(err, requestMapConfig, datasource) {
if (err) {
return next(err);
}
if (layers) {
requestMapConfig.layers = layers;
}
return next(null, requestMapConfig, datasource);
}
);
@@ -8,11 +8,13 @@ function MapConfigNamedLayersAdapter(templateMaps) {
module.exports = MapConfigNamedLayersAdapter;
MapConfigNamedLayersAdapter.prototype.getLayers = function(username, layers, dbMetadata, callback) {
MapConfigNamedLayersAdapter.prototype.getMapConfig = function(username, requestMapConfig, dbMetadata, callback) {
var self = this;
var layers = requestMapConfig.layers;
if (!layers) {
return callback(null);
return callback(null, requestMapConfig);
}
var adaptLayersQueue = queue(layers.length);
@@ -96,7 +98,9 @@ MapConfigNamedLayersAdapter.prototype.getLayers = function(username, layers, dbM
});
return callback(null, layers, datasourceBuilder.build());
requestMapConfig.layers = layers;
return callback(null, requestMapConfig, datasourceBuilder.build());
}
@@ -114,7 +118,7 @@ MapConfigNamedLayersAdapter.prototype.getLayers = function(username, layers, dbM
adaptLayersQueue.awaitAll(layersAdaptQueueFinish);
});
} else {
return callback(null, layers, datasourceBuilder.build());
return callback(null, requestMapConfig, datasourceBuilder.build());
}
};
@@ -131,15 +131,12 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
assert.ifError(err);
var next = this;
self.analysesResults = analysesResults || [];
self.namedLayersAdapter.getLayers(self.owner, _mapConfig.layers, self.pgConnection,
function(err, layers, datasource) {
self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, self.pgConnection,
function(err, _mapConfig, datasource) {
if (err) {
return next(err);
}
if (layers) {
_mapConfig.layers = layers;
}
return next(null, _mapConfig, datasource);
}
);