Merge remote-tracking branch 'origin/main' into clean-polygons

This commit is contained in:
Erica Fischer
2023-12-22 10:34:48 -08:00
9 changed files with 57 additions and 6 deletions
+9 -2
View File
@@ -644,9 +644,9 @@ drawvec fix_polygon(drawvec &geom) {
// A polygon ring must contain at least three points
// (and really should contain four). If this one does
// not have enough, avoid a division by zero trying to
// not have any, avoid a division by zero trying to
// calculate the centroid below.
if (j - i < 3) {
if (j - i < 1) {
i = j - 1;
outer = 0;
continue;
@@ -663,6 +663,13 @@ drawvec fix_polygon(drawvec &geom) {
ring.push_back(ring[0]);
}
// A polygon ring at this point should contain at least four points.
// Flesh it out with some vertex copies if it doesn't.
while (ring.size() < 4) {
ring.push_back(ring[0]);
}
// Reverse ring if winding order doesn't match
// inner/outer expectation