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

enable empty coordinantes #99

Closed
wants to merge 1 commit into from
Closed

Conversation

vincentsarago
Copy link
Member

closes #89

TODO:

  • add tests

f"{self._wkt_inset}({self._wkt_coordinates})"
if self.coordinates
else " EMPTY"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the 2 abstract method because it was going to create more line of code (repeating the 2 if not self.coordinates)

Copy link
Collaborator

Choose a reason for hiding this comment

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

While there may need to be a couple extra safety checks to keep the type checking happy. Checking the value exists isn't an expensive operation but it cuts down on a lot of duplicated code to use the base functions.

I was actually going to propose a has_z property specifically to get rid of the _wkt_inset and get rid of the duplication of the " Z " if ... else " " everywhere.

Copy link
Collaborator

@eseglem eseglem left a comment

Choose a reason for hiding this comment

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

coordinates cannot be None. A Point must always be a Position and for anything else [] is acceptable.

I had code for this stashed and will put it up soon. I just added a test and it is now failing so I want to track that down first.

f"{self._wkt_inset}({self._wkt_coordinates})"
if self.coordinates
else " EMPTY"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

While there may need to be a couple extra safety checks to keep the type checking happy. Checking the value exists isn't an expensive operation but it cuts down on a lot of duplicated code to use the base functions.

I was actually going to propose a has_z property specifically to get rid of the _wkt_inset and get rid of the duplication of the " Z " if ... else " " everywhere.

@@ -161,22 +154,31 @@ def check_closure(cls, coordinates: List) -> List:
@property
def exterior(self) -> LinearRing:
"""Return the exterior Linear Ring of the polygon."""
if not self.coordinates:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Initially I thought this would be a None, as there is not an exterior at all. But I guess [] could be valid as well.

return self.coordinates[0]

@property
def interiors(self) -> Iterator[LinearRing]:
"""Interiors (Holes) of the polygon."""
if not self.coordinates:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is necessary, as the current yield statement already covers this case.

@vincentsarago
Copy link
Member Author

coordinates cannot be None. A Point must always be a Position and for anything else [] is acceptable.

I guess I mis understood this

A GeoJSON Geometry object of any type other than
"GeometryCollection" has a member with the name "coordinates".
The value of the "coordinates" member is an array. The structure
of the elements in this array is determined by the type of
geometry. GeoJSON processors MAY interpret Geometry objects with
empty "coordinates" arrays as null objects.

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 this pull request may close these issues.

Rationale for not supporting empty geometries?
2 participants