mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-01 16:30:35 +00:00
Track how many features of each type are in each layer
This commit is contained in:
parent
65c095cc2b
commit
62ee53992b
19
geojson.cpp
19
geojson.cpp
@ -295,10 +295,29 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
|
||||
if (ai != layermap->end()) {
|
||||
layer = ai->second.id;
|
||||
layername = tippecanoe_layername;
|
||||
|
||||
if (mb_geometry[t] == VT_POINT) {
|
||||
ai->second.points++;
|
||||
} else if (mb_geometry[t] == VT_LINE) {
|
||||
ai->second.lines++;
|
||||
} else if (mb_geometry[t] == VT_POLYGON) {
|
||||
ai->second.polygons++;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Internal error: can't find layer name %s\n", tippecanoe_layername.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
auto fk = layermap->find(layername);
|
||||
if (fk != layermap->end()) {
|
||||
if (mb_geometry[t] == VT_POINT) {
|
||||
fk->second.points++;
|
||||
} else if (mb_geometry[t] == VT_LINE) {
|
||||
fk->second.lines++;
|
||||
} else if (mb_geometry[t] == VT_POLYGON) {
|
||||
fk->second.polygons++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t nprop = 0;
|
||||
|
@ -378,6 +378,12 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
||||
if (map->second.maxzoom > out_entry->second.maxzoom) {
|
||||
out_entry->second.maxzoom = map->second.maxzoom;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ struct type_and_string {
|
||||
std::string string;
|
||||
|
||||
size_t attribute_count = 0;
|
||||
std::vector<mvt_value> sample_values;
|
||||
std::set<mvt_value> sample_values;
|
||||
double min = INFINITY;
|
||||
double max = -INFINITY;
|
||||
|
||||
@ -21,7 +21,10 @@ struct layermap_entry {
|
||||
std::set<type_and_string> file_keys;
|
||||
int minzoom;
|
||||
int maxzoom;
|
||||
size_t feature_count = 0;
|
||||
|
||||
size_t points = 0;
|
||||
size_t lines = 0;
|
||||
size_t polygons = 0;
|
||||
|
||||
layermap_entry(size_t _id) {
|
||||
id = _id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user