Oracle Spatial User's Guide and ReferenceRelease 8.1.6A77132-01

15 Geometry Functions and Procedures

This chapter contains descriptions of the geometric functions and procedures shown in Table 15-1.

Table 15-1 Geometric Functions and Procedures
Function/Procedure  Description

Determines how two objects interact.

Determines if a geometry is valid.

Determines if all geometries in a layer are valid.

This chapter refers to the relational Spatial model only.

SDO_GEOM.RELATE

Purpose

Examines two geometry objects to determine their spatial relationship. This function is available in two forms. See the Usage Notes for more information.

Syntax

SDO_GEOM.RELATE (layername1, SDO_GID1, mask, [layername2,] SDO_GID2)

SDO_GEOM.RELATE (layername1, SDO_GID1, mask, X_tolerance, Y_tolerance,
SDO_ETYPE, num_ordinates, X_ordinate1, Y_ordinate1 [,...,Xn, Yn]
[,SDO_ETYPE, num_ordinates, X_ordinate1, Y_ordinate1 [,...,Xn, Yn]])

Keywords and Parameters

 layername1,layername2 Specifies the name of the data set layer. The layer name is used to construct the name of the geometry and spatial index tables. Data type is VARCHAR2. SDO_GID1,SDO_GID2 Specifies the geometry object identifier. Data type is NUMBER. mask Specifies a list of relationships to check. See the list of keywords in the Usage Notes. X_tolerance, Y_tolerance Specifies the distance two points can be apart and still be considered the same due to rounding errors. Tolerance must be greater than zero. If you want zero tolerance, enter a number such as 0.000005, where the number of zeros to the right of the decimal point matches the precision of your data. Data type is NUMBER. SDO_ETYPE Specifies the type of geometry element. Data type is INTEGER, corresponding to the following constants: 1 SDO_GEOM.POINT_TYPE 2 SDO_GEOM.LINESTRING_TYPE 3 SDO_GEOM.POLYGON_TYPE num_ordinates Specifies the number of ordinates for this element. Data type is NUMBER. X_ordinateN, Y_ordinateN Specifies the X and Y values of a vertex (coordinate pair) in a geometry. Data type is NUMBER.

Returns

The SDO_GEOM.RELATE function can return three types of answers:

1. If you pass a mask listing one or more relationships, the function returns the name of the relationship if it is true for the pair of geometries. If all of the relationships are false, the function returns FALSE.

2. If you pass the DETERMINE keyword in the mask, the function returns the one relationship keyword that best matches the geometries. The DETERMINE keyword can only be used when SDO_GEOM.RELATE is in the SELECT clause of the SQL statement.

3. If you pass the ANYINTERACT keyword in the mask, the function returns TRUE if the two geometries are not disjoint.

The data type is VARCHAR2.

Usage Notes

Use the first form of the function to examine two stored geometric objects.

Use the second form of the function to compare a stored object against a user-defined object. You can specify up to 123 vertices for a single-element geometry. If the geometry has multiple elements, the total number of arguments passed, including SDO_ETYPE, num_ordinates, and the list of vertex coordinates, cannot exceed 255 values.

The following relationships can be tested:

• ANYINTERACT - Returns TRUE if the objects are not disjoint.

• CONTAINS - Returns CONTAINS if the second object is entirely within the first object and the object boundaries do not touch; otherwise, returns FALSE.

• COVEREDBY - Returns COVEREDBY if the first object is entirely within the second object and the object boundaries touch at one or more points; otherwise, returns FALSE.

• COVERS - Returns COVERS if the second object is entirely within the first object and the boundaries touch in one or more places; otherwise, returns FALSE.

• DISJOINT - Returns DISJOINT if the objects have no common boundary or interior points; otherwise, returns FALSE.

• EQUAL - Returns EQUAL if the objects share every point of their boundaries and interior, including any holes in the objects; otherwise, returns FALSE.

• INSIDE - Returns INSIDE if the first object is entirely within the second object and the object boundaries do not touch; otherwise, returns FALSE.

• OVERLAPBDYDISJOINT - Returns OVERLAPBDYDISJOINT if the objects overlap, but their boundaries do not interact; otherwise, returns FALSE.

• OVERLAPBDYINTERSECT - Returns OVERLAPBDYINTERSECT if the objects overlap, and their boundaries intersect in one or more places; otherwise, returns FALSE.

• TOUCH - Returns TOUCH if the two objects share a common boundary point, but no interior points; otherwise, returns FALSE.

Mask values can be combined using the logical Boolean operator OR. For example, `INSIDE + TOUCH' returns 'INSIDE + TOUCH' or 'FALSE' depending on the outcome of the test.

None.

SDO_GEOM.VALIDATE_GEOMETRY

Purpose

Provides a consistency check for valid geometry types. This function checks the representation of the geometry from the tables against the element definitions.

Syntax

SDO_GEOM.VALIDATE_GEOMETRY (layername,SDO_GID)

Returns

This function returns one of the following:

• TRUE if the geometry is valid.

• FALSE if the geometry is invalid for some unknown reason.

• An Oracle error number indicating the problem with the geometry.

The data type is VARCHAR2.

Usage Notes

This function checks for the following:

• Polygons must have at least three points and must be closed.

• Line strings must have at least two points.

• When an SDO_ESEQ spans multiple rows, the last point of the previous row must be the first point on the next row.

None.

SDO_GEOM.VALIDATE_LAYER

Purpose

Examines a layer to determine if the stored geometries follow the defined rules for geometric objects.

Syntax

SDO_GEOM.VALIDATE_LAYER (layername, result_table)

Returns

This function fills the result table with validation results.

Usage Notes

Create an empty result table prior to calling this function. The format of the result table is: (sdo_gid number, result varchar2).

This function checks for the following:

• Polygons must have at least three points and must be closed.

• Line strings must have at least two points.

• When an SDO_ESEQ spans multiple rows, the last point of the previous row must be the first point on the next row.

None.