Skip to content

Commit

Permalink
Add a flag to get the feature ID from the query
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Dec 17, 2024
1 parent c88f8c0 commit 03daaef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tile-join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ std::vector<std::string> unidecode_data;
std::string join_tile_column;
std::string join_table_column;
std::string join_table;
std::string attribute_for_id;

bool want_overzoom = false;
int buffer = 5;
Expand Down Expand Up @@ -279,7 +280,10 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st

if (f < joined.size()) {
for (auto const &kv : joined[f]) {
if (kv.second.type != mvt_null) {
if (kv.first == attribute_for_id) {
outfeature.has_id = true;
outfeature.id = mvt_value_to_long_long(kv.second);
} else 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);
matched = true;
Expand Down Expand Up @@ -1371,6 +1375,7 @@ int main(int argc, char **argv) {
{"join-tile-column", required_argument, 0, '~'},
{"join-table-column", required_argument, 0, '~'},
{"join-table", required_argument, 0, '~'},
{"use-attribute-for-id", required_argument, 0, '~'},

{"no-tile-size-limit", no_argument, &pk, 1},
{"no-tile-compression", no_argument, &pC, 1},
Expand Down Expand Up @@ -1568,6 +1573,8 @@ int main(int argc, char **argv) {
join_table_column = optarg;
} else if (strcmp(opt, "join-tile-column") == 0) {
join_tile_column = optarg;
} else if (strcmp(opt, "use-attribute-for-id") == 0) {
attribute_for_id = optarg;
} else {
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
exit(EXIT_ARGS);
Expand Down

0 comments on commit 03daaef

Please sign in to comment.