Unifiy getMapConfig signature
This commit is contained in:
parent
12c44fda6f
commit
9c1db98f67
@ -137,7 +137,6 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
|
|||||||
var analysesResults = [];
|
var analysesResults = [];
|
||||||
|
|
||||||
var user = req.context.user;
|
var user = req.context.user;
|
||||||
var params = req.params;
|
|
||||||
var context = {};
|
var context = {};
|
||||||
|
|
||||||
step(
|
step(
|
||||||
@ -147,11 +146,11 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
|
|||||||
prepareConfigFn,
|
prepareConfigFn,
|
||||||
function prepareSqlWrap(err, requestMapConfig) {
|
function prepareSqlWrap(err, requestMapConfig) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, params, context, this);
|
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, req.params, context, this);
|
||||||
},
|
},
|
||||||
function prepareAnalysisLayers(err, requestMapConfig) {
|
function prepareAnalysisLayers(err, requestMapConfig) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
var analysisConfiguration = {
|
context.analysisConfiguration = {
|
||||||
db: {
|
db: {
|
||||||
host: req.params.dbhost,
|
host: req.params.dbhost,
|
||||||
port: req.params.dbport,
|
port: req.params.dbport,
|
||||||
@ -164,16 +163,7 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
|
|||||||
apiKey: req.params.api_key
|
apiKey: req.params.api_key
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
self.analysisMapConfigAdapter.getMapConfig(user, requestMapConfig, req.params, context, this);
|
||||||
var filters = {};
|
|
||||||
if (req.params.filters) {
|
|
||||||
try {
|
|
||||||
filters = JSON.parse(req.params.filters);
|
|
||||||
} catch (e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.analysisMapConfigAdapter.getMapConfig(analysisConfiguration, requestMapConfig, filters, this);
|
|
||||||
},
|
},
|
||||||
function beforeLayergroupCreate(err, requestMapConfig, _analysesResults) {
|
function beforeLayergroupCreate(err, requestMapConfig, _analysesResults) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
@ -69,15 +69,25 @@ function getFilter(dataview, params) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalysisMapConfigAdapter.prototype.getMapConfig = function(analysisConfiguration, requestMapConfig, filters, callback) {
|
AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfig, params, context, callback) {
|
||||||
// jshint maxcomplexity:7
|
// jshint maxcomplexity:7
|
||||||
var self = this;
|
var self = this;
|
||||||
filters = filters || {};
|
|
||||||
|
|
||||||
if (!shouldAdaptLayers(requestMapConfig)) {
|
if (!shouldAdaptLayers(requestMapConfig)) {
|
||||||
return callback(null, requestMapConfig);
|
return callback(null, requestMapConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var analysisConfiguration = context.analysisConfiguration;
|
||||||
|
|
||||||
|
var filters = {};
|
||||||
|
if (params.filters) {
|
||||||
|
try {
|
||||||
|
filters = JSON.parse(params.filters);
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var dataviewsFilters = filters.dataviews || {};
|
var dataviewsFilters = filters.dataviews || {};
|
||||||
debug(dataviewsFilters);
|
debug(dataviewsFilters);
|
||||||
var dataviews = requestMapConfig.dataviews || {};
|
var dataviews = requestMapConfig.dataviews || {};
|
||||||
|
@ -61,7 +61,6 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
|
|||||||
var apiKey;
|
var apiKey;
|
||||||
|
|
||||||
var user = this.owner;
|
var user = this.owner;
|
||||||
var params = this.params;
|
|
||||||
var context = {};
|
var context = {};
|
||||||
|
|
||||||
step(
|
step(
|
||||||
@ -103,11 +102,11 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
|
|||||||
},
|
},
|
||||||
function prepareSqlWrap(err, requestMapConfig) {
|
function prepareSqlWrap(err, requestMapConfig) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, params, context, this);
|
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, rendererParams, context, this);
|
||||||
},
|
},
|
||||||
function prepareAnalysisLayers(err, requestMapConfig) {
|
function prepareAnalysisLayers(err, requestMapConfig) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
var analysisConfiguration = {
|
context.analysisConfiguration = {
|
||||||
db: {
|
db: {
|
||||||
host: rendererParams.dbhost,
|
host: rendererParams.dbhost,
|
||||||
port: rendererParams.dbport,
|
port: rendererParams.dbport,
|
||||||
@ -121,15 +120,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var filters = {};
|
self.analysisMapConfigAdapter.getMapConfig(user, requestMapConfig, rendererParams, context, this);
|
||||||
if (self.params.filters) {
|
|
||||||
try {
|
|
||||||
filters = JSON.parse(self.params.filters);
|
|
||||||
} catch (e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.analysisMapConfigAdapter.getMapConfig(analysisConfiguration, requestMapConfig, filters, this);
|
|
||||||
},
|
},
|
||||||
function prepareLayergroup(err, _mapConfig, analysesResults) {
|
function prepareLayergroup(err, _mapConfig, analysesResults) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user