geom
geom copied to clipboard
Multipolygon difference error
The following difference of mp1
and mp2
multipolygons gives the empty polygon, but the difference is not empty:
mp1 := geom.MultiPolygon{geom.Polygon{geom.Path{geom.Point{X: 99, Y: 164}, geom.Point{X: 99, Y: 108}, geom.Point{X: 114, Y: 108}, geom.Point{X: 114, Y: 0}, geom.Point{X: 121, Y: 0}, geom.Point{X: 121, Y: 164}, geom.Point{X: 99, Y: 164}}, geom.Path{geom.Point{X: 0, Y: 499}, geom.Point{X: 0, Y: 488}, geom.Point{X: 88, Y: 488}, geom.Point{X: 88, Y: 465}, geom.Point{X: 97, Y: 465}, geom.Point{X: 97, Y: 326}, geom.Point{X: 79, Y: 326}, geom.Point{X: 79, Y: 258}, geom.Point{X: 121, Y: 258}, geom.Point{X: 121, Y: 499}, geom.Point{X: 0, Y: 499}}}}
mp2 := geom.MultiPolygon{geom.Polygon{geom.Path{geom.Point{X: 114, Y: 0}, geom.Point{X: 161, Y: 0}, geom.Point{X: 161, Y: 168}, geom.Point{X: 114, Y: 168}, geom.Point{X: 114, Y: 0}}}}
difference := mp2.Difference(mp1)
fmt.Printf("DIFFERENCE %+v", difference)
The green and blue polygons are mp1
and the magenta is mp2
What is the difference expected to be in this case?
In the following drawings, green shapes are mp1
and magenta shape mp2
, the expected result is mp2
shape(s) without mp1
parts
Maybe this drawing is better:
Let me know whether #3 fixes the issue. You will also have to update the upstream library github.com/ctessum/polyclip-go.
The case of the issue now is working, but I have a new one that doesn't. I will put here when I extract the coordinates. Thanks
I made pull request #4 with a test file that gets the errors that I found in the library
Hi, do you can run the tests?
Thanks for the pull request, but it will probably be several days before I have time to take a look at it.