Skip to content

Commit

Permalink
jsontogeojson: add any_spans_with_geometry and any_nodes_with_geometr…
Browse files Browse the repository at this point in the history
…y to meta

Helpful for Open-Telecoms-Data/cove-ofds#6
  • Loading branch information
odscjames committed Nov 9, 2022
1 parent ae77123 commit c5d3816
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add more fields to output object
- GeoJSON to JSON:
- meta information includes inconsistent ids on organisations and phases
- JSON to GeoJSON:
- add any_spans_with_geometry and any_nodes_with_geometry to meta
- Python Validate:
- add more information to errors

Expand Down
7 changes: 7 additions & 0 deletions libcoveofds/geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def get_meta_json(self) -> dict:
out["spans_output_field_coverage"][key] = {"count": 1}
else:
out["spans_output_field_coverage"][key]["count"] += 1
# Any geometries?
out["any_spans_with_geometry"] = bool(
[True for s in self._spans_geojson_features if s.get("geometry")]
)
out["any_nodes_with_geometry"] = bool(
[True for n in self._nodes_geojson_features if n.get("geometry")]
)
# return
return out

Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/json_to_geojson/basic_1.expected.meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,7 @@
"/features/properties/network/name": {
"count": 1
}
}
},
"any_spans_with_geometry": true,
"any_nodes_with_geometry": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,7 @@
"/features/properties/network/name": {
"count": 1
}
}
},
"any_spans_with_geometry": false,
"any_nodes_with_geometry": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,7 @@
"/features/properties/network/name": {
"count": 1
}
}
},
"any_spans_with_geometry": true,
"any_nodes_with_geometry": true
}
4 changes: 3 additions & 1 deletion tests/fixtures/json_to_geojson/phases_1.expected.meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,7 @@
"/features/properties/network/contracts/relatedPhases/description": {
"count": 1
}
}
},
"any_spans_with_geometry": true,
"any_nodes_with_geometry": true
}

0 comments on commit c5d3816

Please sign in to comment.