-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
Description
I'm looking for a way to use this library to check, using Cartesian coordinates:
- If two polygons intersect
- if a polygon fully contains another polygon
I'm not seeing any exported functions for doing this. Is there any support for it, or should I look somewhere else?
From what I can tell, checking if a point is contained in a polygon can be accomplished this way:
func PolygonContainsPoint(polygon *geom.Polygon, p *geom.Point) bool {
exterior := polygon.LinearRing(0)
if !xy.IsPointInRing(geom.XY, p.Coords(), exterior.FlatCoords()) {
return false
}
// Next rings are holes
num := polygon.NumLinearRings()
for i := 1; i < num; i++ {
interior := polygon.LinearRing(i)
if xy.IsPointInRing(geom.XY, p.Coords(), interior.FlatCoords()) {
return false
}
}
return true
}Or? I'm not too familiar with rings or if this is how they're intended to be used. Either way, such a function would be a useful addition to this library, I think.
Reactions are currently unavailable