mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 12:28:03 +00:00
If a tile is too big, try backing off to lower resolutions before failing
This commit is contained in:
parent
bda20fe8a6
commit
8594dbe56b
31
tile.cc
31
tile.cc
@ -643,6 +643,9 @@ int coalindexcmp(const struct coalesce *c1, const struct coalesce *c2) {
|
||||
}
|
||||
|
||||
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, char *layername, sqlite3 *outdb) {
|
||||
int line_detail;
|
||||
|
||||
for (line_detail = detail; line_detail >= 7; line_detail--) {
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
mapnik::vector::tile tile;
|
||||
@ -651,7 +654,7 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
||||
layer->set_name(layername);
|
||||
layer->set_version(1);
|
||||
|
||||
layer->set_extent(1 << detail);
|
||||
layer->set_extent(1 << line_detail);
|
||||
|
||||
struct pool keys, values, dup;
|
||||
pool_init(&keys, 0);
|
||||
@ -686,27 +689,27 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
||||
}
|
||||
}
|
||||
|
||||
drawvec geom = decode_feature(&meta, z, tx, ty, detail);
|
||||
drawvec geom = decode_feature(&meta, z, tx, ty, line_detail);
|
||||
|
||||
if (t == VT_LINE) {
|
||||
geom = clip_lines(geom, z, detail);
|
||||
geom = clip_lines(geom, z, line_detail);
|
||||
}
|
||||
|
||||
if (t == VT_POLYGON) {
|
||||
geom = clip_poly(geom, z, detail);
|
||||
geom = clip_poly(geom, z, line_detail);
|
||||
}
|
||||
|
||||
if (t == VT_LINE || t == VT_POLYGON) {
|
||||
geom = simplify_lines(geom, z, detail);
|
||||
geom = simplify_lines(geom, z, line_detail);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (t == VT_LINE && z != basezoom) {
|
||||
geom = shrink_lines(geom, z, detail, basezoom, &along);
|
||||
geom = shrink_lines(geom, z, line_detail, basezoom, &along);
|
||||
}
|
||||
#endif
|
||||
|
||||
to_tile_scale(geom, z, detail);
|
||||
to_tile_scale(geom, z, line_detail);
|
||||
|
||||
if (t == VT_POINT || to_feature(geom, NULL)) {
|
||||
struct pool_val *pv = pool_long_long(&dup, &i->fpos, 0);
|
||||
@ -818,12 +821,14 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
||||
compress(s, compressed);
|
||||
|
||||
if (compressed.size() > 500000) {
|
||||
fprintf(stderr, "tile %d/%u/%u size is %lld, >500000\n", z, tx, ty, (long long) compressed.size());
|
||||
fprintf(stderr, "tile %d/%u/%u size is %lld with detail %d, >500000 \n", z, tx, ty, (long long) compressed.size(), line_detail);
|
||||
} else {
|
||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "could not make tile %d/%u/%u small enough\n", z, tx, ty);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user