Add an attribute for square root of cluster count

This commit is contained in:
Eric Fischer 2018-02-26 12:53:43 -08:00
parent e4e39289a2
commit 06ed9d14d8
6 changed files with 3821 additions and 3814 deletions

View File

@ -217,7 +217,7 @@ tippecanoe -z5 -o filtered.mbtiles -j '{ "ne_10m_admin_0_countries": [ "all", [
* `-aD` or `--coalesce-densest-as-needed`: Dynamically combine the densest features from each zoom level into other nearby features to keep large tiles under the 500K size limit. (Again, mostly useful for polygons.)
* `-aS` or `--coalesce-fraction-as-needed`: Dynamically combine a fraction of features from each zoom level into other nearby features to keep large tiles under the 500K size limit. (Again, mostly useful for polygons.)
* `-pd` or `--force-feature-limit`: Dynamically drop some fraction of features from large tiles to keep them under the 500K size limit. It will probably look ugly at the tile boundaries. (This is like `-ad` but applies to each tile individually, not to the entire zoom level.) You probably don't want to use this.
* `-aC` or `--cluster-densest-as-needed`: If a tile is too large, try to reduce its size by increasing the minimum spacing between features, and leaving one placeholder feature from each group. The remaining feature will be given a `"cluster": true` attribute to indicate that it represents a cluster and a `"point_count"` attribute to indicate the number of features that were clustered into it.
* `-aC` or `--cluster-densest-as-needed`: If a tile is too large, try to reduce its size by increasing the minimum spacing between features, and leaving one placeholder feature from each group. The remaining feature will be given a `"cluster": true` attribute to indicate that it represents a cluster, a `"point_count"` attribute to indicate the number of features that were clustered into it, and a `"sqrt_point_count"` attribute to indicate the relative width of a feature to represent the cluster.
### Dropping tightly overlapping features

View File

@ -256,7 +256,7 @@ compensate for the larger marker, or \fB\fC\-Bf\fR\fInumber\fP to allow at most
.IP \(bu 2
\fB\fC\-pd\fR or \fB\fC\-\-force\-feature\-limit\fR: Dynamically drop some fraction of features from large tiles to keep them under the 500K size limit. It will probably look ugly at the tile boundaries. (This is like \fB\fC\-ad\fR but applies to each tile individually, not to the entire zoom level.) You probably don't want to use this.
.IP \(bu 2
\fB\fC\-aC\fR or \fB\fC\-\-cluster\-densest\-as\-needed\fR: If a tile is too large, try to reduce its size by increasing the minimum spacing between features, and leaving one placeholder feature from each group. The remaining feature will be given a \fB\fC"cluster": true\fR attribute to indicate that it represents a cluster and a \fB\fC"point_count"\fR attribute to indicate the number of features that were clustered into it.
\fB\fC\-aC\fR or \fB\fC\-\-cluster\-densest\-as\-needed\fR: If a tile is too large, try to reduce its size by increasing the minimum spacing between features, and leaving one placeholder feature from each group. The remaining feature will be given a \fB\fC"cluster": true\fR attribute to indicate that it represents a cluster, a \fB\fC"point_count"\fR attribute to indicate the number of features that were clustered into it, and a \fB\fC"sqrt_point_count"\fR attribute to indicate the relative width of a feature to represent the cluster.
.RE
.SS Dropping tightly overlapping features
.RS

View File

@ -3,7 +3,7 @@
"center": "1.000000,1.000000,0",
"description": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
"format": "pbf",
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"clustered\": \"Boolean\", \"point_count\": \"Number\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 1000,\"geometry\": \"Point\",\"attributeCount\": 2,\"attributes\": [{\"attribute\": \"clustered\",\"count\": 1,\"type\": \"boolean\",\"values\": [true]},{\"attribute\": \"point_count\",\"count\": 1,\"type\": \"number\",\"values\": [1000],\"min\": 1000,\"max\": 1000}]}]}}",
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"clustered\": \"Boolean\", \"point_count\": \"Number\", \"sqrt_point_count\": \"Number\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 1000,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"clustered\",\"count\": 1,\"type\": \"boolean\",\"values\": [true]},{\"attribute\": \"point_count\",\"count\": 1,\"type\": \"number\",\"values\": [1000],\"min\": 1000,\"max\": 1000},{\"attribute\": \"sqrt_point_count\",\"count\": 1,\"type\": \"number\",\"values\": [31.620000],\"min\": 31.62,\"max\": 31.62}]}]}}",
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
@ -12,7 +12,7 @@
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { "clustered": true, "point_count": 1000 }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 1.054628 ] } }
{ "type": "Feature", "properties": { "clustered": true, "point_count": 1000, "sqrt_point_count": 31.62 }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 1.054628 ] } }
] }
] }
] }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1754,7 +1754,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
if (p.clustered > 0) {
std::string layername = (*layer_unmaps)[p.segment][p.layer];
serial_val sv, sv2;
serial_val sv, sv2, sv3;
p.full_keys.push_back("clustered");
sv.type = mvt_bool;
@ -1769,6 +1769,13 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
p.full_values.push_back(sv2);
add_tilestats(layername, z, layermaps, tiling_seg, layer_unmaps, "point_count", sv2);
p.full_keys.push_back("sqrt_point_count");
sv3.type = mvt_double;
sv3.s = std::to_string(round(100 * sqrt(p.clustered + 1)) / 100.0);
p.full_values.push_back(sv3);
add_tilestats(layername, z, layermaps, tiling_seg, layer_unmaps, "sqrt_point_count", sv3);
}
if (p.need_tilestats.size() > 0) {