google / s2-geometry-library-java

Automatically exported from code.google.com/p/s2-geometry-library-java
Apache License 2.0
533 stars 230 forks source link

bug in initToUnion #18

Closed silicontrip closed 3 years ago

silicontrip commented 5 years ago

I'm getting the message Bad Directed edges when trying to Union merge two polygons with correctly oriented edges, and the resulting polygon is not correct. I haven't been able to determine the exact reason it's failing, but I suspect that the edge of one of my polygons is completely obscured by the other polygon and ending up in the unused Edges array and therefore returning false from the polygon builder.

I've noticed that it also happens when trying to union two polygons that share an edge (they will correctly assemble however using the polygonbuilder directed xor options)

Is anyone able to confirm if initToUnion behaves as expected, and if it does, what are the limitations on calling this method?

Thanks Mark

silicontrip commented 5 years ago

I believe the issue is caused by coincident edges, where one edge is a segment of another. RobustCrossing returns 1. I'm not sure how to test for these cases. Looks like I'm going to need to implement my own robustUnion (intersection and subtraction) methods,

eengle commented 3 years ago

Try again. The last update to the library included numerous robustness improvements that generally improve these kinds of operations.

eengle commented 3 years ago

Feel free to reopen if you have any examples to share that still fail on the latest version.