From c07b3de43db06315c3e4ae0e5e7758afacf6eb5a Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 10:33:58 +0200 Subject: [PATCH 1/7] Adapt tests for more accurate PROJ Fixes #994 With exact point 0,0 transformations, the point is between tiles and can appear in several --- test/acceptance/aggregation.js | 166 +++++++++++++++++++++++++-------- 1 file changed, 126 insertions(+), 40 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index b674bb2d..56d3e7ca 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -27,6 +27,15 @@ describe('aggregation', function () { from generate_series(-3, 3) x `; + const POINTS_SQL_0 = ` + select + x + 4 as cartodb_id, + st_setsrid(st_makepoint(x*10+1, x*10+1), 4326) as the_geom, + st_transform(st_setsrid(st_makepoint(x*10+1, x*10+1), 4326), 3857) as the_geom_webmercator, + x as value + from generate_series(-3, 3) x + `; + const POINTS_SQL_TIMESTAMP_1 = ` select row_number() over() AS cartodb_id, @@ -2129,62 +2138,139 @@ describe('aggregation', function () { }); }); - ['default', 'centroid', 'point-sample', 'point-grid'].forEach(placement => { - it(`aggregated ids are unique for ${placement} aggregation`, function (done) { - this.mapConfig = { - version: '1.6.0', - buffersize: { 'mvt': 0 }, - layers: [ - { - type: 'cartodb', + // describe('without points between tiles', function () { + it(`aggregated ids are unique for ${placement} aggregation`, function (done) { + this.mapConfig = { + version: '1.6.0', + buffersize: { 'mvt': 0 }, + layers: [ + { + type: 'cartodb', - options: { - sql: POINTS_SQL_1, - resolution: 1, - aggregation: { - threshold: 1 + options: { + sql: POINTS_SQL_0, + resolution: 1, + aggregation: { + threshold: 1 + } } } - } - ] - }; - if (placement !== 'default') { - this.mapConfig.layers[0].options.aggregation.placement = placement; - } - - this.testClient = new TestClient(this.mapConfig); - - this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { - if (err) { - return done(err); + ] + }; + if (placement !== 'default') { + this.mapConfig.layers[0].options.aggregation.placement = placement; } - const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); + this.testClient = new TestClient(this.mapConfig); - assert.ok(Array.isArray(tile1.features)); - assert.ok(tile1.features.length > 0); - - this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { + this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { if (err) { return done(err); } - const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); + const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); - assert.ok(Array.isArray(tile2.features)); - assert.ok(tile2.features.length > 0); + assert.ok(Array.isArray(tile1.features)); + assert.ok(tile1.features.length > 0); - const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); - const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); - const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); - assert.equal(repeatedIds.length, 0); + this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { + if (err) { + return done(err); + } + + const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); + + assert.ok(Array.isArray(tile2.features)); + assert.ok(tile2.features.length > 0); + + const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); + const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); + const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); + + assert.equal(repeatedIds.length, 0); + + done(); + }); - done(); }); - }); - }); + // }); + // describe('with points between tiles', function () { + it(`aggregated ids are unique for ${placement} aggregation save for points between tiles`, function (done) { + this.mapConfig = { + version: '1.6.0', + buffersize: { 'mvt': 0 }, + layers: [ + { + type: 'cartodb', + + options: { + sql: POINTS_SQL_1, + resolution: 1, + aggregation: { + threshold: 1 + } + } + } + ] + }; + if (placement !== 'default') { + this.mapConfig.layers[0].options.aggregation.placement = placement; + } + + this.testClient = new TestClient(this.mapConfig); + + this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { + if (err) { + return done(err); + } + + const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); + + assert.ok(Array.isArray(tile1.features)); + assert.ok(tile1.features.length > 0); + + this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { + if (err) { + return done(err); + } + + const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); + + assert.ok(Array.isArray(tile2.features)); + assert.ok(tile2.features.length > 0); + + const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); + const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); + const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); + + // It is not guaranteed that features appear in a single tile: + // features on the border of tiles can appear in multiple tiles + if (repeatedIds.length > 0) { + repeatedIds.forEach(id => { + const tile1Features = tile1.features.filter(f => f.properties.cartodb_id === id); + const tile2Features = tile2.features.filter(f => f.properties.cartodb_id === id); + // repetitions cannot occur inside a tile + assert.equal(tile1Features.length, 1); + assert.equal(tile2Features.length, 1); + const feature1 = tile1Features[0]; + const feature2 = tile2Features[0]; + // features should be identical (geometry and properties) + assert.deepEqual(feature1.properties, feature2.properties); + assert.deepEqual(feature1.geometry, feature2.geometry); + // and geometry should be on the border; + // for the dataset and zoom 1, only point with cartodb_id=4 (0,0) + assert.equal(feature1.properties.cartodb_id, 4); + assert.equal(feature2.properties.cartodb_id, 4); + }); + } + done(); + }); + + }); + }); + // }); }); ['default', 'centroid', 'point-sample', 'point-grid'].forEach(placement => { From 8442a9a7115861e87fa0f3d81e7e6228e2ac57ae Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 11:29:22 +0200 Subject: [PATCH 2/7] Shorten long lines --- test/acceptance/aggregation.js | 200 ++++++++++++++++----------------- 1 file changed, 98 insertions(+), 102 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 56d3e7ca..193330d5 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -2139,138 +2139,134 @@ describe('aggregation', function () { }); ['default', 'centroid', 'point-sample', 'point-grid'].forEach(placement => { - // describe('without points between tiles', function () { - it(`aggregated ids are unique for ${placement} aggregation`, function (done) { - this.mapConfig = { - version: '1.6.0', - buffersize: { 'mvt': 0 }, - layers: [ - { - type: 'cartodb', + it(`for ${placement} and no points between tiles has unique ids`, function (done) { + this.mapConfig = { + version: '1.6.0', + buffersize: { 'mvt': 0 }, + layers: [ + { + type: 'cartodb', - options: { - sql: POINTS_SQL_0, - resolution: 1, - aggregation: { - threshold: 1 - } + options: { + sql: POINTS_SQL_0, + resolution: 1, + aggregation: { + threshold: 1 } } - ] - }; - if (placement !== 'default') { - this.mapConfig.layers[0].options.aggregation.placement = placement; + } + ] + }; + if (placement !== 'default') { + this.mapConfig.layers[0].options.aggregation.placement = placement; + } + + this.testClient = new TestClient(this.mapConfig); + + this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { + if (err) { + return done(err); } - this.testClient = new TestClient(this.mapConfig); + const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); - this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { + assert.ok(Array.isArray(tile1.features)); + assert.ok(tile1.features.length > 0); + + this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { if (err) { return done(err); } - const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); + const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); - assert.ok(Array.isArray(tile1.features)); - assert.ok(tile1.features.length > 0); + assert.ok(Array.isArray(tile2.features)); + assert.ok(tile2.features.length > 0); - this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { - if (err) { - return done(err); - } + const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); + const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); + const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); - const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); - - assert.ok(Array.isArray(tile2.features)); - assert.ok(tile2.features.length > 0); - - const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); - const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); - const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); - - assert.equal(repeatedIds.length, 0); - - done(); - }); + assert.equal(repeatedIds.length, 0); + done(); }); - }); - // }); - // describe('with points between tiles', function () { - it(`aggregated ids are unique for ${placement} aggregation save for points between tiles`, function (done) { - this.mapConfig = { - version: '1.6.0', - buffersize: { 'mvt': 0 }, - layers: [ - { - type: 'cartodb', - options: { - sql: POINTS_SQL_1, - resolution: 1, - aggregation: { - threshold: 1 - } + }); + }); + it(`for ${placement} has unique ids save between tiles`, function (done) { + this.mapConfig = { + version: '1.6.0', + buffersize: { 'mvt': 0 }, + layers: [ + { + type: 'cartodb', + + options: { + sql: POINTS_SQL_1, + resolution: 1, + aggregation: { + threshold: 1 } } - ] - }; - if (placement !== 'default') { - this.mapConfig.layers[0].options.aggregation.placement = placement; + } + ] + }; + if (placement !== 'default') { + this.mapConfig.layers[0].options.aggregation.placement = placement; + } + + this.testClient = new TestClient(this.mapConfig); + + this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { + if (err) { + return done(err); } - this.testClient = new TestClient(this.mapConfig); + const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); - this.testClient.getTile(1, 0, 1, { format: 'mvt' }, (err, res, mvt) => { + assert.ok(Array.isArray(tile1.features)); + assert.ok(tile1.features.length > 0); + + this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { if (err) { return done(err); } - const tile1 = JSON.parse(mvt.toGeoJSONSync(0)); + const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); - assert.ok(Array.isArray(tile1.features)); - assert.ok(tile1.features.length > 0); + assert.ok(Array.isArray(tile2.features)); + assert.ok(tile2.features.length > 0); - this.testClient.getTile(1, 1, 0, { format: 'mvt' }, (err, res, mvt) => { - if (err) { - return done(err); - } - - const tile2 = JSON.parse(mvt.toGeoJSONSync(0)); - - assert.ok(Array.isArray(tile2.features)); - assert.ok(tile2.features.length > 0); - - const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); - const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); - const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); - - // It is not guaranteed that features appear in a single tile: - // features on the border of tiles can appear in multiple tiles - if (repeatedIds.length > 0) { - repeatedIds.forEach(id => { - const tile1Features = tile1.features.filter(f => f.properties.cartodb_id === id); - const tile2Features = tile2.features.filter(f => f.properties.cartodb_id === id); - // repetitions cannot occur inside a tile - assert.equal(tile1Features.length, 1); - assert.equal(tile2Features.length, 1); - const feature1 = tile1Features[0]; - const feature2 = tile2Features[0]; - // features should be identical (geometry and properties) - assert.deepEqual(feature1.properties, feature2.properties); - assert.deepEqual(feature1.geometry, feature2.geometry); - // and geometry should be on the border; - // for the dataset and zoom 1, only point with cartodb_id=4 (0,0) - assert.equal(feature1.properties.cartodb_id, 4); - assert.equal(feature2.properties.cartodb_id, 4); - }); - } - done(); - }); + const tile1Ids = tile1.features.map(f => f.properties.cartodb_id); + const tile2Ids = tile2.features.map(f => f.properties.cartodb_id); + const repeatedIds = tile1Ids.filter(id => tile2Ids.includes(id)); + // It is not guaranteed that features appear in a single tile: + // features on the border of tiles can appear in multiple tiles + if (repeatedIds.length > 0) { + repeatedIds.forEach(id => { + const tile1Features = tile1.features.filter(f => f.properties.cartodb_id === id); + const tile2Features = tile2.features.filter(f => f.properties.cartodb_id === id); + // repetitions cannot occur inside a tile + assert.equal(tile1Features.length, 1); + assert.equal(tile2Features.length, 1); + const feature1 = tile1Features[0]; + const feature2 = tile2Features[0]; + // features should be identical (geometry and properties) + assert.deepEqual(feature1.properties, feature2.properties); + assert.deepEqual(feature1.geometry, feature2.geometry); + // and geometry should be on the border; + // for the dataset and zoom 1, only point with cartodb_id=4 (0,0) + assert.equal(feature1.properties.cartodb_id, 4); + assert.equal(feature2.properties.cartodb_id, 4); + }); + } + done(); }); + }); - // }); + }); }); ['default', 'centroid', 'point-sample', 'point-grid'].forEach(placement => { From e17dd4b5faaafc9efc7ff4d544e4a49c49e4158d Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 13:19:07 +0200 Subject: [PATCH 3/7] Make tests independent of coordinate accuracy by not placing points near tile boundaries --- test/acceptance/aggregation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 193330d5..90b23e79 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -112,10 +112,10 @@ describe('aggregation', function () { const POINTS_SQL_PAIRS = ` -- Generate pairs of near points select - x + 4 as cartodb_id, - st_setsrid(st_makepoint(Floor(x/2)*10 + x/1000.0, Floor(x/2)*10 + x/1000.0), 4326) as the_geom, + x + 7 as cartodb_id, + st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2), Floor(x/2)*10 + 9E-3*(x % 2)), 4326) as the_geom, st_transform( - st_setsrid(st_makepoint(Floor(x/2)*10 + x/1000.0, Floor(x/2)*10 + x/1000.0),4326), + st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2), Floor(x/2)*10 + 9E-3*(x % 2)),4326), 3857) as the_geom_webmercator, x as value from generate_series(-6, 6) x From b8365e9f6ef87126eaa15e9bf43385b0cb0ec981 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 15:21:23 +0200 Subject: [PATCH 4/7] Make sampling tests more stable Some sample tests, which cannot use RNG seeding, are nondeterministical. Increment size of test table used in sampling tests to make less likely that the sample is empty --- .../stats/mapnik_stats_layergroup.js | 29 +++++++++---- test/support/sql/windshaft.test.sql | 42 +++++++++++++++++++ 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/test/acceptance/stats/mapnik_stats_layergroup.js b/test/acceptance/stats/mapnik_stats_layergroup.js index 4e8413ae..dd58fd85 100644 --- a/test/acceptance/stats/mapnik_stats_layergroup.js +++ b/test/acceptance/stats/mapnik_stats_layergroup.js @@ -56,6 +56,17 @@ describe('Create mapnik layergroup', function() { } }; + var mapnikLayer100 = { + type: 'mapnik', + options: { + sql: [ + 'SELECT * FROM test_table_100' + ].join(''), + cartocss_version: cartocssVersion, + cartocss: cartocss + } + }; + var httpLayer = { type: 'http', options: { @@ -512,8 +523,8 @@ describe('Create mapnik layergroup', function() { var testClient = new TestClient({ version: '1.4.0', layers: [ - layerWithMetadata(mapnikLayer4, { - sample: { num_rows: 3 } + layerWithMetadata(mapnikLayer100, { + sample: { num_rows: 30 } }) ] }); @@ -521,9 +532,9 @@ describe('Create mapnik layergroup', function() { testClient.getLayergroup(function(err, layergroup) { assert.ifError(err); assert.equal(layergroup.metadata.layers[0].id, mapnikBasicLayerId(0)); - assert.equal(layergroup.metadata.layers[0].meta.stats.estimatedFeatureCount, 5); + assert.equal(layergroup.metadata.layers[0].meta.stats.estimatedFeatureCount, 100); assert(layergroup.metadata.layers[0].meta.stats.sample.length > 0); - const expectedCols = [ 'cartodb_id', 'address', 'the_geom', 'the_geom_webmercator' ].sort(); + const expectedCols = [ 'cartodb_id', 'value', 'the_geom', 'the_geom_webmercator' ].sort(); assert.deepEqual(Object.keys(layergroup.metadata.layers[0].meta.stats.sample[0]).sort(), expectedCols); testClient.drain(done); }); @@ -533,10 +544,10 @@ describe('Create mapnik layergroup', function() { var testClient = new TestClient({ version: '1.4.0', layers: [ - layerWithMetadata(mapnikLayer4, { + layerWithMetadata(mapnikLayer100, { sample: { - num_rows: 3, - include_columns: [ 'cartodb_id', 'address', 'the_geom' ] + num_rows: 30, + include_columns: [ 'cartodb_id', 'the_geom' ] } }) ] @@ -545,9 +556,9 @@ describe('Create mapnik layergroup', function() { testClient.getLayergroup(function(err, layergroup) { assert.ifError(err); assert.equal(layergroup.metadata.layers[0].id, mapnikBasicLayerId(0)); - assert.equal(layergroup.metadata.layers[0].meta.stats.estimatedFeatureCount, 5); + assert.equal(layergroup.metadata.layers[0].meta.stats.estimatedFeatureCount, 100); assert(layergroup.metadata.layers[0].meta.stats.sample.length > 0); - const expectedCols = [ 'cartodb_id', 'address', 'the_geom' ].sort(); + const expectedCols = [ 'cartodb_id', 'the_geom' ].sort(); assert.deepEqual(Object.keys(layergroup.metadata.layers[0].meta.stats.sample[0]).sort(), expectedCols); testClient.drain(done); }); diff --git a/test/support/sql/windshaft.test.sql b/test/support/sql/windshaft.test.sql index 51a6de8a..3c957db6 100644 --- a/test/support/sql/windshaft.test.sql +++ b/test/support/sql/windshaft.test.sql @@ -778,4 +778,46 @@ CREATE OR REPLACE FUNCTION cdb_crankshaft.CDB_KMeans(query text, no_clusters int $$ LANGUAGE plpgsql; GRANT ALL ON FUNCTION cdb_crankshaft.CDB_KMeans(text, integer, integer) TO :TESTUSER; +-- Table with 100 rows +-- first table +CREATE TABLE test_table_100 ( + cartodb_id integer NOT NULL, + value int, + the_geom geometry, + the_geom_webmercator geometry, + CONSTRAINT enforce_dims_the_geom CHECK ((st_ndims(the_geom) = 2)), + CONSTRAINT enforce_dims_the_geom_webmercator CHECK ((st_ndims(the_geom_webmercator) = 2)), + CONSTRAINT enforce_geotype_the_geom CHECK (((geometrytype(the_geom) = 'POINT'::text) OR (the_geom IS NULL))), + CONSTRAINT enforce_geotype_the_geom_webmercator CHECK (((geometrytype(the_geom_webmercator) = 'POINT'::text) OR (the_geom_webmercator IS NULL))), + CONSTRAINT enforce_srid_the_geom CHECK ((st_srid(the_geom) = 4326)), + CONSTRAINT enforce_srid_the_geom_webmercator CHECK ((st_srid(the_geom_webmercator) = 3857)) +); + +CREATE SEQUENCE test_table_100_cartodb_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE test_table_100_cartodb_id_seq OWNED BY test_table_100.cartodb_id; + +SELECT pg_catalog.setval('test_table_100_cartodb_id_seq', 60, true); + +ALTER TABLE test_table_100 ALTER COLUMN cartodb_id SET DEFAULT nextval('test_table_100_cartodb_id_seq'::regclass); + +INSERT INTO test_table_100(the_geom, value) + SELECT + ST_SetSRID(ST_MakePoint(n*10 + 9E-3, n*10 + 9E-3), 4326) AS the_geom,n AS value + FROM generate_series(1, 100) n; + +ALTER TABLE ONLY test_table_100 ADD CONSTRAINT test_table_100_pkey PRIMARY KEY (cartodb_id); + +CREATE INDEX test_table_100_the_geom_idx ON test_table_100 USING gist (the_geom); +CREATE INDEX test_table_100_the_geom_webmercator_idx ON test_table_100 USING gist (the_geom_webmercator); + +GRANT ALL ON TABLE test_table_100 TO :TESTUSER; +GRANT SELECT ON TABLE test_table_100 TO :PUBLICUSER; + + ANALYZE; From d3a3a7353accd2206a76919bc1556f20d0e398b8 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 16:34:39 +0200 Subject: [PATCH 5/7] Fix tests They were not numerical accuracy independent, as intended --- test/acceptance/aggregation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 90b23e79..ba3afee9 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -113,9 +113,9 @@ describe('aggregation', function () { -- Generate pairs of near points select x + 7 as cartodb_id, - st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2), Floor(x/2)*10 + 9E-3*(x % 2)), 4326) as the_geom, + st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2 + 1), Floor(x/2)*10 + 9E-3*(x % 2 + 1)), 4326) as the_geom, st_transform( - st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2), Floor(x/2)*10 + 9E-3*(x % 2)),4326), + st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2 + 1), Floor(x/2)*10 + 9E-3*(x % 2 + 1)),4326), 3857) as the_geom_webmercator, x as value from generate_series(-6, 6) x @@ -2384,7 +2384,7 @@ describe('aggregation', function () { assert.equal(typeof body.metadata, 'object'); assert.ok(Array.isArray(body.metadata.layers)); assert.ok(body.metadata.layers[0].meta.aggregation.mvt); - assert.equal(body.metadata.layers[0].meta.stats.aggrFeatureCount, 9); + assert.equal(body.metadata.layers[0].meta.stats.aggrFeatureCount, 8); done(); }); From 7cadbcc533c0990723cac3fd525a9e0cea1495f9 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 16:47:10 +0200 Subject: [PATCH 6/7] Fix tests, this time for good :fingers_crossed: --- test/acceptance/aggregation.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index ba3afee9..4455f575 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -112,13 +112,13 @@ describe('aggregation', function () { const POINTS_SQL_PAIRS = ` -- Generate pairs of near points select - x + 7 as cartodb_id, - st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2 + 1), Floor(x/2)*10 + 9E-3*(x % 2 + 1)), 4326) as the_geom, + x + 1 as cartodb_id, + st_setsrid(st_makepoint(Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1), Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1)), 4326) as the_geom, st_transform( - st_setsrid(st_makepoint(Floor(x/2)*10 + 9E-3*(x % 2 + 1), Floor(x/2)*10 + 9E-3*(x % 2 + 1)),4326), + st_setsrid(st_makepoint(Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1), Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1)),4326), 3857) as the_geom_webmercator, x as value - from generate_series(-6, 6) x + from generate_series(0, 13) x `; function createVectorMapConfig (layers = [ @@ -2384,7 +2384,7 @@ describe('aggregation', function () { assert.equal(typeof body.metadata, 'object'); assert.ok(Array.isArray(body.metadata.layers)); assert.ok(body.metadata.layers[0].meta.aggregation.mvt); - assert.equal(body.metadata.layers[0].meta.stats.aggrFeatureCount, 8); + assert.equal(body.metadata.layers[0].meta.stats.aggrFeatureCount, 7); done(); }); From 9cbcd43fda09c81fa96a5cc199eda9ece1d57837 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 11 Jul 2018 16:56:37 +0200 Subject: [PATCH 7/7] Fix another test --- test/acceptance/aggregation.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 4455f575..ca350110 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -113,10 +113,23 @@ describe('aggregation', function () { -- Generate pairs of near points select x + 1 as cartodb_id, - st_setsrid(st_makepoint(Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1), Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1)), 4326) as the_geom, + st_setsrid( + st_makepoint( + Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1), + Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1) + ), + 4326 + ) as the_geom, st_transform( - st_setsrid(st_makepoint(Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1), Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1)),4326), - 3857) as the_geom_webmercator, + st_setsrid( + st_makepoint( + Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1), + Floor((x-6)/2)*10 + 9E-3*(x % 2 + 1) + ), + 4326 + ), + 3857 + ) as the_geom_webmercator, x as value from generate_series(0, 13) x `; @@ -2425,7 +2438,7 @@ describe('aggregation', function () { assert.equal(typeof body.metadata, 'object'); assert.ok(Array.isArray(body.metadata.layers)); assert.ok(body.metadata.layers[0].meta.aggregation.mvt); - assert.equal(body.metadata.layers[0].meta.stats.featureCount, 13); + assert.equal(body.metadata.layers[0].meta.stats.featureCount, 14); done(); });