Merge pull request #855 from CartoDB/846-fix-point-grid

Add cartodb_id to point-grid aggregations
This commit is contained in:
Javier Goizueta 2018-01-29 14:48:17 +01:00 committed by GitHub
commit 44c4db93da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -211,6 +211,7 @@ const aggregationQueryTemplates = {
GROUP BY _cdb_gx, _cdb_gy ${dimensionNames(ctx)}
)
SELECT
row_number() over() AS cartodb_id,
ST_SetSRID(ST_MakePoint((_cdb_gx+0.5)*res, (_cdb_gy+0.5)*res), 3857) AS the_geom_webmercator
${dimensionNames(ctx)}
${aggregateColumnNames(ctx)}

View File

@ -1366,6 +1366,41 @@ describe('aggregation', function () {
});
});
});
['centroid', 'point-sample', 'point-grid'].forEach(placement => {
it(`cartodb_id should be present in ${placement} aggregation`, function(done) {
this.mapConfig = createVectorMapConfig([
{
type: 'cartodb',
options: {
sql: POINTS_SQL_1,
aggregation: {
placement: placement,
threshold: 1
},
cartocss: '#layer { marker-width: 1; }',
cartocss_version: '2.3.0',
interactivity: ['cartodb_id']
}
}
]);
this.testClient = new TestClient(this.mapConfig);
this.testClient.getLayergroup((err, body) => {
if (err) {
return done(err);
}
assert.equal(typeof body.metadata, 'object');
assert.ok(Array.isArray(body.metadata.layers));
body.metadata.layers.forEach(layer => assert.ok(layer.meta.aggregation.mvt));
body.metadata.layers.forEach(layer => assert.ok(layer.meta.aggregation.png));
done();
});
});
});
});
});
});