mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Add --cluster-maxzoom option (#75)
* Add `--cluster-maxzoom` option * Add tests, update changelog * Update manpage * Update tests --------- Co-authored-by: Aurele Nitoref <aurele.nitoref@icloud.com>
This commit is contained in:
co-authored by
Aurele Nitoref
parent
3d714e32b0
commit
329dd86bfd
@@ -82,6 +82,7 @@ size_t max_tile_size = 500000;
|
||||
size_t max_tile_features = 200000;
|
||||
int cluster_distance = 0;
|
||||
int tiny_polygon_size = 2;
|
||||
int cluster_maxzoom = MAX_ZOOM;
|
||||
long justx = -1, justy = -1;
|
||||
std::string attribute_for_id = "";
|
||||
size_t limit_tile_feature_count = 0;
|
||||
@@ -1163,7 +1164,7 @@ void choose_first_zoom(long long *file_bbox, std::vector<struct reader> &readers
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, std::map<std::string, int> const *attribute_types, const char *pgm, std::map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
|
||||
std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, bool guess_cluster_maxzoom, std::map<std::string, int> const *attribute_types, const char *pgm, std::map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
std::vector<struct reader> readers;
|
||||
@@ -2102,7 +2103,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
while (maxzoom < 32 - full_detail && maxzoom < 33 - low_detail && cluster_distance > 0) {
|
||||
while (maxzoom < 32 - full_detail && maxzoom < 33 - low_detail && maxzoom < cluster_maxzoom && cluster_distance > 0) {
|
||||
unsigned long long zoom_mingap = ((1LL << (32 - maxzoom)) / 256 * cluster_distance) * ((1LL << (32 - maxzoom)) / 256 * cluster_distance);
|
||||
if (avg > zoom_mingap) {
|
||||
break;
|
||||
@@ -2112,7 +2113,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
printf("Choosing a maxzoom of -z%d to keep most features distinct with cluster distance %d\n", maxzoom, cluster_distance);
|
||||
printf("Choosing a maxzoom of -z%d to keep most features distinct with cluster distance %d and cluster maxzoom %d\n", maxzoom, cluster_distance, cluster_maxzoom);
|
||||
}
|
||||
|
||||
if (droprate == -3) {
|
||||
@@ -2203,6 +2204,11 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
}
|
||||
}
|
||||
|
||||
if (cluster_maxzoom >= maxzoom && guess_cluster_maxzoom) {
|
||||
cluster_maxzoom = maxzoom - 1;
|
||||
fprintf(stderr, "Choosing a cluster maxzoom of -k%d to make all features visible at maximum zoom %d\n", cluster_maxzoom, maxzoom);
|
||||
}
|
||||
|
||||
if (basezoom < 0 || droprate < 0) {
|
||||
struct tile {
|
||||
unsigned x;
|
||||
@@ -2692,6 +2698,7 @@ int main(int argc, char **argv) {
|
||||
const char *postfilter = NULL;
|
||||
bool guess_maxzoom = false;
|
||||
int minimum_maxzoom = 0;
|
||||
bool guess_cluster_maxzoom = false;
|
||||
|
||||
std::set<std::string> exclude, include;
|
||||
std::map<std::string, int> attribute_types;
|
||||
@@ -2770,6 +2777,7 @@ int main(int argc, char **argv) {
|
||||
{"drop-lines", no_argument, &additional[A_LINE_DROP], 1},
|
||||
{"drop-polygons", no_argument, &additional[A_POLYGON_DROP], 1},
|
||||
{"cluster-distance", required_argument, 0, 'K'},
|
||||
{"cluster-maxzoom", required_argument, 0, 'k'},
|
||||
|
||||
{"Dropping or merging a fraction of features to keep under tile size limits", 0, 0, 0},
|
||||
{"drop-densest-as-needed", no_argument, &additional[A_DROP_DENSEST_AS_NEEDED], 1},
|
||||
@@ -3073,6 +3081,15 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
if (strcmp(optarg, "g") == 0) {
|
||||
cluster_maxzoom = MAX_ZOOM - 1;
|
||||
guess_cluster_maxzoom = true;
|
||||
} else {
|
||||
cluster_maxzoom = atoi_require(optarg, "Cluster maxzoom");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
full_detail = atoi_require(optarg, "Full detail");
|
||||
if (full_detail > 30) {
|
||||
@@ -3484,7 +3501,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
auto input_ret = read_input(sources, name ? name : out_mbtiles ? out_mbtiles
|
||||
: out_dir,
|
||||
maxzoom, minzoom, basezoom, basezoom_marker_width, outdb, out_dir, &exclude, &include, exclude_all, filter, droprate, buffer, tmpdir, gamma, read_parallel, forcetable, attribution, gamma != 0, file_bbox, prefilter, postfilter, description, guess_maxzoom, &attribute_types, argv[0], &attribute_accum, attribute_descriptions, commandline, minimum_maxzoom);
|
||||
maxzoom, minzoom, basezoom, basezoom_marker_width, outdb, out_dir, &exclude, &include, exclude_all, filter, droprate, buffer, tmpdir, gamma, read_parallel, forcetable, attribution, gamma != 0, file_bbox, prefilter, postfilter, description, guess_maxzoom, guess_cluster_maxzoom, &attribute_types, argv[0], &attribute_accum, attribute_descriptions, commandline, minimum_maxzoom);
|
||||
|
||||
ret = std::get<0>(input_ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user