mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Add an option to exclude specified properties
This commit is contained in:
@@ -24,13 +24,14 @@ Options
|
|||||||
* -Z Lowest zoom level (default 0)
|
* -Z Lowest zoom level (default 0)
|
||||||
* -d Detail at base zoom level (default 12, for tile resolution of 4096)
|
* -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)
|
* -D Detail at lower zoom levels (default 10, for tile resolution of 1024)
|
||||||
|
* -x property (removes the named properties from all features)
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|
||||||
tippecanoe -o alameda.mbtiles -l alameda -n "Alameda County from TIGER" -z13 tl_2014_06001_roads.json
|
tippecanoe -o alameda.mbtiles -l alameda -n "Alameda County from TIGER" -z13 tl_2014_06001_roads.json
|
||||||
|
|
||||||
cat tiger/tl_2014_*_roads.json | tippecanoe -o tiger.mbtiles -l roads -n "All TIGER roads, one zoom" -z12 -Z12 -d14
|
cat tiger/tl_2014_*_roads.json | tippecanoe -o tiger.mbtiles -l roads -n "All TIGER roads, one zoom" -z12 -Z12 -d14 -x LINEARID -x RTTYP
|
||||||
|
|
||||||
Geometric simplifications
|
Geometric simplifications
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|||||||
@@ -171,6 +171,29 @@ struct pool_val *pool1(struct pool *p, char *s, int type, int (*compare)(const c
|
|||||||
return *v;
|
return *v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_pooled(struct pool *p, char *s, int type) {
|
||||||
|
struct pool_val **v = &(p->vals);
|
||||||
|
|
||||||
|
while (*v != NULL) {
|
||||||
|
int cmp = strcmp(s, (*v)->s);
|
||||||
|
|
||||||
|
if (cmp == 0) {
|
||||||
|
cmp = type - (*v)->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmp == 0) {
|
||||||
|
return 1;
|
||||||
|
} else if (cmp < 0) {
|
||||||
|
v = &((*v)->left);
|
||||||
|
} else {
|
||||||
|
v = &((*v)->right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct pool_val *pool(struct pool *p, char *s, int type) {
|
struct pool_val *pool(struct pool *p, char *s, int type) {
|
||||||
return pool1(p, s, type, strcmp);
|
return pool1(p, s, type, strcmp);
|
||||||
}
|
}
|
||||||
@@ -412,7 +435,7 @@ void aprintf(char **buf, const char *format, ...) {
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom, sqlite3 *outdb) {
|
void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom, sqlite3 *outdb, struct pool *exclude) {
|
||||||
char metaname[] = "/tmp/meta.XXXXXXXX";
|
char metaname[] = "/tmp/meta.XXXXXXXX";
|
||||||
char indexname[] = "/tmp/index.XXXXXXXX";
|
char indexname[] = "/tmp/index.XXXXXXXX";
|
||||||
|
|
||||||
@@ -500,6 +523,10 @@ void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom,
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < properties->length; i++) {
|
for (i = 0; i < properties->length; i++) {
|
||||||
if (properties->keys[i]->type == JSON_STRING) {
|
if (properties->keys[i]->type == JSON_STRING) {
|
||||||
|
if (is_pooled(exclude, properties->keys[i]->string, VT_STRING)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
metakey[m] = properties->keys[i]->string;
|
metakey[m] = properties->keys[i]->string;
|
||||||
|
|
||||||
if (properties->values[i] != NULL && properties->values[i]->type == JSON_STRING) {
|
if (properties->values[i] != NULL && properties->values[i]->type == JSON_STRING) {
|
||||||
@@ -762,7 +789,13 @@ int main(int argc, char **argv) {
|
|||||||
int maxzoom = 14;
|
int maxzoom = 14;
|
||||||
int minzoom = 0;
|
int minzoom = 0;
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:")) != -1) {
|
struct pool exclude;
|
||||||
|
exclude.n = 0;
|
||||||
|
exclude.vals = NULL;
|
||||||
|
exclude.head = NULL;
|
||||||
|
exclude.tail = NULL;
|
||||||
|
|
||||||
|
while ((i = getopt(argc, argv, "l:n:z:Z:d:D:o:x:")) != -1) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'n':
|
case 'n':
|
||||||
name = optarg;
|
name = optarg;
|
||||||
@@ -792,8 +825,15 @@ int main(int argc, char **argv) {
|
|||||||
outdir = optarg;
|
outdir = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
{
|
||||||
|
struct pool_val *pv = pool(&exclude, optarg, VT_STRING);
|
||||||
|
pv->n = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Usage: %s -o out.mbtiles [-n name] [-l layername] [-z maxzoom] [-Z minzoom] [-d detail] [-D lower-detail] [file.json]\n", argv[0]);
|
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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -846,7 +886,7 @@ int main(int argc, char **argv) {
|
|||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb);
|
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb, &exclude);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -854,7 +894,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "%s: Only accepts one input file\n", argv[0]);
|
fprintf(stderr, "%s: Only accepts one input file\n", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else {
|
} else {
|
||||||
read_json(stdin, name ? name : "standard input", layer, maxzoom, minzoom, outdb);
|
read_json(stdin, name ? name : "standard input", layer, maxzoom, minzoom, outdb, &exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqlite3_exec(outdb, "ANALYZE;", NULL, NULL, &err) != SQLITE_OK) {
|
if (sqlite3_exec(outdb, "ANALYZE;", NULL, NULL, &err) != SQLITE_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user