mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-04 17:35:42 +02:00
Add flag --raw-tiles or -pC to get raw protobuf
This commit is contained in:
@@ -69,6 +69,8 @@ struct source {
|
|||||||
std::string file;
|
std::string file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char *outpbfdir;
|
||||||
|
|
||||||
size_t CPUS;
|
size_t CPUS;
|
||||||
size_t TEMP_FILES;
|
size_t TEMP_FILES;
|
||||||
long long MAX_FILES;
|
long long MAX_FILES;
|
||||||
@@ -1843,7 +1845,9 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
|||||||
ai->second.minzoom = minzoom;
|
ai->second.minzoom = minzoom;
|
||||||
ai->second.maxzoom = maxzoom;
|
ai->second.maxzoom = maxzoom;
|
||||||
}
|
}
|
||||||
mbtiles_write_metadata(outdb, fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, forcetable, attribution, merged_lm, true, description);
|
|
||||||
|
if(!prevent[P_PBF_COMPRESSION])
|
||||||
|
mbtiles_write_metadata(outdb, fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, forcetable, attribution, merged_lm, true, description);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1873,6 +1877,7 @@ int main(int argc, char **argv) {
|
|||||||
char *description = NULL;
|
char *description = NULL;
|
||||||
char *layername = NULL;
|
char *layername = NULL;
|
||||||
char *outdir = NULL;
|
char *outdir = NULL;
|
||||||
|
sqlite3 *outdb = NULL;
|
||||||
int maxzoom = 14;
|
int maxzoom = 14;
|
||||||
int minzoom = 0;
|
int minzoom = 0;
|
||||||
int basezoom = -1;
|
int basezoom = -1;
|
||||||
@@ -1955,6 +1960,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},
|
||||||
|
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
@@ -2247,7 +2253,12 @@ int main(int argc, char **argv) {
|
|||||||
unlink(outdir);
|
unlink(outdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3 *outdb = mbtiles_open(outdir, argv, forcetable);
|
if(!prevent[P_PBF_COMPRESSION]){
|
||||||
|
outdb = mbtiles_open(outdir, argv, forcetable);
|
||||||
|
}else{
|
||||||
|
outpbfdir = outdir;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
for (i = optind; i < argc; i++) {
|
for (i = optind; i < argc; i++) {
|
||||||
@@ -2274,7 +2285,8 @@ 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);
|
||||||
|
|
||||||
mbtiles_close(outdb, argv);
|
if(!prevent[P_PBF_COMPRESSION])
|
||||||
|
mbtiles_close(outdb, argv);
|
||||||
|
|
||||||
#ifdef MTRACE
|
#ifdef MTRACE
|
||||||
muntrace();
|
muntrace();
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ void checkdisk(struct reader *r, int nreader);
|
|||||||
extern int geometry_scale;
|
extern int geometry_scale;
|
||||||
extern int quiet;
|
extern int quiet;
|
||||||
|
|
||||||
|
extern char *outpbfdir;
|
||||||
|
|
||||||
extern size_t CPUS;
|
extern size_t CPUS;
|
||||||
extern size_t TEMP_FILES;
|
extern size_t TEMP_FILES;
|
||||||
|
|
||||||
|
|||||||
@@ -367,10 +367,7 @@ std::string mvt_tile::encode() {
|
|||||||
writer.add_message(3, layer_string);
|
writer.add_message(3, layer_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string compressed;
|
return data;
|
||||||
compress(data, compressed);
|
|
||||||
|
|
||||||
return compressed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mvt_value::operator<(const mvt_value &o) const {
|
bool mvt_value::operator<(const mvt_value &o) const {
|
||||||
|
|||||||
@@ -25,6 +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')
|
||||||
|
|
||||||
extern int prevent[256];
|
extern int prevent[256];
|
||||||
extern int additional[256];
|
extern int additional[256];
|
||||||
|
|||||||
@@ -1837,7 +1837,14 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string compressed = tile.encode();
|
std::string compressed;
|
||||||
|
std::string pbf = tile.encode();
|
||||||
|
|
||||||
|
if(!prevent[P_PBF_COMPRESSION]){
|
||||||
|
compress(pbf, compressed);
|
||||||
|
}else{
|
||||||
|
compressed = pbf;
|
||||||
|
}
|
||||||
|
|
||||||
if (compressed.size() > max_tile_size && !prevent[P_KILOBYTE_LIMIT]) {
|
if (compressed.size() > max_tile_size && !prevent[P_KILOBYTE_LIMIT]) {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
@@ -1909,7 +1916,22 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
if(!prevent[P_PBF_COMPRESSION]){
|
||||||
|
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||||
|
}else{
|
||||||
|
mkdir(outpbfdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
|
std::string curdir(outpbfdir);
|
||||||
|
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::app | std::ios::binary);
|
||||||
|
pbfFile.write (pbf.data(), pbf.size());
|
||||||
|
pbfFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_mutex_unlock(&db_lock) != 0) {
|
if (pthread_mutex_unlock(&db_lock) != 0) {
|
||||||
perror("pthread_mutex_unlock");
|
perror("pthread_mutex_unlock");
|
||||||
|
|||||||
Reference in New Issue
Block a user