Skip to main content

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

NameTypeDescription
aGeometry | Prepared<Geometry>First geometry
bGeometrySecond geometry

Returns

boolean

true if geometry a contains geometry b

Throws

  • GEOSError on unsupported geometry types (curved)

See also

Examples

contains: true
contains: false