diff --git a/README.md b/README.md index d79135bf..481236e0 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,7 @@ resolution is obtained than by using a smaller _maxzoom_ or _detail_. * `-pf` or `--no-feature-limit`: Don't limit tiles to 200,000 features * `-pk` or `--no-tile-size-limit`: Don't limit tiles to 500K bytes * `-pC` or `--no-tile-compression`: Don't compress the PBF vector tile data. + * `-pg` or `--no-tile-stats`: Don't generate the `tilestats` row in the tileset metadata. Uploads without [tilestats](https://github.com/mapbox/mapbox-geostats) will take longer to process. ### Temporary storage @@ -463,6 +464,7 @@ The options are: * `-i` or `--if-matched`: Only include features that matched the CSV. * `-pk` or `--no-tile-size-limit`: Don't skip tiles larger than 500K. * `-pC` or `--no-tile-compression`: Don't compress the PBF vector tile data. + * `-pg` or `--no-tile-stats`: Don't generate the `tilestats` row in the tileset metadata. Uploads without [tilestats](https://github.com/mapbox/mapbox-geostats) will take longer to process. * `-l` *layer* or `--layer=`*layer*: Include the named layer in the output. You can specify multiple `-l` options to keep multiple layers. If you don't specify, they will all be retained. * `-L` *layer* or `--exclude-layer=`*layer*: Remove the named layer from the output. You can specify multiple `-L` options to remove multiple layers. * `-A` *attribution* or `--attribution=`*attribution*: Set the attribution string. diff --git a/main.cpp b/main.cpp index 93caadec..4ca8012f 100644 --- a/main.cpp +++ b/main.cpp @@ -2000,7 +2000,7 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo } } - mbtiles_write_metadata(outdb, outdir, fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, forcetable, attribution, merged_lm, true, description); + mbtiles_write_metadata(outdb, outdir, fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, forcetable, attribution, merged_lm, true, description, !prevent[P_TILE_STATS]); return ret; } @@ -2176,6 +2176,7 @@ int main(int argc, char **argv) { {"no-feature-limit", no_argument, &prevent[P_FEATURE_LIMIT], 1}, {"no-tile-size-limit", no_argument, &prevent[P_KILOBYTE_LIMIT], 1}, {"no-tile-compression", no_argument, &prevent[P_TILE_COMPRESSION], 1}, + {"no-tile-stats", no_argument, &prevent[P_TILE_STATS], 1}, {"Temporary storage", 0, 0, 0}, {"temporary-directory", required_argument, 0, 't'}, diff --git a/man/tippecanoe.1 b/man/tippecanoe.1 index cbc72e6c..4c5298d2 100644 --- a/man/tippecanoe.1 +++ b/man/tippecanoe.1 @@ -271,6 +271,8 @@ the line or polygon within one tile unit of its proper location. You can probabl \fB\fC\-pk\fR or \fB\fC\-\-no\-tile\-size\-limit\fR: Don't limit tiles to 500K bytes .IP \(bu 2 \fB\fC\-pC\fR or \fB\fC\-\-no\-tile\-compression\fR: Don't compress the PBF vector tile data. +.IP \(bu 2 +\fB\fC\-pg\fR or \fB\fC\-\-no\-tile\-stats\fR: Don't generate the \fB\fCtilestats\fR row in the tileset metadata. Uploads without tilestats \[la]https://github.com/mapbox/mapbox-geostats\[ra] will take longer to process. .RE .SS Temporary storage .RS @@ -543,6 +545,8 @@ The options are: .IP \(bu 2 \fB\fC\-pC\fR or \fB\fC\-\-no\-tile\-compression\fR: Don't compress the PBF vector tile data. .IP \(bu 2 +\fB\fC\-pg\fR or \fB\fC\-\-no\-tile\-stats\fR: Don't generate the \fB\fCtilestats\fR row in the tileset metadata. Uploads without tilestats \[la]https://github.com/mapbox/mapbox-geostats\[ra] will take longer to process. +.IP \(bu 2 \fB\fC\-l\fR \fIlayer\fP or \fB\fC\-\-layer=\fR\fIlayer\fP: Include the named layer in the output. You can specify multiple \fB\fC\-l\fR options to keep multiple layers. If you don't specify, they will all be retained. .IP \(bu 2 \fB\fC\-L\fR \fIlayer\fP or \fB\fC\-\-exclude\-layer=\fR\fIlayer\fP: Remove the named layer from the output. You can specify multiple \fB\fC\-L\fR options to remove multiple layers. diff --git a/mbtiles.cpp b/mbtiles.cpp index ddab94a8..ece277ab 100644 --- a/mbtiles.cpp +++ b/mbtiles.cpp @@ -299,7 +299,7 @@ std::string tilestats(std::map const &layermap1) { return out2; } -void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, int forcetable, const char *attribution, std::map const &layermap, bool vector, const char *description) { +void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, int forcetable, const char *attribution, std::map const &layermap, bool vector, const char *description, bool do_tilestats) { char *sql, *err; sqlite3 *db = outdb; @@ -455,8 +455,12 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fnam aprintf(&buf, "} }"); } - aprintf(&buf, " ],"); - aprintf(&buf, "\"tilestats\": %s", tilestats(layermap).c_str()); + aprintf(&buf, " ]"); + + if (do_tilestats) { + aprintf(&buf, ",\"tilestats\": %s", tilestats(layermap).c_str()); + } + aprintf(&buf, "}"); sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('json', %Q);", buf.c_str()); diff --git a/mbtiles.hpp b/mbtiles.hpp index efc0a976..2e252622 100644 --- a/mbtiles.hpp +++ b/mbtiles.hpp @@ -39,7 +39,7 @@ sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable); void mbtiles_write_tile(sqlite3 *outdb, int z, int tx, int ty, const char *data, int size); -void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, int forcetable, const char *attribution, std::map const &layermap, bool vector, const char *description); +void mbtiles_write_metadata(sqlite3 *outdb, const char *outdir, const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, int forcetable, const char *attribution, std::map const &layermap, bool vector, const char *description, bool do_tilestats); void mbtiles_close(sqlite3 *outdb, const char *pgm); diff --git a/options.hpp b/options.hpp index 3b585497..3ebc6e66 100644 --- a/options.hpp +++ b/options.hpp @@ -30,6 +30,7 @@ #define P_DUPLICATION ((int) 'D') #define P_TINY_POLYGON_REDUCTION ((int) 't') #define P_TILE_COMPRESSION ((int) 'C') +#define P_TILE_STATS ((int) 'g') extern int prevent[256]; extern int additional[256]; diff --git a/tile-join.cpp b/tile-join.cpp index ebfed4f7..e168338d 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -32,6 +32,7 @@ std::string dequote(std::string s); int pk = false; int pC = false; +int pg = false; size_t CPUS; int quiet = false; @@ -1035,6 +1036,7 @@ int main(int argc, char **argv) { {"no-tile-size-limit", no_argument, &pk, 1}, {"no-tile-compression", no_argument, &pC, 1}, + {"no-tile-stats", no_argument, &pg, 1}, {0, 0, 0, 0}, }; @@ -1092,6 +1094,8 @@ int main(int argc, char **argv) { pk = true; } else if (strcmp(optarg, "C") == 0) { pC = true; + } else if (strcmp(optarg, "g") == 0) { + pg = true; } else { fprintf(stderr, "%s: Unknown option for -p%s\n", argv[0], optarg); exit(EXIT_FAILURE); @@ -1194,7 +1198,7 @@ int main(int argc, char **argv) { name = set_name; } - mbtiles_write_metadata(outdb, out_dir, name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.midlat, st.midlon, 0, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str()); + mbtiles_write_metadata(outdb, out_dir, name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.midlat, st.midlon, 0, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str(), !pg); if (outdb != NULL) { mbtiles_close(outdb, argv[0]);