geom.Contains expected behavior #639
-
Thank you for this awesome project In function description, // Contains returns true if and only if geometry A contains geometry B.
// Formally, the following two conditions must hold:
//
// 1. No points of B lies on the exterior of geometry A. That is, B must only
// be in the exterior or boundary of A.
//
// 2 .At least one point of the interior of B lies on the interior of A. That
// is, they can't *only* intersect at their boundaries.
func Contains(a, b Geometry) (bool, error) {
return relateMatchesAnyPattern(a, b, "T*****FF*")
} But while running below code, result is a := geom.NewPolygon(
[]geom.LineString{
geom.NewLineString(geom.NewSequence([]float64{0, -10, 0, 10, 5, 10, 5, -10, 0, -10}, geom.DimXY)),
}).AsGeometry()
b := geom.NewPoint(geom.Coordinates{XY: geom.XY{X: 0, Y: 0}}).AsGeometry()
contains, err := geom.Contains(a, b)
if err != nil {
return
}
fmt.Println(contains) https://go.dev/play/p/JP_jmoRgylV I'm sure I'm doing something wrong or misunderstand of description, what is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @smallfish06,
The boundary of a point is always the empty geometry.
The
In particular, the interior of B (which is the point itself) doesn't lie on the interior of A (the rectangle). Instead, it lies on the boundary of A. Hopefully that helps! |
Beta Was this translation helpful? Give feedback.
Hi @smallfish06,
The boundary of a point is always the empty geometry.
The
Contains
predicate is false because the 2nd condition (below) is not met.In particular, the interior of B (which is the point itself) doesn't lie on the interior of A (the rectangle). Instead, it lies on the boundary of A.
Hopefully that helps!