Encapsulate threshold layer validation in aggregation-mapconfig
This commit is contained in:
@@ -89,6 +89,14 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
return aggregation;
|
||||
}
|
||||
|
||||
doesLayerReachThreshold(index, featureCount) {
|
||||
const threshold = this.getAggregation(index) && this.getAggregation(index).threshold ?
|
||||
this.getAggregation(index).threshold :
|
||||
AggregationMapConfig.THRESHOLD;
|
||||
|
||||
return featureCount >= threshold;
|
||||
}
|
||||
|
||||
validate () {
|
||||
const validate = aggregationValidator(this);
|
||||
const numberValidator = createNumberValidator(this);
|
||||
|
||||
@@ -118,11 +118,7 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
const result = res.rows[0] || {};
|
||||
const estimatedFeatureCount = result.count;
|
||||
|
||||
const threshold = layer.options.aggregation && layer.options.aggregation.threshold ?
|
||||
layer.options.aggregation.threshold :
|
||||
AggregationMapConfig.THRESHOLD;
|
||||
|
||||
if (estimatedFeatureCount < threshold) {
|
||||
if (!mapConfig.doesLayerReachThreshold(index, estimatedFeatureCount)) {
|
||||
return callback(null, shouldAdapt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user