From e3cdbeebaa4164069c71b2629aed3a939669ded8 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Mon, 18 Dec 2023 16:43:46 -0800 Subject: [PATCH] Plumb tippecanoe_decisions metadata through pmtiles --- pmtiles_file.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pmtiles_file.cpp b/pmtiles_file.cpp index c1226d07b..0326c92ac 100644 --- a/pmtiles_file.cpp +++ b/pmtiles_file.cpp @@ -103,6 +103,13 @@ std::string metadata_to_pmtiles_json(metadata m) { state.json_write_string("strategies"); state.json_write_json(m.strategies_json); } + + if (m.decisions_json.size() > 0) { + state.json_comma_newline(); + state.json_write_string("tippecanoe_decisions"); + state.json_write_json(m.decisions_json); + } + out(state, "generator", m.generator); out(state, "generator_options", m.generator_options); @@ -428,6 +435,12 @@ sqlite3 *pmtilesmeta2tmp(const char *fname, const char *pmtiles_map) { fprintf(stderr, "set %s in metadata: %s\n", key, err); } sqlite3_free(sql); + } else if (strcmp(key, "tippecanoe_decisions") == 0 && o->value.object.values[i]->type == JSON_HASH) { + sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('tippecanoe_decisions', %Q);", json_stringify(o->value.object.values[i])); + if (sqlite3_exec(db, sql, NULL, NULL, &err) != SQLITE_OK) { + fprintf(stderr, "set %s in metadata: %s\n", key, err); + } + sqlite3_free(sql); } else if (o->value.object.keys[i]->type != JSON_STRING || o->value.object.values[i]->type != JSON_STRING) { fprintf(stderr, "%s\n", key); fprintf(stderr, "%s: non-string in metadata\n", fname);