Tolerate polygon rings with insufficiently many points in input (#175)

* Tolerate polygon rings with insufficiently many points in input

* Fix changelog typo
This commit is contained in:
Erica Fischer
2023-12-11 11:14:26 -08:00
committed by GitHub
parent d7bdbe363b
commit 15a3e313ff
7 changed files with 46 additions and 3 deletions
+9 -2
View File
@@ -642,9 +642,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;
@@ -661,6 +661,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