35.25 SDO_UTIL.FROM_WKTGEOMETRY
Format
SDO_UTIL.FROM_WKTGEOMETRY( geometry IN CLOB, srid IN NUMBER DEFAULT NULL ) RETURN SDO_GEOMETRY;
or
SDO_UTIL.FROM_WKTGEOMETRY( geometry IN VARCHAR2, srid IN NUMBER DEFAULT NULL ) RETURN SDO_GEOMETRY;
Description
Converts a geometry in the well-known text (WKT) or extended well-known text (EWKT) formats to a Spatial geometry object.
Parameters
Usage Notes
Note:
- The SDO_UTIL.FROM_WKTGEOMETRY function automatically validates and fixes any incorrect ring rotation in the input geometry (in WKT format). The validation process will also update the SDO_GTYPE attribute of the resulting SDO_GEOMETRY object to accurately reflect the corrected orientation, if necessary.
- SDO_UTIL.FROM_WKTGEOMETRY function is supported only if Oracle JVM is enabled on your Oracle Autonomous Database Serverless deployments. To enable Oracle JVM, see Use Oracle Java in Using Oracle Autonomous Database Serverless for more information.
The input geometry may be in the well-known text (WKT) format, or in the EWKT format. The result will be the most suitable minimal SDO_GEOMETRY type required to represent the input geometry.
This function is patterned after the SQL Multimedia recommendations in ISO 13249-3, Information technology - Database languages - SQL Multimedia and Application Packages - Part 3: Spatial.
To convert an SDO_GEOMETRY object to a CLOB in WKT format, use the SDO_UTIL.TO_WKTGEOMETRY function. (You can use the SQL function TO_CHAR to convert the resulting CLOB to VARCHAR2 type.)
Examples
The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Simple Example: Inserting_ Indexing_ and Querying Spatial Data, specifically the cola_b
geometry from the COLA_MARKETS table.)
DECLARE wkbgeom BLOB; wktgeom CLOB; val_result VARCHAR2(5); geom_result SDO_GEOMETRY; geom SDO_GEOMETRY; BEGIN SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b'; -- To WBT/WKT geometry wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom); wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom); DBMS_OUTPUT.PUT_LINE('To WKT geometry result = ' || TO_CHAR(wktgeom)); -- From WBT/WKT geometry geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom); geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom); -- Validate WBT/WKT geometry val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom); DBMS_OUTPUT.PUT_LINE('WKB validation result = ' || val_result); val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom); DBMS_OUTPUT.PUT_LINE('WKT validation result = ' || val_result); END;/ To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0)) WKB validation result = TRUE WKT validation result = TRUE
Parent topic: SDO_UTIL Package (Utility)