Don't accept features or geometries inside another object's properties

This commit is contained in:
Eric Fischer
2018-08-08 13:42:49 -07:00
parent ba8966a4ae
commit 98cf4d94aa
6 changed files with 80 additions and 3 deletions
+32
View File
@@ -93,6 +93,20 @@ void parse_json(json_feature_action *jfa, json_pull *jp) {
}
}
if (is_geometry) {
json_object *jo = j;
while (jo != NULL) {
if (jo->parent != NULL && jo->parent->type == JSON_HASH) {
if (json_hash_get(jo->parent, "properties") == jo) {
// Ancestor is the value corresponding to a properties key
is_geometry = 0;
break;
}
}
jo = jo->parent;
}
}
if (is_geometry) {
if (found_features != 0 && found_geometries == 0) {
fprintf(stderr, "%s:%d: Warning: found a mixture of features and bare geometries\n", jfa->fname.c_str(), jp->line);
@@ -135,6 +149,24 @@ void parse_json(json_feature_action *jfa, json_pull *jp) {
continue;
}
bool is_feature = true;
{
json_object *jo = j;
while (jo != NULL) {
if (jo->parent != NULL && jo->parent->type == JSON_HASH) {
if (json_hash_get(jo->parent, "properties") == jo) {
// Ancestor is the value corresponding to a properties key
is_feature = false;
break;
}
}
jo = jo->parent;
}
}
if (!is_feature) {
continue;
}
json_object *tippecanoe = json_hash_get(j, "tippecanoe");
json_object *id = json_hash_get(j, "id");