Skip to content

Commit

Permalink
2.0.2 (#134)
Browse files Browse the repository at this point in the history
* bug fix: exact match on worldview and class fields

* 2.0.2-dev.1

* [publish binary]

* 2.0.2 [publish binary]

---------

Co-authored-by: lily-chai <[email protected]>
  • Loading branch information
mapsam and lily-chai authored Feb 2, 2023
1 parent ad047c4 commit 63afb63
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.2

- Fixes a bug in `localize` where the class and worldview key prefixes were true for soft matches, which unintentionally filters out features where `class = class*`. Now the logic uses an exact match so `class != classes`. [#134](https://github.com/mapbox/vtcomposite/pull/134)

# 2.0.1

- Fixes a bug in `localize` function that throws an error when languages or worldviews is an empty array [#131](https://github.com/mapbox/vtcomposite/pull/131)
Expand Down
4 changes: 2 additions & 2 deletions 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": "2.0.1",
"version": "2.0.2",
"description": "Compositing operations on Vector Tiles (c++ bindings using N-API)",
"url": "http://github.com/mapbox/vtcomposite",
"main": "./lib/index.js",
Expand Down
8 changes: 4 additions & 4 deletions src/vtcomposite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ struct LocalizeWorker : Napi::AsyncWorker
std::string property_key = property.key().to_string();

if (
utils::startswith(property_key, baton_data_->worldview_property) ||
utils::startswith(property_key, baton_data_->hidden_prefix + baton_data_->worldview_property))
(property_key == baton_data_->worldview_property) ||
(property_key == baton_data_->hidden_prefix + baton_data_->worldview_property))
{
// skip feature only if the value of incompatible worldview key is not 'all'
if (property_key == incompatible_worldview_key)
Expand Down Expand Up @@ -799,8 +799,8 @@ struct LocalizeWorker : Napi::AsyncWorker
}

else if (
utils::startswith(property_key, baton_data_->class_property) ||
utils::startswith(property_key, baton_data_->hidden_prefix + baton_data_->class_property))
(property_key == baton_data_->class_property) ||
(property_key == baton_data_->hidden_prefix + baton_data_->class_property))
{
// check if the property is of higher precedence that class key encountered so far
std::uint32_t idx = static_cast<std::uint32_t>(std::distance(class_key_precedence.begin(), std::find(class_key_precedence.begin(), class_key_precedence.end(), property_key)));
Expand Down
8 changes: 5 additions & 3 deletions test/vtcomposite-localize-class.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,18 @@ test('[localize class] requesting localized worldview; feature with compatible w
id: 10,
tags: [
0, 0, // _mbx_worldview
1, 1 // _mbx_class
1, 1, // _mbx_class
2, 2
],
type: 1, // point
geometry: [9, 55, 38]
}
],
keys: ['_mbx_worldview', '_mbx_class'],
keys: ['_mbx_worldview', '_mbx_class', 'classes'],
values: [
{ string_value: 'US' },
{ string_value: 'affogato' },
{ string_value: 'should_not_change' },
],
extent: 4096
}
Expand All @@ -265,7 +267,7 @@ test('[localize class] requesting localized worldview; feature with compatible w
const tile = vtinfo(vtBuffer);
assert.ok('admin' in tile.layers, 'has admin layer');
assert.equal(tile.layers.admin.length, 1, 'has one feature');
assert.deepEqual(tile.layers.admin.feature(0).properties, { worldview: 'US', class: 'affogato' }, 'expected properties');
assert.deepEqual(tile.layers.admin.feature(0).properties, { worldview: 'US', class: 'affogato', classes: 'should_not_change' }, 'expected properties');
assert.end();
});
});
Expand Down

0 comments on commit 63afb63

Please sign in to comment.