mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-01 16:30:35 +00:00
Track sample values for each attribute in each layer
This commit is contained in:
parent
b1771a3365
commit
77bf14bfb0
37
geojson.cpp
37
geojson.cpp
@ -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) {
|
||||
auto fk = layermap->find(layername);
|
||||
fk->second.file_keys.insert(std::pair<type_and_string, type_and_string_stats>(tas, type_and_string_stats()));
|
||||
}
|
||||
|
||||
if (track) {
|
||||
type_and_string attrib;
|
||||
attrib.type = metatype[m - 1];
|
||||
attrib.string = metaval[m - 1];
|
||||
if (track) {
|
||||
auto fka = fk->second.file_keys.find(tas);
|
||||
if (fka == fk->second.file_keys.end()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,6 +367,8 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// XXX tilestats: merge file-keys
|
||||
|
||||
for (auto fk = map->second.file_keys.begin(); fk != map->second.file_keys.end(); ++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.lines += map->second.lines;
|
||||
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;
|
||||
double min = INFINITY;
|
||||
double max = -INFINITY;
|
||||
int type = 0;
|
||||
};
|
||||
|
||||
struct layermap_entry {
|
||||
|
Loading…
x
Reference in New Issue
Block a user