From 6ec453229c2e7d7cbc507dadbcddddb390e4b48f Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 4 May 2017 13:30:45 -0700 Subject: [PATCH] Preserve the tileset names from the source mbtiles in tile-join --- CHANGELOG.md | 4 ++++ tests/join-population/joined-i.mbtiles.json | 2 +- tests/join-population/joined.mbtiles.json | 2 +- .../join-population/just-macarthur.mbtiles.json | 2 +- tests/join-population/merged.mbtiles.json | 2 +- tests/join-population/no-macarthur.mbtiles.json | 2 +- tests/join-population/windows.mbtiles.json | 2 +- tile-join.cpp | 17 ++++++++++++++--- version.hpp | 2 +- 9 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ffb96..2d08ebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.17.5 + +* Preserve the tileset names from the source mbtiles in tile-join + ## 1.17.4 * Fix RFC 8142 support: Don't try to split *all* memory mapped files diff --git a/tests/join-population/joined-i.mbtiles.json b/tests/join-population/joined-i.mbtiles.json index d69dd18..e32ec68 100644 --- a/tests/join-population/joined-i.mbtiles.json +++ b/tests/join-population/joined-i.mbtiles.json @@ -6,7 +6,7 @@ "json": "{\"vector_layers\": [ { \"id\": \"tabblock_06001420\", \"description\": \"\", \"minzoom\": 3, \"maxzoom\": 12, \"fields\": {\"ALAND10\": \"Number\", \"AWATER10\": \"Number\", \"BLOCKCE10\": \"String\", \"COUNTYFP10\": \"String\", \"FUNCSTAT10\": \"String\", \"INTPTLAT10\": \"String\", \"INTPTLON10\": \"String\", \"MTFCC10\": \"String\", \"NAME10\": \"String\", \"STATEFP10\": \"String\", \"TRACTCE10\": \"String\", \"UACE10\": \"String\", \"UATYP10\": \"String\", \"UR10\": \"String\", \"population\": \"Number\"} } ] }", "maxzoom": "12", "minzoom": "0", -"name": "tests/join-population/joined-i.mbtiles", +"name": "tests/join-population/tabblock_06001420.mbtiles", "type": "overlay", "version": "2" }, "features": [ diff --git a/tests/join-population/joined.mbtiles.json b/tests/join-population/joined.mbtiles.json index da4ed6c..0e45d02 100644 --- a/tests/join-population/joined.mbtiles.json +++ b/tests/join-population/joined.mbtiles.json @@ -6,7 +6,7 @@ "json": "{\"vector_layers\": [ { \"id\": \"tabblock_06001420\", \"description\": \"\", \"minzoom\": 3, \"maxzoom\": 12, \"fields\": {\"ALAND10\": \"Number\", \"AWATER10\": \"Number\", \"BLOCKCE10\": \"String\", \"COUNTYFP10\": \"String\", \"FUNCSTAT10\": \"String\", \"INTPTLAT10\": \"String\", \"INTPTLON10\": \"String\", \"MTFCC10\": \"String\", \"NAME10\": \"String\", \"STATEFP10\": \"String\", \"TRACTCE10\": \"String\", \"UACE10\": \"String\", \"UATYP10\": \"String\", \"UR10\": \"String\", \"population\": \"Number\"} } ] }", "maxzoom": "12", "minzoom": "0", -"name": "tests/join-population/joined.mbtiles", +"name": "tests/join-population/tabblock_06001420.mbtiles", "type": "overlay", "version": "2" }, "features": [ diff --git a/tests/join-population/just-macarthur.mbtiles.json b/tests/join-population/just-macarthur.mbtiles.json index babe200..3c2f362 100644 --- a/tests/join-population/just-macarthur.mbtiles.json +++ b/tests/join-population/just-macarthur.mbtiles.json @@ -6,7 +6,7 @@ "json": "{\"vector_layers\": [ { \"id\": \"macarthur\", \"description\": \"\", \"minzoom\": 5, \"maxzoom\": 11, \"fields\": {\"FULLNAME\": \"String\", \"LINEARID\": \"String\", \"MTFCC\": \"String\", \"RTTYP\": \"String\"} } ] }", "maxzoom": "12", "minzoom": "0", -"name": "tests/join-population/just-macarthur.mbtiles", +"name": "tests/join-population/macarthur.mbtiles + tests/join-population/macarthur2.mbtiles + tests/join-population/tabblock_06001420.mbtiles", "type": "overlay", "version": "2" }, "features": [ diff --git a/tests/join-population/merged.mbtiles.json b/tests/join-population/merged.mbtiles.json index ff5f3c8..1cb3323 100644 --- a/tests/join-population/merged.mbtiles.json +++ b/tests/join-population/merged.mbtiles.json @@ -6,7 +6,7 @@ "json": "{\"vector_layers\": [ { \"id\": \"macarthur\", \"description\": \"\", \"minzoom\": 5, \"maxzoom\": 11, \"fields\": {\"FULLNAME\": \"String\", \"LINEARID\": \"String\", \"MTFCC\": \"String\", \"RTTYP\": \"String\"} }, { \"id\": \"tabblock_06001420\", \"description\": \"\", \"minzoom\": 3, \"maxzoom\": 12, \"fields\": {\"ALAND10\": \"Number\", \"AWATER10\": \"Number\", \"BLOCKCE10\": \"String\", \"COUNTYFP10\": \"String\", \"FUNCSTAT10\": \"String\", \"GEOID10\": \"String\", \"INTPTLAT10\": \"String\", \"INTPTLON10\": \"String\", \"MTFCC10\": \"String\", \"NAME10\": \"String\", \"STATEFP10\": \"String\", \"TRACTCE10\": \"String\", \"UACE10\": \"String\", \"UATYP10\": \"String\", \"UR10\": \"String\"} } ] }", "maxzoom": "12", "minzoom": "0", -"name": "tests/join-population/merged.mbtiles", +"name": "tests/join-population/macarthur.mbtiles + tests/join-population/macarthur2.mbtiles + tests/join-population/tabblock_06001420.mbtiles", "type": "overlay", "version": "2" }, "features": [ diff --git a/tests/join-population/no-macarthur.mbtiles.json b/tests/join-population/no-macarthur.mbtiles.json index 0288448..5dcb5e8 100644 --- a/tests/join-population/no-macarthur.mbtiles.json +++ b/tests/join-population/no-macarthur.mbtiles.json @@ -6,7 +6,7 @@ "json": "{\"vector_layers\": [ { \"id\": \"tabblock_06001420\", \"description\": \"\", \"minzoom\": 3, \"maxzoom\": 12, \"fields\": {\"ALAND10\": \"Number\", \"AWATER10\": \"Number\", \"BLOCKCE10\": \"String\", \"COUNTYFP10\": \"String\", \"FUNCSTAT10\": \"String\", \"GEOID10\": \"String\", \"INTPTLAT10\": \"String\", \"INTPTLON10\": \"String\", \"MTFCC10\": \"String\", \"NAME10\": \"String\", \"STATEFP10\": \"String\", \"TRACTCE10\": \"String\", \"UACE10\": \"String\", \"UATYP10\": \"String\", \"UR10\": \"String\"} } ] }", "maxzoom": "12", "minzoom": "0", -"name": "tests/join-population/no-macarthur.mbtiles", +"name": "tests/join-population/macarthur.mbtiles + tests/join-population/macarthur2.mbtiles + tests/join-population/tabblock_06001420.mbtiles", "type": "overlay", "version": "2" }, "features": [ diff --git a/tests/join-population/windows.mbtiles.json b/tests/join-population/windows.mbtiles.json index 2874056..825bae6 100644 --- a/tests/join-population/windows.mbtiles.json +++ b/tests/join-population/windows.mbtiles.json @@ -6,7 +6,7 @@ "json": "{\"vector_layers\": [ { \"id\": \"macarthur\", \"description\": \"\", \"minzoom\": 5, \"maxzoom\": 10, \"fields\": {\"FULLNAME\": \"String\", \"LINEARID\": \"String\", \"MTFCC\": \"String\", \"RTTYP\": \"String\"} } ] }", "maxzoom": "10", "minzoom": "5", -"name": "tests/join-population/windows.mbtiles", +"name": "tests/join-population/macarthur.mbtiles", "type": "overlay", "version": "2" }, "features": [ diff --git a/tile-join.cpp b/tile-join.cpp index 40229aa..4a6a99e 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -464,7 +464,7 @@ void handle_tasks(std::map> &tasks, std::vector &layermap, sqlite3 *outdb, struct stats *st, std::vector &header, std::map> &mapping, std::set &exclude, int ifmatched, std::string &attribution, std::string &description, std::set &keep_layers, std::set &remove_layers) { +void decode(struct reader *readers, char *map, std::map &layermap, sqlite3 *outdb, struct stats *st, std::vector &header, std::map> &mapping, std::set &exclude, int ifmatched, std::string &attribution, std::string &description, std::set &keep_layers, std::set &remove_layers, std::string &name) { std::vector> layermaps; for (size_t i = 0; i < CPUS; i++) { layermaps.push_back(std::map()); @@ -558,6 +558,16 @@ void decode(struct reader *readers, char *map, std::mapstmt); } + if (sqlite3_prepare_v2(r->db, "SELECT value from metadata where name = 'name'", -1, &r->stmt, NULL) == SQLITE_OK) { + if (sqlite3_step(r->stmt) == SQLITE_ROW) { + if (name.size() == 0) { + name = std::string((char *) sqlite3_column_text(r->stmt, 0)); + } else { + name += " + " + std::string((char *) sqlite3_column_text(r->stmt, 0)); + } + } + sqlite3_finalize(r->stmt); + } if (sqlite3_prepare_v2(r->db, "SELECT value from metadata where name = 'bounds'", -1, &r->stmt, NULL) == SQLITE_OK) { if (sqlite3_step(r->stmt) == SQLITE_ROW) { const unsigned char *s = sqlite3_column_text(r->stmt, 0); @@ -752,6 +762,7 @@ int main(int argc, char **argv) { std::map layermap; std::string attribution; std::string description; + std::string name; struct reader *readers = NULL; @@ -769,9 +780,9 @@ int main(int argc, char **argv) { *rr = r; } - decode(readers, csv, layermap, outdb, &st, header, mapping, exclude, ifmatched, attribution, description, keep_layers, remove_layers); + decode(readers, csv, layermap, outdb, &st, header, mapping, exclude, ifmatched, attribution, description, keep_layers, remove_layers, name); - mbtiles_write_metadata(outdb, NULL, outfile, st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.midlat, st.midlon, 0, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str()); + mbtiles_write_metadata(outdb, NULL, name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.midlat, st.midlon, 0, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str()); mbtiles_close(outdb, argv); return 0; diff --git a/version.hpp b/version.hpp index 65d04a1..5d1bd52 100644 --- a/version.hpp +++ b/version.hpp @@ -1 +1 @@ -#define VERSION "tippecanoe v1.17.4\n" +#define VERSION "tippecanoe v1.17.5\n"