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

Add customizable invalid geometry handling #46

Merged
merged 8 commits into from
May 6, 2016

Conversation

rmarianski
Copy link
Member

Connects to #45

@zerebubuth could you review please?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 93.385% when pulling d1aaa2d on invalid-geometry-handling into 773dbfd on master.

@@ -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)
Copy link
Member

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)?

Copy link
Member Author

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 85.409% when pulling 9660d52 on invalid-geometry-handling into 773dbfd on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 93.398% when pulling 6a1e8e0 on invalid-geometry-handling into 773dbfd on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 85.437% when pulling 4e356b6 on invalid-geometry-handling into 773dbfd on master.

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.
@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 85.468% when pulling 29e307c on invalid-geometry-handling into 773dbfd on master.

@rmarianski
Copy link
Member Author

@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)
Copy link
Contributor

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.

@rmarianski
Copy link
Member Author

Thanks @loicgasser

@rmarianski
Copy link
Member Author

Whoops, hit enter too early. Updated in 3e7e4f2.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 85.468% when pulling 3e7e4f2 on invalid-geometry-handling into 773dbfd on master.

@zerebubuth
Copy link
Member

@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!

@coveralls
Copy link

coveralls commented May 6, 2016

Coverage Status

Coverage increased (+1.8%) to 94.961% when pulling 24ab05b on invalid-geometry-handling into 773dbfd on master.

@rmarianski
Copy link
Member Author

@zerebubuth do you think this can be merged in now? Or are there still other scenarios to consider?

@zerebubuth
Copy link
Member

👍

@rmarianski rmarianski merged commit 8ea6dd2 into master May 6, 2016
@rmarianski rmarianski deleted the invalid-geometry-handling branch May 6, 2016 16:47
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.

4 participants