From 8270699b8ea1d32e32304210fbb00f9ec5e7cb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 29 Nov 2017 13:12:09 +0100 Subject: [PATCH] Tests to fect mvt tiles without styles --- test/acceptance/multilayer.js | 4 ++ test/acceptance/mvt.js | 120 +++++++++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 51545416..a1a93e40 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -1163,6 +1163,10 @@ describe(suiteName, function() { ); }); + // WARN: MapConfig with mapnik layer and no cartocss it's valid since + // vector & raster aggregation project, now we can request MVT format w/o defining styles + // for the layer. + // See https://github.com/CartoDB/Windshaft-cartodb/issues/133 it.skip("MapConfig with mapnik layer and no cartocss", function(done) { diff --git a/test/acceptance/mvt.js b/test/acceptance/mvt.js index ded1772e..c1958ca5 100644 --- a/test/acceptance/mvt.js +++ b/test/acceptance/mvt.js @@ -34,6 +34,124 @@ return function () { serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS; }); + describe('vector-layergroup', function () { + const POLYGONS_SQL = ` + select + st_buffer(st_setsrid(st_makepoint(x*10, x*10), 4326)::geography, 1000000)::geometry as the_geom, + st_transform( + st_buffer(st_setsrid(st_makepoint(x*10, x*10), 4326)::geography, 1000000)::geometry, + 3857 + ) as the_geom_webmercator, + x as value + from generate_series(-3, 3) x + `; + + const POINTS_SQL = ` + select + st_setsrid(st_makepoint(x*10, x*10), 4326) as the_geom, + st_transform(st_setsrid(st_makepoint(x*10, x*10), 4326), 3857) as the_geom_webmercator, + x as value + from generate_series(-3, 3) x + `; + + function createVectorLayergroup () { + return { + version: '1.6.0', + layers: [ + { + type: 'cartodb', + options: { + sql: POINTS_SQL + } + }, + { + type: 'cartodb', + options: { + sql: POLYGONS_SQL + } + } + ] + }; + } + + beforeEach(function () { + this.mapConfig = createVectorLayergroup(); + this.testClient = new TestClient(this.mapConfig); + }); + + afterEach(function (done) { + this.testClient.drain(done); + }); + + it('should get vector tiles from layergroup with layers w/o cartocss', function (done) { + this.testClient.getTile(0, 0, 0, { format: 'mvt' }, (err, res, tile) => { + if (err) { + return done(err); + } + + assert.equal(tile.tileSize, 4096); + assert.equal(tile.z, 0); + assert.equal(tile.x, 0); + assert.equal(tile.y, 0); + + const layer0 = JSON.parse(tile.toGeoJSONSync(0)); + + assert.equal(layer0.name, 'layer0'); + assert.equal(layer0.features[0].type, 'Feature'); + assert.equal(layer0.features[0].geometry.type, 'Point'); + + const layer1 = JSON.parse(tile.toGeoJSONSync(1)); + + assert.equal(layer1.name, 'layer1'); + assert.equal(layer1.features[0].type, 'Feature'); + assert.equal(layer1.features[0].geometry.type, 'Polygon'); + done(); + }); + }); + + it('should get vector tiles from specific layer (layer0)', function (done) { + this.testClient.getTile(0, 0, 0, { format: 'mvt', layers: 0 }, (err, res, tile) => { + if (err) { + return done(err); + } + + assert.equal(tile.tileSize, 4096); + assert.equal(tile.z, 0); + assert.equal(tile.x, 0); + assert.equal(tile.y, 0); + + const layer = JSON.parse(tile.toGeoJSONSync(0)); + + assert.equal(layer.name, 'layer0'); + assert.equal(layer.features[0].type, 'Feature'); + assert.equal(layer.features[0].geometry.type, 'Point'); + + done(); + }); + }); + + it('should get vector tiles from specific layer (layer1)', function (done) { + this.testClient.getTile(0, 0, 0, { format: 'mvt', layers: 1 }, (err, res, tile) => { + if (err) { + return done(err); + } + + assert.equal(tile.tileSize, 4096); + assert.equal(tile.z, 0); + assert.equal(tile.x, 0); + assert.equal(tile.y, 0); + + const layer = JSON.parse(tile.toGeoJSONSync(0)); + + assert.equal(layer.name, 'layer1'); + assert.equal(layer.features[0].type, 'Feature'); + assert.equal(layer.features[0].geometry.type, 'Polygon'); + + done(); + }); + }); + }); + describe('analysis-layers-dataviews-mvt', function () { function createMapConfig(layers, dataviews, analysis) { @@ -504,4 +622,4 @@ return function () { } }; -} \ No newline at end of file +}