OceanBase Database in Oracle mode supports the following member functions of SDO_GEOMETRY that allow you to convert SDO_GEOMETRY objects into data in the WKB, WKT, and JSON formats for output: GET_WKB(), GET_WKT(), and GET_GEOJSON().
GET_WKB()
GET_WKB() converts a spatial object to into a binary string in the WKB format. The WKB format is a common standard format that represents spatial objects in binary strings.
Here is an example:
obclient [SYS]> SELECT SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(10,500)).GET_WKB() AS test_get_wkb FROM dual;
The return result is as follows:
+--------------------------------------------+
| TEST_GET_WKB |
+--------------------------------------------+
| 00000000014024000000000000407F400000000000 |
+--------------------------------------------+
1 row in set
GET_WKT()
GET_WKT() converts a spatial object into a string in the WKT format. The WKT format is a common standard format that represents spatial objects in text strings.
Here is an example:
obclient [SYS]> SELECT SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(10, 50, NULL), NULL, NULL).GET_WKT() AS test_get_wkt FROM dual;
The return result is as follows:
+---------------+
| TEST_GET_WKT |
+---------------+
| POINT (10 50) |
+---------------+
1 row in set
GET_GEOJSON()
GET_GEOJSON() converts a spatial object into a string in the JSON format.
Here is an example:
obclient [SYS]> SELECT SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(10,500)).GET_GEOJSON() AS test_get_geojson FROM dual;
The return result is as follows:
+-----------------------------------------------+
| TEST_GET_GEOJSON |
+-----------------------------------------------+
| { "type": "Point", "coordinates": [10, 500] } |
+-----------------------------------------------+
1 row in set