diff --git a/README.md b/README.md index 53f1d1c..e9561fd 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ Options * -Z Lowest zoom level (default 0) * -d Detail at base zoom level (default 12, for tile resolution of 4096) * -D Detail at lower zoom levels (default 10, for tile resolution of 1024) - * -x property (removes the named properties from all features) + * -x Property (removes the named properties from all features) + * -f Force: Delete existing mbtiles file if it already exists. Example ------- diff --git a/geojson.c b/geojson.c index 11937a8..675384c 100644 --- a/geojson.c +++ b/geojson.c @@ -538,11 +538,12 @@ int main(int argc, char **argv) { char *outdir = NULL; int maxzoom = 14; int minzoom = 0; + int force = 0; struct pool exclude; pool_init(&exclude, 0); - while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:x:")) != -1) { + while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:x:f")) != -1) { switch (i) { case 'n': name = optarg; @@ -576,6 +577,10 @@ int main(int argc, char **argv) { pool(&exclude, optarg, VT_STRING); break; + case 'f': + force = 1; + break; + default: fprintf(stderr, "Usage: %s -o out.mbtiles [-n name] [-l layername] [-z maxzoom] [-Z minzoom] [-d detail] [-D lower-detail] [-x excluded-field ...] [file.json]\n", argv[0]); exit(EXIT_FAILURE); @@ -587,6 +592,10 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + if (force) { + unlink(outdir); + } + sqlite3 *outdb = mbtiles_open(outdir, argv); if (argc == optind + 1) {