mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Add options to specify the base and low-zoom level of detail
This commit is contained in:
@@ -17,6 +17,9 @@
|
|||||||
#include "jsonpull.h"
|
#include "jsonpull.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
|
||||||
|
int low_detail = 10;
|
||||||
|
int full_detail = 12;
|
||||||
|
|
||||||
#define GEOM_POINT 0 /* array of positions */
|
#define GEOM_POINT 0 /* array of positions */
|
||||||
#define GEOM_MULTIPOINT 1 /* array of arrays of positions */
|
#define GEOM_MULTIPOINT 1 /* array of arrays of positions */
|
||||||
#define GEOM_LINESTRING 2 /* array of arrays of positions */
|
#define GEOM_LINESTRING 2 /* array of arrays of positions */
|
||||||
@@ -359,7 +362,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));
|
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 ? 12 : 10, 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);
|
||||||
|
|
||||||
if (z == maxzoom && len > most) {
|
if (z == maxzoom && len > most) {
|
||||||
*midx = tx;
|
*midx = tx;
|
||||||
@@ -409,7 +412,7 @@ void aprintf(char **buf, const char *format, ...) {
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom, char *outdir, sqlite3 *outdb) {
|
void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom, sqlite3 *outdb) {
|
||||||
char metaname[] = "/tmp/meta.XXXXXXXX";
|
char metaname[] = "/tmp/meta.XXXXXXXX";
|
||||||
char indexname[] = "/tmp/index.XXXXXXXX";
|
char indexname[] = "/tmp/index.XXXXXXXX";
|
||||||
|
|
||||||
@@ -750,7 +753,7 @@ int main(int argc, char **argv) {
|
|||||||
int maxzoom = 14;
|
int maxzoom = 14;
|
||||||
int minzoom = 0;
|
int minzoom = 0;
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "l:n:z:Z:o:")) != -1) {
|
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:")) != -1) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'n':
|
case 'n':
|
||||||
name = optarg;
|
name = optarg;
|
||||||
@@ -768,12 +771,20 @@ int main(int argc, char **argv) {
|
|||||||
minzoom = atoi(optarg);
|
minzoom = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
full_detail = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
low_detail = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
outdir = optarg;
|
outdir = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Usage: %s -o out.mbtiles [-n name] [-l layername] [-z maxzoom] [-Z minzoom] 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] file.json ...\n", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -826,14 +837,12 @@ int main(int argc, char **argv) {
|
|||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
// XXX
|
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb);
|
||||||
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, "tiles", outdb);
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// XXX
|
read_json(stdin, name ? name : "standard input", layer, maxzoom, minzoom, outdb);
|
||||||
read_json(stdin, name ? name : "standard input", layer, maxzoom, minzoom, "tiles", outdb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqlite3_exec(outdb, "ANALYZE;", NULL, NULL, &err) != SQLITE_OK) {
|
if (sqlite3_exec(outdb, "ANALYZE;", NULL, NULL, &err) != SQLITE_OK) {
|
||||||
@@ -844,6 +853,10 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "%s: index tiles: %s\n", argv[0], err);
|
fprintf(stderr, "%s: index tiles: %s\n", argv[0], err);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
if (sqlite3_close(outdb) != SQLITE_OK) {
|
||||||
|
fprintf(stderr, "%s: could not close database: %s\n", argv[0], sqlite3_errmsg(outdb));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ void douglas_peucker(struct draw *geom, int n, double e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int simplify_lines(struct draw *geom, int n, int z, int detail) {
|
int simplify_lines(struct draw *geom, int n, int z, int detail) {
|
||||||
int res = 1 << (32 - 10 - z); // 1/4 pixel
|
int res = 1 << (32 - detail - z);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user