ST_Relate

Definition

ST_Relate compares two ST_Geometries and returns 1 (Oracle) or t (PostgreSQL) if the geometries meet the conditions specified by the DE-9IM pattern matrix string; otherwise, 0 (Oracle) or f (PostgreSQL) is returned.

Syntax

sde.st_relate (g1 sde.st_geometry, g2 sde.st_geometry, patternMatrix String)

Return type

Boolean

Example

A DE-9IM pattern matrix is a device for comparing geometries. There are several types of such matrices. For example, the equals pattern matrix will tell you if any two geometries are equal.

The table relate_test is created with the following CREATE TABLE statement.

CREATE TABLE relate_test (g1 sde.st_geometry, g2 sde.st_geometry, g3 sde.st_geometry);

The following INSERT statements insert a sample subclass into the relate_test table.

INSERT INTO relate_test VALUES (
sde.st_pointfromtext ('point (10.02 20.01)', 0),
sde.st_pointfromtext ('point (10.02 20.01)', 0),
sde.st_pointfromtext ('point (30.01 20.01)', 0)
);

The following SELECT statement and the corresponding result SET lists the subclass name stored in the geotype column with the dimension of that geotype.

Oracle

SELECT sde.st_relate (g1, g2, 'T*F**FFF*') equals, sde.st_relate (g1, g3, 'T*F**FFF*') not_equals 
FROM RELATE_TEST;
 
equals     not_equals 

1          0

PostgreSQL

SELECT st_relate (g1, g2, 'T*F**FFF*') 
AS equals, 
st_relate (g1, g3, 'T*F**FFF*') 
AS not_equals 
FROM relate_test;
 
equals     not_equals 

t          f

2/5/2013