Closed cmy235 closed 1 year ago
Hello @cmy235 ,
Sorry for delay with response. Infinite loop happens because of numeric errors when two close segments intersect. I cannot overcome this problem completely, but I can suggest workaround. You may scale you polygons before performing operation:
const m = new Flatten.Matrix().scale(1e6, 1e6);
p0 = p0.transform(m);
p1 = p1.transform(m);
I also found that two polygons have different orientations, it may be fixed like this:
if ([...p0.faces][0].orientation() != [...p1.faces][0].orientation()) {
p1 = p1.reverse();
}
Then unfy will succeed. In this case. Hope it was helpful
Thanks, Alex Bol
I consistently see this error from the
.testInfiniteLoop
check. It generally happens when two polygons share points and one is contained inside the other. I am working with 2D geoJSON coordinate data (epsg:4326), see img below for polygons being compared (p0 = dark, p1 = light)I originally thought was tied to the floating points based on previous issues, but it persists after rounding. Before calls to unify I check that the polygon is valid and the face simple.
I am using v1.2.24 and also tested with 1.2.22.