mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 18:35:41 +02:00
Still looks terrible, but make segment shortening work again
This commit is contained in:
@@ -230,36 +230,24 @@ drawvec remove_noop(drawvec geom, int type) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
int shrink_lines(struct draw *geom, int len, int z, int basezoom) {
|
drawvec shrink_lines(drawvec &geom, int z, int basezoom) {
|
||||||
double scale = 1.0 / exp(log(sqrt(2.5)) * (basezoom - z));
|
double scale = 1.0 / exp(log(sqrt(2.5)) * (basezoom - z));
|
||||||
struct draw tmp[3 * len];
|
unsigned i;
|
||||||
int out = 0;
|
drawvec out;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < geom.size(); i++) {
|
||||||
if (i > 0 && (geom[i - 1].op == VT_MOVETO || geom[i - 1].op == VT_LINETO) && geom[i].op == VT_LINETO) {
|
if (i > 0 && (geom[i - 1].op == VT_MOVETO || geom[i - 1].op == VT_LINETO) && geom[i].op == VT_LINETO) {
|
||||||
long long cx = (geom[i].x + geom[i - 1].x) / 2;
|
long long cx = (geom[i].x + geom[i - 1].x) / 2;
|
||||||
long long cy = (geom[i].y + geom[i - 1].y) / 2;
|
long long cy = (geom[i].y + geom[i - 1].y) / 2;
|
||||||
|
|
||||||
tmp[out + 0].op = VT_MOVETO;
|
out.push_back(draw(VT_MOVETO, cx + (geom[i - 1].x - cx) * scale, cy + (geom[i - 1].y - cy) * scale));
|
||||||
tmp[out + 0].x = cx + (geom[i - 1].x - cx) * scale;
|
out.push_back(draw(VT_LINETO, cx + (geom[i].x - cx) * scale, cy + (geom[i].y - cy) * scale));
|
||||||
tmp[out + 0].y = cy + (geom[i - 1].y - cy) * scale;
|
out.push_back(draw(VT_MOVETO, geom[i].x, geom[i].y));
|
||||||
|
|
||||||
tmp[out + 1].op = VT_LINETO;
|
|
||||||
tmp[out + 1].x = cx + (geom[i].x - cx) * scale;
|
|
||||||
tmp[out + 1].y = cy + (geom[i].y - cy) * scale;
|
|
||||||
|
|
||||||
tmp[out + 2].op = VT_MOVETO;
|
|
||||||
tmp[out + 2].x = geom[i].x;
|
|
||||||
tmp[out + 2].y = geom[i].y;
|
|
||||||
|
|
||||||
out += 3;
|
|
||||||
} else {
|
} else {
|
||||||
tmp[out++] = geom[i];
|
out.push_back(geom[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(geom, tmp, out * sizeof(struct draw));
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +532,7 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (t == VT_LINE && z != basezoom) {
|
if (t == VT_LINE && z != basezoom) {
|
||||||
len = shrink_lines(geom, len, z, basezoom);
|
geom = shrink_lines(geom, z, basezoom);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user