-
Notifications
You must be signed in to change notification settings - Fork 954
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
turf.dissolve pegs cpu and does not return #2832
Comments
We would love a fix, but a workaround test of the features before calling dissolve would help us too. We're desparate to get beyond this because it does not return or crash. |
Hi @jim-greene-l2. Have some good news for you, in the form of a workaround. Hopefully it's acceptable. I was able to process all polygons successfully by first calling Turf truncate on the FeatureCollection. A call with 14 decimal places precision seemed to work. 6 decimal places is about 11cm. If that's of use to you as a workaround, please give it a try. import { truncate } from "@turf/truncate";
...
fc = truncate(fc, { precision: 14 }); We'll leave the issue open as there is definitely a problem occurring, though not 100% sure why just yet. We will look into the root cause when we can. If the workaround doesn't work for you, sing out and we'll provide what details we can to help you try other approaches. |
Some further detail for identifying the root cause. The call to polyclip.union isn't returning if the provided data for the 1st, 3rd, and 4th polygons are included: fc.features = fc.features.filter(
(f) =>
f.properties.id === "340110103022053" || // Poly 1
// f.properties.id === "340110103022061" ||
f.properties.id === "340110103022092" || // Poly 3
f.properties.id === "340110103022057" || // Poly 4
// f.properties.id === "340110103022066" ||
// f.properties.id === "340110103022042" ||
// f.properties.id === "340110103022095" ||
// f.properties.id === "340110103022062"
); Unioning poly 1 with 3, or poly 1 with 4, works ok. Combining poly 1 with 3 AND 4 hangs. This may have something to do with how poly 3 and 4 are being merged. Curiously poly 3 and 4 share a point:
Altering this point slightly e.g. to 39.22267171331342 in one of the polygons allowed the union to work. The truncate workaround mentioned above is a more accessible way to nudge the coords slightly to jar them out of whatever alignment is causing polyclip to have issues. |
Thank you. Truncate is a lot simpler and more elegant than what we had scrambled together! |
The enclosed javascript file contains a feature collection of 9 tabblocks.
turf.dissolve works instanstaneously if one of the tabblocks is removed. Otherwise it does not return and the cpu is running at 100+%
The code will run with the good 8 tabblocks as-is. Comment line 57 to avoid filtering the one other tabblock that causes the issue.
We are able to load the feature collection into geojson.io and visualize and select all 9 of the component features (see image below)
This is running with turf 7.2.0, node version 20.16, on RHEL 8.10
turftest.txt
The text was updated successfully, but these errors were encountered: