mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 01:45:41 +02:00
Add a flag to select the rate at which points are dropped at low zooms.
This commit is contained in:
@@ -233,7 +233,7 @@ struct pool_val *deserialize_string(char **f, struct pool *p, int type) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy, char *layername, int maxzoom, int minzoom, sqlite3 *outdb) {
|
||||
void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy, char *layername, int maxzoom, int minzoom, sqlite3 *outdb, double droprate) {
|
||||
fprintf(stderr, "\n");
|
||||
long long most = 0;
|
||||
|
||||
@@ -269,7 +269,7 @@ void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, s
|
||||
|
||||
fprintf(stderr, " %3.1f%% %d/%u/%u %x %x %lld to %lld \r", (((i - ix) + (j - ix)) / 2.0 / n + (maxzoom - z)) / (maxzoom - minzoom + 1) * 100, z, tx, ty, wx, wy, (long long)(i - ix), (long long)(j - ix));
|
||||
|
||||
long long len = write_tile(i, j, metabase, file_bbox, z, tx, ty, z == maxzoom ? full_detail : low_detail, maxzoom, file_keys, layername, outdb);
|
||||
long long len = write_tile(i, j, metabase, file_bbox, z, tx, ty, z == maxzoom ? full_detail : low_detail, maxzoom, file_keys, layername, outdb, droprate);
|
||||
|
||||
if (z == maxzoom && len > most) {
|
||||
*midx = tx;
|
||||
@@ -282,7 +282,7 @@ void check(struct index *ix, long long n, char *metabase, unsigned *file_bbox, s
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom, sqlite3 *outdb, struct pool *exclude) {
|
||||
void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom, sqlite3 *outdb, struct pool *exclude, double droprate) {
|
||||
char metaname[] = "/tmp/meta.XXXXXXXX";
|
||||
char indexname[] = "/tmp/index.XXXXXXXX";
|
||||
|
||||
@@ -509,7 +509,7 @@ next_feature:
|
||||
}
|
||||
|
||||
qsort(index, indexst.st_size / sizeof(struct index), sizeof(struct index), indexcmp);
|
||||
check(index, indexst.st_size / sizeof(struct index), meta, file_bbox, &file_keys, &midx, &midy, layername, maxzoom, minzoom, outdb);
|
||||
check(index, indexst.st_size / sizeof(struct index), meta, file_bbox, &file_keys, &midx, &midy, layername, maxzoom, minzoom, outdb, droprate);
|
||||
|
||||
munmap(index, indexst.st_size);
|
||||
munmap(meta, metast.st_size);
|
||||
@@ -545,11 +545,12 @@ int main(int argc, char **argv) {
|
||||
int maxzoom = 14;
|
||||
int minzoom = 0;
|
||||
int force = 0;
|
||||
double droprate = 2.5;
|
||||
|
||||
struct pool exclude;
|
||||
pool_init(&exclude, 0);
|
||||
|
||||
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:x:f")) != -1) {
|
||||
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:x:r:f")) != -1) {
|
||||
switch (i) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
@@ -583,12 +584,16 @@ int main(int argc, char **argv) {
|
||||
pool(&exclude, optarg, VT_STRING);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
droprate = atof(optarg);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
force = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s -o out.mbtiles [-n name] [-l layername] [-z maxzoom] [-Z minzoom] [-d detail] [-D lower-detail] [-x excluded-field ...] [file.json]\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s -o out.mbtiles [-n name] [-l layername] [-z maxzoom] [-Z minzoom] [-d detail] [-D lower-detail] [-x excluded-field ...] [-r droprate] [file.json]\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -611,7 +616,7 @@ int main(int argc, char **argv) {
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
||||
} else {
|
||||
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb, &exclude);
|
||||
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb, &exclude, droprate);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
@@ -619,7 +624,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "%s: Only accepts one input file\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
read_json(stdin, name ? name : outdir, layer, maxzoom, minzoom, outdb, &exclude);
|
||||
read_json(stdin, name ? name : outdir, layer, maxzoom, minzoom, outdb, &exclude, droprate);
|
||||
}
|
||||
|
||||
mbtiles_close(outdb, argv);
|
||||
|
||||
Reference in New Issue
Block a user