mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
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:
+9
-2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user