I think it actually behaves now

This commit is contained in:
Erica Fischer
2023-10-16 14:38:44 -07:00
parent 9254f81f77
commit 3e6fcf13ad
2 changed files with 18 additions and 8 deletions
+16 -6
View File
@@ -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;
+2 -2
View File
@@ -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);