Compare commits

...
4 Commits
Author SHA1 Message Date
Erica Fischer 63259a8757 Schwartzberg compactness
for i in ../place/*.zip; do echo $i >&2; ogr2ogr -f GeoJSONSeq /vsistdout/ /vsizip/$i;done | ./tippecanoe -y NAME -y Schwartzberg --no-tile-size-limit --no-feature-limit -z0 -D30 -d30 -f -o foo.mbtiles

tippecanoe-decode -c foo.mbtiles| sed 's/"properties": { \(.*\), "Schwartzberg": \([0-9.-]*\)/"properties": { "Schwartzberg": \2, \1/' | sort -n -k16 | less -S | perl -e 'while (<>) { $seq++; s/"Schwartzberg"/"seq": $seq, "Schwartzberg"/; print }' | tail -500 > /tmp/sch.json
2024-04-05 12:19:55 -07:00
Erica Fischer bb4f220678 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
2024-04-03 07:12:26 -07:00
Dane Springmeyer 266ef3c286 Add tippecanoe-overzoom to .gitignore (#224)
add tippecanoe-overzoom to .gitignore
2024-03-25 11:00:18 -07:00
Dane Springmeyer 1519b50791 Upgrade catch from v1.5.7 to v2.13.10 (#223)
upgrade catch from v1.5.7 to v2.13.10
2024-03-25 10:39:11 -07:00
9 changed files with 16935 additions and 9319 deletions
+1
View File
@@ -35,6 +35,7 @@ tile-join
tippecanoe-decode
tippecanoe-enumerate
tippecanoe-json-tool
tippecanoe-overzoom
unit
# Tests
+4
View File
@@ -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
View File
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
+62 -25
View File
@@ -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
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.52.0"
#define VERSION "v2.53.0"
#endif