mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Use closepath for each polygon ring to match the vector tile spec
This commit is contained in:
+30
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user