-
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
Implement SpadeBoolops
trait
#1089
Conversation
5f9b675
to
409b815
Compare
@RobWalt this is a cool implementation! I don't fully understand the correctness yet, but are you getting this to pass all the JTS test fixtures that we run the current bool. ops. on? If so, I'm happy to merge this as the default boolean op. |
SpadeBoolops
traitSpadeBoolops
trait
SpadeBoolops
traitSpadeBoolops
trait
@rmanoka How would you define "passing the current tests"? My algorithm won't find the outputs specified in these tests with the points in the linestrings in the exact same order. Is that allowed? |
I ported the tests under the name "legacy_tests". They all run through. There is a small caveat though: The 894 test runs awfully long. (~18s for 3 intersections on my machine). This is probably due to the fact that the new algo isn't very efficient for bigger geometries. |
SpadeBoolops
traitSpadeBoolops
trait
How long does the test take using the existing bool ops? How long in release mode? I don't think worse perf than the existing impl is a problem, but I'm interested in the performance characteristics more generally. |
It's
So you really should consider if you want to use that and if the input is ok for it. I might add a warning. I can also look into subtle optimizations (via bounding boxes) to squeeze out a bit of performance. Please note that the Multipolygons in this example are absolutely giant (23 KB, 150 polygons per Multipolygon, 2600 vertices total per Multipolygon) |
I implemented some minor bounding box optimizations and now the big test runs through in
There were two test results I needed to change for it still to work:
|
436110d
to
5128160
Compare
5128160
to
d8bbf17
Compare
I'm now hitting crashes with the current implementation in a web-only rewrite of one of my main projects (https://github.com/dabreegster/ltn) and will switch over to this branch soon. Anything I can do to help the Stitch PR and this one get through? I don't see pending tasks in either one; would another review be useful? (Not that I'm any good at georust internals/math as a reviewer) |
Sorry that the review train kind of stalled out on this! It's hard to review big algorithms, especially when they are novel like this one.
If you're brave enough to integrate and use this branch in one of your applications with real world data for a while, that would definitely build some confidence for me. I'll also take a pass at reviewing the stitch PR now. |
Oops, for the project I was thinking of, actually I'm using clip, which doesn't have an equivalent yet. Intersecting a I'll instead cutover the A/B Street repo (with the LTN tool particularly) to use this, but it'll take more time to get to it. :\ |
ccc5df5
to
4d4d92f
Compare
4d4d92f
to
495760a
Compare
I'm for merging this PR too. Reg. the failing tests, could we adjust the code that checks the outputs to accept equivalent polygons? I think we have such test glue-code that checks equiv. upto an adjustible Reg. the increase in time, I dont have a great opinion, but we could at least expose this impl. as an additional impl. the users can use. Reg. the impl., I only scanned through this, but IIUC, the key pre-processing involves rounding the inputs to some |
Authored-by: RobWalt <robwalter96@gmail.com>
0e2c9e0
to
4f643a8
Compare
{ | ||
// this scaling is to prevent tiny triangles that can potentially occur on the outer boundary | ||
// of the poly to be included into the result | ||
p.scale(<T as From<f32>>::from(0.9999)) |
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.
I think this will have the opposite effect on concave polygons
Tried this, it was very nice. A bit cumbersome with the difference in API to switch to this algorithm. Much slower, but its very very nice to not have a library crash when input is malformed... |
To be honest I'm fine with #1234 superseding this PR here. I'll close the PR, but not delete the branch for now. |
Relevant commits start from 409b815
This PR depends on #1083 and #1087
Feel free to test the latest version of the algo with this app
... and report errors if you find some 🤞🏼
Description
This is a draft for a new algorithm for boolops.
It was created because the current implementation in the repo has some issues with panics. This spawns a lot of issues in the repository.
The new algorithm might not be the most performant candidate. Still, it poses a good alternative for scenarios in which not every nano second is counted. Overall, I couldn't notice any performance issues in my application yet. That being said, I'm still open for a discussion about performance if that's a critical thing for you.
Algorithm on a high level
The algorithm itself is dead simple:
Stitch
trait to reassemble the triangles intoMultiPolygons
CHANGES.md
if knowledge of this change could be valuable to users.