If stopping early, don't simplify or clean; leave that to overzoom

This commit is contained in:
Erica Fischer
2024-07-30 15:27:36 -07:00
parent bedfa8af95
commit 830885fea0
+9 -1
View File
@@ -557,6 +557,7 @@ struct simplification_worker_arg {
std::vector<serial_feature> *features = NULL; std::vector<serial_feature> *features = NULL;
int task = 0; int task = 0;
int tasks = 0; int tasks = 0;
bool trying_to_stop_early = false;
drawvec *shared_nodes; drawvec *shared_nodes;
node *shared_nodes_map; node *shared_nodes_map;
@@ -689,7 +690,10 @@ static void *simplification_worker(void *v) {
std::vector<serial_feature> *features = a->features; std::vector<serial_feature> *features = a->features;
for (size_t i = a->task; i < (*features).size(); i += a->tasks) { for (size_t i = a->task; i < (*features).size(); i += a->tasks) {
double area = simplify_feature(&((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos); double area = 0;
if (!a->trying_to_stop_early) {
area = simplify_feature(&((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos);
}
signed char t = (*features)[i].t; signed char t = (*features)[i].t;
int z = (*features)[i].z; int z = (*features)[i].z;
@@ -703,6 +707,8 @@ static void *simplification_worker(void *v) {
// Give Clipper a chance to try to fix it. // Give Clipper a chance to try to fix it.
{ {
drawvec before = geom; drawvec before = geom;
if (!a->trying_to_stop_early) {
// we can try scaling up because this is now tile scale // we can try scaling up because this is now tile scale
geom = clean_or_clip_poly(geom, 0, 0, false, true); geom = clean_or_clip_poly(geom, 0, 0, false, true);
if (additional[A_DEBUG_POLYGON]) { if (additional[A_DEBUG_POLYGON]) {
@@ -719,6 +725,7 @@ static void *simplification_worker(void *v) {
} }
} }
} }
}
if (t == VT_POLYGON && additional[A_GENERATE_POLYGON_LABEL_POINTS]) { if (t == VT_POLYGON && additional[A_GENERATE_POLYGON_LABEL_POINTS]) {
t = (*features)[i].t = VT_POINT; t = (*features)[i].t = VT_POINT;
@@ -2191,6 +2198,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
args[i].shared_nodes = &shared_nodes; args[i].shared_nodes = &shared_nodes;
args[i].shared_nodes_map = shared_nodes_map; args[i].shared_nodes_map = shared_nodes_map;
args[i].nodepos = nodepos; args[i].nodepos = nodepos;
args[i].trying_to_stop_early = trying_to_stop_early;
if (tasks > 1) { if (tasks > 1) {
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) { if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {