Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add same layer test #114

Merged
merged 4 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.1

- Bugfix for v0.5.0 to fix an issue where compositing multiple tiles with specific layers included would drop same-named layers [#114](https://github.com/mapbox/vtcomposite/pull/114)

# 0.5.0

- Add `buffers[n].layers` array to allow keeping of specific layers during compositing [#113](https://github.com/mapbox/vtcomposite/pull/113)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapbox/vtcomposite",
"version": "0.5.0",
"version": "0.5.1",
"description": "Compositing operations on Vector Tiles (c++ bindings using N-API)",
"url": "http://github.com/mapbox/vtcomposite",
"main": "./lib/index.js",
Expand Down
3 changes: 1 addition & 2 deletions src/vtcomposite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,13 @@ struct CompositeWorker : Napi::AsyncWorker
std::uint32_t const version = layer.version();
if (std::find(std::begin(names), std::end(names), name) == std::end(names))
{
names.push_back(name);

// should we keep this layer?
// if include_layers is empty, keep all layers
// if include_layers is not empty, keep layer if we can find its name in the vector
std::string sname(name);
if (include_layers.empty() || std::find(std::begin(include_layers), std::end(include_layers), sname) != std::end(include_layers))
{
names.push_back(name);
std::uint32_t extent = layer.extent();
if (zoom_factor == 1)
{
Expand Down
32 changes: 31 additions & 1 deletion test/vtcomposite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ test('[composite] success: drop layers if "layers" array is in tiles object', fu
composite(tiles, zxy, {}, (err, vtBuffer) => {
assert.notOk(err);
assert.deepEqual(Object.keys(vtinfo(vtBuffer).layers), ['building', 'poi_label'], 'expected layers');
assert.notEqual(vtBuffer.length, bufferSF.length, 'buffer is not of the same sie');
assert.notEqual(vtBuffer.length, bufferSF.length, 'buffer is not of the same size');
assert.end();
});
});
Expand All @@ -352,3 +352,33 @@ test('[composite] success: composite and drop layers', function(assert) {
assert.end();
});
});

test('[composite] success: composite and drop same layer names', function(assert) {
const tiles = [
{ buffer: bufferSF, z:15, x:5238, y:12666, layers: ['building'] },
{ buffer: bufferSF, z:15, x:5238, y:12666, layers: ['poi_label'] }
];

const zxy = {z:15, x:5238, y:12666};

composite(tiles, zxy, {}, (err, vtBuffer) => {
assert.notOk(err);
assert.deepEqual(Object.keys(vtinfo(vtBuffer).layers), ['building', 'poi_label'], 'expected layers');
assert.end();
manoharuss marked this conversation as resolved.
Show resolved Hide resolved
});
});

test('[composite] success: composite and drop same layer names reversed', function(assert) {
const tiles = [
{ buffer: bufferSF, z:15, x:5238, y:12666, layers: ['poi_label'] },
{ buffer: bufferSF, z:15, x:5238, y:12666, layers: ['building'] }
];

const zxy = {z:15, x:5238, y:12666};

composite(tiles, zxy, {}, (err, vtBuffer) => {
assert.notOk(err);
assert.deepEqual(Object.keys(vtinfo(vtBuffer).layers), ['poi_label', 'building'], 'expected layers');
assert.end();
});
});