Export supported placements and create static methods to expose them in a fancy way
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const MapConfig = require('windshaft').model.MapConfig;
|
||||
const aggregationQuery = require('./aggregation-query');
|
||||
const { SUPPORTED_AGGREGATE_FUNCTIONS } = require('./aggregation-query');
|
||||
const aggregationValidator = require('./aggregation-validator');
|
||||
const {
|
||||
createPositiveNumberValidator,
|
||||
@@ -9,16 +8,16 @@ const {
|
||||
} = aggregationValidator;
|
||||
|
||||
module.exports = class AggregationMapConfig extends MapConfig {
|
||||
static get AGGREGATIONS () {
|
||||
return aggregationQuery.SUPPORTED_AGGREGATE_FUNCTIONS;
|
||||
}
|
||||
|
||||
static get PLACEMENTS () {
|
||||
return [
|
||||
'centroid',
|
||||
'point-grid',
|
||||
'point-sample'
|
||||
];
|
||||
return aggregationQuery.SUPPORTED_PLACEMENTS;
|
||||
}
|
||||
|
||||
static get PLACEMENT () {
|
||||
return AggregationMapConfig.PLACEMENTS[0];
|
||||
return AggregationMapConfig.PLACEMENTS.find(placement => placement === 'centroid');
|
||||
}
|
||||
|
||||
static get THRESHOLD () {
|
||||
@@ -45,7 +44,7 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
const validate = aggregationValidator(this);
|
||||
const positiveNumberValidator = createPositiveNumberValidator(this);
|
||||
const includesValidPlacementsValidator = createIncludesValueValidator(this, AggregationMapConfig.PLACEMENTS);
|
||||
const aggregationColumnsValidator = createAggregationColumnsValidator(this, SUPPORTED_AGGREGATE_FUNCTIONS);
|
||||
const aggregationColumnsValidator = createAggregationColumnsValidator(this, AggregationMapConfig.AGGREGATIONS);
|
||||
|
||||
validate('resolution', positiveNumberValidator);
|
||||
validate('placement', includesValidPlacementsValidator);
|
||||
|
||||
@@ -190,3 +190,5 @@ const aggregationQueryTemplates = {
|
||||
ON (_cdb_clusters.cartodb_id = _cdb_query.cartodb_id)
|
||||
`
|
||||
};
|
||||
|
||||
module.exports.SUPPORTED_PLACEMENTS = Object.keys(aggregationQueryTemplates);
|
||||
|
||||
Reference in New Issue
Block a user