mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
Merge pull request #34 from mapbox/warn-no-features
Warn if no Features have been seen after 50 JSON hashes are closed.
This commit is contained in:
commit
12fb2c969c
13
geojson.c
13
geojson.c
@ -425,6 +425,8 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
||||
json_pull *jp;
|
||||
const char *reading;
|
||||
FILE *fp;
|
||||
long long found_hashes = 0;
|
||||
long long found_features = 0;
|
||||
|
||||
if (n >= argc) {
|
||||
reading = "standard input";
|
||||
@ -451,11 +453,22 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
||||
break;
|
||||
}
|
||||
|
||||
if (j->type == JSON_HASH) {
|
||||
found_hashes++;
|
||||
|
||||
if (found_hashes == 50 && found_features == 0) {
|
||||
fprintf(stderr, "%s:%d: Not finding any GeoJSON features in input. Is your file just bare geometries?\n", reading, jp->line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
json_object *type = json_hash_get(j, "type");
|
||||
if (type == NULL || type->type != JSON_STRING || strcmp(type->string, "Feature") != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
found_features++;
|
||||
|
||||
json_object *geometry = json_hash_get(j, "geometry");
|
||||
if (geometry == NULL) {
|
||||
fprintf(stderr, "%s:%d: feature with no geometry\n", reading, jp->line);
|
||||
|
Loading…
Reference in New Issue
Block a user