Merge branch 'full-sample' into pg-mvt-do-not-filter-columns
This commit is contained in:
commit
a1d536642e
@ -118,7 +118,8 @@ const gridResolution = ctx => `(${256*0.00028/ctx.res}*!scale_denominator!)::dou
|
|||||||
|
|
||||||
const aggregationQueryTemplates = {
|
const aggregationQueryTemplates = {
|
||||||
'centroid': ctx => `
|
'centroid': ctx => `
|
||||||
WITH _cdb_params AS (
|
WITH
|
||||||
|
_cdb_params AS (
|
||||||
SELECT
|
SELECT
|
||||||
${gridResolution(ctx)} AS res,
|
${gridResolution(ctx)} AS res,
|
||||||
!bbox! AS bbox
|
!bbox! AS bbox
|
||||||
@ -142,7 +143,8 @@ const aggregationQueryTemplates = {
|
|||||||
`,
|
`,
|
||||||
|
|
||||||
'point-grid': ctx => `
|
'point-grid': ctx => `
|
||||||
WITH _cdb_params AS (
|
WITH
|
||||||
|
_cdb_params AS (
|
||||||
SELECT
|
SELECT
|
||||||
${gridResolution(ctx)} AS res,
|
${gridResolution(ctx)} AS res,
|
||||||
!bbox! AS bbox
|
!bbox! AS bbox
|
||||||
@ -165,11 +167,42 @@ const aggregationQueryTemplates = {
|
|||||||
`,
|
`,
|
||||||
|
|
||||||
'point-sample': ctx => `
|
'point-sample': ctx => `
|
||||||
WITH _cdb_params AS (
|
WITH
|
||||||
|
_cdb_params AS (
|
||||||
SELECT
|
SELECT
|
||||||
${gridResolution(ctx)} AS res,
|
${gridResolution(ctx)} AS res,
|
||||||
!bbox! AS bbox
|
!bbox! AS bbox
|
||||||
), _cdb_clusters AS (
|
),
|
||||||
|
_cdb_clusters AS (
|
||||||
|
SELECT
|
||||||
|
MIN(cartodb_id) AS cartodb_id
|
||||||
|
${dimensionDefs(ctx)}
|
||||||
|
${aggregateColumnDefs(ctx)}
|
||||||
|
FROM (${ctx.sourceQuery}) _cdb_query, _cdb_params
|
||||||
|
WHERE _cdb_query.the_geom_webmercator && _cdb_params.bbox
|
||||||
|
GROUP BY
|
||||||
|
Floor(ST_X(_cdb_query.the_geom_webmercator)/_cdb_params.res),
|
||||||
|
Floor(ST_Y(_cdb_query.the_geom_webmercator)/_cdb_params.res)
|
||||||
|
${dimensionNames(ctx)}
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
_cdb_clusters.cartodb_id,
|
||||||
|
the_geom, the_geom_webmercator
|
||||||
|
${dimensionNames(ctx)}
|
||||||
|
${aggregateColumnNames(ctx)}
|
||||||
|
FROM
|
||||||
|
_cdb_clusters INNER JOIN (${ctx.sourceQuery}) _cdb_query
|
||||||
|
ON (_cdb_clusters.cartodb_id = _cdb_query.cartodb_id)
|
||||||
|
`,
|
||||||
|
|
||||||
|
'full-sample': ctx => `
|
||||||
|
WITH
|
||||||
|
_cdb_params AS (
|
||||||
|
SELECT
|
||||||
|
${gridResolution(ctx)} AS res,
|
||||||
|
!bbox! AS bbox
|
||||||
|
),
|
||||||
|
_cdb_clusters AS (
|
||||||
SELECT
|
SELECT
|
||||||
MIN(cartodb_id) AS cartodb_id
|
MIN(cartodb_id) AS cartodb_id
|
||||||
${dimensionDefs(ctx)}
|
${dimensionDefs(ctx)}
|
||||||
@ -181,9 +214,7 @@ const aggregationQueryTemplates = {
|
|||||||
Floor(ST_Y(_cdb_query.the_geom_webmercator)/_cdb_params.res)
|
Floor(ST_Y(_cdb_query.the_geom_webmercator)/_cdb_params.res)
|
||||||
${dimensionNames(ctx)}
|
${dimensionNames(ctx)}
|
||||||
) SELECT
|
) SELECT
|
||||||
_cdb_clusters.cartodb_id,
|
_cdb_query.*
|
||||||
the_geom, the_geom_webmercator
|
|
||||||
${dimensionNames(ctx)}
|
|
||||||
${aggregateColumnNames(ctx)}
|
${aggregateColumnNames(ctx)}
|
||||||
FROM
|
FROM
|
||||||
_cdb_clusters INNER JOIN (${ctx.sourceQuery}) _cdb_query
|
_cdb_clusters INNER JOIN (${ctx.sourceQuery}) _cdb_query
|
||||||
|
@ -732,6 +732,51 @@ describe('aggregation', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('aggregates with full-sample placement', function (done) {
|
||||||
|
this.mapConfig = createVectorMapConfig([
|
||||||
|
{
|
||||||
|
type: 'cartodb',
|
||||||
|
options: {
|
||||||
|
sql: POINTS_SQL_1,
|
||||||
|
resolution: 256,
|
||||||
|
aggregation: {
|
||||||
|
placement: 'point-grid',
|
||||||
|
columns: {
|
||||||
|
total: {
|
||||||
|
aggregate_function: 'sum',
|
||||||
|
aggregated_column: 'value'
|
||||||
|
},
|
||||||
|
v_avg: {
|
||||||
|
aggregate_function: 'avg',
|
||||||
|
aggregated_column: 'value'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
threshold: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.testClient = new TestClient(this.mapConfig);
|
||||||
|
|
||||||
|
this.testClient.getTile(0, 0, 0, { format: 'mvt' }, function (err, res, mvt) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const geojsonTile = JSON.parse(mvt.toGeoJSONSync(0));
|
||||||
|
|
||||||
|
assert.ok(Array.isArray(geojsonTile.features));
|
||||||
|
assert.ok(geojsonTile.features.length > 0);
|
||||||
|
|
||||||
|
const feature = geojsonTile.features[0];
|
||||||
|
|
||||||
|
assert.ok(feature.properties.hasOwnProperty('value'), 'Missing value property');
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should fail with bad resolution', function (done) {
|
it('should fail with bad resolution', function (done) {
|
||||||
this.mapConfig = createVectorMapConfig([
|
this.mapConfig = createVectorMapConfig([
|
||||||
{
|
{
|
||||||
@ -802,10 +847,10 @@ describe('aggregation', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.deepEqual(body, {
|
assert.deepEqual(body, {
|
||||||
errors: [ 'Invalid placement. Valid values: centroid, point-grid, point-sample'],
|
errors: [ 'Invalid placement. Valid values: centroid, point-grid, point-sample, full-sample'],
|
||||||
errors_with_context:[{
|
errors_with_context:[{
|
||||||
type: 'layer',
|
type: 'layer',
|
||||||
message: 'Invalid placement. Valid values: centroid, point-grid, point-sample',
|
message: 'Invalid placement. Valid values: centroid, point-grid, point-sample, full-sample',
|
||||||
layer: {
|
layer: {
|
||||||
id: "layer0",
|
id: "layer0",
|
||||||
index: 0,
|
index: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user