Add -f option to overwrite existing mbtiles file

This commit is contained in:
Eric Fischer 2014-09-29 15:09:21 -07:00
parent c02c91df5a
commit f0d2dbd2a8
2 changed files with 12 additions and 2 deletions

View File

@ -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
-------

View File

@ -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) {