Fix gridding of small squares; use less memory for small features

This commit is contained in:
Eric Fischer
2018-11-21 15:34:43 -08:00
parent 739445cb6c
commit 5229990523
11 changed files with 10990 additions and 1431 deletions
+12 -2
View File
@@ -318,6 +318,7 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
long long offset = 0;
long long prev = 0;
bool has_prev = false;
double scale = 1.0 / (1 << geometry_scale);
for (size_t i = 0; i < geom.size(); i++) {
if (geom[i].op == VT_MOVETO || geom[i].op == VT_LINETO) {
@@ -365,8 +366,17 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
*(sst->initialized) = 1;
}
geom[i].x = x >> geometry_scale;
geom[i].y = y >> geometry_scale;
if (additional[A_GRID_LOW_ZOOMS]) {
// If we are gridding, snap to the maxzoom grid in case the incoming data
// is already supposed to be aligned to tile boundaries (but is not, exactly,
// because of rounding error during projection).
geom[i].x = std::round(x * scale);
geom[i].y = std::round(y * scale);
} else {
geom[i].x = x >> geometry_scale;
geom[i].y = y >> geometry_scale;
}
}
}