User's Guide and Reference

ST_Relate

ST_Relate compares two geometries and returns 1 (TRUE) if the geometries meet the conditions specified by the DE-9IM pattern matrix string; otherwise, 0 (FALSE) is returned. For information about DE-9IM pattern matrices, see Predicate functions.

Syntax

db2gse.ST_Relate(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry, patternMatrix String)

Return type

Integer

Examples

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.

In this example, an equals pattern matrix, shown in Table 56, is read left to right and top to bottom into a string ("T*F**FFF*").

Table 56. Equals pattern matrix



b




Interior

Boundary

Exterior


Interior

T

*

F

a

Boundary

*

*

F


Exterior

F

F

*

Next, the table RELATE_TEST is created with the following CREATE TABLE statement.

CREATE TABLE RELATE_TEST (rid integer, g1 db2gse.ST_Geometry, 
g2 db2gse.ST_Geometry, g3 db2gse.ST_Geometry);

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

INSERT INTO RELATE_TEST VALUES( 
       1, 
        db2gse.ST_PointFromText('point (10.02 20.01)',db2gse.coordref()..srid(0),
        db2gse.ST_PointFromText('point (10.02 20.01)',db2gse.coordref()..srid(0), 
        db2gse.ST_PointFromText('point (30.01 20.01)',db2gse.coordref()..srid(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.

SELECT rid, relate(g1,g2) equals, relate(g1,g3) not_equals 
FROM relate_test
 
RID     equals    not_equals    
-------- -----------   -----------------
1         1              0 
 
  1 record(s) selected.


[ Top of Page | Previous Page | Next Page ]