Add aggregation test with buffer overlapping cells partially

Also fix resolution parameter incrrectly placed in some tests
This commit is contained in:
Javier Goizueta 2018-07-16 14:27:39 +02:00
parent 2d102c4810
commit e1ec38446d

View File

@ -1245,9 +1245,9 @@ describe('aggregation', function () {
type: 'cartodb',
options: {
sql: POINTS_SQL_1,
resolution: 256,
aggregation: {
threshold: 1
threshold: 1,
resolution: 256
}
}
}
@ -2256,9 +2256,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_0,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
}
}
}
@ -2385,9 +2385,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_GRID,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
}
}
}
@ -2455,6 +2455,83 @@ describe('aggregation', function () {
});
});
it(`for ${placement} no partially aggregated cells`, function (done) {
// Use level 1 with resolution 2 tiles and buffersize 1 (half the cell size)
// Only the cells completely inside the buffer are aggregated
this.mapConfig = {
version: '1.6.0',
buffersize: { 'mvt': 1 },
layers: [
{
type: 'cartodb',
options: {
sql: POINTS_SQL_GRID,
aggregation: {
threshold: 1,
resolution: 2
}
}
}
]
};
if (placement !== 'default') {
this.mapConfig.layers[0].options.aggregation.placement = placement;
}
this.testClient = new TestClient(this.mapConfig);
this.testClient.getTile(1, 0, 0, { format: 'mvt' }, (err, res, mvt) => {
if (err) {
return done(err);
}
const tile00 = JSON.parse(mvt.toGeoJSONSync(0));
this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => {
if (err) {
return done(err);
}
const tile01 = JSON.parse(mvt.toGeoJSONSync(0));
this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => {
if (err) {
return done(err);
}
const tile10 = JSON.parse(mvt.toGeoJSONSync(0));
this.testClient.getTile(1, 1, 1, { format: 'mvt' }, (err, res, mvt) => {
if (err) {
return done(err);
}
const tile11 = JSON.parse(mvt.toGeoJSONSync(0));
const tile00Expected = [
{ cartodb_id: 4, _cdb_feature_count: 3 }
];
const tile10Expected = [
{ cartodb_id: 5, _cdb_feature_count: 5 }
];
const tile01Expected = [
{ cartodb_id: 1, _cdb_feature_count: 2 }
];
const tile11Expected = [
{ cartodb_id: 2, _cdb_feature_count: 3 }
];
const tile00Actual = tile00.features.map(f => f.properties);
const tile10Actual = tile10.features.map(f => f.properties);
const tile01Actual = tile01.features.map(f => f.properties);
const tile11Actual = tile11.features.map(f => f.properties);
const orderById = (a, b) => a.cartodb_id - b.cartodb_id;
assert.deepEqual(tile00Actual.sort(orderById), tile00Expected);
assert.deepEqual(tile10Actual.sort(orderById), tile10Expected);
assert.deepEqual(tile01Actual.sort(orderById), tile01Expected);
assert.deepEqual(tile11Actual.sort(orderById), tile11Expected);
done();
});
});
});
});
});
it(`for ${placement} points aggregated into corner cluster`, function (done) {
// this test will fail due to !bbox! lack of accuracy if strict cell filtering is in place
this.mapConfig = {
@ -2466,9 +2543,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_CELL,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
}
}
}
@ -2506,9 +2583,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_CELL_INNER,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
}
}
}
@ -2549,9 +2626,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_PAIRS,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
}
}
}
@ -2587,9 +2664,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_PAIRS,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
},
metadata: {
aggrFeatureCount: 10
@ -2628,9 +2705,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_PAIRS,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
},
metadata: {
aggrFeatureCount: 0
@ -2669,9 +2746,9 @@ describe('aggregation', function () {
options: {
sql: POINTS_SQL_PAIRS,
resolution: 1,
aggregation: {
threshold: 1
threshold: 1,
resolution: 1
},
metadata: {
featureCount: true