Merge pull request #16 from mapbox/nullprop

Allow features to have null properties
This commit is contained in:
Eric Fischer 2014-12-16 22:49:23 -08:00
commit 3b9f4691c1

View File

@ -387,7 +387,7 @@ void read_json(FILE *f, const char *fname, const char *layername, int maxzoom, i
} }
json_object *properties = json_hash_get(j, "properties"); json_object *properties = json_hash_get(j, "properties");
if (properties == NULL || properties->type != JSON_HASH) { if (properties == NULL || (properties->type != JSON_HASH && properties->type != JSON_NULL)) {
fprintf(stderr, "%s:%d: feature without properties hash\n", fname, jp->line); fprintf(stderr, "%s:%d: feature without properties hash\n", fname, jp->line);
json_free(j); json_free(j);
continue; continue;
@ -420,13 +420,18 @@ void read_json(FILE *f, const char *fname, const char *layername, int maxzoom, i
parse_geometry(t, coordinates, bbox, &fpos, metafile, VT_MOVETO, fname, jp); parse_geometry(t, coordinates, bbox, &fpos, metafile, VT_MOVETO, fname, jp);
serialize_byte(metafile, VT_END, &fpos, fname, jp); serialize_byte(metafile, VT_END, &fpos, fname, jp);
char *metakey[properties->length]; int nprop = 0;
char *metaval[properties->length]; if (properties->type == JSON_HASH) {
int metatype[properties->length]; nprop = properties->length;
}
char *metakey[nprop];
char *metaval[nprop];
int metatype[nprop];
int m = 0; int m = 0;
int i; int i;
for (i = 0; i < properties->length; i++) { for (i = 0; i < nprop; i++) {
if (properties->keys[i]->type == JSON_STRING) { if (properties->keys[i]->type == JSON_STRING) {
if (exclude_all) { if (exclude_all) {
if (!is_pooled(include, properties->keys[i]->string, VT_STRING)) { if (!is_pooled(include, properties->keys[i]->string, VT_STRING)) {