Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputs invalid GeoJSON for null geometries #18

Open
danvk opened this issue Oct 28, 2024 · 0 comments · May be fixed by #19
Open

Outputs invalid GeoJSON for null geometries #18

danvk opened this issue Oct 28, 2024 · 0 comments · May be fixed by #19

Comments

@danvk
Copy link

danvk commented Oct 28, 2024

If you set geometry to None in a Feature, it gets dropped from the feature during serialization:

>>> import pygeojson
>>> pygeojson.dumps(pygeojson.Feature(id="123", geometry=None))
'{"type": "Feature", "id": "123", "properties": {}}'

This is in violation of the spec, which states that a Feature must have a geometry member, which may be null.

I noticed that pygeojson has a test for reading null geometries, but no test for writing them back:

def test_feature_with_null_geom(load_json):
o: Feature = load_json("feature_with_null_geom.json")
assert o == Feature(
id=None, bbox=None, type="Feature", geometry=None, properties={},
)

@danvk danvk linked a pull request Oct 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant