turbo-carto adapter with getMapConfig interface

This commit is contained in:
Raul Ochoa 2016-05-23 15:18:20 +02:00
parent 01a69ef15c
commit 3e35604df0
3 changed files with 9 additions and 13 deletions

View File

@ -210,15 +210,11 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
assert.ifError(err);
var next = this;
self.turboCartoAdapter.getLayers(req.context.user, requestMapConfig.layers, function (err, layers) {
self.turboCartoAdapter.getMapConfig(req.context.user, requestMapConfig, function (err, requestMapConfig) {
if (err) {
return next(err);
}
if (layers) {
requestMapConfig.layers = layers;
}
return next(null, requestMapConfig, datasource);
});
},

View File

@ -11,11 +11,13 @@ function TurboCartoAdapter(turboCartoParser) {
module.exports = TurboCartoAdapter;
TurboCartoAdapter.prototype.getLayers = function (username, layers, callback) {
TurboCartoAdapter.prototype.getMapConfig = function (username, requestMapConfig, callback) {
var self = this;
var layers = requestMapConfig.layers;
if (!layers || layers.length === 0) {
return callback(null, layers);
return callback(null, requestMapConfig);
}
var parseCartoQueue = queue(layers.length);
@ -29,7 +31,9 @@ TurboCartoAdapter.prototype.getLayers = function (username, layers, callback) {
return callback(err);
}
return callback(null, layers);
requestMapConfig.layers = layers;
return callback(null, requestMapConfig);
});
};

View File

@ -164,15 +164,11 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
assert.ifError(err);
var next = this;
self.turboCartoAdapter.getLayers(self.owner, _mapConfig.layers, function (err, layers) {
self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, function (err, _mapConfig) {
if (err) {
return next(err);
}
if (layers) {
_mapConfig.layers = layers;
}
return next(null, _mapConfig, datasource);
});
},