Extract method

This commit is contained in:
Daniel García Aubert
2017-12-05 16:50:18 +01:00
parent 4f8b541010
commit 7b35701fa8
@@ -34,10 +34,7 @@ module.exports = class AggregationMapConfigAdapter {
for (let index = 0; index < layers.length; index++) {
const layer = layers[index];
const { aggregation } = layer.options;
const hasAggregationColumns = aggregation !== undefined &&
typeof aggregation !== 'boolean' &&
typeof aggregation.columns === 'object';
const aggregationColumns = hasAggregationColumns ? Object.keys(aggregation.columns) : [];
const aggregationColumns = this._getAggregationColumns(aggregation);
const layerColumns = mapConfig.getColumnsByLayer(index);
if (layerColumns.length === 0) {
@@ -126,8 +123,23 @@ module.exports = class AggregationMapConfigAdapter {
_getAggregationMetadata (requestMapConfig) {
return requestMapConfig.layers.map(layer => {
return this._hasLayerAggregation(layer) ?
{ aggregated: true } :
{ aggregated: false };
{ png: false, mvt: true } :
{ png: false, mvt: false };
});
}
_getAggregationColumns (aggregation) {
const hasAggregationColumns = aggregation !== undefined &&
typeof aggregation !== 'boolean' &&
typeof aggregation.columns === 'object';
let aggregationColumns = [];
if (hasAggregationColumns) {
aggregationColumns = Object.keys(aggregation.columns).map(key => {
return aggregation.columns[key].aggregated_column;
});
}
return aggregationColumns;
}
};