Skip to content

Commit

Permalink
move clipping test to vtcomposite.test.js [#95]
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Feb 20, 2019
1 parent 5bae50a commit 153982b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
31 changes: 0 additions & 31 deletions test/vtcomposite-polygons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,34 +129,3 @@ test('[composite] composite and overzooming success polygons - overzooming polyg
assert.end();
});
});


test('[composite] check all geometries are clipped to the tile extent', function(assert) {

const buffer = require('fs').readFileSync('./test/fixtures/clipping-test-tile.mvt');
const tiles = [
{buffer: buffer, z:1, x:1, y:1},
];

const zxy = {z:4, x:10, y:14};
const options = { compress: false, buffer_size: 4080 };
var tile_extent = [ -4080, -4080, 4096 + 4080, 4096 + 4080 ];
composite(tiles, zxy, options, (err, output_buffer) => {
assert.notOk(err);
const info = vtinfo(output_buffer);
for (var name in info.layers)
{
var layer = info.layers[name];
for (var index = 0; index < layer.length; ++index)
{
var bbox = layer.feature(index).bbox();
var within = (bbox[0] >= tile_extent[0] &&
bbox[1] >= tile_extent[1] &&
bbox[2] <= tile_extent[2] &&
bbox[3] <= tile_extent[3]);
assert.ok(within);
}
}
assert.end();
});
});
30 changes: 30 additions & 0 deletions test/vtcomposite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,36 @@ test('[composite] resolves zero length linestring error for overzoomed V1 tiles
});
});

test('[composite] check all geometries are clipped to the tile extent', function(assert) {

const buffer = require('fs').readFileSync('./test/fixtures/clipping-test-tile.mvt');
const tiles = [
{buffer: buffer, z:1, x:1, y:1},
];

const zxy = {z:4, x:10, y:14};
const options = { compress: false, buffer_size: 4080 };
var tile_extent = [ -4080, -4080, 4096 + 4080, 4096 + 4080 ];
composite(tiles, zxy, options, (err, output_buffer) => {
assert.notOk(err);
const info = vtinfo(output_buffer);
for (var name in info.layers)
{
var layer = info.layers[name];
for (var index = 0; index < layer.length; ++index)
{
var bbox = layer.feature(index).bbox();
var within = (bbox[0] >= tile_extent[0] &&
bbox[1] >= tile_extent[1] &&
bbox[2] <= tile_extent[2] &&
bbox[3] <= tile_extent[3]);
assert.ok(within);
}
}
assert.end();
});
});

// These tiles are invalid v2 tiles such that boost::geometry can't handle some zero-area polygons
// and results in unsigned integer overflow. So, we skip this test for the sanitize job
// This should be able to be enabled again after upgrading to https://github.com/boostorg/geometry/pull/505
Expand Down

0 comments on commit 153982b

Please sign in to comment.