-
-
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
Fix MultiPolygon validation #63
Fix MultiPolygon validation #63
Conversation
@@ -58,14 +58,19 @@ def is_valid(obj): | |||
'must be equivalent') | |||
|
|||
if isinstance(obj, geojson.MultiPolygon): | |||
if checkListOfObjects(obj['coordinates'], | |||
lambda x: len(x) >= 4 and x[0] == x[-1]): | |||
if checkListOfObjects(obj['coordinates'], lambda x: is_polygon(x)): |
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.
Can you wrap this line? It's one character too long for flake8 :P
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.
It wasn't this line, but I fixed it in the last commit:
https://travis-ci.org/frewsxcv/python-geojson/jobs/84946771
Reopened to restart travis |
return output('the "coordinates" member must be an array' | ||
'of Polygon coordinate arrays') | ||
|
||
return output('') | ||
|
||
|
||
def is_polygon(coords): | ||
lengths = all([len(elem) >= 4 for elem in coords]) | ||
isring = all([elem[0] == elem[-1] for elem in coords]) |
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.
You can remove the inner brackets in these so they become generators
lengths = all(len(elem) >= 4 for elem in coords)
isring = all(elem[0] == elem[-1] for elem in coords)
Done. BTW, I'm really interested in improving validation with more detailled feedback. |
I have no constraints with the validation format. Do whatever you think makes the most sense to you
Sounds goods to me! I would just rename the key to In the meantime, thanks for your contribution! |
Also, feel free to add yourself to the credits in the README for your daily dose of egotism |
Thanks ! |
Version 1.3.1 has been released which includes this fix. Thanks again! |
1.3.1 (2015-10-12) ------------------ - Fix validation bug for MultiPolygons - jazzband/geojson#63
1.3.1 (2015-10-12) ------------------ - Fix validation bug for MultiPolygons - jazzband/geojson#63
This pull-request fix the multipolygon validation (and the associated test).
Tha data used for testing were false.