Refactor supported geometry types
This commit is contained in:
@@ -22,6 +22,16 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static get SUPPORTED_GEOMETRY_TYPES () {
|
||||
return [
|
||||
'ST_Point'
|
||||
];
|
||||
}
|
||||
|
||||
static supportsGeometryType(geometryType) {
|
||||
return AggregationMapConfig.SUPPORTED_GEOMETRY_TYPES.includes(geometryType);
|
||||
}
|
||||
|
||||
constructor (config, datasource) {
|
||||
super(config, datasource);
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ const AggregationMapConfig = require('../../aggregation/aggregation-map-config')
|
||||
const queryUtils = require('../../../utils/query-utils');
|
||||
|
||||
const unsupportedGeometryTypeErrorMessage = ctx =>
|
||||
`Unsupported geometry type: ${ctx.geometryType}. Aggregation is available only for geometry type: ST_Point`;
|
||||
`Unsupported geometry type: ${ctx.geometryType}. ` +
|
||||
`Aggregation is available only for geometry type: ${AggregationMapConfig.SUPPORTED_GEOMETRY_TYPES}`;
|
||||
|
||||
const invalidAggregationParamValueErrorMessage = ctx =>
|
||||
`Invalid value for 'aggregation' query param: ${ctx.value}. Valid ones are 'true' or 'false'`;
|
||||
@@ -116,16 +117,13 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
}
|
||||
|
||||
const result = res.rows[0] || {};
|
||||
const estimatedFeatureCount = result.count;
|
||||
|
||||
if (!mapConfig.doesLayerReachThreshold(index, estimatedFeatureCount)) {
|
||||
if (!mapConfig.doesLayerReachThreshold(index, result.count)) {
|
||||
return callback(null, shouldAdapt);
|
||||
}
|
||||
|
||||
const geometryType = result.type;
|
||||
|
||||
if (geometryType !== 'ST_Point') {
|
||||
return callback(new Error(unsupportedGeometryTypeErrorMessage({ geometryType })));
|
||||
if (!AggregationMapConfig.supportsGeometryType(result.type)) {
|
||||
return callback(new Error(unsupportedGeometryTypeErrorMessage({ geometryType: result.type })));
|
||||
}
|
||||
|
||||
shouldAdapt = true;
|
||||
|
||||
Reference in New Issue
Block a user