From 380550ce85867c60d6f9be0241b41f6ec7020dde Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 4 Dec 2014 14:54:11 -0800 Subject: [PATCH] Remember to remove the closepath after clipping away a polygon --- geometry.cc | 12 ++++++++++-- tile.cc | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/geometry.cc b/geometry.cc index 54fbf7c..8c4ad12 100644 --- a/geometry.cc +++ b/geometry.cc @@ -308,7 +308,9 @@ drawvec clip_poly(drawvec &geom, int z, int detail, int buffer) { } if (j >= geom.size() || geom[j].op == VT_CLOSEPATH) { - out.push_back(draw(VT_CLOSEPATH, 0, 0)); + if (out.size() > 0 && out[out.size() - 1].op != VT_CLOSEPATH) { + out.push_back(draw(VT_CLOSEPATH, 0, 0)); + } i = j; } else { i = j - 1; @@ -374,7 +376,13 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double i = j; } else { - fprintf(stderr, "how did we get here with %d?\n", geom[i].op); + fprintf(stderr, "how did we get here with %d in %d?\n", geom[i].op, (int) geom.size()); + + for (unsigned n = 0; n < geom.size(); n++) { + fprintf(stderr, "%d/%lld/%lld ", geom[n].op, geom[n].x, geom[n].y); + } + fprintf(stderr, "\n"); + out.push_back(geom[i]); } } diff --git a/tile.cc b/tile.cc index d03bcd3..767eafc 100644 --- a/tile.cc +++ b/tile.cc @@ -412,7 +412,6 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u if (line_detail == detail) { /* only write out the next zoom once, even if we retry */ if (geom.size() > 0) { if (!within) { - printf("writing %d/%u/%u\n", z, tx, ty); serialize_int(geomfile, z, &geompos, fname, jp); serialize_uint(geomfile, tx, &geompos, fname, jp); serialize_uint(geomfile, ty, &geompos, fname, jp); @@ -554,7 +553,6 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u evaluate(features, metabase, file_keys, layername, line_detail, compressed.size()); } } else { - printf("output %d/%u/%u\n", z, tx, ty); mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size()); return count; }