Oracle8i Spatial User's Guide and Reference
Release 8.1.5

A67295-01
 Library Product Contents Index

# 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

SDO_GEOM.RELATE

Determines how two objects interact.

SDO_GEOM.VALIDATE_GEOM

Determines if a geometry is valid.

SDO_GEOM.VALIDATE_LAYER

Determines if all geometries in a layer are valid.

This chapter refers to the relational Spatial model only.

## SDO_GEOM.RELATE

### Purpose

This function examines two geometry objects to determine their spatial relationship. It 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. DETERMINE 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 either 'INSIDE', 'TOUCH', or 'FALSE' depending on the outcome of the test.

None.

## SDO_GEOM.VALIDATE_GEOM

### Purpose

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

### Syntax

SDO_GEOM.VALIDATE_GEOM (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 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 is the first point on the next row

None.

## SDO_GEOM.VALIDATE_LAYER

### Purpose

This function 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 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 is the first point on the next row

None.