Track desired feature count and geometry size in strategies

This commit is contained in:
Erica Fischer
2022-10-20 12:09:04 -07:00
parent 71b9fd9226
commit becb04693d
9 changed files with 47 additions and 7 deletions
+21 -1
View File
@@ -1295,6 +1295,8 @@ struct write_tile_args {
double fraction = 0;
double fraction_out = 0;
size_t tile_size_out = 0;
size_t feature_count_out = 0;
size_t geometry_size_out = 0;
const char *prefilter = NULL;
const char *postfilter = NULL;
std::map<std::string, attribute_op> const *attribute_accum = NULL;
@@ -2483,6 +2485,10 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
if (totalsize > 0 && tile.layers.size() > 0) {
if (max_geometry_size > 0 && (size_t) total_geom_size > max_geometry_size) {
if ((size_t) total_geom_size > arg->geometry_size_out) {
arg->geometry_size_out = total_geom_size;
}
if (!quiet) {
fprintf(stderr, "tile %d/%u/%u has %lld vertices, >%zu \n", z, tx, ty, total_geom_size, max_geometry_size);
}
@@ -2569,6 +2575,10 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
}
if (totalsize > max_tile_features && !prevent[P_FEATURE_LIMIT]) {
if (totalsize > arg->feature_count_out) {
arg->feature_count_out = totalsize;
}
if (!quiet) {
fprintf(stderr, "tile %d/%u/%u has %zu features, >%zu \n", z, tx, ty, totalsize, max_tile_features);
}
@@ -3043,6 +3053,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
long long zoom_minextent = 0;
double zoom_fraction = 1;
size_t zoom_tile_size = 0;
size_t zoom_feature_count = 0;
size_t zoom_geometry_size = 0;
for (size_t pass = start; pass < 2; pass++) {
pthread_t pthreads[threads];
@@ -3072,6 +3084,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
args[thread].fraction = zoom_fraction;
args[thread].fraction_out = zoom_fraction;
args[thread].tile_size_out = 0;
args[thread].feature_count_out = 0;
args[thread].geometry_size_out = 0;
args[thread].child_shards = TEMP_FILES / threads;
if (i == maxzoom && maxzoom_simplification > 0) {
@@ -3141,6 +3155,12 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
if (args[thread].tile_size_out > zoom_tile_size) {
zoom_tile_size = args[thread].tile_size_out;
}
if (args[thread].feature_count_out > zoom_feature_count) {
zoom_feature_count = args[thread].feature_count_out;
}
if (args[thread].geometry_size_out > zoom_geometry_size) {
zoom_geometry_size = args[thread].geometry_size_out;
}
// Zoom counter might be lower than reality if zooms are being skipped
if (args[thread].wrote_zoom > i) {
@@ -3155,7 +3175,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
if ((size_t) i >= strategies.size()) {
strategies.resize(i + 1);
}
struct strategy s(strategy, zoom_tile_size);
struct strategy s(strategy, zoom_tile_size, zoom_feature_count, zoom_geometry_size);
strategies[i] = s;
}