mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Merge branch 'master' into multithread
This commit is contained in:
@@ -92,6 +92,7 @@ Options
|
|||||||
* -po: Don't reorder features to put the same properties in sequence
|
* -po: Don't reorder features to put the same properties in sequence
|
||||||
* -pl: Let "dot" simplification apply to lines too
|
* -pl: Let "dot" simplification apply to lines too
|
||||||
* -pd: 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.
|
* -pd: 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.
|
||||||
|
* -q: Work quietly instead of reporting progress
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
int low_detail = 10;
|
int low_detail = 10;
|
||||||
int full_detail = -1;
|
int full_detail = -1;
|
||||||
int min_detail = 7;
|
int min_detail = 7;
|
||||||
|
int quiet = 0;
|
||||||
|
|
||||||
unsigned initial_x = 0, initial_y = 0;
|
unsigned initial_x = 0, initial_y = 0;
|
||||||
int geometry_scale = 0;
|
int geometry_scale = 0;
|
||||||
@@ -297,7 +298,9 @@ static void merge(struct merge *merges, int nmerges, unsigned char *map, FILE *f
|
|||||||
along++;
|
along++;
|
||||||
long long report = 100 * along / nrec;
|
long long report = 100 * along / nrec;
|
||||||
if (report != reported) {
|
if (report != reported) {
|
||||||
fprintf(stderr, "Merging: %lld%%\r", report);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "Merging: %lld%%\r", report);
|
||||||
|
}
|
||||||
reported = report;
|
reported = report;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -705,7 +708,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (seq % 10000 == 0) {
|
if (seq % 10000 == 0) {
|
||||||
fprintf(stderr, "Read %.2f million features\r", seq / 1000000.0);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "Read %.2f million features\r", seq / 1000000.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seq++;
|
seq++;
|
||||||
}
|
}
|
||||||
@@ -794,7 +799,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
}
|
}
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
|
|
||||||
printf("using layer %d name %s\n", i, trunc);
|
if (!quiet) {
|
||||||
|
printf("using layer %d name %s\n", i, trunc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +809,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
|
|
||||||
{
|
{
|
||||||
int bytes = sizeof(struct index);
|
int bytes = sizeof(struct index);
|
||||||
fprintf(stderr, "Sorting %lld features\n", (long long) indexpos / bytes);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "Sorting %lld features\n", (long long) indexpos / bytes);
|
||||||
|
}
|
||||||
|
|
||||||
int page = sysconf(_SC_PAGESIZE);
|
int page = sysconf(_SC_PAGESIZE);
|
||||||
long long unit = (50 * 1024 * 1024 / bytes) * bytes;
|
long long unit = (50 * 1024 * 1024 / bytes) * bytes;
|
||||||
@@ -821,7 +830,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nmerges != 1) {
|
if (nmerges != 1) {
|
||||||
fprintf(stderr, "Sorting part %lld of %d\r", start / unit + 1, nmerges);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "Sorting part %lld of %d\r", start / unit + 1, nmerges);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
merges[start / unit].start = start;
|
merges[start / unit].start = start;
|
||||||
@@ -853,7 +864,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nmerges != 1) {
|
if (nmerges != 1) {
|
||||||
fprintf(stderr, "\n");
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *map = mmap(NULL, indexpos, PROT_READ, MAP_PRIVATE, indexfd, 0);
|
void *map = mmap(NULL, indexpos, PROT_READ, MAP_PRIVATE, indexfd, 0);
|
||||||
@@ -927,7 +940,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
|
|
||||||
long long p = 1000 * i / (indexpos / sizeof(struct index));
|
long long p = 1000 * i / (indexpos / sizeof(struct index));
|
||||||
if (p != progress) {
|
if (p != progress) {
|
||||||
fprintf(stderr, "Reordering geometry: %3.1f%%\r", p / 10.0);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "Reordering geometry: %3.1f%%\r", p / 10.0);
|
||||||
|
}
|
||||||
progress = p;
|
progress = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -972,7 +987,9 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
size[j] = 0;
|
size[j] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "%lld features, %lld bytes of geometry, %lld bytes of metadata, %lld bytes of string pool\n", seq, (long long) geomst.st_size, (long long) metast.st_size, poolfile->off);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "%lld features, %lld bytes of geometry, %lld bytes of metadata, %lld bytes of string pool\n", seq, (long long) geomst.st_size, (long long) metast.st_size, poolfile->off);
|
||||||
|
}
|
||||||
|
|
||||||
int written = traverse_zooms(fd, size, meta, stringpool, file_bbox, file_keys, &midx, &midy, layernames, maxzoom, minzoom, outdb, droprate, buffer, fname, tmpdir, gamma, nlayers, prevent, full_detail, low_detail, min_detail);
|
int written = traverse_zooms(fd, size, meta, stringpool, file_bbox, file_keys, &midx, &midy, layernames, maxzoom, minzoom, outdb, droprate, buffer, fname, tmpdir, gamma, nlayers, prevent, full_detail, low_detail, min_detail);
|
||||||
|
|
||||||
@@ -1052,7 +1069,7 @@ int main(int argc, char **argv) {
|
|||||||
prevent[i] = 0;
|
prevent[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:m:o:x:y:r:b:fXt:g:p:v")) != -1) {
|
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:m:o:x:y:r:b:fXt:g:p:vq")) != -1) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'n':
|
case 'n':
|
||||||
name = optarg;
|
name = optarg;
|
||||||
@@ -1119,6 +1136,10 @@ int main(int argc, char **argv) {
|
|||||||
gamma = atof(optarg);
|
gamma = atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'q':
|
||||||
|
quiet = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'p': {
|
case 'p': {
|
||||||
char *cp;
|
char *cp;
|
||||||
for (cp = optarg; *cp != '\0'; cp++) {
|
for (cp = optarg; *cp != '\0'; cp++) {
|
||||||
|
|||||||
+3
-1
@@ -78,7 +78,7 @@ it encounters.
|
|||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\-m \fIdetail\fP: Minimum detail that it will try if tiles are too big at regular detail (default 7)
|
\-m \fIdetail\fP: Minimum detail that it will try if tiles are too big at regular detail (default 7)
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\-b \fIpixels\fP: Buffer size where features are duplicated from adjacent tiles (default 5)
|
\-b \fIpixels\fP: Buffer size where features are duplicated from adjacent tiles. Units are "screen pixels"\-\-1/256th of the tile width or height. (default 5)
|
||||||
.RE
|
.RE
|
||||||
.SS Properties
|
.SS Properties
|
||||||
.RS
|
.RS
|
||||||
@@ -114,6 +114,8 @@ it encounters.
|
|||||||
\-pl: Let "dot" simplification apply to lines too
|
\-pl: Let "dot" simplification apply to lines too
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\-pd: 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.
|
\-pd: 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.
|
||||||
|
.IP \(bu 2
|
||||||
|
\-q: Work quietly instead of reporting progress
|
||||||
.RE
|
.RE
|
||||||
.SH Example
|
.SH Example
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
@@ -547,7 +547,9 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, unsigned *f
|
|||||||
|
|
||||||
double progress = floor((((*geoms - geomstart + along) / (double) todo) + z) / (file_maxzoom + 1) * 1000) / 10;
|
double progress = floor((((*geoms - geomstart + along) / (double) todo) + z) / (file_maxzoom + 1) * 1000) / 10;
|
||||||
if (progress != oprogress) {
|
if (progress != oprogress) {
|
||||||
fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty);
|
||||||
|
}
|
||||||
oprogress = progress;
|
oprogress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,7 +768,9 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, unsigned *f
|
|||||||
compress(s, compressed);
|
compress(s, compressed);
|
||||||
|
|
||||||
if (compressed.size() > 500000 && !prevent['k' & 0xFF]) {
|
if (compressed.size() > 500000 && !prevent['k' & 0xFF]) {
|
||||||
fprintf(stderr, "tile %d/%u/%u size is %lld with detail %d, >500000 \n", z, tx, ty, (long long) compressed.size(), line_detail);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "tile %d/%u/%u size is %lld with detail %d, >500000 \n", z, tx, ty, (long long) compressed.size(), line_detail);
|
||||||
|
}
|
||||||
|
|
||||||
if (line_detail == min_detail || !evaluated) {
|
if (line_detail == min_detail || !evaluated) {
|
||||||
evaluated = true;
|
evaluated = true;
|
||||||
@@ -780,7 +784,9 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, unsigned *f
|
|||||||
// and probably actually varies based on how much duplicated metadata there is
|
// and probably actually varies based on how much duplicated metadata there is
|
||||||
|
|
||||||
fraction = fraction * 500000 / compressed.size() * 0.95;
|
fraction = fraction * 500000 / compressed.size() * 0.95;
|
||||||
fprintf(stderr, "Going to try keeping %0.2f%% of the features to make it fit\n", fraction * 100);
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "Going to try keeping %0.2f%% of the features to make it fit\n", fraction * 100);
|
||||||
|
}
|
||||||
line_detail++; // to keep it the same when the loop decrements it
|
line_detail++; // to keep it the same when the loop decrements it
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -903,6 +909,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
if (!quiet) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
return maxzoom;
|
return maxzoom;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,5 +31,6 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
|
|||||||
|
|
||||||
extern unsigned initial_x, initial_y;
|
extern unsigned initial_x, initial_y;
|
||||||
extern int geometry_scale;
|
extern int geometry_scale;
|
||||||
|
extern int quiet;
|
||||||
|
|
||||||
#define TEMP_FILES 64
|
#define TEMP_FILES 64
|
||||||
|
|||||||
Reference in New Issue
Block a user