This topic describes the ST_Relate function. This function checks whether two geometry objects are spatially related. For example, this function checks whether two geometry objects intersect or whether one geometry object is included in the other.
Syntax
boolean ST_Relate(geometry geomA , geometry geomB , text intersectionMatrixPattern);
text ST_Relate(geometry geomA , geometry geomB);
text ST_Relate(geometry geomA , geometry geomB , integer boundaryNodeRule);Parameters
| Parameter | Description |
|---|---|
| geomA | The first geometry object that you want to specify. |
| geomB | The second geometry object that you want to specify. |
| intersectionMatrixPattern | The DE-9IM matrix pattern that you want to specify. |
| boundaryNodeRule | The boundary node rule that you want to specify. |
Description
- Version 1: This function checks whether the geometry objects that you specify spatially
intersect at their interior rings, boundaries, or exterior rings in compliance with
the DE-9IM matrix pattern that you define. If all the specified conditions are met, this function
returns True. Otherwise, this function returns False.
- This usage is suitable especially when you need to test compound checks of road intersections or crosses in one step.
- This function does not support GeometryCollection objects.
- Version 2: This function returns the DE-9IM matrices of the geometry objects that you specify. This function does not support GeometryCollection objects.
- Version 3: Version 3 is similar to version 2, except that version 3 allows you to
define a boundary node rule.
- 1: OGC/MOD2
- 2: Endpoint
- 3: MultivalentEndpoint
- 4: MonovalentEndpoint
Examples
- Version 1:
SELECT ST_Relate('LINESTRING(0 0,0 1)'::geometry, 'LINESTRING(0 0,1 1)'::geometry,'FF1F00102'); st_relate ----------- t (1 row) - Version 2:
SELECT ST_Relate('LINESTRING(0 0,0 1)'::geometry, 'LINESTRING(0 0,1 1)'::geometry); st_relate ----------- FF1F00102 (1 row)