Remove magic number

This commit is contained in:
Daniel García Aubert 2017-12-12 13:32:01 +01:00
parent 0b27d174ef
commit e26cfb2efb
2 changed files with 6 additions and 2 deletions

View File

@ -4,7 +4,11 @@ const RASTER_AGGREGATION = 'RasterAggregation';
const VECTOR_AGGREGATION = 'VectorAggregation'; const VECTOR_AGGREGATION = 'VectorAggregation';
module.exports = class AggregationProxy { module.exports = class AggregationProxy {
constructor (mapconfig, query, { resolution = 256, threshold = 1e5, placement = 'centroid', columns = {}} = {}) { static get THRESHOLD() {
return 1e5; // 100K
}
constructor (mapconfig, query, { resolution = 256, threshold = AggregationProxy.THRESHOLD, placement = 'centroid', columns = {}} = {}) {
this.mapconfig = mapconfig; this.mapconfig = mapconfig;
this.query = query; this.query = query;
this.resolution = resolution; this.resolution = resolution;

View File

@ -177,7 +177,7 @@ module.exports = class AggregationMapConfigAdapter {
const threshold = layer.options.aggregation && layer.options.aggregation.threshold ? const threshold = layer.options.aggregation && layer.options.aggregation.threshold ?
layer.options.aggregation.threshold : layer.options.aggregation.threshold :
1e5; AggregationProxy.THRESHOLD;
if (estimatedFeatureCount < threshold) { if (estimatedFeatureCount < threshold) {
return callback(null, shouldAdapt); return callback(null, shouldAdapt);