Skip to main content

relatePattern

Returns true if the spatial relationship between geometries a and b matches the specified DE-9IM pattern.

DE-9IM pattern is a 9-character string described by the regular expression /^[F012T*]{9}$/.
Each character represents a dimension of intersection:

  • F - no intersection (-1 dimension)
  • 0 - point
  • 1 - line
  • 2 - area
  • T - any intersection (0, 1 or 2)
  • * - wildcard (F, 0, 1 or 2)

If possible it is better to use a named relationship functions like overlaps or covers.

warning

Do not use this function with invalid geometries. You will get unexpected results.

Parameters

NameTypeDescription
aGeometry | Prepared<Geometry>First geometry
bGeometrySecond geometry
patternstringDE-9IM pattern, 9-character string where each character is one of F,0,1,2,T,*

Returns

boolean

true if the specified pattern matches the spatial relationship between geometries a and b

Throws

  • GEOSError on unsupported geometry types (curved)

See also

  • relate returns the exact DE-9IM matrix string for two geometries
  • prepare improves performance of repeated calls against a single geometry

Examples