mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-21 17:56:40 +00:00
Make layer attributes a map to sample values
This commit is contained in:
parent
7445feb845
commit
b1771a3365
@ -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<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
|
||||
}
|
||||
|
||||
if (track) {
|
||||
|
2
main.cpp
2
main.cpp
@ -1967,7 +1967,7 @@ int read_input(std::vector<source> &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<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
|
||||
}
|
||||
}
|
||||
|
||||
|
17
mbtiles.cpp
17
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<type_and_string>::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\"");
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MBTILES_HPP
|
||||
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
#include "mvt.hpp"
|
||||
|
||||
struct type_and_string {
|
||||
@ -19,7 +20,7 @@ struct type_and_string_stats {
|
||||
|
||||
struct layermap_entry {
|
||||
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 maxzoom;
|
||||
|
||||
|
@ -210,7 +210,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::st
|
||||
tas.string = tp.first;
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user