mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-23 17:01:18 +01:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63259a8757 | ||
|
|
bb4f220678 | ||
|
|
266ef3c286 | ||
|
|
1519b50791 |
@@ -35,6 +35,7 @@ tile-join
|
||||
tippecanoe-decode
|
||||
tippecanoe-enumerate
|
||||
tippecanoe-json-tool
|
||||
tippecanoe-overzoom
|
||||
unit
|
||||
|
||||
# Tests
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# 2.53.0
|
||||
|
||||
* Stop trying to add features to the tile after the feature limit is reached
|
||||
|
||||
# 2.52.0
|
||||
|
||||
* Fix accidental loss (at all zooms) of features that specify an explicit minzoom
|
||||
|
||||
+16245
-8793
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"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",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"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",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"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",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1490,6 +1490,20 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
|
||||
return false; // did not drop because nothing could be found to accumulate attributes onto
|
||||
}
|
||||
|
||||
double get_perimeter(const drawvec &geom, size_t i, size_t j) {
|
||||
double perimeter = 0;
|
||||
|
||||
for (size_t k = i; k + 1 < j; k++) {
|
||||
if (geom[k + 1].op == VT_LINETO) {
|
||||
double dx = geom[k].x - geom[k + 1].x;
|
||||
double dy = geom[k].y - geom[k + 1].y;
|
||||
perimeter += sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
|
||||
return perimeter;
|
||||
}
|
||||
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, 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, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::vector<std::string> const &unidecode_data) {
|
||||
double merge_fraction = 1;
|
||||
double mingap_fraction = 1;
|
||||
@@ -1875,7 +1889,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
unsigned long long sfindex = sf.index;
|
||||
|
||||
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
|
||||
// at least one byte in the output tile, so this can't possibly work.
|
||||
skipped++;
|
||||
@@ -2051,6 +2065,25 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
for (size_t i = 0; i < features.size(); i++) {
|
||||
serial_feature &p = features[i];
|
||||
|
||||
double area = get_mp_area(p.geometry);
|
||||
double schwartzberg = 1;
|
||||
|
||||
if (area != 0) {
|
||||
// polygon compactness measure
|
||||
// https://fisherzachary.github.io/public/r-output.html
|
||||
// Schwartzberg, Joseph E. 1965. “Reapportionment, gerrymanders, and the notion of compactness”.
|
||||
// In: Minn. L. Rev. 50, 443.
|
||||
|
||||
double perimeter = get_perimeter(p.geometry, 0, p.geometry.size());
|
||||
schwartzberg = 1 / (perimeter / (2 * M_PI * sqrt(std::fabs(area) / M_PI)));
|
||||
|
||||
serial_val sv;
|
||||
p.full_keys.push_back("Schwartzberg");
|
||||
sv.type = mvt_double;
|
||||
sv.s = std::to_string(schwartzberg);
|
||||
p.full_values.push_back(sv);
|
||||
}
|
||||
|
||||
if (p.clustered > 0) {
|
||||
serial_val sv, sv2, sv3, sv4;
|
||||
long long point_count = p.clustered + 1;
|
||||
@@ -2110,33 +2143,35 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
tasks = 1;
|
||||
}
|
||||
|
||||
pthread_t pthreads[tasks];
|
||||
std::vector<simplification_worker_arg> args;
|
||||
args.resize(tasks);
|
||||
for (int i = 0; i < tasks; i++) {
|
||||
args[i].task = i;
|
||||
args[i].tasks = tasks;
|
||||
args[i].features = &features;
|
||||
args[i].shared_nodes = &shared_nodes;
|
||||
args[i].shared_nodes_map = shared_nodes_map;
|
||||
args[i].nodepos = nodepos;
|
||||
{
|
||||
pthread_t pthreads[tasks];
|
||||
std::vector<simplification_worker_arg> args;
|
||||
args.resize(tasks);
|
||||
for (int i = 0; i < tasks; i++) {
|
||||
args[i].task = i;
|
||||
args[i].tasks = tasks;
|
||||
args[i].features = &features;
|
||||
args[i].shared_nodes = &shared_nodes;
|
||||
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 (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
|
||||
perror("pthread_create");
|
||||
exit(EXIT_PTHREAD);
|
||||
}
|
||||
} else {
|
||||
simplification_worker(&args[i]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < tasks; i++) {
|
||||
void *retval;
|
||||
|
||||
if (tasks > 1) {
|
||||
for (int i = 0; i < tasks; i++) {
|
||||
void *retval;
|
||||
|
||||
if (pthread_join(pthreads[i], &retval) != 0) {
|
||||
perror("pthread_join");
|
||||
if (pthread_join(pthreads[i], &retval) != 0) {
|
||||
perror("pthread_join");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2261,6 +2296,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
|
||||
if (layer_features[x].geometry.size() == 0) {
|
||||
layer_features[x] = serial_feature();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2301,6 +2337,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
|
||||
layer.features.push_back(std::move(feature));
|
||||
layer_features[x] = serial_feature();
|
||||
}
|
||||
|
||||
if (layer.features.size() > 0) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v2.52.0"
|
||||
#define VERSION "v2.53.0"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user