Skip to content

Commit

Permalink
Plumb tippecanoe_decisions metadata through pmtiles
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Dec 19, 2023
1 parent 62e39d1 commit e3cdbee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pmtiles_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e3cdbee

Please sign in to comment.