User's Guide and Reference

ST_OrderingEquals

ST_OrderingEquals compares two geometries and returns 1 (TRUE) if the geometries are equal and the coordinates are in the same order; otherwise it returns 0 (FALSE).

Syntax

db2gse.ST_OrderingEquals(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry)

Return type

Integer

Examples

The following CREATE TABLE statement creates the LINESTRING_TEST table, which has two linestring columns, L1 and L2.

CREATE TABLE LINESTRING_TEST (lid integer, l1 db2gse.ST_LineString, 
l2 db2gse.ST_LineString);

The following INSERT statement inserts two linestrings into L1 and L2 that are equal and have the same coordinate ordering.

INSERT INTO linestring_test VALUES (1,
db2gse.LineFromText('linestring (10.01 20.02, 21.50 12.10)', db2gse.coordref()..srid(0)), 
db2gse.LineFromText('linestring (10.01 20.02, 21.50 12.10)', 
db2gse.coordref()..srid(0)));

The following INSERT statement inserts two linestrings into L1 and L2 that are equal but do not have the same coordinate ordering.

INSERT INTO linestring_test VALUES (2,
db2gse.LineFromText('linestring (10.01 20.02, 21.50 12.10)', db2gse.coordref()..srid(0)), 
db2gse.LineFromText('linestring (21.50 12.10,10.01 20.02)', db2gse.coordref()..srid(0)));

The following SELECT statement and corresponding result set shows how the ST_Equals function returns 1 (TRUE) regardless of the order of the coordinates. The ST_OrderingEquals function returns 0 (FALSE) if the geometries are not both equal and have the same coordinate ordering.

SELECT lid, db2gse.ST_Equals(l1,l2) equals, db2gse.ST_OrderingEquals(l1,l2) 
OrderingEquals 
FROM linestring_test
 
lid   equals   OrderingEquals
---   ------   -----------
 1       1           1
 2       1           0


[ Top of Page | Previous Page | Next Page ]