Use closepath for each polygon ring to match the vector tile spec

This commit is contained in:
Eric Fischer
2015-10-28 14:34:57 -07:00
parent b07a40ed5a
commit 358e9cad5b
4 changed files with 38 additions and 1 deletions
+30 -1
View File
@@ -98,7 +98,6 @@ drawvec remove_noop(drawvec geom, int type, int shift) {
}
if (geom[i].op == VT_CLOSEPATH) {
fprintf(stderr, "Shouldn't happen\n");
out.push_back(geom[i]);
} else { /* moveto or lineto */
out.push_back(geom[i]);
@@ -310,6 +309,36 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int detail, int buffer, bool cl
return out;
}
drawvec close_poly(drawvec &geom) {
drawvec out;
for (unsigned i = 0; i < geom.size(); i++) {
if (geom[i].op == VT_MOVETO) {
unsigned j;
for (j = i + 1; j < geom.size(); j++) {
if (geom[j].op != VT_LINETO) {
break;
}
}
if (j - 1 > i) {
if (geom[j - 1].x != geom[i].x || geom[j - 1].y != geom[i].y) {
fprintf(stderr, "Internal error: polygon not closed\n");
}
}
for (unsigned n = i; n < j - 1; n++) {
out.push_back(geom[n]);
}
out.push_back(draw(VT_CLOSEPATH, 0, 0));
i = j - 1;
}
}
return out;
}
drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double *accum_area) {
drawvec out;
long long pixel = (1 << (32 - detail - z)) * 2;