mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Track sample values for each attribute in each layer
This commit is contained in:
+31
-6
@@ -429,17 +429,42 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX tilestats: tas.type shouldn't be used since, type is also tracked as variant inside it
|
||||||
|
|
||||||
if (tas.type >= 0) {
|
if (tas.type >= 0) {
|
||||||
auto fk = layermap->find(layername);
|
auto fk = layermap->find(layername);
|
||||||
fk->second.file_keys.insert(std::pair<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
|
fk->second.file_keys.insert(std::pair<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
|
||||||
}
|
|
||||||
|
|
||||||
if (track) {
|
if (track) {
|
||||||
type_and_string attrib;
|
auto fka = fk->second.file_keys.find(tas);
|
||||||
attrib.type = metatype[m - 1];
|
if (fka == fk->second.file_keys.end()) {
|
||||||
attrib.string = metaval[m - 1];
|
fprintf(stderr, "Can't happen (tilestats)\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// XXX increment in type_and_string_stats.sample_values
|
type_and_string attrib;
|
||||||
|
attrib.type = metatype[m - 1];
|
||||||
|
attrib.string = metaval[m - 1];
|
||||||
|
|
||||||
|
if (attrib.type == mvt_double) {
|
||||||
|
double d = atof(attrib.string.c_str());
|
||||||
|
|
||||||
|
if (d < fka->second.min) {
|
||||||
|
fka->second.min = d;
|
||||||
|
}
|
||||||
|
if (d > fka->second.max) {
|
||||||
|
fka->second.max = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fka->second.sample_values.count(attrib)) {
|
||||||
|
if (fka->second.sample_values.size() < 1000) {
|
||||||
|
fka->second.sample_values.insert(attrib);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fka->second.type |= (1 << attrib.type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -367,6 +367,8 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX tilestats: merge file-keys
|
||||||
|
|
||||||
for (auto fk = map->second.file_keys.begin(); fk != map->second.file_keys.end(); ++fk) {
|
for (auto fk = map->second.file_keys.begin(); fk != map->second.file_keys.end(); ++fk) {
|
||||||
out_entry->second.file_keys.insert(*fk);
|
out_entry->second.file_keys.insert(*fk);
|
||||||
}
|
}
|
||||||
@@ -381,8 +383,6 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
|||||||
out_entry->second.points += map->second.points;
|
out_entry->second.points += map->second.points;
|
||||||
out_entry->second.lines += map->second.lines;
|
out_entry->second.lines += map->second.lines;
|
||||||
out_entry->second.polygons += map->second.polygons;
|
out_entry->second.polygons += map->second.polygons;
|
||||||
|
|
||||||
printf("%zu %zu %zu\n", out_entry->second.points, out_entry->second.lines, out_entry->second.polygons);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ struct type_and_string_stats {
|
|||||||
std::set<type_and_string> sample_values;
|
std::set<type_and_string> sample_values;
|
||||||
double min = INFINITY;
|
double min = INFINITY;
|
||||||
double max = -INFINITY;
|
double max = -INFINITY;
|
||||||
|
int type = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct layermap_entry {
|
struct layermap_entry {
|
||||||
|
|||||||
Reference in New Issue
Block a user