33.17 GET_SDO_GEOMETRY Function

This function returns SDO_GEOMETRY member value from a GeoJSON member. This function supports only two-dimensional geometry objects.

Note:

This function is only available if SDO_GEOMETRY (Oracle Locator) is installed in the database.

Syntax

APEX_JSON.GET_SDO_GEOMETRY FUNCTION (
    p_path             IN VARCHAR2,
    p0                 IN VARCHAR2  DEFAULT NULL,
    p1                 IN VARCHAR2  DEFAULT NULL,
    p2                 IN VARCHAR2  DEFAULT NULL,
    p3                 IN VARCHAR2  DEFAULT NULL,
    p4                 IN VARCHAR2  DEFAULT NULL,
    p_srid             IN NUMBER    DEFAULT 4326,
    p_values           IN t_values  DEFAULT g_values )
    RETURN mdsys.sdo_geometry;

Parameters

Table 33-18 GET_SDO_GEOMETRY Parameters

Parameter Description
p_values Parsed JSON members. Defaults to g_values.
p_path Index into p_values.
p[0-4] Each %N in p_path is replaced by pN and every i-th %s or %d is replaced by the p[i-1].
p_default Default value if the member does not exist.
p_srid Coordinate system (SRID) to return the SDO_GEOMETRY in.

Returns

Table 33-19 GET_SDO_GEOMETRY Returns

Return Description
a geometry Value at the given path position.

Raises

Table 33-20 GET_SDO_GEOMETRY Raises

Raise Description
VALUE_ERROR If p_values(p_path) is not a GeoJSON object.

Example

The following example parses a JSON string and prints the value at a position.

DECLARE
    j apex_json.t_values;
BEGIN
    apex_json.parse(j, '{ "items": [ 1, 2, { "geom": {"type":"Point","coordinates":[-122.7783356,38.8198318,1.85 ] } } ] }');
    dbms_output.put_line(to_char(apex_json.get_sdo_geometry (
                                     p_values => j,
                                     p_path   => 'items[%d].geom',
                                     p0       => 3) ) );
END;