Skip to content

Commit

Permalink
Allow --set-attribute to override existing attribute values (#123)
Browse files Browse the repository at this point in the history
* Allow --set-attribute to override existing attribute values

* Bump version number
  • Loading branch information
e-n-f authored Jul 26, 2023
1 parent 4318e96 commit 55b9aa5
Show file tree
Hide file tree
Showing 4 changed files with 6,333 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.28.1

* Allow --set-attribute to override an existing attribute value

# 2.28.0

* Add --preserve-point-density-threshold option to reduce blank areas of the map at low zooms
Expand Down
15 changes: 13 additions & 2 deletions serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,19 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
}

for (auto &kv : set_attributes) {
sf.full_keys.push_back(kv.first);
sf.full_values.push_back(kv.second);
bool found = false;
for (size_t i = 0; i < sf.full_keys.size(); i++) {
if (sf.full_keys[i] == kv.first) {
sf.full_values[i] = kv.second;
found = true;
break;
}
}

if (!found) {
sf.full_keys.push_back(kv.first);
sf.full_values.push_back(kv.second);
}
}

for (ssize_t i = (ssize_t) sf.full_keys.size() - 1; i >= 0; i--) {
Expand Down
Loading

0 comments on commit 55b9aa5

Please sign in to comment.