Refactor aggregation resolution
This commit is contained in:
parent
e4407ece84
commit
9d8ce6bc44
@ -78,9 +78,14 @@ const aggregateColumnDefs = ctx => {
|
||||
}).join(', ');
|
||||
};
|
||||
|
||||
|
||||
// SQL expression to compute the aggregation resolution (grid cell size).
|
||||
// This is equivalent to `${256/ctx.res}*CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!))`
|
||||
// This is defined by the ctx.res parameter, which is the number of grid cells per tile linear dimension
|
||||
// (i.e. each tile is divided into ctx.res*ctx.res cells).
|
||||
const gridResolution = ctx => `(${256*0.00028/ctx.res}*!scale_denominator!)::double precision`;
|
||||
|
||||
// Notes:
|
||||
// * ${256*0.00028/ctx.res}*!scale_denominator! is equivalent to
|
||||
// ${256/ctx.res}*CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!))
|
||||
// * We need to filter spatially using !bbox! to make the queries efficient because
|
||||
// the filter added by Mapnik (wrapping the query)
|
||||
// is only applied after the aggregation.
|
||||
@ -90,7 +95,7 @@ const aggregationQueryTemplates = {
|
||||
'centroid': ctx => `
|
||||
WITH _cdb_params AS (
|
||||
SELECT
|
||||
(${256*0.00028/ctx.res}*!scale_denominator!)::double precision AS res,
|
||||
${gridResolution(ctx)} AS res,
|
||||
!bbox! AS bbox
|
||||
)
|
||||
SELECT
|
||||
@ -112,7 +117,7 @@ const aggregationQueryTemplates = {
|
||||
'point-grid': ctx => `
|
||||
WITH _cdb_params AS (
|
||||
SELECT
|
||||
(${256*0.00028/ctx.res}*!scale_denominator!)::double precision AS res,
|
||||
${gridResolution(ctx)} AS res,
|
||||
!bbox! AS bbox
|
||||
),
|
||||
_cdb_clusters AS (
|
||||
@ -133,8 +138,7 @@ const aggregationQueryTemplates = {
|
||||
'point-sample': ctx => `
|
||||
WITH _cdb_params AS (
|
||||
SELECT
|
||||
|
||||
(${256*0.00028/ctx.res}*!scale_denominator!)::double precision AS res,
|
||||
${gridResolution(ctx)} AS res,
|
||||
!bbox! AS bbox
|
||||
), _cdb_clusters AS (
|
||||
SELECT
|
||||
|
Loading…
Reference in New Issue
Block a user