mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Do make indent, add flag --output-to-directory or -e to write pbf files to a directory, also add flag --no-tile-compression or -pC to get raw protobuf
This commit is contained in:
@@ -112,7 +112,7 @@ parallel-test:
|
|||||||
rm tests/parallel/*.mbtiles tests/parallel/*.json
|
rm tests/parallel/*.mbtiles tests/parallel/*.json
|
||||||
|
|
||||||
raw-tiles-test:
|
raw-tiles-test:
|
||||||
./tippecanoe -o tests/raw-tiles/raw-tiles tests/raw-tiles/hackspots.geojson --raw-tiles
|
./tippecanoe -e tests/raw-tiles/raw-tiles tests/raw-tiles/hackspots.geojson -pC
|
||||||
diff -x '.*' -rq tests/raw-tiles/raw-tiles tests/raw-tiles/compare
|
diff -x '.*' -rq tests/raw-tiles/raw-tiles tests/raw-tiles/compare
|
||||||
rm -rf tests/raw-tiles/raw-tiles
|
rm -rf tests/raw-tiles/raw-tiles
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ static int full_detail = -1;
|
|||||||
static int min_detail = 7;
|
static int min_detail = 7;
|
||||||
|
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
|
int outdirtable = 0;
|
||||||
int geometry_scale = 0;
|
int geometry_scale = 0;
|
||||||
double simplification = 1;
|
double simplification = 1;
|
||||||
size_t max_tile_size = 500000;
|
size_t max_tile_size = 500000;
|
||||||
@@ -1846,7 +1847,7 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
|||||||
ai->second.maxzoom = maxzoom;
|
ai->second.maxzoom = maxzoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!prevent[P_PBF_COMPRESSION])
|
if (!outdirtable)
|
||||||
mbtiles_write_metadata(outdb, fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, forcetable, attribution, merged_lm, true, description);
|
mbtiles_write_metadata(outdb, fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, forcetable, attribution, merged_lm, true, description);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1903,6 +1904,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"output", required_argument, 0, 'o'},
|
{"output", required_argument, 0, 'o'},
|
||||||
|
{"output-to-directory", required_argument, 0, 'e'},
|
||||||
|
|
||||||
{"name", required_argument, 0, 'n'},
|
{"name", required_argument, 0, 'n'},
|
||||||
{"description", required_argument, 0, 'N'},
|
{"description", required_argument, 0, 'N'},
|
||||||
@@ -1960,7 +1962,7 @@ int main(int argc, char **argv) {
|
|||||||
{"no-clipping", no_argument, &prevent[P_CLIPPING], 1},
|
{"no-clipping", no_argument, &prevent[P_CLIPPING], 1},
|
||||||
{"no-duplication", no_argument, &prevent[P_DUPLICATION], 1},
|
{"no-duplication", no_argument, &prevent[P_DUPLICATION], 1},
|
||||||
{"no-tiny-polygon-reduction", no_argument, &prevent[P_TINY_POLYGON_REDUCTION], 1},
|
{"no-tiny-polygon-reduction", no_argument, &prevent[P_TINY_POLYGON_REDUCTION], 1},
|
||||||
{"raw-tiles", no_argument, &prevent[P_PBF_COMPRESSION], 1},
|
{"no-tile-compression", no_argument, &prevent[P_TILE_COMPRESSION], 1},
|
||||||
|
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
@@ -1983,7 +1985,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((i = getopt_long(argc, argv, "n:l:z:Z:B:d:D:m:o:x:y:r:b:t:g:p:a:XfFqvPL:A:s:S:M:N:", long_options, NULL)) != -1) {
|
while ((i = getopt_long(argc, argv, "n:l:z:Z:B:d:D:m:o:e:x:y:r:b:t:g:p:a:XfFqvPL:A:s:S:M:N:", long_options, NULL)) != -1) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@@ -2063,6 +2065,11 @@ int main(int argc, char **argv) {
|
|||||||
outdir = optarg;
|
outdir = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'e':
|
||||||
|
outpbfdir = optarg;
|
||||||
|
outdirtable = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
exclude.insert(std::string(optarg));
|
exclude.insert(std::string(optarg));
|
||||||
break;
|
break;
|
||||||
@@ -2244,8 +2251,8 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "Forcing -g0 since -B or -r is not known\n");
|
fprintf(stderr, "Forcing -g0 since -B or -r is not known\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outdir == NULL) {
|
if (outdir == NULL && outpbfdir == NULL) {
|
||||||
fprintf(stderr, "%s: must specify -o out.mbtiles\n", argv[0]);
|
fprintf(stderr, "%s: must specify -o out.mbtiles or -e directory\n", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2253,10 +2260,8 @@ int main(int argc, char **argv) {
|
|||||||
unlink(outdir);
|
unlink(outdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!prevent[P_PBF_COMPRESSION]){
|
if (!outdirtable) {
|
||||||
outdb = mbtiles_open(outdir, argv, forcetable);
|
outdb = mbtiles_open(outdir, argv, forcetable);
|
||||||
}else{
|
|
||||||
outpbfdir = outdir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
@@ -2285,7 +2290,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
ret = read_input(sources, name ? name : outdir, maxzoom, minzoom, basezoom, basezoom_marker_width, outdb, &exclude, &include, exclude_all, droprate, buffer, tmpdir, gamma, read_parallel, forcetable, attribution, gamma != 0, file_bbox, description);
|
ret = read_input(sources, name ? name : outdir, maxzoom, minzoom, basezoom, basezoom_marker_width, outdb, &exclude, &include, exclude_all, droprate, buffer, tmpdir, gamma, read_parallel, forcetable, attribution, gamma != 0, file_bbox, description);
|
||||||
|
|
||||||
if(!prevent[P_PBF_COMPRESSION])
|
if (!outdirtable)
|
||||||
mbtiles_close(outdb, argv);
|
mbtiles_close(outdb, argv);
|
||||||
|
|
||||||
#ifdef MTRACE
|
#ifdef MTRACE
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ void checkdisk(struct reader *r, int nreader);
|
|||||||
|
|
||||||
extern int geometry_scale;
|
extern int geometry_scale;
|
||||||
extern int quiet;
|
extern int quiet;
|
||||||
|
extern int outdirtable;
|
||||||
extern char *outpbfdir;
|
extern char *outpbfdir;
|
||||||
|
|
||||||
extern size_t CPUS;
|
extern size_t CPUS;
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
#define P_CLIPPING ((int) 'c')
|
#define P_CLIPPING ((int) 'c')
|
||||||
#define P_DUPLICATION ((int) 'D')
|
#define P_DUPLICATION ((int) 'D')
|
||||||
#define P_TINY_POLYGON_REDUCTION ((int) 't')
|
#define P_TINY_POLYGON_REDUCTION ((int) 't')
|
||||||
#define P_PBF_COMPRESSION ((int) 'C')
|
#define P_TILE_COMPRESSION ((int) 'C')
|
||||||
|
|
||||||
extern int prevent[256];
|
extern int prevent[256];
|
||||||
extern int additional[256];
|
extern int additional[256];
|
||||||
|
|||||||
+3
-3
@@ -7,14 +7,14 @@
|
|||||||
void write_raw_tile(char *outdir, int z, int tx, int ty, std::string pbf) {
|
void write_raw_tile(char *outdir, int z, int tx, int ty, std::string pbf) {
|
||||||
mkdir(outdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
mkdir(outdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
std::string curdir(outdir);
|
std::string curdir(outdir);
|
||||||
std::string slash( "/" );
|
std::string slash("/");
|
||||||
std::string newdir = curdir + slash + std::to_string(z);
|
std::string newdir = curdir + slash + std::to_string(z);
|
||||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
newdir = newdir + "/" + std::to_string(tx);
|
newdir = newdir + "/" + std::to_string(tx);
|
||||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
|
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
|
||||||
|
|
||||||
std::ofstream pbfFile (newdir, std::ios::out | std::ios::binary);
|
std::ofstream pbfFile(newdir, std::ios::out | std::ios::binary);
|
||||||
pbfFile.write (pbf.data(), pbf.size());
|
pbfFile.write(pbf.data(), pbf.size());
|
||||||
pbfFile.close();
|
pbfFile.close();
|
||||||
}
|
}
|
||||||
@@ -1841,9 +1841,9 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
|||||||
std::string compressed;
|
std::string compressed;
|
||||||
std::string pbf = tile.encode();
|
std::string pbf = tile.encode();
|
||||||
|
|
||||||
if(!prevent[P_PBF_COMPRESSION]){
|
if (!prevent[P_TILE_COMPRESSION]) {
|
||||||
compress(pbf, compressed);
|
compress(pbf, compressed);
|
||||||
}else{
|
} else {
|
||||||
compressed = pbf;
|
compressed = pbf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1917,10 +1917,10 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!prevent[P_PBF_COMPRESSION]){
|
if (!outdirtable) {
|
||||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||||
}else{
|
} else {
|
||||||
write_raw_tile(outpbfdir, z, tx, ty, pbf);
|
write_raw_tile(outpbfdir, z, tx, ty, compressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_unlock(&db_lock) != 0) {
|
if (pthread_mutex_unlock(&db_lock) != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user