-
Notifications
You must be signed in to change notification settings - Fork 942
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
Replacing jsts for turf/difference #644
Conversation
👍 I'll have a crack at it, I scanned briefly the source code of the Also another library that looks solid is |
Thanks for taking a look. Let me know if you want me to do anything additional. Yeah the polygon offset library does look good, hopefully between that and martinez I think we could do away with jsts. |
… replace-jsts-difference
@rowanwins Ok I've added a significant amounts of tests to this library. Things I've noticed/modified:
|
awesome work as always @DenisCarriere ! Yeah happy to ditch the Yep the polygon/multipolygon thing is a bit complicated but hopefully with a bit of thought between here and martinez it shouldn't be a deal breaker. And Im glad to see the performance is holding up. I flagged performance over in the martinez repo a while ago and it may be something we can look at further, Im not sure they've had much time to do any optimising (or at least checking that it's as optimised as possible!) |
👍 Sounds good, lets keep these PR's open and revamp all the modules that have Since these will be breaking changes, lets keep the PR's open until we are ready to do the next major release. That way we can still add patches & minor updates while we continue working on this. 🛌 now |
yep agreed re holding off on the release until all the other modules are ready as well |
Just thinking @DenisCarriere - is there anything stopping us from starting to implement the other modules (eg union, clip, xor). Do we need to wait on anything downstream in martinez etc, or should we just get cracking? |
@rowanwins Had another look at this library and it's 95% done (very good so far!), we just need to solve that issue with Polygon/MultiPolygon outputs. Example - Split polygon with holeCurrent Output:
Expected Output:
@rowanwins Which option would you prefer? FeatureCollection or MultiPolygon (both are fine with me)? |
For comparison here are the results using the polybooljs library which offers an alternate martinez implementation. Most the results appear to be marginally faster compared to the
It has the same shortcomings in terms of the output not adequately distinguishing between poly with holes and multi-poly. |
@rowanwins I'd say the performance is pretty much the same between the two libraries. Both libraries seem to be in their early stages of development (<40 commits and only a few issues opened/closed). |
This PR is ready to be merged 👍 (waiting for other Benefits of replacing
|
Gday @DenisCarriere Good news, glad you're happy with where it's at. I reckon we hold off on creating the others and merging I/we take a peak upstream in Cheers |
Agreed, commented here: w8r/martinez#16 (comment) |
With my latest changes to martinez I'm getting the following results running the benchmark tests, so some improvements.
It would be good to get some comparable benchmark results with jsts. |
Awesome stuff! 👍 I had already ran some benchmark tests with turf/packages/turf-difference/bench.js Lines 16 to 35 in 261295a
|
Thanks @DenisCarriere . It might also be worth getting one or two really complex polys (eg lots of vertices, not complex in terms of holes and multi-ness) jut to check that performance doesn't degrade as the count of vertices goes up. |
👍 Agreed, the current fixtures are the "simple" ones, we get those perfect first, then we investigate in more complex geometries (not including invalid geometries of course). |
Gday @DenisCarriere I've pushed up the latest version which I think now matches the output that will come from martinez. I've also added a complex poly test although for some reason Anyway Im running out of puff this evening but another step closer I think... |
👍 Awesome work @rowanwins , I'll have a look at those |
@rowanwins Might need to merge the changes from #725 (might be easier to close this PR and start a new one). Seems like |
Going to close this PR due to so many Conflicts, this PR will simply be used as reference. |
@rowanwins I just released a asm.js / webassembly port of Angus Johnson's Clipper (https://sourceforge.net/projects/polyclipping/) library named js-angusj-clipper (https://www.npmjs.com/package/js-angusj-clipper). While the port is pretty new, the library it is based on is pretty solid on itself. PS: It supports both clipping (Union, Difference, Xor, Intersection) as well as offsetting. |
Woot it's made in Typescript & C++ (rarely see those two languages together), it must be fast! 🏎 💨 @xaviergonz Feel free to send a PR to get a rough draft up and @rowanwins or myself can have a look at it afterwards. 👍 Definitely looking forward to using this. |
To-Do
Gday @DenisCarriere
I thought perhaps we could make a start replacing JSTS. I'm somewhat familiar with the martinez module so I thought that might be a good starting point and would help reduce a lot of the jsts dependencies.
So I've replaced jsts with martinez, it's gone pretty smoothly, a couple of notes
Anyway just getting the ball rolling on this long over-due task :)