mfogel / polygon-clipping

Apply boolean polygon clipping operations (union, intersection, difference, xor) to your Polygons & MultiPolygons.
MIT License
547 stars 63 forks source link

Error: Unable to complete output ring starting at #40

Closed jliebrand closed 5 years ago

jliebrand commented 6 years ago

The following coordinates cause an error to be thrown (unable to complete output ring)

https://gist.github.com/jliebrand/d59d08d3a571ccec7d7f55db47aecf0e

haven't had time to simplify this

jliebrand commented 6 years ago

Hi @mfogel - I know you're busy, but any update on this and the other bugs?

mfogel commented 6 years ago

Hi @jliebrand I'm having some trouble replicating this. On version 0.8.0 and on the current HEAD of master I'm able to run union, intersection and difference on these coords on my machine (xor fails with an 'Maximum call stack size exceeded', but I correct me if I'm wrong I don't think that's what you're running into)

Just to make sure we're on the same page, here's exactly what I'm running https://gist.github.com/mfogel/f65acbc483bc1792111c7349c6d9c0dc (scroll down to the bottom to see anything interesting - the coords variable is copied over from your gist)

Am I using the coords variable as intended from your gist?

jliebrand commented 6 years ago

Hmm maybe I pasted the wrong coords. We see this pop up on our client side error logging, and we see a lot of both errors... Let me see if I can create a gist with coords that show this specific error.

jliebrand commented 6 years ago

Here's a few: https://gist.github.com/jliebrand/d209f3efe395feff17333ed07ec76352

and another: https://gist.github.com/jliebrand/51059805816f7d385cdcb970d5059f08

jliebrand commented 6 years ago

let me know if you need more examples (also for the max callsize exceeded - we got examples of those too)

mfogel commented 6 years ago

Thanks. I've reproduced this locally with v0.9 with the first set of coordinates (https://gist.github.com/jliebrand/d209f3efe395feff17333ed07ec76352)

The second set of coordinates (https://gist.github.com/jliebrand/51059805816f7d385cdcb970d5059f08) gets stuck in an infinite loop for me on v0.9, similar to #42

mfogel commented 5 years ago

It appears the fix for #36 has fixed two of the three sets of coordinates referenced in this bug. This set is still failing for me: https://gist.github.com/jliebrand/d59d08d3a571ccec7d7f55db47aecf0e

mfogel commented 5 years ago

I take it back. https://gist.github.com/jliebrand/d59d08d3a571ccec7d7f55db47aecf0e does work for me now, on all four operations. It appears the fix for #36 fixed these cases.

arunasank commented 5 years ago

Please reopen here. I found a case that does not work:

levskaya commented 5 years ago

Another test case for this as of v0.12.2 (feb 2 2019)

Error: Unable to complete output ring starting at [-15.416889550792858, 71.79703627304265]. Last matching segment found ends at [-0.01762902507286057, -3.049711540808145].
    at Function.factory (polygon-clipping.umd.js?cd87:2214)
    at Operation.run (polygon-clipping.umd.js?cd87:2699)
    at Object.intersection (polygon-clipping.umd.js?cd87:2723)
polygonClipping.intersection(
    [[-16.639026895674363, 105.1939588084514],
    [-46.30338186260189, 22.843560819765436],
    [-0.017629025072857116, -3.0497115408081457],
    [-16.639026895674363, 105.1939588084514]],
    [[16.541025708252015, -14.156174343204842],
    [-15.416889550792858, 71.79703627304265],
    [-0.017629025072857116, -3.0497115408081457],
    [16.541025708252015, -14.156174343204842]])