Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - Spatial Data Support » Spatial types and functions » ST_Geometry type

ST_OrderingEquals method

Tests if a geometry is identical to another geometry.

Name Type Description



The other geometry value that is to be compared to the geometry-expression.

  • BIT

    Returns 1 if the two geometry values are exactly equal, otherwise 0.


Tests if an ST_Geometry value is identical to another ST_Geometry value. The two geometries must contain the same hierarchy of objects with the exact same points in the same order to be considered equal under ST_OrderingEquals.

The ST_OrderingEquals method differs from ST_Equals in that it considers the orientation of curves. Two curves can contain exactly the same points but in opposite orders. These two curves are considered equal with ST_Equals but unequal with ST_OrderingEquals. Additionally, ST_OrderingEquals requires that each point in both geometries is exactly equal, not just equal within the tolerance-distance specified by the spatial reference system.

The ST_OrderingEquals method defines the semantics used for comparison predicates (= and <>), IN list predicates, DISTINCT, and GROUP BY. If you wish to compare if two spatial values are spatially equal (contain the same set of points in set), you can use the ST_Equals method.

Note The SQL/MM standard defines ST_OrderingEquals to return a relative ordering, with 0 returned if two geometries are spatially equal (according to ST_Equals) and 1 if they are not equal. The software follows industry practice and differs from SQL/MM in that it returns a boolean with 1 indicating the geometries are equal and 0 indicating they are different. Further, the ST_OrderingEquals implementation differs from SQL/MM because it tests that values are identical (same hierarchy of objects in the same order) instead of spatially equal (same set of points in space).
  • SQL/MM (ISO/IEC 13249-3: 2006)



The following example returns the result 16. The Shape corresponding to ShapeID the result 16 contains the exact same points in the exact same order as the specified polygon.

SELECT ShapeID FROM SpatialShapes
WHERE Shape.ST_OrderingEquals( NEW ST_Polygon( 'Polygon ((0 0, 2 0, 1 2, 0 0))' ) ) = 1

The following returns the result 1 because the two linestrings contain exactly the same points in the same order.

SELECT NEW ST_LineString('LineString(0 0, 1 0)')
    .ST_OrderingEquals(NEW ST_LineString('LineString(0 0, 1 0)'))

The following returns the result 0 because the two linestrings are defined in different orders (even though the two linestrings are spatially equal (ST_Equals is 1)).

SELECT NEW ST_LineString('LineString(0 0, 1 0)')
    .ST_OrderingEquals(NEW ST_LineString('LineString(1 0, 0 0)'))