Improve readability
This commit is contained in:
@@ -24,6 +24,7 @@ module.exports = class ClusterBackend {
|
||||
const { user, layer: layerIndex } = params;
|
||||
const mapConfig = new AggregationMapConfig(user, _mapConfig.obj(), pg);
|
||||
const layer = mapConfig.getLayer(layerIndex);
|
||||
|
||||
let { aggregation } = params;
|
||||
|
||||
try {
|
||||
@@ -44,35 +45,35 @@ module.exports = class ClusterBackend {
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
const query = layer.options.sql_raw;
|
||||
const resolution = layer.options.aggregation.resolution || 1;
|
||||
params.aggregation = aggregation;
|
||||
|
||||
getColumnsName(pg, query, (err, columns) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
const { zoom, clusterId } = params;
|
||||
|
||||
getClusterFeatures(pg, zoom, clusterId, columns, query, resolution, aggregation, (err, features) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
return callback(null, features);
|
||||
});
|
||||
});
|
||||
getFeatures(pg, layer, params, callback);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function getFeatures (pg, layer, params, callback) {
|
||||
const query = layer.options.sql_raw;
|
||||
const resolution = layer.options.aggregation.resolution || 1;
|
||||
|
||||
getColumnsName(pg, query, (err, columns) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
const { zoom, clusterId, aggregation } = params;
|
||||
|
||||
getClusterFeatures(pg, zoom, clusterId, columns, query, resolution, aggregation, callback);
|
||||
});
|
||||
}
|
||||
|
||||
const SKIP_COLUMNS = {
|
||||
'the_geom': true,
|
||||
'the_geom_webmercator': true
|
||||
};
|
||||
|
||||
function getColumnsName (pg, query, callback) {
|
||||
const sql = limitedQuery({
|
||||
const sql = schemaQuery({
|
||||
query: query
|
||||
});
|
||||
|
||||
@@ -126,7 +127,7 @@ function getClusterFeatures (pg, zoom, clusterId, columns, query, resolution, ag
|
||||
} , true); // use read-only transaction
|
||||
}
|
||||
|
||||
const limitedQuery = ctx => `SELECT * FROM (${ctx.query}) __cdb_schema LIMIT 0`;
|
||||
const schemaQuery = ctx => `SELECT * FROM (${ctx.query}) __cdb_schema LIMIT 0`;
|
||||
const clusterFeaturesQuery = ctx => `
|
||||
WITH
|
||||
_cdb_params AS (
|
||||
|
||||
Reference in New Issue
Block a user