From b1771a3365542ef62eaf0ee7be7198d9a11228d5 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 17 Jul 2017 11:58:37 -0700 Subject: [PATCH] Make layer attributes a map to sample values --- geojson.cpp | 2 +- main.cpp | 2 +- mbtiles.cpp | 17 ++++++++--------- mbtiles.hpp | 3 ++- tile-join.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/geojson.cpp b/geojson.cpp index 1a9a7bd0..129aaf51 100644 --- a/geojson.cpp +++ b/geojson.cpp @@ -431,7 +431,7 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje if (tas.type >= 0) { auto fk = layermap->find(layername); - fk->second.file_keys.insert(tas); + fk->second.file_keys.insert(std::pair(tas, type_and_string_stats())); } if (track) { diff --git a/main.cpp b/main.cpp index c1786ba5..467fd5d3 100644 --- a/main.cpp +++ b/main.cpp @@ -1967,7 +1967,7 @@ int read_input(std::vector &sources, char *fname, int &maxzoom, int minz type_and_string tas; tas.type = mvt_double; tas.string = "tippecanoe_feature_density"; - ai->second.file_keys.insert(tas); + ai->second.file_keys.insert(std::pair(tas, type_and_string_stats())); } } diff --git a/mbtiles.cpp b/mbtiles.cpp index be64f172..4095f642 100644 --- a/mbtiles.cpp +++ b/mbtiles.cpp @@ -257,9 +257,8 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fnam quote(&buf, lnames[i].c_str()); aprintf(&buf, "\", \"description\": \"\", \"minzoom\": %d, \"maxzoom\": %d, \"fields\": {", fk->second.minzoom, fk->second.maxzoom); - std::set::iterator j; bool first = true; - for (j = fk->second.file_keys.begin(); j != fk->second.file_keys.end(); ++j) { + for (auto j = fk->second.file_keys.begin(); j != fk->second.file_keys.end(); ++j) { if (first) { first = false; } else { @@ -267,15 +266,15 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fnam } aprintf(&buf, "\""); - quote(&buf, j->string.c_str()); + quote(&buf, j->first.string.c_str()); - if (j->type == mvt_double || - j->type == mvt_float || - j->type == mvt_double || - j->type == mvt_uint || - j->type == mvt_sint) { + if (j->first.type == mvt_double || + j->first.type == mvt_float || + j->first.type == mvt_double || + j->first.type == mvt_uint || + j->first.type == mvt_sint) { aprintf(&buf, "\": \"Number\""); - } else if (j->type == mvt_bool) { + } else if (j->first.type == mvt_bool) { aprintf(&buf, "\": \"Boolean\""); } else { aprintf(&buf, "\": \"String\""); diff --git a/mbtiles.hpp b/mbtiles.hpp index e25e615c..bcdbb771 100644 --- a/mbtiles.hpp +++ b/mbtiles.hpp @@ -2,6 +2,7 @@ #define MBTILES_HPP #include +#include #include "mvt.hpp" struct type_and_string { @@ -19,7 +20,7 @@ struct type_and_string_stats { struct layermap_entry { size_t id; - std::set file_keys; // XXX map to type_and_string_stats + std::map file_keys; int minzoom; int maxzoom; diff --git a/tile-join.cpp b/tile-join.cpp index 256621f5..0095f85f 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -210,7 +210,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::mapsecond.file_keys.insert(tas); + file_keys->second.file_keys.insert(std::pair(tas, type_and_string_stats())); } // To keep attributes in their original order instead of alphabetical