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

Expose PointInPolygon and other helpers #5

Open
thomasp85 opened this issue Sep 6, 2017 · 5 comments
Open

Expose PointInPolygon and other helpers #5

thomasp85 opened this issue Sep 6, 2017 · 5 comments
Assignees

Comments

@thomasp85
Copy link

While my own interest is mainly in PointInPolygon, there are other helpers which would be nice to have access to from R, such as Area, Poly2ContainsPoly1, and IntersectPoint

@baddstats baddstats self-assigned this Sep 8, 2017
@baddstats
Copy link
Owner

This has been put on the to-do list..

@thomasp85
Copy link
Author

Perfect - thanks.

Do you have any idea of a time-frame (not being pushy - just out of interest)

@baddstats
Copy link
Owner

PointInPolygon is now exposed (through new function pointinpolygon)

@baddstats
Copy link
Owner

Uh-oh,..., Poly2ContainsPoly1 seems to be incorrect. The code tests whether every vertex of Poly1 lies inside Poly2 but this doesn't deal with cases where an edge of Poly1 crosses outside Poly2. I will investigate whether this has been fixed in later versions of Clipper, and update.

@mpadge
Copy link

mpadge commented Jun 26, 2019

To avoid opening a new issue, may I request another extension of PointInPolygon, via vectorization of polygons to return a matrix of [npoints, npolygons] (or the other way around)?

I also concur with @thomasp85 that it would be helpful to expose other clipper fns, with my choice being to use area in an extension of the main ClipperLib::Clipper::Execute routine to calculate overlap areas? I suspect a great many people using the main polyclip routine would do so because they are interested in areas of overlap, and since the Clipper::Area function directly accepts the Paths object from the solution to the clip, it would be much more efficient if that could be extended within the C++ code, like this:

# set up layer1, layer2
areas <- polyclip_areas (layer1, layer2)
head (areas)
# area1   area2
# 1 456   123
# 2 ...

where area1 is just the area of the "subject polygon" (in AJ's terminology); area2 comes straight from the clipper solution in each instance; and the units can be directly re-scaled with your eps value, because clipper::Area returns a <double>.

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

No branches or pull requests

3 participants