mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-01 08:47:57 +00:00
Fix gridding of small squares; use less memory for small features
This commit is contained in:
parent
739445cb6c
commit
5229990523
@ -1,3 +1,10 @@
|
||||
## 1.32.5
|
||||
|
||||
* Use less memory on lines and polygons that are too small for the tile
|
||||
* Fix coordinate rounding problem that was causing --grid-low-zooms grids
|
||||
to be lost at low zooms if the original polygons were not aligned to
|
||||
tile boundaries
|
||||
|
||||
## 1.32.4
|
||||
|
||||
* Ignore leading zeroes when converting string attributes to feature IDs
|
||||
|
@ -1135,8 +1135,8 @@ drawvec stairstep(drawvec &geom, int z, int detail) {
|
||||
double scale = 1 << (32 - detail - z);
|
||||
|
||||
for (size_t i = 0; i < geom.size(); i++) {
|
||||
geom[i].x = std::round(geom[i].x / scale);
|
||||
geom[i].y = std::round(geom[i].y / scale);
|
||||
geom[i].x = std::floor(geom[i].x / scale);
|
||||
geom[i].y = std::floor(geom[i].y / scale);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < geom.size(); i++) {
|
||||
|
11
main.cpp
11
main.cpp
@ -3050,9 +3050,14 @@ int main(int argc, char **argv) {
|
||||
full_detail = 12;
|
||||
}
|
||||
|
||||
if (full_detail < min_detail || low_detail < min_detail) {
|
||||
fprintf(stderr, "%s: Full detail and low detail must be at least minimum detail\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
if (full_detail < min_detail) {
|
||||
min_detail = full_detail;
|
||||
fprintf(stderr, "%s: Reducing minimum detail to match full detail %d\n", argv[0], min_detail);
|
||||
}
|
||||
|
||||
if (low_detail < min_detail) {
|
||||
min_detail = low_detail;
|
||||
fprintf(stderr, "%s: Reducing minimum detail to match low detail %d\n", argv[0], min_detail);
|
||||
}
|
||||
|
||||
// Need two checks: one for geometry representation, the other for
|
||||
|
14
serial.cpp
14
serial.cpp
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
1024
tests/grid-aligned/in.json
Normal file
1024
tests/grid-aligned/in.json
Normal file
File diff suppressed because it is too large
Load Diff
2806
tests/grid-aligned/out/-z11_-D7_--grid-low-zooms.json
Normal file
2806
tests/grid-aligned/out/-z11_-D7_--grid-low-zooms.json
Normal file
File diff suppressed because it is too large
Load Diff
1024
tests/grid-unaligned/in.json
Normal file
1024
tests/grid-unaligned/in.json
Normal file
File diff suppressed because it is too large
Load Diff
4670
tests/grid-unaligned/out/-z11_-D7_--grid-low-zooms.json
Normal file
4670
tests/grid-unaligned/out/-z11_-D7_--grid-low-zooms.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
25
tile.cpp
25
tile.cpp
@ -1688,6 +1688,26 @@ bool find_partial(std::vector<partial> &partials, serial_feature &sf, ssize_t &o
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool line_is_too_small(drawvec const &geometry, int z, int detail) {
|
||||
if (geometry.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
long long x = geometry[0].x >> (32 - detail - z);
|
||||
long long y = geometry[0].y >> (32 - detail - z);
|
||||
|
||||
for (auto &g : geometry) {
|
||||
long long xx = g.x >> (32 - detail - z);
|
||||
long long yy = g.y >> (32 - detail - z);
|
||||
|
||||
if (xx != x || yy != y) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, FILE **geomfile, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, size_t passes, unsigned long long mingap, long long minextent, double fraction, const char *prefilter, const char *postfilter, struct json_object *filter, write_tile_args *arg) {
|
||||
int line_detail;
|
||||
double merge_fraction = 1;
|
||||
@ -1929,6 +1949,11 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
|
||||
}
|
||||
has_polygons = true;
|
||||
}
|
||||
if (sf.t == VT_POLYGON || sf.t == VT_LINE) {
|
||||
if (line_is_too_small(sf.geometry, z, line_detail)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (sf.geometry.size() > 0) {
|
||||
partial p;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v1.32.4"
|
||||
#define VERSION "v1.32.5"
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user