Skip to content
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

Maximum call stack size exceeded on intersection #124

Closed
Tracked by #1
braadworst opened this issue Jul 26, 2021 · 2 comments
Closed
Tracked by #1

Maximum call stack size exceeded on intersection #124

braadworst opened this issue Jul 26, 2021 · 2 comments

Comments

@braadworst
Copy link

Hi, trying to intersect two polygons, but get the aforementioned error.

polygon-clipping.v0.15.3.js:1110 Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at Segment.afterState (polygon-clipping.v0.15.3.js:1110)
    at Segment.beforeState (polygon-clipping.v0.15.3.js:1103)
    at Segment.afterState (polygon-clipping.v0.15.3.js:1111)
    at Segment.beforeState (polygon-clipping.v0.15.3.js:1103)
    at Segment.afterState (polygon-clipping.v0.15.3.js:1111)
    at Segment.beforeState (polygon-clipping.v0.15.3.js:1103)
    at Segment.afterState (polygon-clipping.v0.15.3.js:1111)
    at Segment.beforeState (polygon-clipping.v0.15.3.js:1103)
    at Segment.afterState (polygon-clipping.v0.15.3.js:1111)
    at Segment.beforeState (polygon-clipping.v0.15.3.js:1103)

I've included the files that I was working with
geojson.zip

Am I using it in the wrong way? I didn't see the same issue yet hence I made a new ticket for it

@Athorcis
Copy link

Athorcis commented Nov 2, 2021

The problem seems to happen when the RingOut object is built, I found a case where one of the segments has itself as the previous segment
Screenshot_1
but I'm not sure that add a check to the following line would suffice

segment.prev = prevSeg

@macksal
Copy link
Contributor

macksal commented Jun 24, 2022

@Athorcis I get the same issue, and it seems to propagate from earlier in the code.

At this line:

prevNode = this.tree.prev(prevNode)

I get these evaluations:

> node.key == this.tree.prev(node).key
true
> node == this.tree.prev(node)
false

So it looks like there are two nodes in the splay tree with the same key. I don't know enough about the algorithm to know if this should be avoided or not, but I will read the paper. If this is the triggering condition, it seems easy to just use tree.add and not tree.insert since insert allows for two nodes with the same key.

macksal added a commit to macksal/polygon-clipping that referenced this issue Jun 24, 2022
Tentative fix for mfogel#124: Maximum call stack size exceeded on intersection
macksal added a commit to macksal/polygon-clipping that referenced this issue Mar 8, 2023
macksal added a commit to macksal/polygon-clipping that referenced this issue Mar 8, 2023
Tentative fix for mfogel#124: Maximum call stack size exceeded on intersection
macksal added a commit to macksal/polygon-clipping that referenced this issue Mar 8, 2023
@mfogel mfogel closed this as completed in 3621dcf Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants