Add params to instantiate aggregation

This commit is contained in:
Daniel García Aubert 2017-11-30 19:10:57 +01:00
parent 73ae736603
commit d937ed31d5

View File

@ -4,11 +4,12 @@ const RASTER_AGGREGATION = 'RasterAggregation';
const VECTOR_AGGREGATION = 'VectorAggregation'; const VECTOR_AGGREGATION = 'VectorAggregation';
module.exports = class AggregationProxy { module.exports = class AggregationProxy {
constructor (mapconfig, resolution = 256, threshold = 10e5, placement = 'centroid') { constructor (mapconfig, { resolution = 256, threshold = 10e5, placement = 'centroid', columns = {}} = {}) {
this.mapconfig = mapconfig; this.mapconfig = mapconfig;
this.resolution = resolution; this.resolution = resolution;
this.threshold = threshold; this.threshold = threshold;
this.placement = placement; this.placement = placement;
this.columns = columns;
this.implementation = this._getAggregationImplementation(); this.implementation = this._getAggregationImplementation();
} }
@ -17,10 +18,10 @@ module.exports = class AggregationProxy {
switch (this._getAggregationType()) { switch (this._getAggregationType()) {
case VECTOR_AGGREGATION: case VECTOR_AGGREGATION:
implementation = new VectorAggregation(this.resolution, this.threshold, this.placement); implementation = new VectorAggregation(this.resolution, this.threshold, this.placement, this.columns);
break; break;
case RASTER_AGGREGATION: case RASTER_AGGREGATION:
implementation = new RasterAggregation(this.resolution, this.threshold, this.placement); implementation = new RasterAggregation(this.resolution, this.threshold, this.placement, this.columns);
break; break;
default: default:
throw new Error('Unsupported aggregation type'); throw new Error('Unsupported aggregation type');