Include tilestats in the metadata table. (Not all tests are passing)

This commit is contained in:
Eric Fischer
2017-07-19 13:09:47 -07:00
parent 9078098511
commit 7b03e1ee87
80 changed files with 102 additions and 5 deletions
+18 -3
View File
@@ -273,14 +273,20 @@ std::string tilestats(std::map<std::string, layermap_entry> const &layermap) {
out.append("\t]\n");
out.append("}");
return out;
std::string out2;
for (size_t i = 0; i < out.size(); i++) {
if (out[i] != '\t' && out[i] != '\n') {
out2.push_back(out[i]);
}
}
return out2;
}
void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, int forcetable, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description) {
char *sql, *err;
printf("%s\n", tilestats(layermap).c_str());
sqlite3 *db = outdb;
if (outdb == NULL) {
if (sqlite3_open("", &db) != SQLITE_OK) {
@@ -444,6 +450,15 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fnam
}
}
sqlite3_free(sql);
sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('tilestats', %Q);", tilestats(layermap).c_str());
if (sqlite3_exec(db, sql, NULL, NULL, &err) != SQLITE_OK) {
fprintf(stderr, "set tilestats: %s\n", err);
if (!forcetable) {
exit(EXIT_FAILURE);
}
}
sqlite3_free(sql);
}
if (outdir != NULL) {