Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Polygon.Intersection #44

Open
ctessum opened this issue Jul 25, 2018 · 9 comments
Open

Implement Polygon.Intersection #44

ctessum opened this issue Jul 25, 2018 · 9 comments

Comments

@ctessum
Copy link

ctessum commented Jul 25, 2018

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.

@dsymonds
Copy link
Contributor

Yep, it is totally acceptable. ;-)

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

@ctessum
Copy link
Author

ctessum commented Jul 25, 2018

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

dsymonds pushed a commit that referenced this issue Jul 26, 2018
This contributes to #44.

Signed-off-by: David Symonds <dsymonds@golang.org>
dsymonds pushed a commit that referenced this issue Aug 11, 2019
This contributes towards #44.

Signed-off-by: David Symonds <dsymonds@golang.org>
@brendanashworth
Copy link

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?

@ctessum
Copy link
Author

ctessum commented Oct 17, 2019

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?

@brendanashworth
Copy link

@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?

@alphairys
Copy link

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

@brendanashworth
Copy link

@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.

@rsned
Copy link
Collaborator

rsned commented Apr 8, 2020

There is still work being done on this

@ipipdotnet
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants