-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Errors method for validating geometry collections. #102
Errors method for validating geometry collections. #102
Conversation
Codecov Report
@@ Coverage Diff @@
## master #102 +/- ##
=========================================
+ Coverage 78.41% 78.61% +0.2%
=========================================
Files 11 11
Lines 315 318 +3
Branches 52 54 +2
=========================================
+ Hits 247 250 +3
Misses 58 58
Partials 10 10
Continue to review full report at Codecov.
|
geojson/geometry.py
Outdated
@@ -53,6 +53,9 @@ def __init__(self, geometries=None, **extra): | |||
super(GeometryCollection, self).__init__(**extra) | |||
self["geometries"] = geometries or [] | |||
|
|||
def errors(self): | |||
return any(list(geom.errors() for geom in self['geometries'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think errors
is supposed to return a list of errors instead of a boolean, like the other implementations
Note the |
geojson/geometry.py
Outdated
@@ -53,6 +53,13 @@ def __init__(self, geometries=None, **extra): | |||
super(GeometryCollection, self).__init__(**extra) | |||
self["geometries"] = geometries or [] | |||
|
|||
def errors(self): | |||
return [geom.errors() for geom in self['geometries']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I promise this is my last comment! 🙈
I noticed that for MultiPoint
, MultiLineString
, and MultiPolygon
, we call check_list_errors
which:
- iterates over all the sub-geometries
- checks for errors for each subgeometry
- if there's no error, no item gets added to the resulting list
This behavior is different from your GeometryCollection
behavior where the result here be something like [[], [], []]
.
What do you think? Would it be good to make the implementations more similar or do you think we should keep them how they are right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I think it is a slightly different case than the Multi geometries because a geometry collection could contain any of those objects. However I do like the idea of consistency around errors array, so i'll change the method to only add the errors if they exist. Then we can leave the baseclass is_valid property.
bors r+ |
thanks @hrfuller! 🙇 |
Build succeeded |
Closes #101