The Oracle-compatible mode of OceanBase Database provides some functions for the construction, query, calculation, and format conversion of spatial objects.
Function list
The following table describes the member functions of the SDO_GEOMETRY type.
| Function | Return type | Description |
|---|---|---|
| GET_DIMS() | NUMBER | Obtains the dimension information of a geometry object. It returns an integer that represents the number of dimensions of the geometry object, as defined in the SDO_GTYPE attribute. The value returned is the same as that returned by ST_COORDDIM(). |
| ST_COORDDIM() | NUMBER | Obtains the dimension information of a geometry object. It returns an integer indicating the number of dimensions of the geometry object. It is defined in SDO_GTYPE. The result is the same as that of the GET_DIMS function. |
| GET_GTYPE() | NUMBER | Obtains the type code of a geometry object. It returns an integer that represents the type of the geometry object. For example, 2001 represents a point, 2002 represents a line, and 2003 represents a polygon. |
| ST_ISVALID() | NUMBER | Tests the validity of a geometry object. It returns a Boolean value that indicates whether the geometry object is valid. If the geometry object is valid, TRUE is returned. If not, FALSE is returned. |
| GET_WKB() | BLOB | Obtains the well-known binary (WKB) representation of a geometry object. It returns a binary string that represents the geometry object in the WKB format, without the spatial reference identifier (SRID). |
| GET_WKT() | CLOB | Obtains the well-known text (WKT) representation of a geometry object. It returns a string that represents the geometry object in the WKT format, without the SRID. |
| GET_GEOJSON() | CLOB | Obtains the JSON format of a geometry object. It returns a string indicating the JSON format of the geometry object. The JSON format output of the spatial object is returned. |
Note
The SDO_AREA(), SDO_CONTAINS(), SDO_ANYINTERACT(), and GETVERTICES() functions are available starting from V4.3.5 BP5.
The following table describes the member functions of SDO_GEOMETRY.
| Function | Return type | Description |
|---|---|---|
| SDO_DISTANCE() | NUMBER | Calculates the distance between two geometry objects. It returns an integer indicating the minimum distance between the two geometry objects. |
| SDO_AREA() | NUMBER | Calculates the planar area of a geometry object. The unit of the returned value is consistent with the linear unit of the spatial reference system (SRS) of the geometry object. It does not perform spherical or ellipsoidal conversion. It supports only 2D planar geometry. 3D inputs are not supported. |
The following table describes other spatial functions.
| Function | Return type | Description |
|---|---|---|
| SDO_CONTAINS() | BOOLEAN | Checks whether one geometry object strictly contains another geometry object (the boundary points are not considered as contained). It is equivalent to SDO_RELATE(geomA, geomB, 'mask=CONTAINS'). |
| SDO_ANYINTERACT() | BOOLEAN | Checks whether a geometry object has any spatial intersection with another geometry object, such as intersection, contact, or overlap. The contact at the boundary is considered as an interaction. It is equivalent to SDO_RELATE(..., 'mask=ANYINTERACT'). |
| SDO_RELATE() | VARCHAR2 | Determines the spatial relationship between two geometry objects. It returns a string (TRUE or FALSE) indicating whether the two objects meet the specified spatial relationship. |
The following table describes the functions of the SDO_UTIL package.
| Name | Returns | Description |
|---|---|---|
| GETVERTICES() | TABLE | Obtains the coordinates of the vertices of a geometry object. It supports 2D and 3D geometry objects. It returns a nested table of the VERTEX_SET_TYPE type, where each row contains the X, Y, Z, W, and reserved columns of a vertex. |