contains
Returns true if geometry b lies in geometry a and their interiors intersect.
Geometry a contains geometry b if all points of b are in the interior
or at the boundary of a and the interiors of a and b have at least one
point in common.
note
According to the definition above, a geometry does not contain its boundary, so for example, a LineString that is completely contained in the boundary of a Polygon is not considered to be contained in that Polygon.
In most cases covers should be used, as it has a simpler definition
and allows for additional optimizations.
contains is the converse of within: contains(a, b) === within(b, a).
warning
Do not use this function with invalid geometries. You will get unexpected results.
Parameters
| Name | Type | Description |
|---|---|---|
a | Geometry | Prepared<Geometry> | First geometry |
b | Geometry | Second geometry |
Returns
boolean
true if geometry a contains geometry b
Throws
GEOSErroron unsupported geometry types (curved)
See also
withinconverse ofcontainscoversmore inclusivecontainscontainsProperlyless inclusivecontainsprepareimproves performance of repeated calls against a single geometry
Examples
contains: true
contains: false