Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

cookiedan42
Copy link

Added geoms property to BaseGeometry
Added tests for Simple Geometries to test .geom method

Resolves #1881

@cookiedan42
Copy link
Author

failing tests on seem to be tied to using if hasattr(geom, "geoms") to identify MultiGeometries and decompose them, adding the .geoms attribute to BaseGeometry leads to recursion limit in the tests' helper function

Copy link
Contributor

@sgillies sgillies left a comment

Choose a reason for hiding this comment

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

@cookiedan42 sorry for the delay in review! I have a suggestion that should unblock this work.


@property
def geoms(self):
return GeometrySequence(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

@cookiedan42 here's what I suggest to solve the recursion issue. Do the following for the base class:

Suggested change
return GeometrySequence(self)
raise NotImplementedError

And then for single-part Point, etc, classes, do this:

@property
def geoms(self):
    return [self]

GeometrySequence is nothing more than a Python sequence protocol backed by a GEOS multi-part geometry, but as you notice, introduces some complication.

@sgillies
Copy link
Contributor

@cookiedan42 I enabled the workflow. There are some linting issues and also this change really causes trouble for test_set_operations.py which assumes that recursively walking the parts of geoms is closed at some level. Until now I didn't really get the infinite recursion implications of this feature. It suggests to me that we may want to consider, e.g., Point's, lack of a geoms property as a safety feature and not a bug.

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.

Add .geoms to all shapes
2 participants