Compare commits

..
1 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
6 changed files with 41 additions and 46 deletions
-4
View File
@@ -1,7 +1,3 @@
# 2.55.0
* Fix hash collisions in the string pool
# 2.53.0
* Stop trying to add features to the tile after the feature limit is reached
+7 -7
View File
@@ -9,15 +9,15 @@
#include "errors.hpp"
#include "text.hpp"
inline long long swizzlecmp(const char *a, int atype, unsigned long long ahash, const char *b, int btype, unsigned long long bhash) {
if ((long long) ahash == (long long) bhash) {
inline int swizzlecmp(const char *a, int atype, unsigned long long ahash, const char *b, int btype, unsigned long long bhash) {
if (ahash == bhash) {
if (atype == btype) {
return strcmp(a, b);
} else {
return atype - btype;
}
} else {
return (long long) (ahash - bhash);
return (int) (ahash - bhash);
}
}
@@ -44,10 +44,10 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
}
while (*sp != 0) {
long long cmp = swizzlecmp(s, type, hash,
poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off + 1,
(poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off)[0],
((struct stringpool *) (treefile->map.c_str() + *sp))->hash);
int cmp = swizzlecmp(s, type, hash,
poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off + 1,
(poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off)[0],
((struct stringpool *) (treefile->map.c_str() + *sp))->hash);
if (cmp < 0) {
sp = &(((struct stringpool *) (treefile->map.c_str() + *sp))->left);
-8
View File
@@ -1,8 +0,0 @@
{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.8620223,-15.744153]},"properties":{"id":"0856c5143fffffff0138e27e7a03f7d8","@name":"Andenes","subtype":"locality","local_type":{"en":"hamlet"},"country":"PE","region":"PE-ARE","hierarchies":[[{"division_id":"085bc6b4ffffffff01fb3b67a2808435","subtype":"country","name":"Perú"},{"division_id":"08559acaffffffff01f27abb0a0cb14b","subtype":"region","name":"Arequipa"},{"division_id":"0856c834ffffffff01fd8ac1c98804cb","subtype":"county","name":"Caravelí"},{"division_id":"0856c53b7fffffff019e8d5b8b047485","subtype":"locality","name":"Chaparra"},{"division_id":"0856c5143fffffff0138e27e7a03f7d8","subtype":"locality","name":"Andenes"}]],"parent_division_id":"0856c53b7fffffff019e8d5b8b047485","perspectives":null,"norms":null,"population":null,"capital_division_id":null,"wikidata":null,"names":{"primary":"Andenes","common":{"en":"Andenes","es":"Andenes"},"rules":null},"version":0,"update_time":"2024-05-11T06:56:01Z","sources":[{"property":"","dataset":"OpenStreetMap","record_id":"N3522957503","confidence":null}]},"id":92526}
{"type":"Feature","geometry":{"type":"Point","coordinates":[-0.2216242,51.4948601]},"properties":{"id":"085070173fffffff014fa86038bb5217","@name":"Hammersmith And Fulham","subtype":"county","local_type":{"en":"county"},"country":"GB","region":"GB-ENG","hierarchies":[[{"division_id":"085eea613fffffff01a8a15aa3da4c44","subtype":"country","name":"United Kingdom"},{"division_id":"085255dd7fffffff011aba243af254bd","subtype":"region","name":"England"},{"division_id":"085070173fffffff014fa86038bb5217","subtype":"county","name":"Hammersmith And Fulham"}]],"parent_division_id":"085255dd7fffffff011aba243af254bd","perspectives":null,"norms":null,"population":null,"capital_division_id":null,"wikidata":null,"names":{"primary":"Hammersmith And Fulham","common":null,"rules":null},"version":0,"update_time":"2024-05-11T06:57:45Z","sources":[{"property":"","dataset":"geoBoundaries","record_id":"GBR9080712B6991151074246","confidence":null}]},"id":1096239}
{"type": "Feature", "properties": {"one": "Poull Bojer"}, "geometry": {"type":"Point","coordinates":[0,0]}}
{"type": "Feature", "properties": {"two":
"[[{\"division_id\":\"085ec5c23fffffff01339442745f3d55\",\"subtype\":\"country\",\"name\":\"Ecuador\"},{\"division_id\":\"085dac297fffffff0147c020488d610d\",\"subtype\":\"region\",\"name\":\"Cotopaxi\"},{\"division_id\":\"085bf1b2ffffffff012715ee575c3475\",\"subtype\":\"county\",\"name\":\"Sigchos\"},{\"division_id\":\"085bf010ffffffff014f248c7b4fe243\",\"subtype\":\"locality\",\"name\":\"Sigchos\"},{\"division_id\":\"085bf03a3fffffff01145a02d706b16f\",\"subtype\":\"locality\",\"name\":\"Tiliguila\"}]]"
}, "geometry": {"type":"Point","coordinates":[0,0]}}
-26
View File
@@ -1,26 +0,0 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-73.862022,-15.744153,0.000000,51.494860",
"bounds": "-73.862022,-15.744153,0.000000,51.494860",
"center": "0.000000,0.000000,0",
"description": "tests/overture-235/out/-z0.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/overture-235/out/-z0.json.check.mbtiles -z0 tests/overture-235/in.json",
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{\"@name\":\"String\",\"country\":\"String\",\"hierarchies\":\"String\",\"id\":\"String\",\"local_type\":\"String\",\"names\":\"String\",\"one\":\"String\",\"parent_division_id\":\"String\",\"region\":\"String\",\"sources\":\"String\",\"subtype\":\"String\",\"two\":\"String\",\"update_time\":\"String\",\"version\":\"Number\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":4,\"geometry\":\"Point\",\"attributeCount\":14,\"attributes\":[{\"attribute\":\"@name\",\"count\":2,\"type\":\"string\",\"values\":[\"Andenes\",\"Hammersmith And Fulham\"]},{\"attribute\":\"country\",\"count\":2,\"type\":\"string\",\"values\":[\"GB\",\"PE\"]},{\"attribute\":\"hierarchies\",\"count\":2,\"type\":\"string\",\"values\":[]},{\"attribute\":\"id\",\"count\":2,\"type\":\"string\",\"values\":[\"085070173fffffff014fa86038bb5217\",\"0856c5143fffffff0138e27e7a03f7d8\"]},{\"attribute\":\"local_type\",\"count\":2,\"type\":\"string\",\"values\":[\"{\\\"en\\\":\\\"county\\\"}\",\"{\\\"en\\\":\\\"hamlet\\\"}\"]},{\"attribute\":\"names\",\"count\":2,\"type\":\"string\",\"values\":[\"{\\\"primary\\\":\\\"Andenes\\\",\\\"common\\\":{\\\"en\\\":\\\"Andenes\\\",\\\"es\\\":\\\"Andenes\\\"},\\\"rules\\\":null}\",\"{\\\"primary\\\":\\\"Hammersmith And Fulham\\\",\\\"common\\\":null,\\\"rules\\\":null}\"]},{\"attribute\":\"one\",\"count\":1,\"type\":\"string\",\"values\":[\"Poull Bojer\"]},{\"attribute\":\"parent_division_id\",\"count\":2,\"type\":\"string\",\"values\":[\"085255dd7fffffff011aba243af254bd\",\"0856c53b7fffffff019e8d5b8b047485\"]},{\"attribute\":\"region\",\"count\":2,\"type\":\"string\",\"values\":[\"GB-ENG\",\"PE-ARE\"]},{\"attribute\":\"sources\",\"count\":2,\"type\":\"string\",\"values\":[\"[{\\\"property\\\":\\\"\\\",\\\"dataset\\\":\\\"OpenStreetMap\\\",\\\"record_id\\\":\\\"N3522957503\\\",\\\"confidence\\\":null}]\",\"[{\\\"property\\\":\\\"\\\",\\\"dataset\\\":\\\"geoBoundaries\\\",\\\"record_id\\\":\\\"GBR9080712B6991151074246\\\",\\\"confidence\\\":null}]\"]},{\"attribute\":\"subtype\",\"count\":2,\"type\":\"string\",\"values\":[\"county\",\"locality\"]},{\"attribute\":\"two\",\"count\":1,\"type\":\"string\",\"values\":[]},{\"attribute\":\"update_time\",\"count\":2,\"type\":\"string\",\"values\":[\"2024-05-11T06:56:01Z\",\"2024-05-11T06:57:45Z\"]},{\"attribute\":\"version\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0}]}]}}",
"maxzoom": "0",
"minzoom": "0",
"name": "tests/overture-235/out/-z0.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "id": 1096239, "properties": { "id": "085070173fffffff014fa86038bb5217", "@name": "Hammersmith And Fulham", "subtype": "county", "local_type": "{\"en\":\"county\"}", "country": "GB", "region": "GB-ENG", "hierarchies": "[[{\"division_id\":\"085eea613fffffff01a8a15aa3da4c44\",\"subtype\":\"country\",\"name\":\"United Kingdom\"},{\"division_id\":\"085255dd7fffffff011aba243af254bd\",\"subtype\":\"region\",\"name\":\"England\"},{\"division_id\":\"085070173fffffff014fa86038bb5217\",\"subtype\":\"county\",\"name\":\"Hammersmith And Fulham\"}]]", "parent_division_id": "085255dd7fffffff011aba243af254bd", "names": "{\"primary\":\"Hammersmith And Fulham\",\"common\":null,\"rules\":null}", "version": 0, "update_time": "2024-05-11T06:57:45Z", "sources": "[{\"property\":\"\",\"dataset\":\"geoBoundaries\",\"record_id\":\"GBR9080712B6991151074246\",\"confidence\":null}]" }, "geometry": { "type": "Point", "coordinates": [ -0.263672, 51.508742 ] } }
,
{ "type": "Feature", "id": 92526, "properties": { "id": "0856c5143fffffff0138e27e7a03f7d8", "@name": "Andenes", "subtype": "locality", "local_type": "{\"en\":\"hamlet\"}", "country": "PE", "region": "PE-ARE", "hierarchies": "[[{\"division_id\":\"085bc6b4ffffffff01fb3b67a2808435\",\"subtype\":\"country\",\"name\":\"Perú\"},{\"division_id\":\"08559acaffffffff01f27abb0a0cb14b\",\"subtype\":\"region\",\"name\":\"Arequipa\"},{\"division_id\":\"0856c834ffffffff01fd8ac1c98804cb\",\"subtype\":\"county\",\"name\":\"Caravelí\"},{\"division_id\":\"0856c53b7fffffff019e8d5b8b047485\",\"subtype\":\"locality\",\"name\":\"Chaparra\"},{\"division_id\":\"0856c5143fffffff0138e27e7a03f7d8\",\"subtype\":\"locality\",\"name\":\"Andenes\"}]]", "parent_division_id": "0856c53b7fffffff019e8d5b8b047485", "names": "{\"primary\":\"Andenes\",\"common\":{\"en\":\"Andenes\",\"es\":\"Andenes\"},\"rules\":null}", "version": 0, "update_time": "2024-05-11T06:56:01Z", "sources": "[{\"property\":\"\",\"dataset\":\"OpenStreetMap\",\"record_id\":\"N3522957503\",\"confidence\":null}]" }, "geometry": { "type": "Point", "coordinates": [ -73.828125, -15.707663 ] } }
,
{ "type": "Feature", "properties": { "one": "Poull Bojer" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
,
{ "type": "Feature", "properties": { "two": "[[{\"division_id\":\"085ec5c23fffffff01339442745f3d55\",\"subtype\":\"country\",\"name\":\"Ecuador\"},{\"division_id\":\"085dac297fffffff0147c020488d610d\",\"subtype\":\"region\",\"name\":\"Cotopaxi\"},{\"division_id\":\"085bf1b2ffffffff012715ee575c3475\",\"subtype\":\"county\",\"name\":\"Sigchos\"},{\"division_id\":\"085bf010ffffffff014f248c7b4fe243\",\"subtype\":\"locality\",\"name\":\"Sigchos\"},{\"division_id\":\"085bf03a3fffffff01145a02d706b16f\",\"subtype\":\"locality\",\"name\":\"Tiliguila\"}]]" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
] }
] }
] }
+33
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;
@@ -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;
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.55.0"
#define VERSION "v2.53.0"
#endif