-
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
Turf simplify hangs on this input. #918
Comments
Some other troublesome inputs:
|
Hey @jfgorski Thanks for the report. Yeah obviously the crazy input is going to be problematic however we should be able to find a way to at least throw an error rather than just killing node. We'll have a think and report back. |
@rowanwins @DenisCarriere
Having said that, I think we should implement a |
A |
Thanks for those thoughts and doco @stebogit , I agree with your proposal. I also think it would be good to have some of these principles nailed down, applied consistently, and documented. |
Great PostGIS reference @stebogit, I agree that we shouldn't be testing invalid geometries, but include that as a separate module. |
Is this still a |
@jfgorski I've tried to create MultiPolygon's using your coordinates and they are all "invalid", so unless you can provide valid geometries then this wouldn't be fixed. simplify(multiPolygon([[[[0, 90], [0, 90], [0, 90], [0, 90], [0, 90], [0, 90], [0, 90], [0, 90], [0, 90], [0, 90], [0, 90]]]]));
simplify(multiPolygon([[[[0, 1], [0, 2], [0, 3], [0, 2.5], [0, 1]]]]));
simplify(multiPolygon([[[[0, 1], [0, 1], [1, 2], [0, 1]]]])); All of them throws this error:
@jfgorski Please don't hesitate to re-open this issue if you can replicate these errors with valid geometries using |
@stebogit Actually the error is coming from /**
* Simplifies the coordinates of a Polygon with simplify-js
*
* @private
* @param {Array<number>} coordinates to be processed
* @param {number} tolerance simplification tolerance
* @param {boolean} highQuality whether or not to spend more time to create a higher-quality
* @returns {Array<Array<Array<number>>>} simplified coords
*/
function simplifyPolygon(coordinates, tolerance, highQuality) {
console.log(coordinates, coordinates.length);
return coordinates.map(function (ring) {
var pts = ring.map(function (coord) {
return {x: coord[0], y: coord[1]};
});
if (pts.length < 4) {
throw new Error('invalid polygon');
} When it applies
To:
However... it seems like the latest release doesn't "hang" it simply returns an error saying @stebogit Was this a fix we did post |
@DenisCarriere Here's another try I made that passed the
and then node got stuck using CPU. Makes sense that it could be these versions 4.6.0 without the fix. |
@DenisCarriere yes: #903 |
Throw errors to invalid MultiPolygons fixes #918
My case with version 6.5.0, it hangs when 'invalid polygon' exception has happened twice. I think you all agreed that this is not the expected output. Any ideas on how to fix this? Or Could you suggest alternatives which does not hang? Thanks. |
Running v4.6.0, this input caused simplify to hang the nodejs process in a compute loop:
(I realize it's unusual input.)
The text was updated successfully, but these errors were encountered: