SDO_GEOMETRY is a complex data type with several intrinsic attributes that can be accessed in PL/SQL.
SDO_GEOMETRY.SDO_GTYPE
SDO_GEOMETRY.SDO_GTYPE indicates the geometry type code of a geometry object.
Example
obclient [SYS]> SELECT SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(10, 50, NULL), NULL, NULL).SDO_GTYPE AS test_sdo_gtype FROM dual;
The return result is as follows:
+----------------+
| TEST_SDO_GTYPE |
+----------------+
| 2001 |
+----------------+
1 row in set
SDO_GEOMETRY.SDO_SRID
SDO_GEOMETRY.SDO_SRID indicates the spatial reference system identifier (SRID) of a geometry object.
Example
obclient [SYS]> SELECT SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL).SDO_SRID AS test_sdo_srid FROM dual;
The return result is as follows:
+---------------+
| TEST_SDO_SRID |
+---------------+
| 4326 |
+---------------+
1 row in set
SDO_GEOMETRY.SDO_POINT
SDO_GEOMETRY.SDO_POINT indicates the point coordinates of a geometry object, including the X, Y, and optional Z coordinates. You can also access SDO_POINT sub-attributes of SDO_GEOMETRY to get these coordinate values.
SDO_POINT provides the following sub-attributes:
SDO_GEOMETRY.SDO_POINT.X: the X coordinate of the geometry object.SDO_GEOMETRY.SDO_POINT.Y: the Y coordinate of the geometry object.SDO_GEOMETRY.SDO_POINT.Z: the Z coordinate of the geometry object, which is optional. Not all geometry objects have a Z coordinate value.
Examples
Access the
SDO_POINTattribute that contains the X, Y, and Z coordinates.obclient [SYS]> SELECT SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL).SDO_POINT AS test_sdo_point FROM dual;The return result is as follows:
+------------------------------+ | TEST_SDO_POINT | +------------------------------+ | SDO_POINT_TYPE(12, 14, NULL) | +------------------------------+ 1 row in setAccess the
SDO_POINT.Xsub-attribute.obclient [SYS]> SELECT SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL).SDO_POINT.X AS test_sdo_point_x FROM dual;The return result is as follows:
+------------------+ | TEST_SDO_POINT_X | +------------------+ | 12 | +------------------+ 1 row in setAccess the
SDO_POINT.Ysub-attribute.obclient [SYS]> SELECT SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL).SDO_POINT.Y AS test_sdo_point_y FROM dual;The return result is as follows:
+------------------+ | TEST_SDO_POINT_Y | +------------------+ | 14 | +------------------+ 1 row in setAccess the
SDO_POINT.Zsub-attribute.obclient [SYS]> SELECT SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL).SDO_POINT.Z AS test_sdo_point_z FROM dual;The return result is as follows:
+------------------+ | TEST_SDO_POINT_Z | +------------------+ | NULL | +------------------+ 1 row in set
SDO_GEOMETRY.SDO_ELEM_INFO
SDO_GEOMETRY.SDO_ELEM_INFO indicates the geometric element information of a geometry object, such as the start and end point indices of a line segment or polygon.
Example
obclient [SYS]> SELECT SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(10,105, 15,105, 20,110, 10,110, 10,105)).SDO_ELEM_INFO AS test_sdo_elem_info FROM dual;
The return result is as follows:
+---------------------------------+
| TEST_SDO_ELEM_INFO |
+---------------------------------+
| SDO_ELEM_INFO_ARRAY(1, 1003, 1) |
+---------------------------------+
1 row in set
SDO_GEOMETRY.SDO_ORDINATES
SDO_GEOMETRY.SDO_ORDINATES indicates the coordinate value array of a geometry object.
Example
obclient [SYS]> SELECT SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(10,105, 15,105, 20,110, 10,110, 10,105)).SDO_ORDINATES AS test_sdo_ordinates FROM dual;
The return result is as follows:
+-----------------------------------------------------------------+
| TEST_SDO_ORDINATES |
+-----------------------------------------------------------------+
| SDO_ORDINATE_ARRAY(10, 105, 15, 105, 20, 110, 10, 110, 10, 105) |
+-----------------------------------------------------------------+
1 row in set