Merge branch 'mapconfig-aggregation' of github.com:CartoDB/Windshaft-cartodb into mapconfig-aggregation
This commit is contained in:
commit
8ee4a2c049
@ -50,6 +50,7 @@ const SUPPORTED_AGGREGATE_FUNCTIONS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const aggregateColumns = ctx => {
|
const aggregateColumns = ctx => {
|
||||||
|
// TODO: always add count
|
||||||
let columns = ctx.columns || {};
|
let columns = ctx.columns || {};
|
||||||
if (Object.keys(columns).length === 0) {
|
if (Object.keys(columns).length === 0) {
|
||||||
// default aggregation
|
// default aggregation
|
||||||
@ -71,8 +72,8 @@ const aggregateColumns = ctx => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Notes:
|
// Notes:
|
||||||
// * ${ctx.res*0.00028/256}*!scale_denominator! is equivalent to
|
// * ${256*0.00028/ctx.res}*!scale_denominator! is equivalent to
|
||||||
// ${ctx.res/256}*CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!))
|
// ${256/ctx.res}*CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!))
|
||||||
// * We need to filter spatially using !bbox! to make the queries efficient because
|
// * We need to filter spatially using !bbox! to make the queries efficient because
|
||||||
// the filter added by Mapnik (wrapping the query)
|
// the filter added by Mapnik (wrapping the query)
|
||||||
// is only applied after the aggregation.
|
// is only applied after the aggregation.
|
||||||
@ -82,7 +83,7 @@ const aggregationQueryTemplates = {
|
|||||||
'centroid': ctx => `
|
'centroid': ctx => `
|
||||||
WITH _cdb_params AS (
|
WITH _cdb_params AS (
|
||||||
SELECT
|
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
|
!bbox! AS bbox
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
@ -104,7 +105,7 @@ const aggregationQueryTemplates = {
|
|||||||
'point-grid': ctx => `
|
'point-grid': ctx => `
|
||||||
WITH _cdb_params AS (
|
WITH _cdb_params AS (
|
||||||
SELECT
|
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
|
!bbox! AS bbox
|
||||||
),
|
),
|
||||||
_cdb_clusters AS (
|
_cdb_clusters AS (
|
||||||
@ -117,7 +118,7 @@ const aggregationQueryTemplates = {
|
|||||||
GROUP BY _cdb_gx, _cdb_gy
|
GROUP BY _cdb_gx, _cdb_gy
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
ST_SetSRID(ST_MakePoint(_cdb_gx*(res+0.5), _cdb_gy*(res*0.5)), 3857) AS the_geom_webmercator,
|
ST_SetSRID(ST_MakePoint(_cdb_gx*(res+0.5), _cdb_gy*(res+0.5)), 3857) AS the_geom_webmercator,
|
||||||
_cdb_feature_count
|
_cdb_feature_count
|
||||||
FROM _cdb_clusters, _cdb_params
|
FROM _cdb_clusters, _cdb_params
|
||||||
`,
|
`,
|
||||||
@ -126,7 +127,7 @@ const aggregationQueryTemplates = {
|
|||||||
WITH _cdb_params AS (
|
WITH _cdb_params AS (
|
||||||
SELECT
|
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
|
!bbox! AS bbox
|
||||||
), _cdb_clusters AS (
|
), _cdb_clusters AS (
|
||||||
SELECT
|
SELECT
|
||||||
|
Loading…
Reference in New Issue
Block a user