Warn if no Features have been seen after 50 JSON hashes are closed.

This commit is contained in:
Eric Fischer 2015-04-17 10:48:03 -07:00
parent 4f9edf7f29
commit 167ec690a0

View File

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