From 0922dc23e895df9676c6d7290f0e71fb3d97c6bb Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Fri, 28 Jun 2024 10:29:42 -0700 Subject: [PATCH] Clean up collinearities in coalesced features --- tile-join.cpp | 2 +- tile.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tile-join.cpp b/tile-join.cpp index be33a7e4..3abc70a5 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -771,7 +771,7 @@ void *join_worker(void *v) { } if (!pk && compressed.size() > 500000) { - fprintf(stderr, "Tile %lld/%lld/%lld size is %lld, >500000. Skipping this tile\n.", ai->first.z, ai->first.x, ai->first.y, (long long) compressed.size()); + fprintf(stderr, "Tile %lld/%lld/%lld size is %lld, >500000. Skipping this tile.\n", ai->first.z, ai->first.x, ai->first.y, (long long) compressed.size()); } else { a->outputs.insert(std::pair(ai->first, compressed)); } diff --git a/tile.cpp b/tile.cpp index 33f54133..204958cc 100644 --- a/tile.cpp +++ b/tile.cpp @@ -634,6 +634,13 @@ static double simplify_feature(serial_feature *p, drawvec const &shared_nodes, n // continues to simplify to line_detail even if we have extra detail drawvec ngeom = simplify_lines(geom, z, p->tx, p->ty, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), p->simplification, t == VT_POLYGON ? 4 : 0, shared_nodes, shared_nodes_map, nodepos); + if (p->coalesced && prevent[P_SIMPLIFY_SHARED_NODES]) { + // do another simplification to eliminate collinearities + // that were left behind at the former corners between + // coalesced geometries + ngeom = simplify_lines(ngeom, z, p->tx, p->ty, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), 0.1, t == VT_POLYGON ? 4 : 0, shared_nodes, NULL, 0); + } + if (t != VT_POLYGON || ngeom.size() >= 3) { geom = ngeom; } @@ -2355,7 +2362,6 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch } else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) { mingap_fraction = mingap_fraction * max_tile_features / totalsize * 0.90; unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap); - printf("was %llu, now %llu\n", mingap, m); if (m != mingap) { mingap = m; if (mingap > arg->mingap_out) { @@ -2458,7 +2464,6 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch } else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) { mingap_fraction = mingap_fraction * scaled_max_tile_size / (kept_adjust * compressed.size()) * 0.90; unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap); - printf("was %llu, now %llu\n", mingap, m); if (m != mingap) { mingap = m; if (mingap > arg->mingap_out) { @@ -2466,7 +2471,7 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch arg->still_dropping = true; } if (!quiet) { - fprintf(stderr, "Going to try keeping the sparsest %0.2f%% of the features to make it fit\n", mingap_fraction * 100.0); + fprintf(stderr, "Going to try keeping the sparsest %0.2f%% of the features to make it fit\n", mingap_fraction * 100.0); } line_detail++; continue;