geo icon indicating copy to clipboard operation
geo copied to clipboard

Implement Polygon.Intersection

Open ctessum opened this issue 6 years ago • 9 comments

Since it seems acceptable to use this space to indicate interest in specific features, I would like to request polygon intersections. The Go language currently lacks a high quality library for boolean operations on geographic features, and having one would help me out greatly. (I am one of the maintainers of a low-to-medium quality library.) I greatly appreciate all the work that has happened so far to port this library to Go.

ctessum avatar Jul 25 '18 21:07 ctessum

Yep, it is totally acceptable. ;-)

e7cfa0c added Polygon.Contains and Polygon.Intersects. To clarify, you're after the equivalent of C++'s S2Polygon::InitToIntersection?

dsymonds avatar Jul 25 '18 21:07 dsymonds

Yes, I mean the equivalent of S2Polygon::InitToIntersection. Thanks!

ctessum avatar Jul 25 '18 22:07 ctessum

I'm interested in contributing a PR for this — are there any thoughts on using Martinez-Rueda for the boolean operation algorithm? Or would it be best to port the C++ version accordingly?

brendanashworth avatar Oct 16 '19 18:10 brendanashworth

There is a port of (one of) the Martinez-Rueda algorithms here. However, that one is for planar geometry, not sure that it would work here?

ctessum avatar Oct 17 '19 08:10 ctessum

@ctessum I'm not sure myself. The projection onto a plane would conserve intersection points but not lengths.. is it naive to assume the lengths are proportional and thus area is conserved after we project back to the sphere?

brendanashworth avatar Oct 22 '19 21:10 brendanashworth

any update on this? Curious if anyone is actively working on this piece?

alphairys avatar Apr 06 '20 16:04 alphairys

@alphairys I don't have an update/I haven't been working on it. If you're looking for a workaround, I've been using CellUnions (after covering the polygon with cells) as a workaround, and they implement simple binary operations like CellUnionFromIntersection.

brendanashworth avatar Apr 08 '20 19:04 brendanashworth

There is still work being done on this

rsned avatar Apr 08 '20 20:04 rsned

I think someone has already done that https://github.com/davidreynolds/gos2/blob/master/s2/polygon_test.go

ipipdotnet avatar Jun 25 '22 06:06 ipipdotnet