mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Rename file_keys to the more familiar tilestats
This commit is contained in:
+13
-13
@@ -261,7 +261,7 @@ void tilestats(std::map<std::string, layermap_entry> const &layermap1, size_t el
|
||||
state.nospace = true;
|
||||
state.json_write_string(geomtype);
|
||||
|
||||
size_t attrib_count = layer.second.file_keys.size();
|
||||
size_t attrib_count = layer.second.tilestats.size();
|
||||
if (attrib_count > max_tilestats_attributes) {
|
||||
attrib_count = max_tilestats_attributes;
|
||||
}
|
||||
@@ -277,7 +277,7 @@ void tilestats(std::map<std::string, layermap_entry> const &layermap1, size_t el
|
||||
state.json_write_array();
|
||||
|
||||
size_t attrs = 0;
|
||||
for (auto attribute : layer.second.file_keys) {
|
||||
for (auto attribute : layer.second.tilestats) {
|
||||
if (attrs == elements) {
|
||||
break;
|
||||
}
|
||||
@@ -745,7 +745,7 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
|
||||
|
||||
bool first = true;
|
||||
size_t attribute_count = 0;
|
||||
for (auto j = fk->second.file_keys.begin(); j != fk->second.file_keys.end(); ++j) {
|
||||
for (auto j = fk->second.tilestats.begin(); j != fk->second.tilestats.end(); ++j) {
|
||||
if (first) {
|
||||
first = false;
|
||||
}
|
||||
@@ -852,16 +852,16 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
for (auto fk = map->second.file_keys.begin(); fk != map->second.file_keys.end(); ++fk) {
|
||||
for (auto fk = map->second.tilestats.begin(); fk != map->second.tilestats.end(); ++fk) {
|
||||
std::string attribname = fk->first;
|
||||
if (trunc) {
|
||||
attribname = truncate16(attribname, 256);
|
||||
}
|
||||
|
||||
auto fk2 = out_entry->second.file_keys.find(attribname);
|
||||
auto fk2 = out_entry->second.tilestats.find(attribname);
|
||||
|
||||
if (fk2 == out_entry->second.file_keys.end()) {
|
||||
out_entry->second.file_keys.insert(std::pair<std::string, tilestat>(attribname, fk->second));
|
||||
if (fk2 == out_entry->second.tilestats.end()) {
|
||||
out_entry->second.tilestats.insert(std::pair<std::string, tilestat>(attribname, fk->second));
|
||||
} else {
|
||||
for (auto val : fk->second.sample_values) {
|
||||
auto pt = std::lower_bound(fk2->second.sample_values.begin(), fk2->second.sample_values.end(), val);
|
||||
@@ -901,18 +901,18 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
||||
return out;
|
||||
}
|
||||
|
||||
void add_to_file_keys(std::map<std::string, tilestat> &file_keys, std::string const &attrib, serial_val const &val) {
|
||||
void add_to_tilestats(std::map<std::string, tilestat> &tilestats, std::string const &attrib, serial_val const &val) {
|
||||
if (val.type == mvt_null) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto fka = file_keys.find(attrib);
|
||||
if (fka == file_keys.end()) {
|
||||
file_keys.insert(std::pair<std::string, tilestat>(attrib, tilestat()));
|
||||
fka = file_keys.find(attrib);
|
||||
auto fka = tilestats.find(attrib);
|
||||
if (fka == tilestats.end()) {
|
||||
tilestats.insert(std::pair<std::string, tilestat>(attrib, tilestat()));
|
||||
fka = tilestats.find(attrib);
|
||||
}
|
||||
|
||||
if (fka == file_keys.end()) {
|
||||
if (fka == tilestats.end()) {
|
||||
fprintf(stderr, "Can't happen (tilestats)\n");
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ struct tilestat {
|
||||
|
||||
struct layermap_entry {
|
||||
size_t id = 0;
|
||||
std::map<std::string, tilestat> file_keys{};
|
||||
std::map<std::string, tilestat> tilestats{};
|
||||
int minzoom = 0;
|
||||
int maxzoom = 0;
|
||||
std::string description = "";
|
||||
@@ -76,7 +76,7 @@ void mbtiles_close(sqlite3 *outdb, const char *pgm);
|
||||
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps);
|
||||
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps, bool trunc);
|
||||
|
||||
void add_to_file_keys(std::map<std::string, tilestat> &file_keys, std::string const &layername, serial_val const &val);
|
||||
void add_to_tilestats(std::map<std::string, tilestat> &tilestats, std::string const &layername, serial_val const &val);
|
||||
|
||||
unsigned long long fnv1a(std::string const &s);
|
||||
|
||||
|
||||
+2
-2
@@ -278,7 +278,7 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
|
||||
attrib.type = tp;
|
||||
attrib.s = s;
|
||||
|
||||
add_to_file_keys(fk->second.file_keys, std::string(properties->value.object.keys[i]->value.string.string), attrib);
|
||||
add_to_tilestats(fk->second.tilestats, std::string(properties->value.object.keys[i]->value.string.string), attrib);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
|
||||
attrib.type = v.type;
|
||||
|
||||
if (!postfilter) {
|
||||
add_to_file_keys(fk->second.file_keys, std::string(properties->value.object.keys[i]->value.string.string), attrib);
|
||||
add_to_tilestats(fk->second.tilestats, std::string(properties->value.object.keys[i]->value.string.string), attrib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -828,7 +828,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
if (!sst->filters) {
|
||||
for (size_t i = 0; i < sf.full_keys.size(); i++) {
|
||||
auto fk = sst->layermap->find(sf.layername);
|
||||
add_to_file_keys(fk->second.file_keys, sf.full_keys[i], sf.full_values[i]);
|
||||
add_to_tilestats(fk->second.tilestats, sf.full_keys[i], sf.full_values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -149,7 +149,7 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
}
|
||||
}
|
||||
|
||||
auto file_keys = layermap.find(layer.name);
|
||||
auto tilestats = layermap.find(layer.name);
|
||||
|
||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||
mvt_feature feat = layer.features[f];
|
||||
@@ -269,11 +269,11 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
}
|
||||
|
||||
if (matched || !ifmatched) {
|
||||
if (file_keys == layermap.end()) {
|
||||
if (tilestats == layermap.end()) {
|
||||
layermap.insert(std::pair<std::string, layermap_entry>(layer.name, layermap_entry(layermap.size())));
|
||||
file_keys = layermap.find(layer.name);
|
||||
file_keys->second.minzoom = z;
|
||||
file_keys->second.maxzoom = z;
|
||||
tilestats = layermap.find(layer.name);
|
||||
tilestats->second.minzoom = z;
|
||||
tilestats->second.maxzoom = z;
|
||||
}
|
||||
|
||||
// To keep attributes in their original order instead of alphabetical
|
||||
@@ -282,7 +282,7 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
|
||||
if (fa != attributes.end()) {
|
||||
outlayer.tag(outfeature, k, fa->second.first);
|
||||
add_to_file_keys(file_keys->second.file_keys, k, fa->second.second);
|
||||
add_to_tilestats(tilestats->second.tilestats, k, fa->second.second);
|
||||
attributes.erase(fa);
|
||||
}
|
||||
}
|
||||
@@ -300,19 +300,19 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
features_added++;
|
||||
outlayer.features.push_back(outfeature);
|
||||
|
||||
if (z < file_keys->second.minzoom) {
|
||||
file_keys->second.minzoom = z;
|
||||
if (z < tilestats->second.minzoom) {
|
||||
tilestats->second.minzoom = z;
|
||||
}
|
||||
if (z > file_keys->second.maxzoom) {
|
||||
file_keys->second.maxzoom = z;
|
||||
if (z > tilestats->second.maxzoom) {
|
||||
tilestats->second.maxzoom = z;
|
||||
}
|
||||
|
||||
if (feat.type == mvt_point) {
|
||||
file_keys->second.points++;
|
||||
tilestats->second.points++;
|
||||
} else if (feat.type == mvt_linestring) {
|
||||
file_keys->second.lines++;
|
||||
tilestats->second.lines++;
|
||||
} else if (feat.type == mvt_polygon) {
|
||||
file_keys->second.polygons++;
|
||||
tilestats->second.polygons++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1822,7 +1822,7 @@ void add_tilestats(std::string const &layername, int z, std::vector<std::map<std
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
add_to_file_keys(fk->second.file_keys, key, val);
|
||||
add_to_tilestats(fk->second.tilestats, key, val);
|
||||
}
|
||||
|
||||
void preserve_attribute(attribute_op op, serial_feature &, char *stringpool, long long *pool_off, std::string &key, serial_val &val, partial &p) {
|
||||
|
||||
Reference in New Issue
Block a user