diff --git a/lib/cartodb/models/aggregation/aggregation-query.js b/lib/cartodb/models/aggregation/aggregation-query.js index 55ee53ea..bf995c82 100644 --- a/lib/cartodb/models/aggregation/aggregation-query.js +++ b/lib/cartodb/models/aggregation/aggregation-query.js @@ -72,8 +72,8 @@ const aggregateColumns = ctx => { }; // Notes: -// * ${ctx.res*0.00028/256}*!scale_denominator! is equivalent to -// ${ctx.res/256}*CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!)) +// * ${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. @@ -83,7 +83,7 @@ const aggregationQueryTemplates = { 'centroid': ctx => ` WITH _cdb_params AS ( SELECT - (${ctx.res*0.00028/256}*!scale_denominator!)::double precision AS res, + (${256*0.00028/ctx.res}*!scale_denominator!)::double precision AS res, !bbox! AS bbox ) SELECT @@ -105,7 +105,7 @@ const aggregationQueryTemplates = { 'point-grid': ctx => ` WITH _cdb_params AS ( SELECT - (${ctx.res*0.00028/256}*!scale_denominator!)::double precision AS res, + (${256*0.00028/ctx.res}*!scale_denominator!)::double precision AS res, !bbox! AS bbox ), _cdb_clusters AS ( @@ -127,7 +127,7 @@ const aggregationQueryTemplates = { WITH _cdb_params AS ( SELECT - (${ctx.res*0.00028/256}*!scale_denominator!)::double precision AS res, + (${256*0.00028/ctx.res}*!scale_denominator!)::double precision AS res, !bbox! AS bbox ), _cdb_clusters AS ( SELECT