Don't swap attributes when reducing tiny polygon dust (#207)

* Don't swap attributes when reducing tiny polygon dust

Because the dust placeholder may be misleadingly far from the feature
that contributed the most area to it

* Remove unused arguments; update changelog
This commit is contained in:
Erica Fischer
2024-02-26 15:41:26 -08:00
committed by GitHub
parent 2b6630c42c
commit a987197eed
7 changed files with 35 additions and 59 deletions
+1 -27
View File
@@ -168,11 +168,9 @@ void check_polygon(drawvec &geom) {
}
}
drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area, serial_feature *this_feature, serial_feature *tiny_feature) {
drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area) {
drawvec out;
const double pixel = (1LL << (32 - detail - z)) * (double) tiny_polygon_size;
bool includes_real = false;
bool includes_dust = false;
bool included_last_outer = false;
*still_needs_simplification = false;
@@ -217,7 +215,6 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2 + pixel, geom[i].y - pixel / 2 + pixel);
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2 + pixel);
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2);
includes_dust = true;
*accum_area -= pixel * pixel;
}
@@ -238,7 +235,6 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee
// which means that the overall polygon has a real geometry,
// which means that it gets to be simplified.
*still_needs_simplification = true;
includes_real = true;
if (area > 0) {
included_last_outer = true;
@@ -260,28 +256,6 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee
fprintf(stderr, "\n");
out.push_back(geom[i]);
includes_real = true;
}
}
if (!includes_real) {
if (includes_dust) {
// this geometry is just dust, so if there is another feature that
// contributed to the dust that is larger than this feature,
// keep its attributes instead of this one that just happened to be
// the one that hit the threshold of survival.
if (tiny_feature->extent > this_feature->extent) {
*this_feature = *tiny_feature;
tiny_feature->extent = 0;
}
} else {
// this is a feature that we are throwing away, so hang on to it
// attributes if it is bigger than the biggest one we threw away so far
if (this_feature->extent > tiny_feature->extent) {
*tiny_feature = *this_feature;
}
}
}