-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add customizable invalid geometry handling #46
Conversation
@@ -56,13 +56,28 @@ def transform(shape, func): | |||
raise ValueError('Unknown geometry type, "%s"' % shape.type) | |||
|
|||
|
|||
def on_invalid_geometry_raise(shape): | |||
raise Exception('Invalid geometry: %s' % shape.wkt) |
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.
Do we want to raise plain Exception
, or a more specific class such as ValueError
or RuntimeError
(or even a class of our own)?
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.
Good point. I like ValueError
. Updated in 9660d52.
There are cases where the validation handler can generate points that when rounded will also generate invalid geometry. We repeat the entire rounding, winding, and validation process to catch these scenarios.
@zerebubuth the test failure is due to a rounding behavior change in python 3, specifically that it rounds to the nearest even number for ties instead of always up. This sounds like more balanced rounding behavior to me; do you think that we would want the same behavior with python 2 as well? |
for x in valid_geometries] | ||
self.failUnless(shape1.is_valid) | ||
self.failUnless(shape2.is_valid) | ||
self.failUnless(shape1.area > 0) |
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.
FailUnless is deprecated. Here you want to use assertGreater which will also be easier to debug in case the test fails.
Thanks @loicgasser |
Whoops, hit enter too early. Updated in 3e7e4f2. |
@rmarianski I'm not sure if the rounding behaviour fairness is going to matter much in terms of the tile coordinates, but it's definitely going to be less confusing to be consistent across Python versions! |
@zerebubuth do you think this can be merged in now? Or are there still other scenarios to consider? |
👍 |
Connects to #45
@zerebubuth could you review please?