-
Notifications
You must be signed in to change notification settings - Fork 202
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
Rewrite Polygon structure to enforce closed LineString rings. #337
Conversation
151424c
to
5d46c44
Compare
]); | ||
let poly = Polygon::new(linestring, vec![inner_linestring]); | ||
assert!(poly.contains(&Point::new(0.25, 0.25))); | ||
assert!(!poly.contains(&Point::new(0.25, 0.25))); |
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.
Confusingly, as a result of closing the ring, this went from true
to false
🤔
5d46c44
to
62104d5
Compare
Won't we need an (optional) validation step as part of this? It's relatively straightforward to inadvertently create an invalid geometry (e.g. using https://gist.github.com/urschrei/aa95f3681a09ff1a9d82935ff82ae9c4 as the exterior ring). Not validating isn't strictly worse than what we do now, but auto-closing could be seen as implying validity… |
Oh for sure, we still need to address the validity issue. It's certainly still possible to create invalid geometries with this crate. For instance, in addition to your example, it's still possible to create a To address your concerns, do you think it'd be sufficient to add a disclaimer in the docs warning that there are currently no geometric validity checks in-place? |
Absolutely – being clear in the docs is all we can do anyway. It's a great feature, I didn't mean to imply we shouldn't land it! |
62104d5
to
7e2e9da
Compare
Perfect! |
bors r+ |
337: Rewrite Polygon structure to enforce closed LineString rings. r=frewsxcv a=frewsxcv Prior to this pull request, the `exterior` and `interior` fields on a `Polygon` were public, allowing users to modify their `Coordinate`s as they saw fit. To ensure all rings in a `Polygon`s remain closed, this pull request: - privatizes the `exterior` and `interior` fields - adds getters/mutators - closes all `LineString` rings upon construction or after mutation Fixes #166. Co-authored-by: Corey Farwell <[email protected]>
Build succeeded |
Prior to this pull request, the
exterior
andinterior
fields on aPolygon
were public, allowing users to modify theirCoordinate
s as they saw fit.To ensure all rings in a
Polygon
s remain closed, this pull request:exterior
andinterior
fieldsLineString
rings upon construction or after mutationFixes #166.