-
Notifications
You must be signed in to change notification settings - Fork 199
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
Dealing with Validity #123
Comments
Regardless of when we check validity of geometry, we'll need to implement the validity checks before that happens. Unless anyone else has a better suggestion, I think we can use the same validity checks described by OGC, mentioned in the original post above. Opening a new issue for this: #127 |
I like the concept of "making illegal states unrepresentable". That way you can do things knowing that a particular assumption you make (e.g. all These checks can often introduce For example, you might implement the impl<F: Float> Polygon<F> {
fn new(exterior: LineString<F>, interior: Vec<LineString<F>>) -> Polygon<F> {
let poly = Polygon { exterior, interior };
debug_assert!(poly.is_valid(), "All rings and lines in a polygon must be closed");
poly
}
fn is_valid(&self) -> bool {
exterior.is_closed() && interior.iter().all(|ring| ring.is_closed())
}
} Another option would be to add One question that comes to mind is that if there's a way for someone to create a shape which could break assumptions (e.g. making a polygon which hasn't got a closed exterior), should that constructor be marked |
For posterity, there was a discussion about validity of |
See previous discussions in #56 and #122
First, what do we mean when we talk about validity? The OGC OpenGIS spec discussed in the PostGIS docs gives a good overview.
validate=True
argument, although the latter could cause a lot of headaches in terms of revising calls to the existing constructors, and dealing with invalid geometries; e.g. both of the simplification algorithms can return invalid geometries, so those traits would always have to return aResult
(they should arguably already be doing this)Result
.The text was updated successfully, but these errors were encountered: