From 151f0c116cdacb22c45a5034244454e6b0f3857a Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 16 Oct 2014 15:17:18 -0700 Subject: [PATCH] Fix clipping of polygons with multiple rings. --- tile.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tile.cc b/tile.cc index e281d67..b7ec341 100644 --- a/tile.cc +++ b/tile.cc @@ -487,7 +487,7 @@ drawvec clip_poly(drawvec &geom, int z, int detail) { if (geom[i].op == VT_MOVETO) { unsigned j; for (j = i + 1; j < geom.size(); j++) { - if (geom[j].op == VT_CLOSEPATH) { + if (geom[j].op == VT_CLOSEPATH || geom[j].op == VT_MOVETO) { break; } } @@ -501,8 +501,12 @@ drawvec clip_poly(drawvec &geom, int z, int detail) { out.push_back(tmp[k]); } - out.push_back(draw(VT_CLOSEPATH, 0, 0)); - i = j; + if (j >= geom.size() || geom[j].op == VT_CLOSEPATH) { + out.push_back(draw(VT_CLOSEPATH, 0, 0)); + i = j; + } else { + i = j - 1; + } } else { out.push_back(geom[i]); }