From 3e6fcf13adec96b4cd2e110940c64a00b6ee2218 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Mon, 16 Oct 2023 14:38:44 -0700 Subject: [PATCH] I think it actually behaves now --- geometry.cpp | 22 ++++++++++++++++------ tile.cpp | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index 3292098a..6013efc0 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1448,14 +1448,24 @@ drawvec buffer_poly(drawvec const &geom, double buffer) { double a1 = atan2(p1.y - p0.y, p1.x - p0.x); - printf("at %zu %zu %zu ", (k + 0 - i) % (j - i - 1) + i, - (k + 2 - i) % (j - i - 1) + i, - (k + 3 - i) % (j - i - 1) + i); + printf("at %zu %zu %zu ", + (k + 0 - i) % (j - i - 1) + i, + (k + 1 - i) % (j - i - 1) + i, + (k + 2 - i) % (j - i - 1) + i); printf("%lld,%lld to %lld,%lld to %lld,%lld: ", p0.x, p0.y, p1.x, p1.y, p2.x, p2.y); - printf("angle %f on top of %f\n", adiff * 180 / M_PI, a1 * 180 / M_PI); + printf("angle %f then %f\n", + atan2(p1.y - p0.y, p1.x - p0.x) * 180 / M_PI, + atan2(p2.y - p1.y, p2.x - p1.x) * 180 / M_PI); - out[(k + 2 - i) % (j - i - 1) + i].x = std::round(p1.x + buffer * cos(a1 - adiff / 2)); - out[(k + 2 - i) % (j - i - 1) + i].y = std::round(p1.y + buffer * sin(a1 - adiff / 2)); + double a10 = atan2(p1.y - p0.y, p1.x - p0.x); + double a21 = atan2(p2.y - p1.y, p2.x - p1.x); + + double dx = cos(a10 - 90 * M_PI / 180) + cos(a21 - 90 * M_PI / 180); + double dy = sin(a10 - 90 * M_PI / 180) + sin(a21 - 90 * M_PI / 180); + double a2 = atan2(dy, dx); + + out[(k + 1 - i) % (j - i - 1) + i].x = std::round(p1.x + buffer * cos(a2)); + out[(k + 1 - i) % (j - i - 1) + i].y = std::round(p1.y + buffer * sin(a2)); } out[j - 1].x = out[i].x; diff --git a/tile.cpp b/tile.cpp index af5910d2..f9622fcf 100644 --- a/tile.cpp +++ b/tile.cpp @@ -627,11 +627,11 @@ void *partial_feature_worker(void *v) { check_polygon(geom); } - if (geom.size() < 4) { + if (true || geom.size() < 4) { if (area > 0) { // Try reviving the polygon by buffering it outward a little - geom = buffer_poly(before_scaling, (1LL << (32 - z - out_detail)) * 1.0); + geom = buffer_poly(before_scaling, (1LL << (32 - z - out_detail)) * 2.0); to_tile_scale(geom, z, out_detail); geom = clean_or_clip_poly(geom, 0, 0, false, true);