Make layer attributes a map to sample values

This commit is contained in:
Eric Fischer
2017-07-17 11:58:37 -07:00
parent 7445feb845
commit b1771a3365
5 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -431,7 +431,7 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
if (tas.type >= 0) { if (tas.type >= 0) {
auto fk = layermap->find(layername); auto fk = layermap->find(layername);
fk->second.file_keys.insert(tas); fk->second.file_keys.insert(std::pair<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
} }
if (track) { if (track) {
+1 -1
View File
@@ -1967,7 +1967,7 @@ int read_input(std::vector<source> &sources, char *fname, int &maxzoom, int minz
type_and_string tas; type_and_string tas;
tas.type = mvt_double; tas.type = mvt_double;
tas.string = "tippecanoe_feature_density"; tas.string = "tippecanoe_feature_density";
ai->second.file_keys.insert(tas); ai->second.file_keys.insert(std::pair<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
} }
} }
+8 -9
View File
@@ -257,9 +257,8 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fnam
quote(&buf, lnames[i].c_str()); quote(&buf, lnames[i].c_str());
aprintf(&buf, "\", \"description\": \"\", \"minzoom\": %d, \"maxzoom\": %d, \"fields\": {", fk->second.minzoom, fk->second.maxzoom); aprintf(&buf, "\", \"description\": \"\", \"minzoom\": %d, \"maxzoom\": %d, \"fields\": {", fk->second.minzoom, fk->second.maxzoom);
std::set<type_and_string>::iterator j;
bool first = true; 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) { if (first) {
first = false; first = false;
} else { } else {
@@ -267,15 +266,15 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fnam
} }
aprintf(&buf, "\""); aprintf(&buf, "\"");
quote(&buf, j->string.c_str()); quote(&buf, j->first.string.c_str());
if (j->type == mvt_double || if (j->first.type == mvt_double ||
j->type == mvt_float || j->first.type == mvt_float ||
j->type == mvt_double || j->first.type == mvt_double ||
j->type == mvt_uint || j->first.type == mvt_uint ||
j->type == mvt_sint) { j->first.type == mvt_sint) {
aprintf(&buf, "\": \"Number\""); aprintf(&buf, "\": \"Number\"");
} else if (j->type == mvt_bool) { } else if (j->first.type == mvt_bool) {
aprintf(&buf, "\": \"Boolean\""); aprintf(&buf, "\": \"Boolean\"");
} else { } else {
aprintf(&buf, "\": \"String\""); aprintf(&buf, "\": \"String\"");
+2 -1
View File
@@ -2,6 +2,7 @@
#define MBTILES_HPP #define MBTILES_HPP
#include <math.h> #include <math.h>
#include <map>
#include "mvt.hpp" #include "mvt.hpp"
struct type_and_string { struct type_and_string {
@@ -19,7 +20,7 @@ struct type_and_string_stats {
struct layermap_entry { struct layermap_entry {
size_t id; size_t id;
std::set<type_and_string> file_keys; // XXX map to type_and_string_stats std::map<type_and_string, type_and_string_stats> file_keys;
int minzoom; int minzoom;
int maxzoom; int maxzoom;
+1 -1
View File
@@ -210,7 +210,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::st
tas.string = tp.first; tas.string = tp.first;
tas.type = tp.second; tas.type = tp.second;
file_keys->second.file_keys.insert(tas); file_keys->second.file_keys.insert(std::pair<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
} }
// To keep attributes in their original order instead of alphabetical // To keep attributes in their original order instead of alphabetical