Removed template-maps backend from named-maps controller
This commit is contained in:
parent
c6988cdb88
commit
b0990a1132
@ -10,7 +10,7 @@ var cors = require('../middleware/cors');
|
||||
var userMiddleware = require('../middleware/user');
|
||||
|
||||
function NamedMapsController(authApi, pgConnection, namedMapProviderCache, tileBackend, previewBackend,
|
||||
surrogateKeysCache, tablesExtentApi, metadataBackend, templateMaps) {
|
||||
surrogateKeysCache, tablesExtentApi, metadataBackend) {
|
||||
BaseController.call(this, authApi, pgConnection);
|
||||
|
||||
this.namedMapProviderCache = namedMapProviderCache;
|
||||
@ -19,7 +19,6 @@ function NamedMapsController(authApi, pgConnection, namedMapProviderCache, tileB
|
||||
this.surrogateKeysCache = surrogateKeysCache;
|
||||
this.tablesExtentApi = tablesExtentApi;
|
||||
this.metadataBackend = metadataBackend;
|
||||
this.templateMaps = templateMaps;
|
||||
}
|
||||
|
||||
util.inherits(NamedMapsController, BaseController);
|
||||
@ -127,23 +126,6 @@ NamedMapsController.prototype.staticMap = function(req, res) {
|
||||
function reqParams() {
|
||||
self.req2params(req, this);
|
||||
},
|
||||
function getLayerFilterFromPreviewLayers (err) {
|
||||
assert.ifError(err);
|
||||
|
||||
var next = this;
|
||||
|
||||
self.getLayerFilterFromPreviewLayers(cdbUser, req.params.template_id, next);
|
||||
},
|
||||
function applyPreviewLayers (err, layerVisibilityFilter) {
|
||||
assert.ifError(err);
|
||||
|
||||
if (layerVisibilityFilter) {
|
||||
// overwrite 'all' default filter
|
||||
req.params.layer = layerVisibilityFilter;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
function getNamedMapProvider(err) {
|
||||
assert.ifError(err);
|
||||
self.namedMapProviderCache.get(
|
||||
@ -155,9 +137,15 @@ NamedMapsController.prototype.staticMap = function(req, res) {
|
||||
this
|
||||
);
|
||||
},
|
||||
function prepareImageOptions(err, _namedMapProvider) {
|
||||
function prepareLayerVisibility(err, _namedMapProvider) {
|
||||
assert.ifError(err);
|
||||
|
||||
namedMapProvider = _namedMapProvider;
|
||||
|
||||
self.prepareLayerFilterFromPreviewLayers(req.params, namedMapProvider, this);
|
||||
},
|
||||
function prepareImageOptions(err) {
|
||||
assert.ifError(err);
|
||||
self.getStaticImageOptions(cdbUser, req.params, namedMapProvider, this);
|
||||
},
|
||||
function getImage(err, imageOpts) {
|
||||
@ -202,51 +190,32 @@ NamedMapsController.prototype.staticMap = function(req, res) {
|
||||
);
|
||||
};
|
||||
|
||||
NamedMapsController.prototype.getLayerFilterFromPreviewLayers = function (cdbUser, template_id, callback) {
|
||||
var self = this;
|
||||
|
||||
step(
|
||||
function getTemplate () {
|
||||
var next = this;
|
||||
|
||||
self.templateMaps.getTemplate(cdbUser, template_id, next);
|
||||
},
|
||||
function getLayerVisivilityFilter (err, template) {
|
||||
assert.ifError(err);
|
||||
|
||||
var next = this;
|
||||
|
||||
if (!template || !template.view || !template.view.preview_layers) {
|
||||
return next();
|
||||
}
|
||||
|
||||
var previewLayers = template.view.preview_layers;
|
||||
var layerVisibilityFilter = [];
|
||||
|
||||
template.layergroup.layers.forEach(function (layer, index) {
|
||||
if (previewLayers[''+index] !== false && previewLayers[layer.id] !== false) {
|
||||
layerVisibilityFilter.push(''+index);
|
||||
}
|
||||
});
|
||||
|
||||
if (!layerVisibilityFilter.length) {
|
||||
return next();
|
||||
}
|
||||
|
||||
next(null, layerVisibilityFilter);
|
||||
},
|
||||
function finish (err, layerVisibilityFilter) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!layerVisibilityFilter) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
callback(null, layerVisibilityFilter.join(','));
|
||||
NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (params, namedMapProvider, callback) {
|
||||
namedMapProvider.getTemplate(function (err, template) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
);
|
||||
|
||||
if (!template || !template.view || !template.view.preview_layers) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
var previewLayers = template.view.preview_layers;
|
||||
var layerVisibilityFilter = [];
|
||||
|
||||
template.layergroup.layers.forEach(function (layer, index) {
|
||||
if (previewLayers[''+index] !== false && previewLayers[layer.id] !== false) {
|
||||
layerVisibilityFilter.push(''+index);
|
||||
}
|
||||
});
|
||||
|
||||
if (layerVisibilityFilter.length) {
|
||||
// overwrite 'all' default filter
|
||||
params.layer = layerVisibilityFilter.join(',');
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var DEFAULT_ZOOM_CENTER = {
|
||||
|
@ -217,8 +217,7 @@ module.exports = function(serverOptions) {
|
||||
previewBackend,
|
||||
surrogateKeysCache,
|
||||
tablesExtentApi,
|
||||
metadataBackend,
|
||||
templateMaps
|
||||
metadataBackend
|
||||
).register(app);
|
||||
|
||||
new controller.NamedMapsAdmin(authApi, pgConnection, templateMaps).register(app);
|
||||
|
Loading…
Reference in New Issue
Block a user