mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-24 10:44:51 +00:00
Merge pull request #657 from mapbox/drop-features-earlier
Drop LineStrings and Polygons early in tiling if they are smaller than a pixel
This commit is contained in:
commit
506526ddfa
@ -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
|
## 1.32.4
|
||||||
|
|
||||||
* Ignore leading zeroes when converting string attributes to feature IDs
|
* 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);
|
double scale = 1 << (32 - detail - z);
|
||||||
|
|
||||||
for (size_t i = 0; i < geom.size(); i++) {
|
for (size_t i = 0; i < geom.size(); i++) {
|
||||||
geom[i].x = std::round(geom[i].x / scale);
|
geom[i].x = std::floor(geom[i].x / scale);
|
||||||
geom[i].y = std::round(geom[i].y / scale);
|
geom[i].y = std::floor(geom[i].y / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < geom.size(); i++) {
|
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;
|
full_detail = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (full_detail < min_detail || low_detail < min_detail) {
|
if (full_detail < min_detail) {
|
||||||
fprintf(stderr, "%s: Full detail and low detail must be at least minimum detail\n", argv[0]);
|
min_detail = full_detail;
|
||||||
exit(EXIT_FAILURE);
|
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
|
// Need two checks: one for geometry representation, the other for
|
||||||
|
10
serial.cpp
10
serial.cpp
@ -318,6 +318,7 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
|
|||||||
long long offset = 0;
|
long long offset = 0;
|
||||||
long long prev = 0;
|
long long prev = 0;
|
||||||
bool has_prev = false;
|
bool has_prev = false;
|
||||||
|
double scale = 1.0 / (1 << geometry_scale);
|
||||||
|
|
||||||
for (size_t i = 0; i < geom.size(); i++) {
|
for (size_t i = 0; i < geom.size(); i++) {
|
||||||
if (geom[i].op == VT_MOVETO || geom[i].op == VT_LINETO) {
|
if (geom[i].op == VT_MOVETO || geom[i].op == VT_LINETO) {
|
||||||
@ -365,10 +366,19 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
|
|||||||
*(sst->initialized) = 1;
|
*(sst->initialized) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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].x = x >> geometry_scale;
|
||||||
geom[i].y = y >> geometry_scale;
|
geom[i].y = y >> geometry_scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return geom.size();
|
return geom.size();
|
||||||
}
|
}
|
||||||
|
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;
|
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) {
|
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;
|
int line_detail;
|
||||||
double merge_fraction = 1;
|
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;
|
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) {
|
if (sf.geometry.size() > 0) {
|
||||||
partial p;
|
partial p;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef VERSION_HPP
|
#ifndef VERSION_HPP
|
||||||
#define VERSION_HPP
|
#define VERSION_HPP
|
||||||
|
|
||||||
#define VERSION "v1.32.4"
|
#define VERSION "v1.32.5"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user