Add --stop-after option to tile-join

This commit is contained in:
Erica Fischer
2023-12-07 15:36:17 -08:00
parent cdfda19777
commit 9ce9f686a1
6 changed files with 2454 additions and 1 deletions
+1
View File
@@ -1,6 +1,7 @@
# 2.38.0 # 2.38.0
* `tippecanoe-overzoom` can now merge multiple tiles when overzooming them * `tippecanoe-overzoom` can now merge multiple tiles when overzooming them
* Add `--stop-after` option to `tile-join` to limit the total number of tiles copied
# 2.37.1 # 2.37.1
+7 -1
View File
@@ -431,7 +431,13 @@ join-test: tippecanoe tippecanoe-decode tile-join
./tile-join --overzoom -f -o tests/ne_110m_ocean/join/joined.mbtiles tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles ./tile-join --overzoom -f -o tests/ne_110m_ocean/join/joined.mbtiles tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles
./tippecanoe-decode -x generator tests/ne_110m_ocean/join/joined.mbtiles > tests/ne_110m_ocean/join/joined.mbtiles.json.check ./tippecanoe-decode -x generator tests/ne_110m_ocean/join/joined.mbtiles > tests/ne_110m_ocean/join/joined.mbtiles.json.check
cmp tests/ne_110m_ocean/join/joined.mbtiles.json.check tests/ne_110m_ocean/join/joined.mbtiles.json cmp tests/ne_110m_ocean/join/joined.mbtiles.json.check tests/ne_110m_ocean/join/joined.mbtiles.json
rm -f tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles tests/ne_110m_ocean/join/joined.mbtiles tests/ne_110m_ocean/join/joined.mbtiles.json.check #
# Test overzooming with tile count limit
#
./tile-join --overzoom -f -o tests/ne_110m_ocean/join/joined.mbtiles --stop-after 50 tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles
./tippecanoe-decode -x generator tests/ne_110m_ocean/join/joined.mbtiles > tests/ne_110m_ocean/join/joined.mbtiles-50.json.check
cmp tests/ne_110m_ocean/join/joined.mbtiles-50.json.check tests/ne_110m_ocean/join/joined.mbtiles-50.json
rm -f tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles tests/ne_110m_ocean/join/joined.mbtiles tests/ne_110m_ocean/join/joined.mbtiles.json.check tests/ne_110m_ocean/join/joined.mbtiles-50.json.check
join-filter-test: tippecanoe tippecanoe-decode tile-join join-filter-test: tippecanoe tippecanoe-decode tile-join
# Comes out different from the direct tippecanoe run because null attributes are lost # Comes out different from the direct tippecanoe run because null attributes are lost
+1
View File
@@ -793,6 +793,7 @@ The options are:
* `-z` _zoom_ or `--maximum-zoom=`_zoom_: Don't copy tiles from higher zoom levels than the specified zoom * `-z` _zoom_ or `--maximum-zoom=`_zoom_: Don't copy tiles from higher zoom levels than the specified zoom
* `-Z` _zoom_ or `--minimum-zoom=`_zoom_: Don't copy tiles from lower zoom levels than the specified zoom * `-Z` _zoom_ or `--minimum-zoom=`_zoom_: Don't copy tiles from lower zoom levels than the specified zoom
* `-a` _count_ or `--stop-after=`_count_: Stop copying tile from additional zoom levels after the specified _count_ of tiles has been written to the output.
### Merging attributes from a CSV file ### Merging attributes from a CSV file
+2
View File
@@ -1005,6 +1005,8 @@ The options are:
\fB\fC\-z\fR \fIzoom\fP or \fB\fC\-\-maximum\-zoom=\fR\fIzoom\fP: Don't copy tiles from higher zoom levels than the specified zoom \fB\fC\-z\fR \fIzoom\fP or \fB\fC\-\-maximum\-zoom=\fR\fIzoom\fP: Don't copy tiles from higher zoom levels than the specified zoom
.IP \(bu 2 .IP \(bu 2
\fB\fC\-Z\fR \fIzoom\fP or \fB\fC\-\-minimum\-zoom=\fR\fIzoom\fP: Don't copy tiles from lower zoom levels than the specified zoom \fB\fC\-Z\fR \fIzoom\fP or \fB\fC\-\-minimum\-zoom=\fR\fIzoom\fP: Don't copy tiles from lower zoom levels than the specified zoom
.IP \(bu 2
\fB\fC\-a\fR \fIcount\fP or \fB\fC\-\-stop\-after=\fR\fIcount\fP: Stop copying tile from additional zoom levels after the specified \fIcount\fP of tiles has been written to the output.
.RE .RE
.SS Merging attributes from a CSV file .SS Merging attributes from a CSV file
.RS .RS
File diff suppressed because one or more lines are too long
+18
View File
@@ -54,6 +54,9 @@ int minzoom = 0;
std::map<std::string, std::string> renames; std::map<std::string, std::string> renames;
bool exclude_all = false; bool exclude_all = false;
size_t stop_after = 0;
std::atomic<size_t> tiles_queued_for_write(0);
bool want_overzoom = false; bool want_overzoom = false;
int buffer = 5; int buffer = 5;
@@ -1084,12 +1087,22 @@ void decode(struct tileset_reader *readers, std::map<std::string, layermap_entry
// Then this tile is done and we can safely run the output queue. // Then this tile is done and we can safely run the output queue.
if (readers == NULL || readers->zoom != current.first.z || readers->x != current.first.x || readers->y != current.first.y) { if (readers == NULL || readers->zoom != current.first.z || readers->x != current.first.x || readers->y != current.first.y) {
tiles_queued_for_write++;
if (tasks.size() > 100 * CPUS) { if (tasks.size() > 100 * CPUS) {
dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers); dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers);
tasks.clear(); tasks.clear();
} }
} }
if (readers != NULL && readers->zoom != current.first.z && stop_after != 0 && tiles_queued_for_write >= stop_after) {
dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers);
tasks.clear();
if (!quiet) {
fprintf(stderr, "stopping after zoom %lld, after writing %zu tiles\n", current.first.z, (size_t) tiles_queued_for_write);
break;
}
}
// put the tileset_reader back onto the queue, // put the tileset_reader back onto the queue,
// in whatever sequence its next tile calls for // in whatever sequence its next tile calls for
@@ -1315,6 +1328,7 @@ int main(int argc, char **argv) {
{"feature-filter", required_argument, 0, 'j'}, {"feature-filter", required_argument, 0, 'j'},
{"rename-layer", required_argument, 0, 'R'}, {"rename-layer", required_argument, 0, 'R'},
{"read-from", required_argument, 0, 'r'}, {"read-from", required_argument, 0, 'r'},
{"stop-after", required_argument, 0, 'a'},
{"no-tile-size-limit", no_argument, &pk, 1}, {"no-tile-size-limit", no_argument, &pk, 1},
{"no-tile-compression", no_argument, &pC, 1}, {"no-tile-compression", no_argument, &pC, 1},
@@ -1448,6 +1462,10 @@ int main(int argc, char **argv) {
remove_layers.insert(std::string(optarg)); remove_layers.insert(std::string(optarg));
break; break;
case 'a':
stop_after = atoll(optarg);
break;
case 'R': { case 'R': {
char *cp = strchr(optarg, ':'); char *cp = strchr(optarg, ':');
if (cp == NULL || cp == optarg) { if (cp == NULL || cp == optarg) {