mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Reduce tiling memory (#227)
* Trying to reduce memory in tiling * Let the simplification workers go out of scope earlier * Bail out quickly once the maximum feature count is reached * Update changelog and version
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
# 2.53.0
|
||||||
|
|
||||||
|
* Stop trying to add features to the tile after the feature limit is reached
|
||||||
|
|
||||||
# 2.52.0
|
# 2.52.0
|
||||||
|
|
||||||
* Fix accidental loss (at all zooms) of features that specify an explicit minzoom
|
* Fix accidental loss (at all zooms) of features that specify an explicit minzoom
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
|
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
|
||||||
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":1000}]",
|
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":201}]",
|
||||||
"type": "overlay",
|
"type": "overlay",
|
||||||
"version": "2"
|
"version": "2"
|
||||||
}, "features": [
|
}, "features": [
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles",
|
"name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles",
|
||||||
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
|
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
|
||||||
"type": "overlay",
|
"type": "overlay",
|
||||||
"version": "2"
|
"version": "2"
|
||||||
}, "features": [
|
}, "features": [
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles",
|
"name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles",
|
||||||
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
|
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
|
||||||
"type": "overlay",
|
"type": "overlay",
|
||||||
"version": "2"
|
"version": "2"
|
||||||
}, "features": [
|
}, "features": [
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1875,7 +1875,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
unsigned long long sfindex = sf.index;
|
unsigned long long sfindex = sf.index;
|
||||||
|
|
||||||
if (sf.geometry.size() > 0) {
|
if (sf.geometry.size() > 0) {
|
||||||
if (lead_features_count > max_tile_size) {
|
if (lead_features_count > max_tile_size || (lead_features_count + other_multiplier_cluster_features_count > max_tile_features && !prevent[P_FEATURE_LIMIT])) {
|
||||||
// Even being maximally conservative, each feature is still going to be
|
// Even being maximally conservative, each feature is still going to be
|
||||||
// at least one byte in the output tile, so this can't possibly work.
|
// at least one byte in the output tile, so this can't possibly work.
|
||||||
skipped++;
|
skipped++;
|
||||||
@@ -2110,33 +2110,35 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
tasks = 1;
|
tasks = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_t pthreads[tasks];
|
{
|
||||||
std::vector<simplification_worker_arg> args;
|
pthread_t pthreads[tasks];
|
||||||
args.resize(tasks);
|
std::vector<simplification_worker_arg> args;
|
||||||
for (int i = 0; i < tasks; i++) {
|
args.resize(tasks);
|
||||||
args[i].task = i;
|
for (int i = 0; i < tasks; i++) {
|
||||||
args[i].tasks = tasks;
|
args[i].task = i;
|
||||||
args[i].features = &features;
|
args[i].tasks = tasks;
|
||||||
args[i].shared_nodes = &shared_nodes;
|
args[i].features = &features;
|
||||||
args[i].shared_nodes_map = shared_nodes_map;
|
args[i].shared_nodes = &shared_nodes;
|
||||||
args[i].nodepos = nodepos;
|
args[i].shared_nodes_map = shared_nodes_map;
|
||||||
|
args[i].nodepos = nodepos;
|
||||||
|
|
||||||
|
if (tasks > 1) {
|
||||||
|
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
|
||||||
|
perror("pthread_create");
|
||||||
|
exit(EXIT_PTHREAD);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
simplification_worker(&args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tasks > 1) {
|
if (tasks > 1) {
|
||||||
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
|
for (int i = 0; i < tasks; i++) {
|
||||||
perror("pthread_create");
|
void *retval;
|
||||||
exit(EXIT_PTHREAD);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
simplification_worker(&args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tasks > 1) {
|
if (pthread_join(pthreads[i], &retval) != 0) {
|
||||||
for (int i = 0; i < tasks; i++) {
|
perror("pthread_join");
|
||||||
void *retval;
|
}
|
||||||
|
|
||||||
if (pthread_join(pthreads[i], &retval) != 0) {
|
|
||||||
perror("pthread_join");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2261,6 +2263,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (layer_features[x].geometry.size() == 0) {
|
if (layer_features[x].geometry.size() == 0) {
|
||||||
|
layer_features[x] = serial_feature();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2301,6 +2304,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
layer.features.push_back(std::move(feature));
|
layer.features.push_back(std::move(feature));
|
||||||
|
layer_features[x] = serial_feature();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer.features.size() > 0) {
|
if (layer.features.size() > 0) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#ifndef VERSION_HPP
|
#ifndef VERSION_HPP
|
||||||
#define VERSION_HPP
|
#define VERSION_HPP
|
||||||
|
|
||||||
#define VERSION "v2.52.0"
|
#define VERSION "v2.53.0"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user