-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Currently vtcomposite uses feature.for_each_property to loop over a feature's properties and add them to the builder (in the case that we are keeping a feature during overzooming).
vtcomposite/src/feature_builder.hpp
Lines 142 to 145 in 7310aea
| feature.for_each_property([&builder](vtzero::property const& p) { | |
| builder.add_property(p); | |
| return true; | |
| }); |
This can be optimized. Currently because the code works in vtzero::property objects it means - I think - that the dictionary mapping (aka table) at the layer level is fully rebuilt on the fly from those property key/values as they are added to a new layer. Rebuilding that table is expensive. It would be ideal to, instead of rebuilding the table, just use the existing index values for the key/values. The vtzero library has something called the property mapper which can make this possible: https://github.com/mapbox/vtzero/blob/master/doc/advanced.md
Using the property mapper would allow us to do:
while (auto idxs = feature.next_property_indexes()) {
builder.add_property(mapper_(idxs));
}The gocha is that feature.next_property_indexes changes the feature state (to avoid making any expensive copies of data) so to use this we'll need to pass down a non-const feature object.