mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-23 17:01:18 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3095adb467 |
+2
-2
@@ -1,6 +1,6 @@
|
||||
## 2.14.0
|
||||
## 2.13.1
|
||||
|
||||
* Add --containing-lat-lon and --containing-lon-lat options to tippecanoe-decode
|
||||
* Simplify geometry earlier when the in-memory representation of a tile gets large, to reduce peak memory usage
|
||||
|
||||
## 2.13.0
|
||||
|
||||
|
||||
@@ -164,16 +164,12 @@ decode-test:
|
||||
./tippecanoe-decode -x generator -l subway --fraction tests/muni/decode/multi.mbtiles > tests/muni/decode/multi.mbtiles.fraction.json.check
|
||||
./tippecanoe-decode -x generator -c tests/muni/decode/multi.mbtiles > tests/muni/decode/multi.mbtiles.pipeline.json.check
|
||||
./tippecanoe-decode -x generator tests/muni/decode/multi.mbtiles 11 327 791 > tests/muni/decode/multi.mbtiles.onetile.json.check
|
||||
./tippecanoe-decode -x generator --containing-lat-lon 37.7615594,-122.421015 tests/muni/decode/multi.mbtiles > tests/muni/decode/multi.mbtiles.containing-lat.json.check
|
||||
./tippecanoe-decode -x generator --containing-lon-lat=-122.421015,37.7615594 tests/muni/decode/multi.mbtiles > tests/muni/decode/multi.mbtiles.containing-lon.json.check
|
||||
./tippecanoe-decode -x generator --stats tests/muni/decode/multi.mbtiles > tests/muni/decode/multi.mbtiles.stats.json.check
|
||||
cmp tests/muni/decode/multi.mbtiles.json.check tests/muni/decode/multi.mbtiles.json
|
||||
cmp tests/muni/decode/multi.mbtiles.integer.json.check tests/muni/decode/multi.mbtiles.integer.json
|
||||
cmp tests/muni/decode/multi.mbtiles.fraction.json.check tests/muni/decode/multi.mbtiles.fraction.json
|
||||
cmp tests/muni/decode/multi.mbtiles.pipeline.json.check tests/muni/decode/multi.mbtiles.pipeline.json
|
||||
cmp tests/muni/decode/multi.mbtiles.onetile.json.check tests/muni/decode/multi.mbtiles.onetile.json
|
||||
cmp tests/muni/decode/multi.mbtiles.containing-lat.json.check tests/muni/decode/multi.mbtiles.containing.json
|
||||
cmp tests/muni/decode/multi.mbtiles.containing-lon.json.check tests/muni/decode/multi.mbtiles.containing.json
|
||||
cmp tests/muni/decode/multi.mbtiles.stats.json.check tests/muni/decode/multi.mbtiles.stats.json
|
||||
rm -f tests/muni/decode/multi.mbtiles.json.check tests/muni/decode/multi.mbtiles tests/muni/decode/multi.mbtiles.pipeline.json.check tests/muni/decode/multi.mbtiles.stats.json.check tests/muni/decode/multi.mbtiles.onetile.json.check
|
||||
|
||||
|
||||
@@ -891,8 +891,6 @@ resolutions.
|
||||
* `-f` or `--force`: Decode tiles even if polygon ring order or closure problems are detected
|
||||
* `-I` or `--integer`: Report coordinates in integer tile coordinates
|
||||
* `-F` or `--fraction`: Report coordinates as a fraction of the tile extent
|
||||
* `-m` _lat_,_lon_ or `--containing-lat-lon`=_lat_,_lon_: Decode only tiles containing the specified point
|
||||
* `-M` _lon_,_lat_ or `--containing-lon-lat`=_lon_,_lat_: Decode only tiles containing the specified point
|
||||
|
||||
tippecanoe-json-tool
|
||||
====================
|
||||
|
||||
+1
-31
@@ -28,9 +28,6 @@ int minzoom = 0;
|
||||
int maxzoom = 32;
|
||||
bool force = false;
|
||||
|
||||
double containing_lon = -500;
|
||||
double containing_lat = -500;
|
||||
|
||||
void do_stats(mvt_tile &tile, size_t size, bool compressed, int z, unsigned x, unsigned y, json_writer &state) {
|
||||
state.json_write_hash();
|
||||
|
||||
@@ -428,18 +425,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
|
||||
exit(EXIT_SQLITE);
|
||||
}
|
||||
|
||||
bool contains = true;
|
||||
if (containing_lat > -500 && containing_lon > -500) {
|
||||
long long ctx, cty;
|
||||
lonlat2tile(containing_lon, containing_lat, tz, &ctx, &cty);
|
||||
if (tx != ctx || ty != cty) {
|
||||
contains = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (contains) {
|
||||
handle(std::string(s, len), tz, tx, ty, to_decode, pipeline, stats, state, coordinate_mode);
|
||||
}
|
||||
handle(std::string(s, len), tz, tx, ty, to_decode, pipeline, stats, state, coordinate_mode);
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
@@ -528,8 +514,6 @@ int main(int argc, char **argv) {
|
||||
{"stats", no_argument, 0, 'S'},
|
||||
{"force", no_argument, 0, 'f'},
|
||||
{"exclude-metadata-row", required_argument, 0, 'x'},
|
||||
{"containing-lat-lon", required_argument, 0, 'm'},
|
||||
{"containing-lon-lat", required_argument, 0, 'M'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@@ -589,20 +573,6 @@ int main(int argc, char **argv) {
|
||||
exclude_meta.insert(optarg);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (sscanf(optarg, "%lf,%lf", &containing_lat, &containing_lon) != 2) {
|
||||
fprintf(stderr, "-m option is lat,lon\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (sscanf(optarg, "%lf,%lf", &containing_lon, &containing_lat) != 2) {
|
||||
fprintf(stderr, "-m option is lon,lat\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -517,73 +517,84 @@ drawvec revive_polygon(drawvec &geom, double area, int z, int detail) {
|
||||
}
|
||||
}
|
||||
|
||||
double simplify_partial(partial *p, drawvec &shared_nodes) {
|
||||
drawvec geom;
|
||||
|
||||
for (size_t j = 0; j < p->geoms.size(); j++) {
|
||||
for (size_t k = 0; k < p->geoms[j].size(); k++) {
|
||||
geom.push_back(p->geoms[j][k]);
|
||||
}
|
||||
}
|
||||
|
||||
p->geoms.clear(); // avoid keeping two copies in memory
|
||||
signed char t = p->t;
|
||||
int z = p->z;
|
||||
int line_detail = p->line_detail;
|
||||
int maxzoom = p->maxzoom;
|
||||
|
||||
if (additional[A_GRID_LOW_ZOOMS] && z < maxzoom) {
|
||||
geom = stairstep(geom, z, line_detail);
|
||||
}
|
||||
|
||||
double area = 0;
|
||||
if (t == VT_POLYGON) {
|
||||
area = get_mp_area(geom);
|
||||
}
|
||||
|
||||
if ((t == VT_LINE || t == VT_POLYGON) && !(prevent[P_SIMPLIFY] || (z == maxzoom && prevent[P_SIMPLIFY_LOW]) || (z < maxzoom && additional[A_GRID_LOW_ZOOMS]))) {
|
||||
// Now I finally remember why it doesn't simplify if the feature was reduced:
|
||||
// because it makes square placeholders look like weird triangular placeholders.
|
||||
// Only matters if simplification is set higher than the tiny polygon size.
|
||||
// Tiny polygons that are part of a tiny multipolygon will still get simplified.
|
||||
if (!p->reduced) {
|
||||
if (t == VT_LINE) {
|
||||
// continues to deduplicate to line_detail even if we have extra detail
|
||||
geom = remove_noop(geom, t, 32 - z - line_detail);
|
||||
}
|
||||
|
||||
bool already_marked = false;
|
||||
if (additional[A_DETECT_SHARED_BORDERS] && t == VT_POLYGON) {
|
||||
already_marked = true;
|
||||
}
|
||||
|
||||
if (!already_marked) {
|
||||
if (p->coalesced && t == VT_POLYGON) {
|
||||
// clean coalesced polygons before simplification to avoid
|
||||
// introducing shards between shapes that otherwise would have
|
||||
// unioned exactly
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false);
|
||||
}
|
||||
|
||||
// continues to simplify to line_detail even if we have extra detail
|
||||
drawvec ngeom = simplify_lines(geom, z, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), p->simplification, t == VT_POLYGON ? 4 : 0, shared_nodes);
|
||||
|
||||
if (t != VT_POLYGON || ngeom.size() >= 3) {
|
||||
geom = ngeom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (t == VT_LINE && additional[A_REVERSE]) {
|
||||
geom = reorder_lines(geom);
|
||||
}
|
||||
|
||||
p->geoms.push_back(geom);
|
||||
return area;
|
||||
}
|
||||
|
||||
void *partial_feature_worker(void *v) {
|
||||
struct partial_arg *a = (struct partial_arg *) v;
|
||||
std::vector<struct partial> *partials = a->partials;
|
||||
|
||||
for (size_t i = a->task; i < (*partials).size(); i += a->tasks) {
|
||||
drawvec geom;
|
||||
double area = simplify_partial(&((*partials)[i]), *(a->shared_nodes));
|
||||
|
||||
for (size_t j = 0; j < (*partials)[i].geoms.size(); j++) {
|
||||
for (size_t k = 0; k < (*partials)[i].geoms[j].size(); k++) {
|
||||
geom.push_back((*partials)[i].geoms[j][k]);
|
||||
}
|
||||
}
|
||||
|
||||
(*partials)[i].geoms.clear(); // avoid keeping two copies in memory
|
||||
signed char t = (*partials)[i].t;
|
||||
int z = (*partials)[i].z;
|
||||
int line_detail = (*partials)[i].line_detail;
|
||||
int out_detail = (*partials)[i].extra_detail;
|
||||
int maxzoom = (*partials)[i].maxzoom;
|
||||
|
||||
if (additional[A_GRID_LOW_ZOOMS] && z < maxzoom) {
|
||||
geom = stairstep(geom, z, line_detail);
|
||||
}
|
||||
|
||||
double area = 0;
|
||||
if (t == VT_POLYGON) {
|
||||
area = get_mp_area(geom);
|
||||
}
|
||||
|
||||
if ((t == VT_LINE || t == VT_POLYGON) && !(prevent[P_SIMPLIFY] || (z == maxzoom && prevent[P_SIMPLIFY_LOW]) || (z < maxzoom && additional[A_GRID_LOW_ZOOMS]))) {
|
||||
// Now I finally remember why it doesn't simplify if the feature was reduced:
|
||||
// because it makes square placeholders look like weird triangular placeholders.
|
||||
// Only matters if simplification is set higher than the tiny polygon size.
|
||||
// Tiny polygons that are part of a tiny multipolygon will still get simplified.
|
||||
if (!(*partials)[i].reduced) {
|
||||
if (t == VT_LINE) {
|
||||
// continues to deduplicate to line_detail even if we have extra detail
|
||||
geom = remove_noop(geom, t, 32 - z - line_detail);
|
||||
}
|
||||
|
||||
bool already_marked = false;
|
||||
if (additional[A_DETECT_SHARED_BORDERS] && t == VT_POLYGON) {
|
||||
already_marked = true;
|
||||
}
|
||||
|
||||
if (!already_marked) {
|
||||
if ((*partials)[i].coalesced && t == VT_POLYGON) {
|
||||
// clean coalesced polygons before simplification to avoid
|
||||
// introducing shards between shapes that otherwise would have
|
||||
// unioned exactly
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false);
|
||||
}
|
||||
|
||||
// continues to simplify to line_detail even if we have extra detail
|
||||
drawvec ngeom = simplify_lines(geom, z, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), (*partials)[i].simplification, t == VT_POLYGON ? 4 : 0, *(a->shared_nodes));
|
||||
|
||||
if (t != VT_POLYGON || ngeom.size() >= 3) {
|
||||
geom = ngeom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (t == VT_LINE && additional[A_REVERSE]) {
|
||||
geom = reorder_lines(geom);
|
||||
}
|
||||
|
||||
drawvec geom = (*partials)[i].geoms[0];
|
||||
to_tile_scale(geom, z, out_detail);
|
||||
|
||||
if (t == VT_POLYGON) {
|
||||
@@ -1877,6 +1888,9 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
|
||||
size_t skipped = 0;
|
||||
size_t kept = 0;
|
||||
|
||||
size_t unsimplified_geometry_size = 0;
|
||||
size_t simplified_geometry_through = 0;
|
||||
|
||||
int within[child_shards];
|
||||
std::atomic<long long> geompos[child_shards];
|
||||
for (size_t i = 0; i < (size_t) child_shards; i++) {
|
||||
@@ -2158,6 +2172,23 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
|
||||
}
|
||||
|
||||
partials.push_back(p);
|
||||
|
||||
unsimplified_geometry_size += sf.geometry.size() * sizeof(draw);
|
||||
if (unsimplified_geometry_size > 10 * 1024 * 1024 && !additional[A_DETECT_SHARED_BORDERS]) {
|
||||
drawvec dv;
|
||||
|
||||
for (; simplified_geometry_through < partials.size(); simplified_geometry_through++) {
|
||||
simplify_partial(&partials[simplified_geometry_through], dv);
|
||||
|
||||
for (auto &g : partials[simplified_geometry_through].geoms) {
|
||||
if (partials[simplified_geometry_through].t == VT_POLYGON) {
|
||||
g = clean_or_clip_poly(g, 0, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsimplified_geometry_size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v2.14.0"
|
||||
#define VERSION "v2.13.1"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user