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

fix __geo_interface__ if parts or points is empty list #101

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ def __init__(self, shapeType=NULL, points=None, parts=None, partTypes=None):

@property
def __geo_interface__(self):

""" Case parts or points is empty """
if not self.parts or not self.points:
return False
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False? I am not sure about this. how does geojson handle empty geometries?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False is a valid value for geojson data structure. (https://geojson.org/geojson-spec.html#geometry-objects) I did some tests with geojson that contains a false value in geometry fields in GIS tools, and i not found erros.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be an empty geometry type defined in GeoJSON, but it does state that feature objects without a geometry can be specified with JSON null value, which would be None rather than False in Python.

From the previous link:

A feature object must have a member with the name "geometry". The value of the geometry member is a geometry object as defined above or a JSON null value.

I also think None makes more sense since there literally is "none" geometry object.


if self.shapeType in [POINT, POINTM, POINTZ]:
return {
'type': 'Point',
Expand Down