mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-23 20:35:16 +00: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:
parent
9fb1208b79
commit
a320248857
2
Makefile
2
Makefile
@ -112,7 +112,7 @@ parallel-test:
|
||||
rm tests/parallel/*.mbtiles tests/parallel/*.json
|
||||
|
||||
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
|
||||
rm -rf tests/raw-tiles/raw-tiles
|
||||
|
||||
|
23
main.cpp
23
main.cpp
@ -57,6 +57,7 @@ static int full_detail = -1;
|
||||
static int min_detail = 7;
|
||||
|
||||
int quiet = 0;
|
||||
int outdirtable = 0;
|
||||
int geometry_scale = 0;
|
||||
double simplification = 1;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return ret;
|
||||
@ -1903,6 +1904,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"output-to-directory", required_argument, 0, 'e'},
|
||||
|
||||
{"name", 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-duplication", no_argument, &prevent[P_DUPLICATION], 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},
|
||||
};
|
||||
@ -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) {
|
||||
case 0:
|
||||
break;
|
||||
@ -2063,6 +2065,11 @@ int main(int argc, char **argv) {
|
||||
outdir = optarg;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
outpbfdir = optarg;
|
||||
outdirtable = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
exclude.insert(std::string(optarg));
|
||||
break;
|
||||
@ -2244,8 +2251,8 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "Forcing -g0 since -B or -r is not known\n");
|
||||
}
|
||||
|
||||
if (outdir == NULL) {
|
||||
fprintf(stderr, "%s: must specify -o out.mbtiles\n", argv[0]);
|
||||
if (outdir == NULL && outpbfdir == NULL) {
|
||||
fprintf(stderr, "%s: must specify -o out.mbtiles or -e directory\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -2253,10 +2260,8 @@ int main(int argc, char **argv) {
|
||||
unlink(outdir);
|
||||
}
|
||||
|
||||
if(!prevent[P_PBF_COMPRESSION]){
|
||||
if (!outdirtable) {
|
||||
outdb = mbtiles_open(outdir, argv, forcetable);
|
||||
}else{
|
||||
outpbfdir = outdir;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if(!prevent[P_PBF_COMPRESSION])
|
||||
if (!outdirtable)
|
||||
mbtiles_close(outdb, argv);
|
||||
|
||||
#ifdef MTRACE
|
||||
|
2
main.hpp
2
main.hpp
@ -11,7 +11,7 @@ void checkdisk(struct reader *r, int nreader);
|
||||
|
||||
extern int geometry_scale;
|
||||
extern int quiet;
|
||||
|
||||
extern int outdirtable;
|
||||
extern char *outpbfdir;
|
||||
|
||||
extern size_t CPUS;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define P_CLIPPING ((int) 'c')
|
||||
#define P_DUPLICATION ((int) 'D')
|
||||
#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 additional[256];
|
||||
|
@ -7,14 +7,14 @@
|
||||
void write_raw_tile(char *outdir, int z, int tx, int ty, std::string pbf) {
|
||||
mkdir(outdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
std::string curdir(outdir);
|
||||
std::string slash( "/" );
|
||||
std::string slash("/");
|
||||
std::string newdir = curdir + slash + std::to_string(z);
|
||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
newdir = newdir + "/" + std::to_string(tx);
|
||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
|
||||
|
||||
std::ofstream pbfFile (newdir, std::ios::out | std::ios::binary);
|
||||
pbfFile.write (pbf.data(), pbf.size());
|
||||
std::ofstream pbfFile(newdir, std::ios::out | std::ios::binary);
|
||||
pbfFile.write(pbf.data(), pbf.size());
|
||||
pbfFile.close();
|
||||
}
|
12
tile.cpp
12
tile.cpp
@ -1841,9 +1841,9 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
std::string compressed;
|
||||
std::string pbf = tile.encode();
|
||||
|
||||
if(!prevent[P_PBF_COMPRESSION]){
|
||||
if (!prevent[P_TILE_COMPRESSION]) {
|
||||
compress(pbf, compressed);
|
||||
}else{
|
||||
} else {
|
||||
compressed = pbf;
|
||||
}
|
||||
|
||||
@ -1917,10 +1917,10 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(!prevent[P_PBF_COMPRESSION]){
|
||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||
}else{
|
||||
write_raw_tile(outpbfdir, z, tx, ty, pbf);
|
||||
if (!outdirtable) {
|
||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||
} else {
|
||||
write_raw_tile(outpbfdir, z, tx, ty, compressed);
|
||||
}
|
||||
|
||||
if (pthread_mutex_unlock(&db_lock) != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user