Move .sql() to aggregation-mapconfig
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const MapConfig = require('windshaft').model.MapConfig;
|
||||
const aggregationQuery = require('./aggregation-query');
|
||||
|
||||
module.exports = class AggregationMapConfig extends MapConfig {
|
||||
static get THRESHOLD () {
|
||||
@@ -19,6 +20,26 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
this.validate();
|
||||
}
|
||||
|
||||
getAggregatedQuery (index) {
|
||||
const { sql_raw, sql } = this.getLayer(index).options;
|
||||
const {
|
||||
resolution = 1,
|
||||
threshold = AggregationMapConfig.THRESHOLD,
|
||||
placement = 'centroid',
|
||||
columns = {},
|
||||
dimmensions = {}
|
||||
} = this.getAggregation(index);
|
||||
|
||||
return aggregationQuery({
|
||||
query: sql_raw || sql,
|
||||
resolution,
|
||||
threshold,
|
||||
placement,
|
||||
columns,
|
||||
dimmensions
|
||||
});
|
||||
}
|
||||
|
||||
isAggregationMapConfig () {
|
||||
return this.isVectorOnlyMapConfig() || this.hasAnyLayerAggregation();
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
const aggregationQuery = require('./aggregation-query');
|
||||
const AggregationMapConfig = require('./aggregation-map-config');
|
||||
|
||||
module.exports = class Aggregation {
|
||||
constructor (mapconfig, query, {
|
||||
resolution = 1,
|
||||
threshold = AggregationMapConfig.THRESHOLD,
|
||||
placement = 'centroid',
|
||||
columns = {},
|
||||
dimensions = {}
|
||||
} = {}) {
|
||||
this.mapconfig = mapconfig;
|
||||
this.query = query;
|
||||
this.resolution = resolution;
|
||||
this.threshold = threshold;
|
||||
this.placement = placement;
|
||||
this.columns = columns;
|
||||
this.dimensions = dimensions;
|
||||
}
|
||||
sql () {
|
||||
return aggregationQuery(this);
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
const Aggregation = require('../../aggregation/aggregation');
|
||||
const AggregationMapConfig = require('../../aggregation/aggregation-map-config');
|
||||
const queryUtils = require('../../../utils/query-utils');
|
||||
|
||||
@@ -84,11 +83,9 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
}
|
||||
|
||||
if (shouldAdapt) {
|
||||
const sql = layer.options.sql_raw ? layer.options.sql_raw : layer.options.sql;
|
||||
const aggregation = new Aggregation(mapConfig, sql, layer.options.aggregation);
|
||||
const sqlQueryWrap = layer.options.sql_wrap;
|
||||
|
||||
let aggregationSql = aggregation.sql();
|
||||
let aggregationSql = mapConfig.getAggregatedQuery(index);
|
||||
|
||||
if (sqlQueryWrap) {
|
||||
aggregationSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, aggregationSql);
|
||||
|
||||
Reference in New Issue
Block a user