ctessum / geom

Geometry objects and functions for Go
BSD 2-Clause "Simplified" License
56 stars 15 forks source link

Multipolygon difference error #2

Open pachopepe opened 6 years ago

pachopepe commented 6 years ago

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

image

ctessum commented 6 years ago

What is the difference expected to be in this case?

pachopepe commented 6 years ago

In the following drawings, green shapes are mp1 and magenta shape mp2, the expected result is mp2 shape(s) without mp1 parts

image

Maybe this drawing is better: image

ctessum commented 6 years ago

Let me know whether #3 fixes the issue. You will also have to update the upstream library github.com/ctessum/polyclip-go.

pachopepe commented 6 years ago

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

pachopepe commented 6 years ago

I made pull request #4 with a test file that gets the errors that I found in the library

pachopepe commented 6 years ago

Hi, do you can run the tests?

ctessum commented 6 years ago

Thanks for the pull request, but it will probably be several days before I have time to take a look at it.