-
Notifications
You must be signed in to change notification settings - Fork 946
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
Replaced polygon-clipping with polyclip-ts #2729
Conversation
Really appreciate you putting this together @cmurphy23. Take there is no workaround for the esModuleInterop issue that might let us get this merged (and those issues resolved) sooner? Also understand your note about the tests. Anything that looks like more than a rounding change, we can go through together, perhaps with one of the other maintainers. |
No problem, @smallsaucepan, glad to be able to contribute. The PR for polyclip-ts got merged and a new release was made. This PR now references the new release and should be considered for merging. Thanks! |
Hi @cmurphy23. Had a go at building your branch and ran into the following error during in turf-intersect. Are you seeing this too?
Running polyclip-ts through arethetypeswrong does suggest there's a problem with its packaging: We've fixed problems like these within Turf, so I might submit a PR to polyclip-ts. Wanted to confirm first though that I'm not the only one seeing this error. |
Created an issue luizbarboza/polyclip-ts#18 to follow up on a possible fix at the polyclip-ts end. |
Hi @smallsaucepan, I could have sworn the tests were passing, but I must have had some cached file or something, because I tried with a clean repo and the tests failed like you said. Sorry for the mistake. Thanks for making the issue on polyclip-ts, I'll see if I can be helpful over there. |
All good. Found out the exports PR was rolled back the day after your PR was merged. Just a quirk of timing 🤷 Will give the new issue a week for any testing feedback, then put forward a PR. |
@cmurphy23 FYI just followed up over on the polyclip issue for some feedback on what a successful PR might look like. |
Hi @cmurphy23. I think the issues with polyclip-ts packaging are just about resolved. Once 0.16.8 is released we should be good to go. Will you still have some availability to retest and prepare to merge? |
Hi @smallsaucepan @cmurphy23 I just saw that polyclip-ts v0.16.8 has been released. Do you know how long it will roughly take for this to make it into a Turfjs release? If there's anything I can do to progress this, I'm happy to help, but I haven't worked on this repo before. |
…d a bunch of verification test cases based on problematic example data in related issues.
Hi @cmurphy23. Pushed a few changes now that the 0.16.8 polyclip-ts is published. Also added a few verification tests based on the linked issues. Will give it another once over and hopefully approve to merge. |
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.
Noticed a few empty polygons were added in the case of difference/test/out/issue-#721 and issue-#721-inverse. Proceeding as 721 seems an odd example given we're diffing zero area(?) polygons.
This commit replaces the polygon-clipping library with polyclip-ts, a goal mentioned in several issues (#2409, #2277, #2048), with even more issues related to polyon-clipping problems that don't mention polyclip-ts (#2705, #2420, #1983, and others).
This PR is a placeholder, dependent on this PR for polyclip-ts so that the polyclip-ts library doesn't fail the
esModuleInterop
check. Once those changes have been merged and released, the polyclip-ts version just needs to be incremented in the different modules' package.json files, then turf should should build and the tests should pass.The affected packages are: intersect, difference, union, dissolve, and mask
It is worth noting that I am not an expert on these algorithms, and in the cases where the test results differed, I simply updated the tests with the new results. The vast majority of the differences were just floating point rounding differences, but there were different results for two turf-difference tests. For the test "issue-721", two polygons are returned for the difference instead of one, where the first polygon is basically identical to the original answer, but a new very small polygon on the border of the polygons has also been found and returned. For "issue-721-inverse", instead of no difference being found, three very small polygons have been found on the borders. I don't actually know what the correct answers are since the test case is truly an edge case and higher precision might produce a different result. However, based on the issues I've mentioned, polyclip-ts seems like the more reliable repo, turfjs is regularly having issues with these operations using polygon-clipping, and it would be nice if it didn't.
Resolves #2409
Resolves #2277
Resolves #2048
Resolves #2705
Resolves #2420
Resolves #1983
... and others (TBC)
Allows truncate workaround to be removed from the following already resolved issues as well:
Resolves #2479
Resolves #2306
Resolves #2601
I would argue it's closest to a bug fix.
I followed the steps, just need polyclip-ts to update and release, then this code will work.