Skip to content

Commit

Permalink
Adding the joined attribute should be per-feature, not per-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Jan 7, 2025
1 parent b0326b6 commit 3d22a41
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions tile-join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,26 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
std::map<std::string, std::pair<mvt_value, serial_val>> attributes;
std::vector<std::string> key_order;

if (f < joined.size()) {
if (joined[f].size() > 0) {
matched = true;
}

for (auto const &joined_feature : joined[f]) {
for (auto const &kv : joined_feature) {
if (kv.first == attribute_for_id) {
outfeature.has_id = true;
outfeature.id = mvt_value_to_long_long(kv.second);
} else if (include.count(kv.first) || (!exclude_all && exclude.count(kv.first) == 0 && exclude_attributes.count(kv.first) == 0)) {
if (kv.second.type != mvt_null) {
attributes.insert(std::pair<std::string, std::pair<mvt_value, serial_val>>(kv.first, std::pair<mvt_value, serial_val>(kv.second, mvt_value_to_serial_val(kv.second))));
key_order.push_back(kv.first);
}
}
}
}
}

for (size_t t = 0; t + 1 < feat.tags.size(); t += 2) {
const std::string &key = layer.keys[feat.tags[t]];
mvt_value &val = layer.values[feat.tags[t + 1]];
Expand All @@ -321,26 +341,6 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
}
}

if (f < joined.size()) {
if (joined[f].size() > 0) {
matched = true;
}

for (auto const &joined_feature : joined[f]) {
for (auto const &kv : joined_feature) {
if (kv.first == attribute_for_id) {
outfeature.has_id = true;
outfeature.id = mvt_value_to_long_long(kv.second);
} else if (include.count(kv.first) || (!exclude_all && exclude.count(kv.first) == 0 && exclude_attributes.count(kv.first) == 0)) {
if (kv.second.type != mvt_null) {
attributes.insert(std::pair<std::string, std::pair<mvt_value, serial_val>>(kv.first, std::pair<mvt_value, serial_val>(kv.second, mvt_value_to_serial_val(kv.second))));
key_order.push_back(kv.first);
}
}
}
}
}

if (header.size() > 0 && key == header[0]) {
std::map<std::string, std::vector<std::string>>::iterator ii = mapping.find(sv.s);

Expand Down

0 comments on commit 3d22a41

Please sign in to comment.