1. PACKAGE/COGO [ Modules ]

[ Top ] [ Modules ]

NAME

```    COGO - A package that publishes some common COGO functions used by other object types.
```

DESCRIPTION

```    A package that publishes some common COGO functions used by other object types.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.1. COGO/ArcTan2 [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    ArcTan2 -- Returns the angle in Radians with tangent opp/hyp. The returned value is between PI and -PI
```

SYNOPSIS

```    Function ArcTan2( dOpp in number,
Return Number deterministic
```

DESCRIPTION

```    Returns the angle in Radians with tangent opp/hyp. The returned value is between PI and -PI.
```

INPUTS

```    dOpp : NUMBER : Length of the vector perpendicular to two vectors (cross product)
dAdj : NUMBER : Length of the calculated from the dot product of two vectors
```

RESULT

```    number : The angle in Radians with tangent opp/hyp
```

NOTES

```    Assumes planar projection eg UTM.
```

EXAMPLE

```    SELECT COGO.ArcTan2(14,15) as atan2
FROM dual;

ATAN2
------------
0.7509290624
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.2. COGO/CardinalDirection [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    CardinalDirection -- Returns Compass point string equivalent of decimal degree numeric value.
```

SYNOPSIS

```    Function CardinalDirection(p_bearing      in number,
p_abbreviation in integer default 1)
Return varchar2 Deterministic;
```

INPUTS

```    p_bearing       (Number) -- Decimal degrees.
p_abbreviation (integer) -- Whether to return full text North (0) or abbreviation N (1), South West(0) or SW(1).
```

RESULT

```    Compass Point (varchar2) -- Compass point string for supplied bearing.
```

DESCRIPTION

```    This function converts a numeric decimal degree value into its textual Compass Point equivalent.
```

EXAMPLE

```    select COGO.CardinalDirection(15.8515065952945,t.IntValue) as CardinalDirection
from table(tools.generate_series(0,1,1)) t;

CARDINALDIRECTION
-----------------
NNE
North-NorthEast

-- All Compass Points
select COGO.DD2DMS(avg(t.IntValue))         as bearing,
COGO.CardinalDirection(t.IntValue,0) as CardinalDirection,
COGO.CardinalDirection(t.IntValue,1) as CardinalDirectionFull
from table(tools.generate_series(1,360,1)) t
group by COGO.CardinalDirection(t.IntValue,0),
COGO.CardinalDirection(t.IntValue,1);

BEARING        CARDINALDIRECTION CARDINALDIRECTIONFULL
-------------- ----------------- ----------------
135°0'0"       SE                SouthEast
187°49'33.913" N                 North
90°0'0"        E                 East
112°30'0"      ESE               East-SouthEast
180°0'0"       S                 South
315°0'0"       NW                NorthWest
67°30'0"       ENE               East-NorthEast
337°30'0"      NNW               North-NorthWest
270°0'0"       W                 West
157°30'0"      SSE               South-SouthEast
202°30'0"      SSW               South-SouthWest
292°30'0"      WNW               West-NorthWest
225°0'0"       SW                SouthWest
247°30'0"      WSW               West-SouthWest
22°30'0"       NNE               North-NorthEast
45°0'0"        NE                NorthEast
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.3. COGO/DD2DMS [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    DD2DMS -- Returns string equivalent of decimal degree numeric value.
```

SYNOPSIS

```    Function DD2DMS(
dDecDeg in Number,
pDegree in NChar default '°',
pMinute in NChar default '''',
pSecond in NChar default '"'
)
Return varchar2 Deterministic;
```

INPUTS

```    dDecDeg (Number) - Decimal degrees.
pDegree (NChar)  - Superscript degree value identifier eg °
pMinute (NChar)  - Superscript minute value identifier eg '
pSecond (NChar)  - Superscript second value identifier eg "
```

RESULT

```    Decimal Degrees (NUMBER) - eg 22.16972222.
```

DESCRIPTION

```    This function converts a numeric decimal degree value into its textual whole-circle bearing equivalent.
```

EXAMPLE

```    select COGO.DD2DMS(15.8515065952945,'^','''','"') as dms
from dual;

DMS
------------
15^51'5.424"
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.4. COGO/DD2TIME [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    DD2TIME -- Supplied with a whole-circle bearing, this function returns its equivalent ClockFace Direction eg 45 => 1hr 30min.
```

SYNOPSIS

```    Function DD2TIME(p_dDecDeg in Number,
p_24_hour in integer default 0)
Return varchar2 Deterministic;
```

ARGUMENTS

```    p_dDecDeg (Number) -- Decimal degrees.
p_24_hour (integer) -- 12 hour (0) readout or 24 (1)
```

RESULT

```    Time as string (varchar2) -- ClockFace time as direction 45 degrees is same as 1Hr 30min
```

DESCRIPTION

```    This function converts a whole circular bearing in decimal degrees to its equivalent ClockFace Direction eg 45 => 1hr 30min.
Can return clockface directions as 12-14 hour references or 0-12 references.
```

EXAMPLE

```    select COGO.DD2TIME(t.IntValue,t12.IntValue) as clockface
from table(TOOLS.generate_series(0,360,45)) t,
table(TOOLS.generate_series(0,1,1)) t12
order by t12.IntValue, t.intValue;

CLOCKFACE
----------
0Hr 0min
1Hr 30min
3Hr 0min
4Hr 30min
6Hr 0min
7Hr 30min
9Hr 0min
10Hr 30min
12Hr 0min
12Hr 0min
13Hr 30min
15Hr 0min
16Hr 30min
18Hr 0min
19Hr 30min
21Hr 0min
22Hr 30min
24Hr 0min

18 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - September 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.5. COGO/DMS2DD [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    DMS2DD -- Returns decimal degree value from string input.
```

SYNOPSIS

```    Function DMS2DD(strDegMinSec varchar2)
Return Number Deterministic;
```

INPUTS

```    strDegMinSec (varchar2) - Angle in DMS format (quandrantal, whole circle or Cardinal bearing), with/without separators
```

RESULT

```    Decimal Degrees (NUMBER) - eg 22.16972222.
```

DESCRIPTION

```    This function converts a textual representation of a degree value to its decimal equivalent.
```

EXAMPLE

```    select COGO.DMS2DD('15°51''5.424"') as dd
from DUAL;

DD
-----------------------------------------
15.85150666666666666666666666666666666667

select COGO.DMS2DD('22^10''11"') as dd
from DUAL;

DD
-----------
22.16972222

select COGO.DMS2DD('N22.1697E') as dd
from DUAL;

DD
-----------
22.16972222

select COGO.DMS2DD('S52E') as dd
from dual;

DD
--
52
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.6. COGO/PI [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    PI -- Returns constant PI value.
```

SYNOPSIS

```    Function PI
Return Number Deterministic
```

DESCRIPTION

```    This function exposes static constant PI.
```

EXAMPLE

```    SELECT COGO.PI()
FROM DUAL;

COGO.PI()
---------------------------------------
3.1415926535897932384626433832795028842
```

RESULT

```    PI (NUMBER) - 3.1415926535897932384626433832795028842
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ COGO ] [ Functions ]

NAME

```    QuadrantBearing -- Returns Quadrant Bearing string equivalent of decimal degree numeric value eg N34.5°E
```

SYNOPSIS

```    Function QuadrantBearing(p_bearing in number,
p_Degree  in NChar default '°')
Return varchar2 Deterministic;
```

INPUTS

```    p_bearing (Number) -- Decimal degrees.
p_degree  (NChar)  -- Degree Symbol Superscript.
```

RESULT

```    Quadrant Bearing (varchar2) -- Quadrant bearing eg N34.5°E
```

DESCRIPTION

```    This function converts a numeric decimal degree value into its textual Quadrant bearing equivalent.
```

EXAMPLE

```    select COGO.QuadrantBearing(15.8515065952945,'^') as quadrantBearing
from dual;

---------------
N15.852^E

select COGO.DD2DMS(t.IntValue)          as bearing,
from table(tools.generate_series(0,315,45)) t
order by t.IntValue asc;

---------- ---------------
0°0'0"     N
45°0'0"    N45°E
90°0'0"    E
135°0'0"   S45°E
180°0'0"   S
225°0'0"   S45°W
270°0'0"   W
315°0'0"   N45°W

8 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.8. COGO/ST_Degrees [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    ST_Degrees -- Converts input radians to whole circle bearing (0 North).
```

SYNOPSIS

```    Function ST_Degrees(p_radians   in number,
p_normalize in integer default 1)
Return Number deterministic
```

DESCRIPTION

```    This function converts supplied radians value to whole circle bearing clockwise from 0 as North.
Also normalises bearing to 0..360 if requested.
```

INPUTS

```    p_radians    (Number) - Angle in radians (clockwise from north)
p_normalize (Integer) - Normalises bearing to range 0..360 (defaul)
```

RESULT

```    degrees (NUMBER) - 0 to 360 degrees
```

EXAMPLE

```    SELECT Round(COGO.ST_Degrees(0.789491),4) as degrees
FROM dual;

DEGREES
----------
45.2345
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

1.9. COGO/ST_Normalize [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

```    ST_Normalize -- Converts input degree value to whole circle bearing between 0..360.
```

SYNOPSIS

```    Function ST_Normalize(p_degrees in number)
Return Number deterministic
```

DESCRIPTION

```    This function converts supplied degree value to whole circle bearing clockwise between 0..360.
```

INPUTS

```    p_degrees (Number) - Angle in degrees.
```

RESULT

```    degrees (Number) - 0 to 360 degrees
```

EXAMPLE

```    SELECT COGO.ST_Normalize(400) as degrees
FROM dual;

DEGREES
-------
40
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ COGO ] [ Functions ]

NAME

```    ST_Radians -- Converts input whole circle bearing (0 North) to radians.
```

SYNOPSIS

```    Function ST_Radians(p_radians in number)
Return Number deterministic
```

INPUTS

```    p_degrees (NUMBER) - Angle in degrees,  clockwise from North.
```

DESCRIPTION

```    This function converts supplied decimal degree value to radians.
```

EXAMPLE

```    SELECT Round(COGO.ST_Radians(45.2345),6) as radians
FROM dual;

----------
.789491
```

RESULT

```    radians (NUMBER) - 0 to 2 x PI radians.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

2. PACKAGE/DEBUG [ Modules ]

[ Top ] [ Modules ]

NAME

```    DEBUG - Functions that can be used to create string versions of complex types for output during debugging eg dbms_output.
```

DESCRIPTION

```    A package that publishes some functions that can be used to create string versions of complext types for output during debugging eg dbms_output.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```  Procedure PrintPoint( p_point    in mdsys.sdo_point_type,
p_round    in number default 3,
p_prefix   in varchar2 default null,
p_linefeed in boolean default false);

Procedure PrintPoint( p_point    in mdsys.vertex_type,
p_round    in number default 3,
p_prefix   in varchar2 default null,
p_linefeed in boolean default false);

Procedure PrintPoint( p_point    in &&INSTALL_SCHEMA..T_Vertex,
p_round    in number default 3,
p_prefix   in varchar2 default null,
p_linefeed in boolean default false);

Procedure PrintGeom(  p_geom        in mdsys.sdo_geometry,
p_round       in number default 3,
p_linefeed    in boolean default false,
p_suffix_text in varchar2 default null);

Procedure PrintGeom(  p_geom        in &&INSTALL_SCHEMA..T_Geometry,
p_round       in number default 3,
p_linefeed    in boolean default false,
p_suffix_text in varchar2 default null);

Function PrintGeom(   p_geom     in mdsys.sdo_geometry,
p_round    in number default 3,
p_linefeed in integer default 0,
p_prefix   in varchar2 default null,
p_relative in integer default 0)
Return clob deterministic;

Procedure PrintElemInfo( p_elem_info in mdsys.sdo_elem_info_array,
p_linefeed  in Boolean default false);

Procedure PrintOrdinates(p_ordinates in mdsys.sdo_ordinate_array,
p_coordDim  in pls_integer default 2,
p_round     in pls_integer default 3,
p_linefeed  in Boolean default false);
```

3. PACKAGE/PRINT [ Modules ]

[ Top ] [ Modules ]

NAME

```    PRINT - Functions that can be used to create string versions of complex types for output during debugging eg dbms_output.
```

DESCRIPTION

```    A package that publishes some functions that can be used to create string versions of complex types for output during debugging eg dbms_output.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```  Function sdo_point_type( p_point in mdsys.sdo_point_type,
p_round in number default 3)
Return varchar2 deterministic;

Function Vertex_Type(p_point in mdsys.vertex_type,
p_round in number default 3)
Return varchar2 deterministic;

Function sdo_elem_info( p_elem_info in mdsys.sdo_elem_info_array )
return varchar2 deterministic;

Function sdo_ordinates(p_ordinates in mdsys.sdo_ordinate_array,
p_coordDim  in pls_integer default 2,
p_round     in pls_integer default 3)
Return clob deterministic;

Function sdo_geometry(p_geom  in mdsys.sdo_geometry,
p_round in number default 3)
Return clob deterministic;
```

4. PACKAGE/ST_LRS [ Modules ]

[ Top ] [ Modules ]

NAME

```    ST_LRS - A package that publishes an SDO_LRS view of the T_GEOMETRY object's ST_LRS* functions.
```

DESCRIPTION

```    A package that publishes an SDO_LRS view of the T_GEOMETRY object's ST_LRS* functions.
This is an example of what could be done to help Locator users use my LRS code and be in a position
to migrate with minimal effort to Oracle Spatial's Enterprise SDO_LRS code.
If this package is extended, please supply the changed package to me via simon@spatialdbadvisor.com
```

TODO

```    CONNECTED_GEOM_SEGMENTS
GET_NEXT_SHAPE_PT
GET_NEXT_SHAPE_PT_MEASURE
GET_PREV_SHAPE_PT
GET_PREV_SHAPE_PT_MEASURE
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```   FUNCTION FIND_LRS_DIM_POS(lrs_geometry IN mdsys.sdo_geometry,
tolerance    in number default 0.005)
RETURN INTEGER DETERMINISTIC;

FUNCTION FIND_LRS_DIM_POS(table_name  IN VARCHAR2,
column_name IN VARCHAR2)
RETURN INTEGER DETERMINISTIC;

FUNCTION GEOM_SEGMENT_END_MEASURE(lrs_segment IN mdsys.sdo_geometry)
RETURN NUMBER DETERMINISTIC;

FUNCTION GEOM_SEGMENT_START_MEASURE(lrs_segment IN mdsys.sdo_geometry)
RETURN NUMBER DETERMINISTIC;

/**
* Description
*  Returns the measure range of a geometric segment, that is, the difference between the start measure and end measure.
**/
FUNCTION MEASURE_RANGE(lrs_segment IN mdsys.sdo_geometry,
dim_array   IN mdsys.sdo_dim_ARRAY DEFAULT NULL)
RETURN NUMBER DETERMINISTIC;

FUNCTION GEOM_SEGMENT_START_PT(geom_segment IN mdsys.sdo_geometry)
RETURN mdsys.sdo_geometry Deterministic;

FUNCTION GEOM_SEGMENT_END_PT(geom_segment IN mdsys.sdo_geometry)
RETURN mdsys.sdo_geometry Deterministic;

Function IS_SHAPE_PT_MEASURE(geom_segment in mdsys.sdo_geometry,
measure      in number)
RETURN VARCHAR2 Deterministic;

Function SET_PT_MEASURE(lrs_segment in mdsys.sdo_geometry,
point       IN mdsys.sdo_geometry,
measure     IN NUMBER,
tolerance   in number default 0.005)
RETURN mdsys.sdo_geometry Deterministic;

FUNCTION GET_MEASURE(point IN mdsys.sdo_geometry)
RETURN NUMBER DETERMINISTIC;

FUNCTION IS_MEASURE_INCREASING (lrs_segment IN mdsys.sdo_geometry)
RETURN VARCHAR2 DETERMINISTIC;

FUNCTION IS_MEASURE_DECREASING (lrs_segment IN mdsys.sdo_geometry)
RETURN VARCHAR2 DETERMINISTIC;

/**
* The start and end measures of geom_segment must be defined (cannot be null),
* and any measures assigned must be in an ascending or descending order along the segment direction.
**/
FUNCTION IS_GEOM_SEGMENT_DEFINED(geom_segment IN mdsys.sdo_geometry,
dim_array    IN mdsys.sdo_dim_ARRAY DEFAULT NULL)
RETURN VARCHAR2 DETERMINISTIC;

FUNCTION MEASURE_TO_PERCENTAGE(lrs_segment IN mdsys.sdo_geometry,
measure     IN NUMBER)
RETURN NUMBER DETERMINISTIC;

FUNCTION PERCENTAGE_TO_MEASURE(lrs_segment IN mdsys.sdo_geometry,
percentage  IN NUMBER)
RETURN NUMBER DETERMINISTIC;

Function GEOM_SEGMENT_LENGTH(geom_segment in mdsys.sdo_geometry,
unit         in varchar2 default null)
RETURN NUMBER Deterministic;

FUNCTION SPLIT_GEOM_SEGMENT(geom_segment  IN mdsys.sdo_geometry,
split_measure IN NUMBER,
tolerance     IN NUMBER DEFAULT 0.005)
RETURN mdsys.sdo_geometry_array pipelined;

PROCEDURE SPLIT_GEOM_SEGMENT(geom_segment   IN mdsys.sdo_geometry,
split_measure  IN NUMBER,
segment_1      IN OUT NOCOPY mdsys.sdo_geometry,
segment_2      IN OUT NOCOPY mdsys.sdo_geometry,
tolerance      IN NUMBER DEFAULT 0.005);

FUNCTION CONCATENATE_GEOM_SEGMENTS(geom_segment_1 IN mdsys.sdo_geometry,
geom_segment_2 IN mdsys.sdo_geometry,
tolerance      IN NUMBER DEFAULT 0.005,
unit           IN varchar2 default null)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION CLIP_GEOM_SEGMENT(GEOM_SEGMENT  IN mdsys.sdo_geometry,
START_MEASURE IN NUMBER,
END_MEASURE   IN NUMBER,
TOLERANCE     IN NUMBER   DEFAULT 0.005,
UNIT          IN VARCHAR2 DEFAULT NULL)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION LOCATE_PT(GEOM_SEGMENT IN mdsys.sdo_geometry,
MEASURE      IN NUMBER,
OFFSET       IN NUMBER,
TOLERANCE    IN NUMBER   DEFAULT 0.005,
UNIT         IN VARCHAR2 DEFAULT NULL)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION FIND_OFFSET (GEOM_SEGMENT IN mdsys.sdo_geometry,
POINT        IN mdsys.sdo_geometry,
TOLERANCE    IN NUMBER   DEFAULT 0.005,
UNIT         IN VARCHAR2 DEFAULT NULL)
RETURN NUMBER DETERMINISTIC;

FUNCTION FIND_MEASURE(lrs_segment IN mdsys.sdo_geometry,
POINT       IN mdsys.sdo_geometry,
TOLERANCE   IN NUMBER   DEFAULT 0.005,
UNIT        IN VARCHAR2 DEFAULT NULL)
RETURN NUMBER DETERMINISTIC;

FUNCTION PROJECT_PT (GEOM_SEGMENT IN mdsys.sdo_geometry,
POINT        IN mdsys.sdo_geometry,
TOLERANCE    IN NUMBER DEFAULT 0.005,
UNIT         IN VARCHAR2 DEFAULT NULL)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION LRS_INTERSECTION(GEOM_1    IN mdsys.sdo_geometry,
GEOM_2    IN mdsys.sdo_geometry,
TOLERANCE IN NUMBER DEFAULT 0.005)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION REVERSE_MEASURE (lrs_segment IN mdsys.sdo_geometry)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION REVERSE_GEOMETRY (geom_segment IN mdsys.sdo_geometry)
RETURN mdsys.sdo_geometry DETERMINISTIC;

/* Populates the measures of all shape points based on the start and end measures of a geometric segment, overriding any previously assigned measures between the start point and end point.*/
Function REDEFINE_GEOM_SEGMENT(geom_segment  IN mdsys.sdo_geometry,
start_measure IN NUMBER,
end_measure   IN NUMBER)
RETURN mdsys.sdo_geometry DETERMINISTIC;

Procedure REDEFINE_GEOM_SEGMENT(geom_segment  IN OUT NOCOPY mdsys.sdo_geometry,
start_measure IN NUMBER,
end_measure   IN NUMBER);

PROCEDURE RESET_MEASURE(lrs_segment in OUT NOCOPY mdsys.sdo_geometry);

FUNCTION RESET_MEASURE(lrs_segment IN mdsys.sdo_geometry)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION TRANSLATE_MEASURE(geom_segment IN mdsys.sdo_geometry,
translate_m  IN NUMBER)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION CONVERT_TO_STD_GEOM(lrs_segment IN mdsys.sdo_geometry)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION CONVERT_TO_LRS_GEOM(standard_geom IN mdsys.sdo_geometry,
start_measure IN NUMBER DEFAULT NULL,
end_measure   IN NUMBER DEFAULT NULL)
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION SCALE_GEOM_SEGMENT(lrs_segment   IN mdsys.sdo_geometry,
start_measure IN NUMBER,
end_measure   IN NUMBER,
shift_measure IN NUMBER,
tolerance     IN NUMBER DEFAULT 0.005 )
RETURN mdsys.sdo_geometry DETERMINISTIC;

FUNCTION DYNAMIC_SEGMENT(GEOM_SEGMENT  IN mdsys.sdo_geometry,
START_MEASURE IN NUMBER,
END_MEASURE   IN NUMBER,
TOLERANCE     IN NUMBER   DEFAULT 0.005,
UNIT          IN VARCHAR2 DEFAULT NULL)
RETURN mdsys.sdo_geometry DETERMINISTIC;

Function OFFSET_GEOM_SEGMENT(geom_segment  IN mdsys.sdo_geometry,
start_measure IN NUMBER,
end_measure   IN NUMBER,
offset        IN NUMBER DEFAULT 0,
tolerance     IN NUMBER DEFAULT 0.005,
unit          IN VARCHAR2 default null)
RETURN mdsys.sdo_geometry Deterministic;

Function VALID_GEOM_SEGMENT(geom_segment IN mdsys.sdo_geometry,
dim_array    IN mdsys.sdo_dim_ARRAY default null)
RETURN VARCHAR2 Deterministic;

Function VALID_LRS_PT(point     IN mdsys.sdo_geometry,
dim_array IN mdsys.sdo_dim_ARRAY DEFAULT NULL)
RETURN VARCHAR2 Deterministic;

Function VALID_MEASURE(geom_segment in mdsys.sdo_geometry,
measure      in number)
RETURN VARCHAR2 Deterministic;

Function VALIDATE_LRS_GEOMETRY(geom_segment in mdsys.sdo_geometry,
dim_array    in mdsys.sdo_dim_ARRAY default null)
RETURN VARCHAR2 Deterministic;

Function ROUND_COORDINATES(geom_segment   in mdsys.sdo_geometry,
p_dec_places_x in integer default null,
p_dec_places_y in integer default null,
p_dec_places_z in integer default null,
p_dec_places_m in integer default null)
RETURN mdsys.sdo_geometry Deterministic;
```

5. PACKAGE/TOOLS [ Modules ]

[ Top ] [ Modules ]

NAME

```    TOOLS - A collection of common functions used by other packages and object types.
```

DESCRIPTION

```    A package that publishes a collection of common functions used by other packages and object types.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

5.1. TOOLS/Generate_Series [ Functions ]

[ Top ] [ TOOLS ] [ Functions ]

NAME

```    Generate_Series -- Function that generates a series of numbers mimicking PostGIS's function with the same name
```

SYNOPSIS

```    Function generate_series(p_start pls_integer,
p_end   pls_integer,
p_step  pls_integer
)
Return &&INSTALL_SCHEMA..T_IntValues Pipelined;
```

EXAMPLE

```    with data as (
select sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null) as line
from dual
)
select t.IntValue as point_id,
v.x,
v.y
from data a,
table(tools.generate_series(1,sdo_util.GetNumVertices(a.line),1)) t,
table(sdo_util.getvertices(a.line)) v
where v.id =t.intValue;

POINT_ID          X          Y
---------- ---------- ----------
1          0          0
2         10          0
3         10          5
4         10         10
5          5         10
6          5          5

6 rows selected
```

INPUTS

```   p_start (Integer) - Starting value
p_end   (Integer) - Ending value.
p_step  (Integer) - The step value of the increment between start and end
RETURN
Array of Integers (T_IntValues)
```

AUTHOR

```     Simon Greener
```

HISTORY

```     Simon Greener - Jan 2008 - Original coding.
```

```     (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

5.2. TOOLS/ST_DB_Version [ Functions ]

[ Top ] [ TOOLS ] [ Functions ]

NAME

```    ST_DB_Version -- Returns Database Version and sub version.
```

SYNOPSIS

```    Static Function ST_DB_Version
Return Number Determinisitc
```

DESCRIPTION

```    This function return database version which is useful when handling Oracle functions that only appear in certain versions
```

RESULT

```    Database Version (NUMBER) - eg 11.2 Database(12.1)
```

EXAMPLE

```    select T_GEOMETRY.ST_DB_Version() as database_version
from DUAL;

DATABASE_VERSION
----------------
11.2
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - May 2016 - Original coding.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

5.3. TOOLS/ST_GetSridType [ Functions ]

[ Top ] [ TOOLS ] [ Functions ]

NAME

```    ST_GetSridType - Determines ref sys kind of provided p_srid
```

SYNOPSIS

```    Function ST_GetSridType(p_srid IN Integer)
Return VarChar2 Deterministic;
```

DESCRIPTION

```    Given a null p_srid this function returns PLANAR.
The the p_srid is not null the function checks the Mdsys.Sdo_Coord_Ref_System table's coord_ref_sys_kind column, mapping its values as follows:
COMPOUND     ==> PLANAR,
ENGINEERING  ==> PLANAR,
GEOGENTRIC   ==> GEOGRAPHIC,
GEOGRAPHIC2D ==> GEOGRAPHIC,
GEOGRAPHIC3D ==> GEOGRAPHIC,
PROJECTED    ==> PLANAR,
VERTICAL     ==> GEOGRAPHIC,
```

INPUTS

```    p_srid (integer) - Returns PLANAR or GEOGRAPHIC
NOTE
Used mainly in determinining type of arithmetic to be used when calculating distances etc
```

EXAMPLE

```    select distinct f.sridType
from (select Tools.ST_GetSridType(a.srid) as SridType
from cs_srs a
order by DBMS_RANDOM.VALUE
) f
where rownum < 100;

SRIDTYPE
----------
PLANAR
GEOGRAPHIC
```

AUTHOR

```     Simon Greener
```

HISTORY

```     Simon Greener - Jan 2011 - Original coding.
```

```     (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

5.4. TOOLS/ST_isLocator [ Methods ]

[ Top ] [ TOOLS ] [ Methods ]

NAME

```    ST_isLocator -- Makes best effort to osee if database is a locator databases.
```

SYNOPSIS

```    Function ST_isLocator
Return INTEGER Deterministic,
```

DESCRIPTION

```    A method that attempts to determine if the host database is a Locator database or has Spatial objects.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 Is Locator else 0 (Spatial)
```

EXAMPLE

```    select T_GEOMETRY.ST_isLocator() as isLocator
from dual;

ISLOCATOR
---------
0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2016 - Original coding.
```

```    (c) 2012-2017 by TheSpatialDBAdvisor/Simon Greener
```

5.5. TOOLS/TokenAggregator [ Functions ]

[ Top ] [ TOOLS ] [ Functions ]

NAME

```    TokenAggregator - A string aggregator.
```

SYNOPSIS

```    Function TokenAggregator(p_tokenSet  IN &&INSTALL_SCHEMA..T_Tokens,
p_delimiter IN VarChar2 DEFAULT ',')
Return VarChar2 Deterministic;
```

DESCRIPTION

```    Takes a set of strings an aggregates/appends them using supplied separator
```

INPUTS

```    p_tokenSet  (T_Tokens) - The strings to be aggregated.
p_separator (varchar2) - The character that is placed between each token string.
NOTE
Requires t_Tokens Object Type to exist.
```

EXAMPLE

```    with data as (
select t.ID, T.TOKEN, T.sEPARATOR
from table(TOOLS.Tokenizer('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',',()')) t
)
select TOOLS.TokenAggregator(tokens,',') AS result
from (select CAST(COLLECT(codesys.T_Token(l.id,l.token,l.separator)) AS T_Tokens) as tokens
from data l
) f;
```

RESULT

```    ----------------------------------------
LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)
```

AUTHOR

```     Simon Greener
```

HISTORY

```     Simon Greener - Jan 2011 - Original coding.
```

```     (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

5.6. TOOLS/Tokenizer [ Functions ]

[ Top ] [ TOOLS ] [ Functions ]

NAME

```    Tokenizer - Splits any string into tokens and separators.
```

SYNOPSIS

```    Function Tokenizer (
p_string     varchar2,
OR p_string     varchar2,
p_separators varchar2 default ' '
)
Return T_Tokens Pipelined

Where T_Tokens is array of T_Token:
id        integer,
token     varchar2(30000),
separator varchar2(30000)
)
```

DESCRIPTION

```    Supplied a string and a list of separators this function returns resultant tokens as a table collection.
Function returns both the token and the separator.
Returned table collection contains a unique identifier to ensure tokens and separators are always correctly ordered.
```

INPUTS

```    p_string     (varchar 30000) - Any non-null string.
p_separators (varchar 30000) - List of separators eg '(),'
```

RESULT

```    Table (Array) of T_TOKEN:
id        (integer)       - Unique identifier for each row starting with first token/separator found.
token     (varchar 30000) - Token between separators
separator (varchar 30000) - Separator between tokens.
```

EXAMPLE

```    select t.id, t.token, t.separator
from table(TOOLS.Tokenizer('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',',()')) t

ID TOKEN      SEPARATOR
-- ---------- ---------
1 LINESTRING         (
2 0 0                ,
3 10 0               ,
4 10 5               ,
5 10 10              ,
6 5 10               ,
7 5 5                )

7 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2008 - Original coding.
```

```    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

6. OBJECT TYPE ARRAY/T_BEARING_DISTANCES [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_BEARING_DISTANCES - Array of T_BEARING_DISTANCE Objects.
```

DESCRIPTION

```    An array of T_BEARING_DISTANCE objects used to fully describe a single polygon ring or linestring object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_BEARING_DISTANCES
AS TABLE OF &&INSTALL_SCHEMA..T_BEARING_DISTANCE;
```

7. OBJECT TYPE ARRAY/T_ELEMINFOSET [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_ELEMINFOSET -- A type representing an array (collection) of T_ELEMINFO objects.
```

DESCRIPTION

```    An array of T_ELEMINFO objects that represent an ordered set of sdo_elem_info triplets.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_ElemInfoSet
IS TABLE OF &&INSTALL_SCHEMA..T_ElemInfo;
```

8. OBJECT TYPE ARRAY/T_GEOMETRIES [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_GEOMETRIES -- Array (collection) of T_GEOMETRY_ROW Objects.
```

DESCRIPTION

```    An array if T_GEOMETRY_ROW objects used in PIPELINED Functions.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package for &&INSTALL_SCHEMA..
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_GEOMETRIES
AS TABLE OF &&INSTALL_SCHEMA..T_GEOMETRY_ROW;
```

9. OBJECT TYPE ARRAY/T_GRIDS [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_GRIDS -- An array (collection/table) of T_GRIDs.
```

DESCRIPTION

```    An array of T_GRID objects that represents an array of optimized rectangles
representing a grid, matrix or "raster".
Used mainly by PIPELINED T_GEOMETRY methods.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_Grids
IS TABLE OF &&INSTALL_SCHEMA..T_Grid;
```

10. OBJECT TYPE ARRAY/T_INTVALUES [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_INTVALUES -- Object type representing a collection (array) of T_INTVALUE objects.
```

DESCRIPTION

```    An array of T_INTVALUE objects that represent an ordered set of tokens and separators extracted from a string by the Tokenizer function.
Used by PIPELINED Tokenizer function.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_INTVALUES
IS TABLE OF &&INSTALL_SCHEMA..T_INTVALUE;
```

11. OBJECT TYPE ARRAY/T_SEGMENTS [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_SEGMENTS -- An array (collection/table) of T_SEGMENT type.
```

DESCRIPTION

```    An array of T_SEGMENT that a PIPELINED function can use to return T_SEGMENT objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_SEGMENTS
AS TABLE OF &&INSTALL_SCHEMA..T_SEGMENT
```

12. OBJECT TYPE ARRAY/T_TOKENS [ Structures ]

[ Top ] [ Structures ]

NAME

```    T_TOKENS -- Object type representing a collection (array) of T_TOKEN objects.
```

DESCRIPTION

```    An array of T_TOKEN objects that represent an ordered set of tokens and separators extracted from a string by the Tokenizer function.
Used by PIPELINED Tokenizer function.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_TOKENS
IS TABLE OF &&INSTALL_SCHEMA..T_TOKEN;
```

13. OBJECT TYPE/T_BEARING_DISTANCE [ Types ]

[ Top ] [ Types ]

NAME

```    T_BEARING_DISTANCE - Object Type representing a single bearing and distance COGO instruction.
```

DESCRIPTION

```    An object type that represents a set of bearing/distance instructions for building the sides of a polygon, or the segments of a linestring.
```

NOTES

```    No methods are declared on this type.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

13.1. T_BEARING_DISTANCE/ATTRIBUTES(T_BEARING_DISTANCE) [ Variables ]

[ Top ] [ T_BEARING_DISTANCE ] [ Variables ]

ATTRIBUTES

```    sDegMinSec varchar2(255) -- Textual description of a bearing eg 180^10'5.2" (cf Google).
nBearing   number,       -- A numeric bearing eg 180.092784
distance   number,       -- Length of line along line defined by bearing.
Z          number,       -- Z ordinate of point at end of bearing/distance (line cogo function only)
```

NOTES

```    Normally only one or the other of the sDegMinSec or nBearing attributes are defined.
```

SOURCE

```  Bearing  number,
Distance number,
Z        number,
```

13.2. T_BEARING_DISTANCE/CONSTRUCTORS(T_BEARING_DISTANCE) [ Methods ]

[ Top ] [ T_BEARING_DISTANCE ] [ Methods ]

NAME

```    A collection of T_BEARING_DISTANCE Constructors.
INPUT
p_sDegMinSec varchar2 -- Textual description of a bearing eg 180^10'5.2" (cf Google).
Converted to internal bearing attribute via call to COGO.DMS2DEG.
```

SOURCE

```  Constructor Function T_BEARING_DISTANCE ( p_sDegMinSec in varchar2,
p_distance   in number )
Return Self As Result,

Constructor Function T_BEARING_DISTANCE ( p_bearing  in number,
p_distance in number )
Return Self As Result,

Constructor Function T_BEARING_DISTANCE ( p_sDegMinSec in varchar2,
p_distance   in number,
p_z          in number )
Return Self As Result
```

14. OBJECT TYPE/T_ELEMINFO [ Types ]

[ Top ] [ Types ]

NAME

```    T_ELEMINFO -- Object type representing single mdsys.sdo_elem_info triplet.
```

DESCRIPTION

```    An object type that represents an sdo_elem_info_array "triplet" as a single object.
```

NOTES

```    No methods are declared on this type.
```

TODO

```    Methods on an T_ELEMINFO may be added in future.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

14.1. T_ELEMINFO/ATTRIBUTES(T_ELEMINFO) [ Variables ]

[ Top ] [ T_ELEMINFO ] [ Variables ]

ATTRIBUTES

```    offset         -- Offset value from Element_Info triplet
etype          -- eType value from Element_Info triplet, describes geometry element.
interpretation -- Interpretation value from Element_Info triplet eg 1 is vertex-connected; 3 is optimized rectangle; etc.
```

SOURCE

```   offset           NUMBER,
etype            NUMBER,
interpretation   NUMBER
```

15. OBJECT TYPE/T_GEOMETRY [ Types ]

[ Top ] [ Types ]

NAME

```    T_GEOMETRY Object Type
```

DESCRIPTION

```    An object type that represents a single SDO_GEOMETRY geometry object.
Includes Methods on that type.
```

WARNINGS

```    This type should only be used for programming and should not be stored in the database.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package for &&INSTALL_SCHEMA..
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.1. T_GEOMETRY/ATTRIBUTES(T_GEOMETRY) [ Variables ]

[ Top ] [ T_GEOMETRY ] [ Variables ]

ATTRIBUTES

```    geom       -- mdsys.sdo_geometry Object
tolerance  -- Standard SDO_TOLERANCE value.
Since we need the geometry's tolerance for some operations eg sdo_area etc
let's add it to the type rather than have to supply it all the time to member functions
dPrecision -- Number of Significant Decimal Digits of precision. (PRECISION is an Oracle name)
Some operations require the comparison of two ordinates. For geodetic data this is
not the same as an Oracle tolerance. We allow a user to supply this value for all data
but if set to null it will assume a value based on the tolerance.
projected  -- Whether mdsys.sdo_geometry ordinates are Geodetic (0), Projected (1), or NULL (not defined).
When creating and using bearing and distances one needs to know if the geometry
is projected or not. While one could do this by dynamic query to the database
each time it is needed, an additional property helps us to record this once.
```

SOURCE

```  geom       mdsys.sdo_geometry,
tolerance  number,
dPrecision integer,
projected  integer,
```

15.2. T_GEOMETRY/CONSTRUCTOR(EWKT) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    T_GEOMETRY(EWKT CLOB)-- Constructor that creates an sdo_geometry object from the passed in EWKT.
```

SYNOPSIS

```    Constructor Function T_GEOMETRY(p_ewkt IN CLOB)
Return Self As Result,
```

DESCRIPTION

```    The p_ewkt parameter can be a 2D or greater WKT object.
```

ARGUMENTS

```    p_ewkt (CLOB) -- Any non-null WKT or EWKT object
```

EXAMPLE

```    See ST_FromEWKT().
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - September 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.3. T_GEOMETRY/CONSTRUCTOR(MDSYS.SDO_GEOMETRY_ARRAY) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    T_GEOMETRY(sdo_geometry_array) -- Constructor that creates a GeometryCollection from an array of sdo_geometry objects.
```

SYNOPSIS

```    Constructor Function T_GEOMETRY(p_geoms IN mdsys.sdo_geometry_array)
Return Self As Result,
```

DESCRIPTION

```    The p_geoms geometry array parameter should contain at least one element.
The sdo_geometry objects within the array should have the same dimension, if not the lowest is chosen (cf ST_To2D etc).
All p_geoms objects should be in the same SRID.
```

ARGUMENTS

```    p_geoms (mdsys.sdo_geometry_array) -- Any non-null, geometry array
```

EXAMPLE

```    With data as (
select sdo_geometry('POINT(1 2)',null) as tgeom From Dual
UNION ALL select sdo_geometry(2001,NULL,SDO_POINT_TYPE(3,4,null),null,null) as tgeom From Dual
UNION ALL select sdo_geometry('LINESTRING(5 1,10 1,10 5,10 10,5 10,5 5)',null) as tgeom From Dual
UNION ALL select sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,10,0,10,5,10,10,5,10,5,5)) as tgeom From Dual
UNION ALL select sdo_geometry('MULTILINESTRING((-1 -1, 0 -1),(0 0,10 0,10 5,10 10,5 10,5 5))',null) as tgeom From Dual
UNION ALL select sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null) as tgeom From Dual
UNION ALL select sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null) as tgeom From Dual
)
select t_geometry(
cast(collect(a.tgeom) as mdsys.sdo_geometry_array)
).geom as gArray
from data a;

GARRAYGEOM
-----------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2004,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1,1, 3,1,1, 5,2,1, 17,2,1, 29,2,1, 33,2,1, 45,1003,1, 55,2003,1, 65,1003,1, 75,2003,1, 85,2003,1, 95,1003,1),
SDO_ORDINATE_ARRAY(1,2, 3,4, 5,1, 10,1, 10,5, 10,10, 5,10, 5,5, 0,0, 10,0, 10,5, 10,10, 5,10, 5,5, -1,-1, 0,-1,
0,0, 10,0, 10,5, 10,10, 5,10, 5,5,
0,0, 20,0, 20,20, 0,20, 0,0,
10,10, 10,11, 11,11, 11,10, 10,10,
0,0, 20,0, 20,20, 0,20, 0,0,
10,10, 10,11, 11,11, 11,10, 10,10,
5,5, 5,7, 7,7, 7,5, 5,5,
100,100, 200,100, 200,200, 100,200, 100,100))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - September 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.4. T_GEOMETRY/CONSTRUCTORS(STANDARD) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    A collection of "standard" T_GEOMETRY Constructors.
```

SOURCE

```  Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY)
Return Self As Result,

Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY,
p_geom      IN mdsys.sdo_geometry)
Return Self As Result,

Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY,
p_geom      in mdsys.sdo_geometry,
p_tolerance in number)
Return Self As Result,

Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY,
p_geom      in mdsys.sdo_geometry,
p_tolerance in number,
p_dPrecision in integer)
Return Self As Result,

Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY,
p_geom      in mdsys.sdo_geometry,
p_tolerance in number,
p_dPrecision in integer,
p_projected in varchar2)
Return Self As Result,

Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY,
p_vertex    in mdsys.vertex_type,
p_srid      in integer,
p_tolerance in number default 0.005)
Return Self As Result,

Constructor Function T_GEOMETRY(SELF        IN OUT NOCOPY T_GEOMETRY,
p_segment   in &&INSTALL_SCHEMA..T_SEGMENT)
Return Self As Result,
```

15.5. T_GEOMETRY/OrderBy [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    OrderBy -- Implements ordering function that can be used to sort a collection of T_GEOMETRY objects.
```

SYNOPSIS

```    Order Member Function OrderBy(p_compare_geom in &&INSTALL_SCHEMA..T_GEOMETRY)
Return Number deterministic
```

ARGUMENTS

```    p_compare_geom (T_GEOMETRY) - Order pair
```

DESCRIPTION

```    This order by function allows a collection of T_GEOMETRY objects to be sorted.
For example in the ORDER BY clause of a select statement. Comparison uses all ordinates: X, Y, Z and W.
```

EXAMPLE

```    With geometries as (
select t_geometry(sdo_geometry(2001,null,
sdo_point_type(dbms_random.value(0,level),
dbms_random.value(0,level),
null),
null,null),
0.005,
3,
1) as tgeom
from dual
connect by level < 10
)
select a.tgeom.st_astext(2) as sGeom
from geometries a
order by a.tgeom;

SGEOM
------------------------------------------------------------------------------------------
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0.39,0.87,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0.71,0.04,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(1.68,1.03,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(1.72,1.45,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2.68,1.99,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(3.12,1.14,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(3.38,0.71,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(4.75,4.46,NULL),NULL,NULL);TOLERANCE(.05)
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(5.49,6.87,NULL),NULL,NULL);TOLERANCE(.05)

9 rows selected
```

RESULT

```    order value (Number) - -1 less than; 0 equal; 1 greater than
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Add_SEGMENT -- Adds a segment to an existing geometry.
```

SYNOPSIS

```    Member Function ST_Add_SEGMENT     (p_SEGMENT in &&INSTALL_SCHEMA..T_SEGMENT)
Return &&INSTALL_SCHEMA..T_Geometry deterministic,
```

DESCRIPTION

```    Adds a segment to an existing geometry.
If last vertex of existing geometry equals first vertex of segment the point is not repeated.
Supports segments that define a circular arc.
```

ARGUMENTS

```    p_SEGMENT (T_SEGMENT) - Valid segment. Supports 2 vertex or 3 vertex circular arc segments.
```

RESULT

```    geometry (T_GEOMETRY) - Modified geometry
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.7. T_GEOMETRY/ST_Affine [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Affine -- Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.
```

SYNOPSIS

```    Member Function ST_Affine (
p_a    in number,
p_b    in number,
p_c    in number,
p_d    in number,
p_e    in number,
p_f    in number,
p_g    in number,
p_h    in number,
p_i    in number,
p_xoff in number,
p_yoff in number,
p_zoff in number)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.
To apply a 2D affine transformation only supply a, b, d, e, xoff, yoff
The vertices are transformed as follows:
x' = a*x + b*y + c*z + xoff
y' = d*x + e*y + f*z + yoff
z' = g*x + h*y + i*z + zoff
```

ARGUMENTS

```    a, b, c, d, e, f, g, h, i, xoff, yoff, zoff (all number s)
Represent the transformation matrix
-----------------
| a  b  c  xoff |
| d  e  f  yoff |
| g  h  i  zoff |
| 0  0  0     1 |
-----------------
```

RESULT

```    geometry (T_GEOMETRY) -- Transformed geometry
```

EXAMPLE

```  SELECT t_geometry(sdo_geometry(3001,null,sdo_point_type(1,2,3),null,null),0.05,1,1)
.ST_Affine(p_a=>COS(COGO.pi()),
p_b=>0.0-SIN(COGO.pi()),
p_c=>0.0,
p_d=>SIN(COGO.pi()),
p_e=>COS(COGO.pi()),
p_f=>0.0,
p_g=>0.0,
p_h=>0.0,
p_i=>1.0,
p_xoff=>0.0,
p_yoff=>0.0,
p_zoff=>0.0).geom As affine_geom
FROM dual;

AFFINE_GEOM
--------------------------------------------------------------
SDO_GEOMETRY(3001,NULL,SDO_POINT_TYPE(-1.0,-2.0,3.0),NULL,NULL)

--Rotate a 3d line 180 degrees in both the x and z axis
SELECT f.the_geom
.ST_Affine(cos(COGO.PI()), -sin(COGO.PI()), 0, sin(COGO.PI()), cos(COGO.PI()), -sin(COGO.PI()), 0, sin(COGO.PI()), cos(COGO.PI()), 0, 0, 0).geom as affine_geom
FROM (select T_Geometry(sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,2,3,1,4,3)),0.005,2,1) As the_geom
from dual
) f;

AFFINE_GEOM
-----------
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(-1.0,-2.0,-3.0, -1.0,-4.0,-3.0))

-- Rotate a 3d line 180 degrees about the z axis.
select t_geometry(sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,2,3, 1,4,3)),0.05,1,1)
.ST_Affine(p_a=>COS(COGO.pi()),
p_b=>0.0-SIN(COGO.pi()),
p_c=>0.0,
p_d=>SIN(COGO.pi()),
p_e=>COS(COGO.pi()),
p_f=>0.0,
p_g=>0.0,
p_h=>0.0,
p_i=>1.0,
p_xoff=>0.0,
p_yoff=>0.0,
p_zoff=>0.0).geom
As affine_geom
from dual;

AFFINE_GEOM
--------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(-1.0,-2.0,3.0, -1.0,-4.0,3.0))
REQUIRES
SYS.UTL_NLA Package
SYS.UTL_NLA_ARRAY_DBL Type
SYS.UTL_NLA_ARRAY_INT Type
```

NOTES

```    Cartesian arithmetic only
Not for Oracle XE. Only 10g and above.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Feb 2009 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.8. T_GEOMETRY/ST_Append [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Append -- Appends sdo_geometry to underlying sdo_geometry.
```

SYNOPSIS

```    Member Function ST_Append ()
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

RESULT

```    MultiGeometry (T_GEOMETRY) -- If not already a multi geometry, returns multi-geometry object with 1 geometry;
```

DESCRIPTION

```    Appends p_geom sdo_geometry value to underlying SELF.geom sdo_geometry.
Can be used to append points to points, points to lines, lines to lines, lines to polygons etc.
Detects if two adjacent vertices are within tolerance distance and merges if they are.
For linestrings, p_concatenate mode of 0 appends without checking for duplicate end points and returns a multilinestring.
If p_concatentate is 1 and an end/start point equality relationship is detected, only one coordinate is stored, and a single linestring returned.
It is not implemented using SDO_UTIL.APPEND.
```

NOTES

```    Oracle's SDO_UTIL.APPEND supports 2 and 3D geometies but SDO_UTIL.CONCAT_LINES only supports 2D data.
Also, if underlying linestring geometry is measured, SDO_LRS.CONCATENATE_GEOM_SEGMENTS must be called.
This function implements all these Oracle functions under one "umbrella".
```

EXAMPLE

```    With data as (
select t_geometry(SDO_GEOMETRY(3001,NULL,SDO_POINT_TYPE(157503.148,6568556.703,50.647),null,null)) as tPoint from dual
)
select 'Point+Point'      as test, a.tPoint.ST_Append(SDO_GEOMETRY(3001,null,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(158506.165,6568585.072,26.556))).geom as geom
from data a union all
select 'Point+SdoPoint'   as test, a.tPoint.ST_Append(SDO_GEOMETRY(3001,null,SDO_POINT_TYPE(158506.165,6568585.072,26.556),null,null)).geom as geom
from data a union all
select 'Point+MultiPoint' as test, a.tPoint.ST_Append(SDO_GEOMETRY(3005,null,NULL,SDO_ELEM_INFO_ARRAY(1,1,2),SDO_ORDINATE_ARRAY(157500.896,6568571.813,38.453, 158506.165,6568585.072,26.556))).geom as geom
from data a;

TEST             GEOM
---------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Point+Point      SDO_GEOMETRY(3005,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,2),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,158506.165,6568585.072,26.556))
Point+SdoPoint   SDO_GEOMETRY(3005,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,2),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,158506.165,6568585.072,26.556))
Point+MultiPoint SDO_GEOMETRY(3005,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,3),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157500.896,6568571.813,38.453,158506.165,6568585.072,26.556))

select 'Two 3002 Lines with common point => 3002/3006' as test,
case when t.IntValue = 0 then 'Append' else 'Concatenate' end as testMode,
t_geometry(SDO_GEOMETRY(3002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573)))
.ST_Append(SDO_GEOMETRY(3002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(                              157512.499,6568585.998,15.573,157519.107,6568582.067,2.382)),
t.IntValue).geom as geom
from dual a,
table(tools.generate_series(0,1,1)) t
union all
select 'Two 2002 Lines with common point => 2002/2006' as test,
case when t.IntValue = 0 then 'Append' else 'Concatenate' end as testMode,
t_geometry(SDO_GEOMETRY(2002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998)))
.ST_Append(SDO_GEOMETRY(2002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(                       157512.499,6568585.998,157519.107,6568582.067)),
t.IntValue).geom
from dual a,
table(TOOLS.generate_series(0,1,1)) t
union all
select 'Two 3002 with no common point => 3006' as test,
'Append' as test_mode,
t_geometry(SDO_GEOMETRY(3002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573)))
.ST_Append(SDO_GEOMETRY(3002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(157520.228,6568574.745,1.46,157512.15,6568564.565,28.219)),0).geom
from dual
union all
select 'Two 2002 with no common point => 2006' as test,
'Append' as test_mode,
t_geometry(SDO_GEOMETRY(2002,null,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998)))
.ST_Append(SDO_GEOMETRY(2002,null,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(157520.228,6568574.745,157512.15,6568564.565)),0).geom
from dual;

TEST                                          TESTMODE    GEOM
--------------------------------------------- ----------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Two 3002 Lines with common point => 3002/3006 Append      SDO_GEOMETRY(3006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,7,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573,157512.499,6568585.998,15.573,157519.107,6568582.067,2.382))
Two 3002 Lines with common point => 3002/3006 Concatenate SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573,157519.107,6568582.067,2.382))
Two 2002 Lines with common point => 2002/2006 Append      SDO_GEOMETRY(2006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,5,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998,157512.499,6568585.998,157519.107,6568582.067))
Two 2002 Lines with common point => 2002/2006 Concatenate SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998,157519.107,6568582.067))
Two 3002 with no common point => 3006         Append      SDO_GEOMETRY(3006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,7,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573,157520.228,6568574.745,1.46,157512.15,6568564.565,28.219))
Two 2002 with no common point => 2006         Append      SDO_GEOMETRY(2006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,5,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998,157520.228,6568574.745,157512.15,6568564.565))

6 rows selected

select case when t.IntValue = 0
then 'Append Linestring 2002 and Point 2001 => 2004'
else 'Concat Linestring 2002 and Point 2001 => 2002'
end as test,
t_geometry(SDO_GEOMETRY(2002,null,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703, 157512.499,6568585.998)))
.ST_Append(SDO_GEOMETRY(2001,null,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(157512.499,6568585.998)),
t.IntValue).geom as geom
from table(TOOLS.generate_series(0,1,1)) t
Union all
select case when t.IntValue = 0
then 'Append Linestring 3002 and Point 3001 => 3004'
else 'Concat Linestring 3002 and Point 3001 => 3002'
end as test,
t_geometry(SDO_GEOMETRY(3002,null,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647, 157512.499,6568585.998,15.573)))
.ST_Append(SDO_GEOMETRY(3001,null,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(                               157512.499,6568585.998,15.573)),
t.IntValue).geom as geom
from table(TOOLS.generate_series(0,1,1)) t;

TEST                                          GEOM
--------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Append Linestring 3002 and Point 3001 => 3004 SDO_GEOMETRY(3004,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1, 1,1,1),SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573,157512.499,6568585.998,15.573))
Concat Linestring 3002 and Point 3001 => 3002 SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),       SDO_ORDINATE_ARRAY(157503.148,6568556.703,50.647,157512.499,6568585.998,15.573))
Append Linestring 2002 and Point 2001 => 2004 SDO_GEOMETRY(2004,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,1,1,1), SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998,157512.499,6568585.998))
Concat Linestring 2002 and Point 2001 => 2002 SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),       SDO_ORDINATE_ARRAY(157503.148,6568556.703,157512.499,6568585.998))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.9. T_GEOMETRY/ST_Area [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Area -- Returns area of underlying polygon sdo_geometry
```

SYNOPSIS

```    Member Function ST_Area (
p_unit  in varchar2 default NULL,
p_round in integer  default 0 )
)
Return Number Deterministic
```

ARGUMENTS

```    p_unit (varchar2) - Oracle Unit of Measure eg unit=M.
p_round (integer) - Whether to round result using PRECISION of T_GEOMETRY
```

DESCRIPTION

```    This function computes the area of underlying sdo_geometry polygon.
Result is expressed in the units of the SDO_SRID, or in p_units where supplied.
Result is rounded to SELF.PRECISION if p_round is true (1), otherwise false(0) no rounding.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry(3003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual union all
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',28356),0.0005,3,1) as tgeom From Dual
)
select a.tgeom.ST_Area(case when a.tGeom.ST_Srid() = 28356 then 'unit=SQ_KM' else null end,0) as area_km,
a.tgeom.ST_Area(case when a.tGeom.ST_Srid() = 28356 then 'unit=SQ_KM' else null end,1) as round_area_km
from data a;

AREA_KM ROUND_AREA_KM
----------- -------------
78.30229882        78.302
0.000399             0
```

RESULT

```    area (Number) -- Area in SRID unit of measure or in supplied units (p_unit) possibly rounded to SELF.Precision
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.10. T_GEOMETRY/ST_AsEWKT [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_AsEWKT -- Exports 3/4D mdsys.sdo_geometry object to an Extended Well Known Text (WKT) format.
```

SYNOPSIS

```    Member Function ST_AsEWKT(p_format_model in varchar2 default 'TM9')
Return Integer Deterministic,
```

DESCRIPTION

```    If underlying geometry is 2D, ST_AsWKT() is called.
If 3/4D this function creates an Extended WKT format result.
This function allows the formatting of the ordinates in the EWKT string to be user defined.
```

ARGUMENTS

```    p_format_model (varchar2) -- Oracle Number Format Model (see documentation)
default 'TM9')
```

RESULT

```    WKT (CLOB) -- Extended Well Known Text.
```

EXAMPLE

```    With data as (
select t_geometry(sdo_geometry(3001,NULL,sdo_point_type(100,100,-37.38),NULL,NULL),0.005,2,1) as geom
from dual union all
select t_geometry(sdo_geometry(4001,NULL,NULL,
sdo_elem_info_array(1,1,1),
sdo_ordinate_array(100,100,-37.38,345.24)),0.005,2,1) as geom
from dual union all
select t_geometry(sdo_geometry(2002,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)),0.0005,3,1) as geom
from dual union all
select t_geometry(sdo_geometry(2002,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.4743434348,5526918.37343433, 252400.034348,5526918.33434333473,252230.4434343378,5527000.433445660)),0.0005,3,1) as geom
from dual union all
select t_geometry(SDO_GEOMETRY(3302,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.478,5526918.373,0.0, 252400.08,5526918.373,417.4, 252230.478,5527000.0,506.88)),0.0005,3,1) as geom
from dual union all
select t_geometry(sdo_geometry(2002,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(100,100,900,900.0)),0.005,2,1) as geom
from dual union all
select t_geometry(sdo_geometry(3002,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as geom
from dual union all
select t_geometry(sdo_geometry(3302,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as geom
from dual union all
select t_geometry(sdo_geometry(4402,4283,null,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(147.5,-42.5,849.9,102.0, 147.6,-42.5,1923.0,2100.0)),0.005,2,0) as geom
from dual union all
Select T_GEOMETRY(sdo_geometry(3003,NULL,NULL,
sdo_elem_info_array(1,1003,1),
sdo_ordinate_array(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,2,1) as geom
From Dual
)
select a.geom.geom.sdo_gtype as gtype,
a.geom.ST_AsEWKT() as ewkt
from data a;

GTYPE EWKT
----- -----------------------------------------------------------------------------------------------------------------------
3001 POINTZ (100 100 -37.38)
4001 POINTZM (100 100 -37.38 345.24)
2002 CIRCULARSTRING (252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)
2002 CIRCULARSTRING (252230.4743434348 5526918.37343433, 252400.034348 5526918.334343335, 252230.4434343378 5527000.43344566)
3302 SRID=28355;CIRCULARSTRINGM (252230.478 5526918.373 0,252400.08 5526918.373 417.4,252230.478 5527000 506.88)
2002 LINESTRING (100.0 100.0, 900.0 900.0)
3002 LINESTRINGZ (0 0 1,10 0 2,10 5 3,10 10 4,5 10 5,5 5 6)
3302 LINESTRINGM (0 0 1,10 0 2,10 5 3,10 10 4,5 10 5,5 5 6)
4402 SRID=4283;LINESTRINGZM (147.5 -42.5 849.9 102,147.6 -42.5 1923 2100)
3003 POLYGONZ ((0 0 1,10 0 2,10 5 3,10 10 4,5 10 5,5 5 6))

9 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.11. T_GEOMETRY/ST_AsGeometryRow [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_AsGeometryRow -- Simply returned T_GEOMETRY as an T_GEOMETRYROW object.
```

SYNOPSIS

```    Member Function ST_AsGeometryRow (p_gid in integer default ),
Return &&INSTALL_SCHEMA..T_GEOMETRYROW Deterministic,
```

DESCRIPTION

```    T_GEOMETRIES is defined as a table of T_GEOMETRYROW.
Functions like ST_Dump break up an sdo_geometry and returns them as T_GEOMETRYROW objects within a T_GEOMETRIES object.
```

EXAMPLE

```    select &&INSTALL_SCHEMA..T_Geometry(SDO_GEOMETRY(2005, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(10.719, 8.644)),0.005,3,1)
.ST_AsGeometryRow() as geom
from dual;

GEOM
-------------------------------------------------------------------------------------------------------------------------------
T_GEOMETRY_ROW(1, SDO_GEOMETRY(2005, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(10.719, 8.644)), 0.005, 3, 1)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jul 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.12. T_GEOMETRY/ST_AsText [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_AsText -- Exports mdsys.sdo_geometry object to its Well Known Text (WKT) representation by executing, and returning, result of mdsys.sdo_geometry method get_wkt().
```

SYNOPSIS

```    Member Function ST_AsText
Return Integer Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry method SELF.GEOM.GET_WKT().
Returns Well Known Text (WKT) representation of underlying mdsys.sdo_geometry.
```

RESULT

```    WKT (CLOB) -- eg Well Known Text encoding of mdsys.sdo_geometry object.
```

EXAMPLE

```    with data as (
select 'CircularString (1)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,2),sdo_ordinate_array (10,15,15,20,20,15)) as geom from dual union all
select 'CircularString (2)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,2),sdo_ordinate_array (10,35,15,40,20,35,25,30,30,35)) as geom from dual union all
select 'CircularString (Closed)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,2),sdo_ordinate_array (15,65,10,68,15,70,20,68,15,65)) as geom from dual union all
select 'CompoundCurve (1)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,4,3,1,2,1,3,2,2,7,2,1),sdo_ordinate_array (10,45,20,45,23,48,20,51,10,51)) as geom from dual union all
select 'CompoundCurve (2)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,4,2,1,2,1,7,2,2),sdo_ordinate_array (10,78,10,75,20,75,20,78,15,80,10,78)) as geom from dual union all
select 'CurvePolygon (Circle Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,4),sdo_ordinate_array (15,140,20,150,40,140)) as geom from dual union all
select 'CurvePolygon (CircularArc Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,2),sdo_ordinate_array (15,115,20,118,15,120,10,118,15,115)) as geom from dual union all
select 'CurvePolygon (Compound Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1005,2,1,2,1,7,2,2),sdo_ordinate_array (10,128,10,125,20,125,20,128,15,130,10,128)) as geom from dual union all
select 'GeometryCollection (1)' as test,sdo_geometry (2004,null,null,sdo_elem_info_array (1,1,1,3,2,1,7,1003,1),sdo_ordinate_array (10,5,10,10,20,10,10,105,15,105,20,110,10,110,10,105)) as geom from dual union all
select 'GeometryCollection (2)' as test,sdo_geometry(2004,NULL,NULL,sdo_elem_info_array(1,1003,3,5,1,1,9,2,1),sdo_ordinate_array(0,0,100,100,50,50,0,0,100,100.0)) as geom from dual union all
select 'LineString (1)' as test,sdo_geometry(2002,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,100,900,900.0)) as geom from dual union all
select 'LineString (2)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,25,20,30,25,25,30,30)) as geom from dual union all
select 'LineString (3)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,10,20,10)) as geom from dual union all
select 'LineString (Closed)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,55,15,55,20,60,10,60,10,55)) as geom from dual union all
select 'LineString (Self-Crossing)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,85,20,90,20,85,10,90,10,85)) as geom from dual union all
select 'MultiCurve (1)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,2,7,2,2),sdo_ordinate_array (50,35,55,40,60,35,65,35,70,30,75,35)) as geom from dual union all
select 'MultiCurve (Touching)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,2,7,2,2),sdo_ordinate_array (50,65,50,70,55,68,55,68,60,65,60,70)) as geom from dual union all
select 'MultiLine (Closed)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,1,9,2,1),sdo_ordinate_array (50,55,50,60,55,58,50,55,56,58,60,55,60,60,56,58)) as geom from dual union all
select 'MultiLine (Crossing)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,1,5,2,1),sdo_ordinate_array (50,22,60,22,55,20,55,25)) as geom from dual union all
select 'MultiLine (Stoked)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,1,5,2,1),sdo_ordinate_array (50,15,55,15,60,15,65,15)) as geom from dual union all
select 'MultiPoint (2)' as test,sdo_geometry(2005,NULL,NULL,sdo_elem_info_array(1,1,2),sdo_ordinate_array(100,100,900,900.0)) as geom from dual union all
select 'MultiPoint (3)' as test,sdo_geometry (2005,null,null,sdo_elem_info_array (1,1,1,3,1,1,5,1,1),sdo_ordinate_array (65,5,70,7,75,5)) as geom from dual union all
select 'MultiPoint (4)' as test,sdo_geometry (2005,null,null,sdo_elem_info_array (1,1,3),sdo_ordinate_array (50,5,55,7,60,5)) as geom from dual union all
select 'MultiPolygon (Disjoint)' as test,sdo_geometry (2007,null,null,sdo_elem_info_array (1,1003,1,11,1003,3),sdo_ordinate_array (50,105,55,105,60,110,50,110,50,105,62,108,65,112)) as geom from dual union all
select 'MultiPolygon (Rectangles)' as test,sdo_geometry(2007,NULL,NULL,sdo_elem_info_array(1,1003,3,5,1003,3),sdo_ordinate_array(1500,100,1900,500,1900,500,2300,900.0)) as geom from dual union all
select 'Point (Ordinate Encoding)' as test,sdo_geometry (2001,null,null,sdo_elem_info_array (1,1,1),sdo_ordinate_array (10,5)) as geom from dual union all
select 'Point (SDO_POINT encoding)' as test,sdo_geometry(2001,NULL,sdo_point_type(900,900,NULL),NULL,NULL) as geom from dual union all
select 'Polygon (No Holes)' as test,sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3),sdo_ordinate_array(100,100,500,500.0)) as geom from dual union all
select 'Polygon (Stroked Exterior Ring)' as test,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)) as geom from dual union all
select 'Polygon (With Point and a Hole)' as test,sdo_geometry(2003,NULL,MDSYS.SDO_POINT_TYPE(1000,1000,NULL),sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(500,500,1500,1500,600,750,900,1050.0)) as geom from dual union all
select 'Polygon (With Void)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,3,5,2003,3),sdo_ordinate_array (50,135,60,140,51,136,59,139)) as geom from dual union all
select 'Rectangle (Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,3),sdo_ordinate_array (10,135,20,140)) as geom from dual union all
select 'Rectangle (With Rectangular Hole)' as test,sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(0,0,200,200,75,25,125,75.0)) as geom from dual
)
select a.test,
T_GEOMETRY(a.geom,0.0005,3,1)
.ST_Rectangle2Polygon()
.ST_AsText() as geom
from data a
order by 1;

TEST                                     GEOM
---------------------------------------- -----------------------------------------------------------------------------------------------------------------------------
CircularString (1)                       CIRCULARSTRING (10 15, 15 20, 20 15.0)
CircularString (2)                       CIRCULARSTRING (10 35, 15 40, 20 35, 25 30, 30 35.0)
CircularString (Closed)                  CIRCULARSTRING (15 65, 10 68, 15 70, 20 68, 15 65.0)
CompoundCurve (1)                        COMPOUNDCURVE ((10 45, 20 45.0), CIRCULARSTRING (20 45, 23 48, 20 51.0), (20 51, 10 51.0))
CompoundCurve (2)                        COMPOUNDCURVE ((10 78, 10 75, 20 75, 20 78.0), CIRCULARSTRING (20 78, 15 80, 10 78.0))
CurvePolygon (Circle Exterior Ring)      CURVEPOLYGON ((15 140, 27.5 127.5, 40 140, 27.5 152.5, 15 140.0))
CurvePolygon (CircularArc Exterior Ring) CURVEPOLYGON (CIRCULARSTRING (15 115, 20 118, 15 120, 10 118, 15 115.0))
CurvePolygon (Compound Exterior Ring)    CURVEPOLYGON (COMPOUNDCURVE ((10 128, 10 125, 20 125, 20 128.0), CIRCULARSTRING (20 128, 15 130, 10 128.0)))
GeometryCollection (1)                   GEOMETRYCOLLECTION (POINT (10 5.0), LINESTRING (10 10, 20 10.0), POLYGON ((10 105, 15 105, 20 110, 10 110, 10 105.0)))
GeometryCollection (2)                   GEOMETRYCOLLECTION (POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0.0)), POINT (50 50.0), LINESTRING (100 100.0))
LineString (1)                           LINESTRING (100 100, 900 900.0)
LineString (2)                           LINESTRING (10 25, 20 30, 25 25, 30 30.0)
LineString (3)                           LINESTRING (10 10, 20 10.0)
LineString (Closed)                      LINESTRING (10 55, 15 55, 20 60, 10 60, 10 55.0)
LineString (Self-Crossing)               LINESTRING (10 85, 20 90, 20 85, 10 90, 10 85.0)
MultiCurve (1)                           MULTICURVE (CIRCULARSTRING (50 35, 55 40, 60 35.0), CIRCULARSTRING (65 35, 70 30, 75 35.0))
MultiCurve (Touching)                    MULTICURVE (CIRCULARSTRING (50 65, 50 70, 55 68.0), CIRCULARSTRING (55 68, 60 65, 60 70.0))
MultiLine (Closed)                       MULTILINESTRING ((50 55, 50 60, 55 58, 50 55.0), (56 58, 60 55, 60 60, 56 58.0))
MultiLine (Crossing)                     MULTILINESTRING ((50 22, 60 22.0), (55 20, 55 25.0))
MultiLine (Stoked)                       MULTILINESTRING ((50 15, 55 15.0), (60 15, 65 15.0))
MultiPoint (2)                           MULTIPOINT ((100 100.0), (900 900.0))
MultiPoint (3)                           MULTIPOINT ((65 5.0), (70 7.0), (75 5.0))
MultiPoint (4)                           MULTIPOINT ((50 5.0), (55 7.0), (60 5.0))
MultiPolygon (Disjoint)                  MULTIPOLYGON (((50 105, 55 105, 60 110, 50 110, 50 105.0)), ((62 108, 65 108, 65 112, 62 112, 62 108.0)))
MultiPolygon (Rectangles)                MULTIPOLYGON (((1500 100, 1900 100, 1900 500, 1500 500, 1500 100.0)), ((1900 500, 2300 500, 2300 900, 1900 900, 1900 500.0)))
Point (Ordinate Encoding)                POINT (10 5.0)
Point (SDO_POINT encoding)               POINT (900 900.0)
Polygon (No Holes)                       POLYGON ((100 100, 500 100, 500 500, 100 500, 100 100.0))
Polygon (Stroked Exterior Ring)          POLYGON ((10 105, 15 105, 20 110, 10 110, 10 105.0))
Polygon (With Point and a Hole)          POLYGON ((500 500, 1500 500, 1500 1500, 500 1500, 500 500.0), (900 750, 600 750, 600 1050, 900 1050, 900 750.0))
Polygon (With Void)                      POLYGON ((50 135, 60 135, 60 140, 50 140, 50 135.0), (59 136, 51 136, 51 139, 59 139, 59 136.0))
Rectangle (Exterior Ring)                POLYGON ((10 135, 20 135, 20 140, 10 140, 10 135.0))
Rectangle (With Rectangular Hole)        POLYGON ((0 0, 200 0, 200 200, 0 200, 0 0.0), (125 25, 75 25, 75 75, 125 75, 125 25.0))

33 rows selected
```

NOTES

```    Is an implementation of OGC ST_AsText method.
Any polygon containing optimized rectangles rings is converted to its 5 point equivalent.
Only supports 2D geometries.
```

TODO

```    Convert Optimized Rectangles to BBOX elements.
Create ST_AsEWKT() method and ST_FromEWKT() or use SC4O Java methods.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.13. T_GEOMETRY/ST_AsTText [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_AsTText -- Returns text Description of T_GEOMETRY
```

SYNOPSIS

```    Member Function ST_AsTText(p_linefeed     in integer default 1,
p_format_model in varchar2 default 'TM9')
Return CLOB Deterministic,
```

DESCRIPTION

```    Returns textual description of T_GEOMETRY.
Rounds ordinates via object dPrecision variable.
```

ARGUMENTS

```    p_linefeed (integer) - 1 if apply linefeed to coordinates
p_format_model (varchar2) -- Oracle Number Format Model (see documentation)
default 'TM9')
```

RESULT

```    textual description (string)
```

EXAMPLE

```    with data as (
select 'POINT (0.1 0.2)' as wkt from dual union all
select 'LINESTRING (0.1 0.1,10 0,10 5,10 10,5 10,5 5)' as wkt from dual union all
select 'MULTILINESTRING ((50.0 55.0, 50.0 60.0, 55.0 58.0, 50.0 55.0), (56.0 58.0, 60.0 55.0, 60.0 60.0, 56.0 58.0))' as wkt from dual union all
select 'CIRCULARSTRING (10.0 15.0, 15.0 20.0, 20.0 15.0)' as wkt from dual union all
select 'COMPOUNDCURVE ((10.0 45.0, 20.0 45.0), CIRCULARSTRING (20.0 45.0, 23.0 48.0, 20.0 51.0), (20.0 51.0, 10.0 51.0))' as wkt from dual union all
select 'MULTICURVE (CIRCULARSTRING (50.0 35.0, 55.0 40.0, 60.0 35.0), CIRCULARSTRING (65.0 35.0, 70.0 30.0, 75.0 35.0))' as wkt from dual union all
select 'CURVEPOLYGON (COMPOUNDCURVE ((10.0 128.0, 10.0 125.0, 20.0 125.0, 20.0 128.0), CIRCULARSTRING (20.0 128.0, 15.0 130.0, 10.0 128.0)))' as wkt from dual union all
select 'MULTIPOLYGON (((1500.0 100.0, 1900.0 100.0, 1900.0 500.0, 1500.0 500.0, 1500.0 100.0)), ((1900.0 500.0, 2300.0 500.0, 2300.0 900.0, 1900.0 900.0, 1900.0 500.0)))' as wkt from dual union all
select 'GEOMETRYCOLLECTION (POINT (10.0 5.0), LINESTRING (10.0 10.0, 20.0 10.0), POLYGON ((10.0 105.0, 15.0 105.0, 20.0 110.0, 10.0 110.0, 10.0 105.0)))' as wkt from dual
)
select T_GEOMETRY.ST_FromText(a.wkt).ST_AsTText() as t_geom
from data a;

T_GEOM
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
T_GEOMETRY(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0.1,0.2,NULL),NULL,NULL);TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.1,0.1,10.0,0.0,10.0,5.0,10.0,10.0,5.0,10.0,5.0,5.0));TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,9,2,1),SDO_ORDINATE_ARRAY(50.0,55.0,50.0,60.0,55.0,58.0,50.0,55.0,56.0,58.0,60.0,55.0,60.0,60.0,56.0,58.0));TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(10.0,15.0,15.0,20.0,20.0,15.0));TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,4,3,1,2,1,3,2,2,7,2,1),SDO_ORDINATE_ARRAY(10.0,45.0,20.0,45.0,23.0,48.0,20.0,51.0,10.0,51.0));TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2,7,2,2),SDO_ORDINATE_ARRAY(50.0,35.0,55.0,40.0,60.0,35.0,65.0,35.0,70.0,30.0,75.0,35.0));TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,7,2,2),SDO_ORDINATE_ARRAY(10.0,128.0,10.0,125.0,20.0,125.0,20.0,128.0,15.0,130.0,10.0,128.0));TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2007,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1,11,1003,1),SDO_ORDINATE_ARRAY(1500.0,100.0,1900.0,100.0,1900.0,500.0,1500.0,500.0,1500.0,100.0,1900.0,500.0,2300.0,500.0,2300.0,900.0,1900.0,900.0,1900.0,500.0));
TOLERANCE(.005),PRECISION(2),PROJECTED(1)
T_GEOMETRY(SDO_GEOMETRY(2004,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1,3,2,1,7,1003,1),SDO_ORDINATE_ARRAY(10.0,5.0,10.0,10.0,20.0,10.0,10.0,105.0,15.0,105.0,20.0,110.0,10.0,110.0,10.0,105.0));
TOLERANCE(.005),PRECISION(2),PROJECTED(1)

9 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.14. T_GEOMETRY/ST_AsWKB [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_AsWKB -- Exports mdsys.sdo_geometry object to its Well Known Binary (WKB) representation by executing, and returning, result of mdsys.sdo_geometry method get_wkb().
```

SYNOPSIS

```    Member Function ST_AsWKB
Return Integer Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry method SELF.GEOM.GET_WKB(). Returns Well Known Binary representation of underlying mdsys.sdo_geometry.
```

RESULT

```    WKB (BLOB) -- eg Well Known Binary encoding of mdsys.sdo_geometry object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.15. T_GEOMETRY/ST_AsWKT [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_AsWKT -- Exports mdsys.sdo_geometry object to its Well Known Text (WKT) representation by executing, and returning, result of mdsys.sdo_geometry method get_wkt().
```

SYNOPSIS

```    Member Function ST_AsWKT
Return clob Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry method SELF.GEOM.GET_WKT().
Returns Well Known Text representation of underlying mdsys.sdo_geometry.
Only supports 2D geometries. See ST_AsEWKT for 3/4D.
```

RESULT

```    WKT (CLOB) -- eg Well Known Text encoding of mdsys.sdo_geometry object.
```

EXAMPLE

```    with data as (
select 'CircularString (1)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,2),sdo_ordinate_array (10,15,15,20,20,15)) as geom from dual union all
select 'CircularString (2)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,2),sdo_ordinate_array (10,35,15,40,20,35,25,30,30,35)) as geom from dual union all
select 'CircularString (Closed)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,2),sdo_ordinate_array (15,65,10,68,15,70,20,68,15,65)) as geom from dual union all
select 'CompoundCurve (1)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,4,3,1,2,1,3,2,2,7,2,1),sdo_ordinate_array (10,45,20,45,23,48,20,51,10,51)) as geom from dual union all
select 'CompoundCurve (2)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,4,2,1,2,1,7,2,2),sdo_ordinate_array (10,78,10,75,20,75,20,78,15,80,10,78)) as geom from dual union all
select 'CurvePolygon (Circle Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,4),sdo_ordinate_array (15,140,20,150,40,140)) as geom from dual union all
select 'CurvePolygon (CircularArc Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,2),sdo_ordinate_array (15,115,20,118,15,120,10,118,15,115)) as geom from dual union all
select 'CurvePolygon (Compound Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1005,2,1,2,1,7,2,2),sdo_ordinate_array (10,128,10,125,20,125,20,128,15,130,10,128)) as geom from dual union all
select 'GeometryCollection (1)' as test,sdo_geometry (2004,null,null,sdo_elem_info_array (1,1,1,3,2,1,7,1003,1),sdo_ordinate_array (10,5,10,10,20,10,10,105,15,105,20,110,10,110,10,105)) as geom from dual union all
select 'GeometryCollection (2)' as test,sdo_geometry(2004,NULL,NULL,sdo_elem_info_array(1,1003,3,5,1,1,9,2,1),sdo_ordinate_array(0,0,100,100,50,50,0,0,100,100.0)) as geom from dual union all
select 'LineString (1)' as test,sdo_geometry(2002,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,100,900,900.0)) as geom from dual union all
select 'LineString (2)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,25,20,30,25,25,30,30)) as geom from dual union all
select 'LineString (3)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,10,20,10)) as geom from dual union all
select 'LineString (Closed)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,55,15,55,20,60,10,60,10,55)) as geom from dual union all
select 'LineString (Self-Crossing)' as test,sdo_geometry (2002,null,null,sdo_elem_info_array (1,2,1),sdo_ordinate_array (10,85,20,90,20,85,10,90,10,85)) as geom from dual union all
select 'MultiCurve (1)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,2,7,2,2),sdo_ordinate_array (50,35,55,40,60,35,65,35,70,30,75,35)) as geom from dual union all
select 'MultiCurve (Touching)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,2,7,2,2),sdo_ordinate_array (50,65,50,70,55,68,55,68,60,65,60,70)) as geom from dual union all
select 'MultiLine (Closed)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,1,9,2,1),sdo_ordinate_array (50,55,50,60,55,58,50,55,56,58,60,55,60,60,56,58)) as geom from dual union all
select 'MultiLine (Crossing)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,1,5,2,1),sdo_ordinate_array (50,22,60,22,55,20,55,25)) as geom from dual union all
select 'MultiLine (Stoked)' as test,sdo_geometry (2006,null,null,sdo_elem_info_array (1,2,1,5,2,1),sdo_ordinate_array (50,15,55,15,60,15,65,15)) as geom from dual union all
select 'MultiPoint (2)' as test,sdo_geometry(2005,NULL,NULL,sdo_elem_info_array(1,1,2),sdo_ordinate_array(100,100,900,900.0)) as geom from dual union all
select 'MultiPoint (3)' as test,sdo_geometry (2005,null,null,sdo_elem_info_array (1,1,1,3,1,1,5,1,1),sdo_ordinate_array (65,5,70,7,75,5)) as geom from dual union all
select 'MultiPoint (4)' as test,sdo_geometry (2005,null,null,sdo_elem_info_array (1,1,3),sdo_ordinate_array (50,5,55,7,60,5)) as geom from dual union all
select 'MultiPolygon (Disjoint)' as test,sdo_geometry (2007,null,null,sdo_elem_info_array (1,1003,1,11,1003,3),sdo_ordinate_array (50,105,55,105,60,110,50,110,50,105,62,108,65,112)) as geom from dual union all
select 'MultiPolygon (Rectangles)' as test,sdo_geometry(2007,NULL,NULL,sdo_elem_info_array(1,1003,3,5,1003,3),sdo_ordinate_array(1500,100,1900,500,1900,500,2300,900.0)) as geom from dual union all
select 'Point (Ordinate Encoding)' as test,sdo_geometry (2001,null,null,sdo_elem_info_array (1,1,1),sdo_ordinate_array (10,5)) as geom from dual union all
select 'Point (SDO_POINT encoding)' as test,sdo_geometry(2001,NULL,sdo_point_type(900,900,NULL),NULL,NULL) as geom from dual union all
select 'Polygon (No Holes)' as test,sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3),sdo_ordinate_array(100,100,500,500.0)) as geom from dual union all
select 'Polygon (Stroked Exterior Ring)' as test,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)) as geom from dual union all
select 'Polygon (With Point and a Hole)' as test,sdo_geometry(2003,NULL,MDSYS.SDO_POINT_TYPE(1000,1000,NULL),sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(500,500,1500,1500,600,750,900,1050.0)) as geom from dual union all
select 'Polygon (With Void)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,3,5,2003,3),sdo_ordinate_array (50,135,60,140,51,136,59,139)) as geom from dual union all
select 'Rectangle (Exterior Ring)' as test,sdo_geometry (2003,null,null,sdo_elem_info_array (1,1003,3),sdo_ordinate_array (10,135,20,140)) as geom from dual union all
select 'Rectangle (With Rectangular Hole)' as test,sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(0,0,200,200,75,25,125,75.0)) as geom from dual
)
select a.test,
T_GEOMETRY(a.geom,0.0005,3,1)
.ST_Rectangle2Polygon()
.ST_AsEWKT() as geom
from data a
order by 1;

TEST                                     GEOM
---------------------------------------- -----------------------------------------------------------------------------------------------------------------------------
CircularString (1)                       CIRCULARSTRING (10 15, 15 20, 20 15.0)
CircularString (2)                       CIRCULARSTRING (10 35, 15 40, 20 35, 25 30, 30 35.0)
CircularString (Closed)                  CIRCULARSTRING (15 65, 10 68, 15 70, 20 68, 15 65.0)
CompoundCurve (1)                        COMPOUNDCURVE ((10 45, 20 45.0), CIRCULARSTRING (20 45, 23 48, 20 51.0), (20 51, 10 51.0))
CompoundCurve (2)                        COMPOUNDCURVE ((10 78, 10 75, 20 75, 20 78.0), CIRCULARSTRING (20 78, 15 80, 10 78.0))
CurvePolygon (Circle Exterior Ring)      CURVEPOLYGON ((15 140, 27.5 127.5, 40 140, 27.5 152.5, 15 140.0))
CurvePolygon (CircularArc Exterior Ring) CURVEPOLYGON (CIRCULARSTRING (15 115, 20 118, 15 120, 10 118, 15 115.0))
CurvePolygon (Compound Exterior Ring)    CURVEPOLYGON (COMPOUNDCURVE ((10 128, 10 125, 20 125, 20 128.0), CIRCULARSTRING (20 128, 15 130, 10 128.0)))
GeometryCollection (1)                   GEOMETRYCOLLECTION (POINT (10 5.0), LINESTRING (10 10, 20 10.0), POLYGON ((10 105, 15 105, 20 110, 10 110, 10 105.0)))
GeometryCollection (2)                   GEOMETRYCOLLECTION (POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0.0)), POINT (50 50.0), LINESTRING (100 100.0))
LineString (1)                           LINESTRING (100 100, 900 900.0)
LineString (2)                           LINESTRING (10 25, 20 30, 25 25, 30 30.0)
LineString (3)                           LINESTRING (10 10, 20 10.0)
LineString (Closed)                      LINESTRING (10 55, 15 55, 20 60, 10 60, 10 55.0)
LineString (Self-Crossing)               LINESTRING (10 85, 20 90, 20 85, 10 90, 10 85.0)
MultiCurve (1)                           MULTICURVE (CIRCULARSTRING (50 35, 55 40, 60 35.0), CIRCULARSTRING (65 35, 70 30, 75 35.0))
MultiCurve (Touching)                    MULTICURVE (CIRCULARSTRING (50 65, 50 70, 55 68.0), CIRCULARSTRING (55 68, 60 65, 60 70.0))
MultiLine (Closed)                       MULTILINESTRING ((50 55, 50 60, 55 58, 50 55.0), (56 58, 60 55, 60 60, 56 58.0))
MultiLine (Crossing)                     MULTILINESTRING ((50 22, 60 22.0), (55 20, 55 25.0))
MultiLine (Stoked)                       MULTILINESTRING ((50 15, 55 15.0), (60 15, 65 15.0))
MultiPoint (2)                           MULTIPOINT ((100 100.0), (900 900.0))
MultiPoint (3)                           MULTIPOINT ((65 5.0), (70 7.0), (75 5.0))
MultiPoint (4)                           MULTIPOINT ((50 5.0), (55 7.0), (60 5.0))
MultiPolygon (Disjoint)                  MULTIPOLYGON (((50 105, 55 105, 60 110, 50 110, 50 105.0)), ((62 108, 65 108, 65 112, 62 112, 62 108.0)))
MultiPolygon (Rectangles)                MULTIPOLYGON (((1500 100, 1900 100, 1900 500, 1500 500, 1500 100.0)), ((1900 500, 2300 500, 2300 900, 1900 900, 1900 500.0)))
Point (Ordinate Encoding)                POINT (10 5.0)
Point (SDO_POINT encoding)               POINT (900 900.0)
Polygon (No Holes)                       POLYGON ((100 100, 500 100, 500 500, 100 500, 100 100.0))
Polygon (Stroked Exterior Ring)          POLYGON ((10 105, 15 105, 20 110, 10 110, 10 105.0))
Polygon (With Point and a Hole)          POLYGON ((500 500, 1500 500, 1500 1500, 500 1500, 500 500.0), (900 750, 600 750, 600 1050, 900 1050, 900 750.0))
Polygon (With Void)                      POLYGON ((50 135, 60 135, 60 140, 50 140, 50 135.0), (59 136, 51 136, 51 139, 59 139, 59 136.0))
Rectangle (Exterior Ring)                POLYGON ((10 135, 20 135, 20 140, 10 140, 10 135.0))
Rectangle (With Rectangular Hole)        POLYGON ((0 0, 200 0, 200 200, 0 200, 0 0.0), (125 25, 75 25, 75 75, 125 75, 125 25.0))

33 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.16. T_GEOMETRY/ST_Boundary [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Boundary -- Returns All Outer Rings of a polygon or multipolygon as a single linestring/multilinestring.
```

SYNOPSIS

```    Member Function ST_Boundary()
Return T_GEOMETRY Deterministic,
```

DESCRIPTION

```    This function extracts all the exterior (outer) rings of a polygon/multipolygon and returns them in a T_GEOMETRY object as a linestring.
```

NOTES

```    Is an implementation of OGC ST_Boundary method.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_Boundary().ST_AsText() as Boundary
from data a;

BOUNDARY
----------------------------------------------------------------------------------------------
MULTILINESTRING ((0 0, 20 0, 20 20, 0 20, 0 0), (100 100, 200 100, 200 200, 100 200, 100 100))
```

RESULT

```    Exterior ring(s) (T_GEOMETRY) -- For example, if a single Polygon with 1 exterior and 1 interior ring is provided, then a single polygon with a single exterior ring is returned.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Aug 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.17. T_GEOMETRY/ST_Buffer [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Buffer -- Creates a buffer around input geometry.
```

SYNOPSIS

```    Member Function ST_Buffer(p_distance in number,
p_unit     in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function creates a square buffer around all linestrings in an object.
A negative buffer is not possible.
```

ARGUMENTS

```    p_distance (Number)   - Value > 0.0
p_unit     (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    polygon (T_GEOMETRY) - Result of buffering input geometry.
```

NOTES

```    Uses MDSYS.SDO_GEOM.SDO_BUFFER if Oracle database version is 12c or above,
or if the customer is licensed for the Spatial object before 12c.
```

ERRORS

```    Will throw exception if the user is not licensed to call MDSYS.SDO_GEOM.SDO_BUFFER.
-20102  MDSYS.SDO_GEOM.SDO_BUFFER only supported for Locator users from 12c onwards.';
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.18. T_GEOMETRY/ST_Centroid_A [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Centroid_A -- Creates a centroid for a polygon mdsys.sdo_geometry object.
```

SYNOPSIS

```    Member Function ST_Centroid_A(
P_method     In Integer Default 1,
P_Seed_Value In Number  Default Null,
p_loops      in integer Default 10)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function creates a single centroid if a single polygon.
The position of the centroid is computed in the longest segment defined by a constant X or Y ordinate.
There are a number of options for computing a centroid controlled by p_method; these are described
in the ARGUMENTS section of this document.
```

ARGUMENTS

```    p_method     (integer) --  0 = Use average of all Area's X Ordinates for starting centroid Calculation
10 = Use average of all Area's Y Ordinates for starting centroid Calculation
1 = Use centre X Ordinate of geometry MBR
11 = Use centre Y Ordinate of geometry MBR
2 = User supplied starting seed X ordinate value
12 = User supplied starting seed Y ordinate value
3 = Use MDSYS.SDO_GEOM.SDO_CENTROID function
4 = Use MDSYS.SDO_GEOM.SDO_POINTONSURFACE function.
p_seed_value (number) -- Starting ordinate X/Y for which a Y/X that is inside the polygon is returned.
p_loops     (integer) -- In the rare case that the first pass calculation of a centroid fails (not p_method 3 or 4)
if p_loops is > 0 then the p_seed_value is adjusted by SELF.tolerance and another attempt it made.
When the number of loops is exhausted NULL is returned (very rare).
```

RESULT

```    point (T_GEOMETRY) - Centroid of input object.
```

EXAMPLE

```    -- Process ALL options in one.
With data as (
select T_GEOMETRY(
sdo_geometry(
'POLYGON((2300 -700, 2800 -300, 2300 700, 2800 1100, 2300 1100,
1800 1100, 2300 800, 2000 600, 2300 600, 2300 500, 2400 400,
2300 400, 2300 300, 2300 200, 2500 150, 2100 100, 2500 100,
2300 -200, 1800 -300, 2300 -500, 2200 -400, 2400 -400, 2300 -700),
(2300 1000, 2400 900, 2200 900, 2300 1000),
(2400 -400, 2450 -300, 2550 -400, 2400 -400),
(2300 1000, 2400 1050, 2400 1000, 2300 1000))',null),
0.005,2,1) as tgeom
from dual
)
select t.IntValue as method_id,
case t.IntValue
when  0 then 'Avg of Area''s X Ordinates as Centroid Seed'
when 10 then 'Avg of Area''s Y Ordinates as Centroid Seed'
when  1 then 'Centre X Ordinate of geom MBR as seed'
when 11 then 'Centre Y Ordinate of geom MBR as seed'
when  2 then 'User X ordinate'
when 12 then 'User Y ordinate'
when  3 then 'MDSYS.SDO_GEOM.SDO_CENTROID'
when  4 then 'MDSYS.SDO_GEOM.SDO_PointOnSurface'
end as Method_Text,
a.tGeom.ST_Centroid_A(
p_method     => t.IntValue,
P_Seed_Value => case t.IntValue when 2 then X eg 2035.4 when 12 then Y eg 284.6 else NULL end,
p_loops      => 5
).ST_AsText() as centroid
from data a,
table(TOOLS.generate_series(0,12,1)) t
where t.IntValue in (0, 1, 2, 3, 4, 10, 11, 12)
order by 2 asc;

METHOD_ID METHOD_TEXT                                CENTROID
---------- ------------------------------------------ --------------------------------------------------------------------------------
0 Avg of Area's X Ordinates as Centroid Seed POINT (2322.86 -282.855)
10 Avg of Area's Y Ordinates as Centroid Seed POINT (2396.43 314.29)
1 Centre X Ordinate of geom MBR as seed      POINT (2300.0 -300.0)
11 Centre Y Ordinate of geom MBR as seed      POINT (2425.0 200.0)
3 MDSYS.SDO_GEOM.SDO_CENTROID                POINT (2377.12121212121 234.772727272727)
4 MDSYS.SDO_GEOM.SDO_PointOnSurface          POINT (2300.0 -700.0)
2 User X ordinate                            POINT (2035.4 -323.54)
12 User Y ordinate                            POINT (2403.85 284.6)

8 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2006 - Original coding.
Simon Greener - January 2012 - Added p_seed_x support.
Simon Greener - August  2018 - Added to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.19. T_GEOMETRY/ST_Centroid_L [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Centroid_L -- Creates a centroid for a linestring mdsys.sdo_geometry object.
```

SYNOPSIS

```    Member Function ST_Centroid_L(p_option in varchar2 := 'LARGEST',
p_unit   in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function creates a single centroid if the line-string being operated on
has a single part. The position of the centroid is either the mid-length point
if the line is not measured, or the mid-measure position if measured. For a single
line-string any supplied p_option value is ignored.
If the geometry is a multi-linestring a number of options are available.
- LARGEST  -- Returns centroid of largest (measure/length) line-string in multi-linestring (DEFAULT)
- SMALLEST -- Returns centroid of smallest (measure/length) line-string in multi-linestring
- MULTI    -- Returns all centroid for all parts of multi-linestring as a single multi-point (x005 gtype) geometry.
The centroid of each part is constructed using the same rules as for a single line-string.
```

ARGUMENTS

```    p_option (VarChar2) - LARGEST, SMALLEST, or MULTI. Ignored if single linestring.
p_unit   (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    point (T_GEOMETRY) - Centroid of input object.
```

EXAMPLE

```    -- Largest
-- Smallest
-- Multi
```

AUTHOR

```    Simon Greener
Simon Greener - January 2006 - Original coding.
Simon Greener - January 2012 - Added p_seed_x support.
Simon Greener - August  2018 - Added to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.20. T_GEOMETRY/ST_Centroid_P [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Centroid_P -- Creates a centroid for a multipoint object.
```

SYNOPSIS

```    Member Function ST_Centroid_P
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function creates a single centroid from the underlying MultiPoint geometry.
If the underlying geometry is a point, it is returned.
If the underlying geometry is not a point or multipoint an exception is thrown.
The centroid is returned with the XY ordinates rounded to SELF.dPrecision.
Measured (4x05) objects are not supported.
```

RESULT

```    point (T_GEOMETRY) - Centroid of input object.
```

EXAMPLE

```    -- Single point is returned as it is.
select T_Geometry(sdo_geometry('POINT(45 45)',null),0.005,2,1)
.ST_Centroid_P()
.ST_AsText() as cPoint
from dual;

CPOINT
--------------------------------------------------------------------------------
POINT (45.0 45.0)

-- Points around 0,0, which should return 0.0!
select T_Geometry(sdo_geometry('MULTIPOINT((45 45),(-45 45),(-45 -45),(45 -45))',null),0.005,2,1)
.ST_Centroid_P()
.ST_AsText() as cPoint
from dual;

CPOINT
---------------
POINT (0.0 0.0)

-- 3D MultiPoint
select T_Geometry(
mdsys.sdo_geometry(3005,null,null,mdsys.sdo_elem_info_array(1,1,3),mdsys.sdo_ordinate_array(1.1,2.0,-0.8, 3.3,4.2,-0.95, 5.5,6.8,1.04)),
0.005,2,1)
.ST_Centroid_P()
.ST_Round(2,2,3)
.geom as cPoint
from dual;

CPOINT
----------------------------------------------------------------
SDO_GEOMETRY(3001,NULLSDO_POINT_TYPE(3.3,4.33,-0.237),NULL,NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2006 - Original coding.
Simon Greener - January 2012 - Added p_seed_x support.
Simon Greener - August  2018 - Added to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.21. T_GEOMETRY/ST_Cogo2Line [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```   ST_Cogo2Line - Creates linestring from supplied bearing and distance instructions.
```

SYNOPSIS

```    Member Function ST_Cogo2Line(p_bearings_and_distances in &&INSTALL_SCHEMA..T_BEARING_DISTANCES)
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    This function takes a set of bearings and distances supplied using array of t_bearing_and_distance instructions, and creates a linestring from it.
The underlying geometry must be a single start point.
The final geometry's XY ordinates are not rounded.
```

ARGUMENTS

```    p_bearings_and_distances (t_bearings_distances) - Array of T_BEARING_DISTANCE instructions.
```

RESULT

```    linestring (t_geometry) - New linestring geometry object.
NOTE
Measures not supported: see LRS functions.
```

TODO

```    Create Static version where all instructions are provided including start point.
```

EXAMPLE

```    -- Build 2D Line from default constructor
select F.line.ST_Validate() as vLine,
f.line.geom          as line,
round(f.line.ST_Length(),2) as meters
from (select t_geometry(sdo_geometry(2001,null,sdo_point_type(0.0,3.5,null),null,null),0.005,2,1)
.ST_Cogo2Line (
t_bearing_distances(
t_bearing_distance(180.00,3.50,null),
t_bearing_distance( 90.00,3.50,null),
t_bearing_distance(  0.00,3.50,null),
t_bearing_distance( 43.02,5.43,null),
t_bearing_distance(270.00,9.50,null)
)
)
.ST_Round(8,8) as line
from dual
) f;

VLINE LINE                                                                                                                                                        METERS
----- ----------------------------------------------------------------------------------------------------------------------------------------------------------- ------
TRUE  SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.0,3.5, 0.0,0.0, 3.5,0.0, 3.5,3.5, 7.2046371,7.46995768, -2.2953629,7.46995768))  25.43

-- Build 3D line by decimal degrees using default constructor
select F.line.ST_Validate()        as vLine,
f.line.geom                 as line,
round(f.line.ST_Length(),2) as meters
from (select T_Geometry(sdo_geometry(3001,null,sdo_point_type(0,3.5,0),null,null),0.005,2,1)
.ST_Cogo2Line(
p_bearings_and_distances=>
t_bearing_distances(
t_bearing_distance(180,  3.5, 0.1),
t_bearing_distance(90,   3.5, 0.5),
t_bearing_distance(0,    3.5, 1.6),
t_bearing_distance(43.02,5.43,2.123),
t_bearing_distance(270,  9.5, 0.5)
)
)
.ST_Round(8,8) as line
from dual
) f;

VLINE LINE                                                                                                                                                                                  METERS
----- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------
TRUE  SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.0,3.5,0.0, 0.0,0.0,0.1, 3.5,0.0,0.5, 3.5,3.5,1.6, 7.2046371,7.46995768,2.123, -2.2953629,7.46995768,0.5))  25.79

-- Line by degrees using text constructor
select F.line.ST_Validate()        as vLine,
f.line.geom                 as line,
round(f.line.ST_Length(),2) as meters
from (select T_Geometry(sdo_geometry(3001,null,sdo_point_type(0,3.5,0),null,null),0.005,2,1)
.ST_Cogo2Line(
p_bearings_and_distances=>
t_bearing_distances(
t_bearing_distance(p_sDegMinSec=>'180',         p_distance=>3.5,  p_z=>0.1),
t_bearing_distance(p_sDegMinSec=>'90',          p_distance=>3.5,  p_z=>0.5),
t_bearing_distance(p_sDegMinSec=>'0',           p_distance=>3.5,  p_z=>1.6),
t_bearing_distance(p_sDegMinSec=>'43^01''21"',  p_distance=>5.43, p_z=>2.0),
t_bearing_distance(p_sDegMinSec=>'270',         p_distance=>9.5,  p_z=>0.5),
t_bearing_distance(p_sDegMinSec=>'149^58''6.3"',p_distance=>4.613,p_z=>0.1))
)
.ST_Round(8,8) as line
from dual
) f;

VLINE LINE                                                                                                                                                                                                             METERS
----- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------
TRUE  SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.0,3.5,0.0, 0.0,0.0,0.1, 3.5,0.0,0.5, 3.5,3.5,1.6, 7.20481032,7.46979603,2.0, -2.29518968,7.46979603,0.5, 0.01351213,3.47609287,0.1))  30.39

-- Build 3D line using mixed constructors
select F.line.ST_Validate()        as vLine,
f.line.geom                 as line,
round(f.line.ST_Length(),2) as Meters
from (select T_Geometry(sdo_geometry(3001,null,sdo_point_type(0,3.5,0),null,null),0.005,2,1)
.ST_Cogo2Line(
p_bearings_and_distances=>
t_bearing_distances(
t_bearing_distance(              180.0,                     3.5,       0.1),  -- << Default Constructor
t_bearing_distance(p_sDegMinSec=>'90',          p_distance=>3.5,  p_z=>0.5),
t_bearing_distance(              0.0,                       3.5,       1.6),  -- << Default Constructor
t_bearing_distance(p_sDegMinSec=>'43^01''21"',  p_distance=>5.43, p_z=>2.0),
t_bearing_distance(p_sDegMinSec=>'270',         p_distance=>9.5,  p_z=>0.5),
t_bearing_distance(p_sDegMinSec=>'149^58''6.3"',p_distance=>4.613,p_z=>0.1))
)
.ST_Round(8,8) as line
from dual
) f;

VLINE LINE                                                                                                                                                                                                             METERS
----- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------
TRUE  SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.0,3.5,0.0, 0.0,0.0,0.1, 3.5,0.0,0.5, 3.5,3.5,1.6, 7.20481032,7.46979603,2.0, -2.29518968,7.46979603,0.5, 0.01351213,3.47609287,0.1))  30.39
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.22. T_GEOMETRY/ST_Cogo2Polygon [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```   ST_Cogo2Polygon - Creates single polygon exterior ring from supplied bearing and distance instructions.
```

SYNOPSIS

```    Member Function ST_Cogo2Polygon(p_bearings_and_distances in &&INSTALL_SCHEMA..T_BEARING_DISTANCES)
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    This function takes a set of bearings and distances supplied using array of t_bearing_and_distance instructions, and creates a closed exterior ring from it.
The underlying geometry must be a single start point.
The final geometry will have its XY ordinates rounded to SELF.dPrecision.
Z ordinates are not rounded as they are provided (as is) in the t_bearing_distance.z values.
```

ARGUMENTS

```    p_bearings_and_distances (t_bearings_distances) - Array of T_BEARING_DISTANCE instructions.
```

RESULT

```    polygon (t_geometry) - New polygon object with a single exterior ring.
NOTE
Measured polygons not supported.
```

TODO

```    Create Static version where all instructions are provided including start point.
```

EXAMPLE

```    -- Polygon built from default constructor...
select F.poly.ST_Validate()      as vPoly,
f.poly.ST_AsText()        as pWKT,
round(f.Poly.ST_Area(),2) as sqM
from (select t_geometry(sdo_geometry(2001,null,sdo_point_type(0,3.5,null),null,null),0.005,2,1)
.ST_Cogo2Polygon(
t_bearing_distances(
t_bearing_distance(180,3.5,null),
t_bearing_distance(90,3.5,null),
t_bearing_distance(0,3.5,null),
t_bearing_distance(43.02,5.43,null),
t_bearing_distance(270,9.5,null))
)
.ST_Round(3,3) as poly
from dual
) f;

VPOLY PWKT                                                                               SQM
----- -------------------------------------------------------------------------------- -----
TRUE  POLYGON ((0.0 3.5, 0.0 0.0, 3.5 0.0, 3.5 3.5, 7.205 7.47, -2.295 7.47, 0.0 3.5)) 38.06

-- Different way of building directions.
-- Simple bearing/distance constructors used
With data as (
select CAST(MULTISET(
Select bd
from (select 1 as rin, t_bearing_distance(180.0,3.5) as bd                      from dual union all
select 2,        t_bearing_distance( 90.0,3.5)                            from dual union all
select 3,        t_bearing_distance(  0.0,3.5)                            from dual union all
select 4,        t_bearing_distance(43.02,round(sqrt(4.5*4.5+2.2*4.2),2)) from dual union all
select 5,        t_bearing_distance(270.0,(4.5+3.4+1.6))                  from dual )
order by rin
) as t_bearing_distances ) as directions
from dual
)
select F.poly.ST_Validate()      as vPoly,
f.poly.ST_AsText()        as pWKT,
round(f.Poly.ST_Area(),2) as sqM
from (select t_geometry(sdo_geometry(2001,null,sdo_point_type(0,3.5,null),null,null),0.005,2,1)
.ST_Cogo2Polygon (
p_bearings_and_distances=>a.directions
)
.ST_Round(3,3) as poly
from data a
) f;

VPOLY PWKT                                                                               SQM
----- -------------------------------------------------------------------------------- -----
TRUE  POLYGON ((0.0 3.5, 0.0 0.0, 3.5 0.0, 3.5 3.5, 7.205 7.47, -2.295 7.47, 0.0 3.5)) 38.06

-- Mixed Constructors with Z for 3D Polygon...
select F.poly.ST_Validate()      as vPoly,
f.poly.geom               as polygon,
round(f.Poly.ST_Area(),2) as sqM
from (select t_geometry(sdo_geometry(3001,null,sdo_point_type(0,3.5,10.0),null,null),0.005,2,1)
.ST_Cogo2Polygon (
t_bearing_distances(
t_bearing_distance(180,3.5,11.1),
t_bearing_distance(p_sDegMinSec=>'90^0''0"',p_distance=>3.5,p_z=>12.2),
t_bearing_distance(0.0,3.5,13.3),
t_bearing_distance(p_sDegMinSec=>'43^01''12"',p_distance=>5.43,p_z=>14.4),
t_bearing_distance(270.0,9.5,13.3)
)
)
.ST_Round(3,3) as poly
from dual
) f;

VPOLY POLYGON                                                                                                                                                                                  SQM
----- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----
TRUE  SDO_GEOMETRY(3003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0.0,3.5,10.0, 0.0,0.0,11.1, 3.5,0.0,12.2, 3.5,3.5,13.3, 7.205,7.47,14.4, -2.295,7.47,13.3, 0.0,3.5,10.0)) 43.37
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.23. T_GEOMETRY/ST_Compress [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```   ST_Compress - Turns coordinate array of linestring/polygon into equivalent to MoveTo and LineTo components.
```

SYNOPSIS

```    Member Function ST_Decompress(p_delta_factor in number default 1,
p_origin       in &&INSTALL_SCHEMA..T_Vertex default null )
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    Starting point as abolute value is kept if p_origin is null.
p_origin could contain lower left ordinate of the MBR of the geometry.
Extracts pairs of adjacent vertices, substracts their ordinates and applies delta factor.
p_delta_factor is scalar applied to difference between two vertices in a linestring.
EG:
* 1.0 leaves delta XY alone
* 0.5 divides each delta x and y by 2
* 0.1 divides each delta x and y by 10
No rounding occurs as full precision is needed for ST_Decompress.
```

ARGUMENTS

```    p_delta_factor (number)   -- Coordinate delta multiplying factor.
p_origin       (t_vertex) -- Contains starting point for decompressing geometry cf MoveTo in SVG.
```

RESULT

```    Compressed Linestring (t_geometry) - New polygon/linestring object with coordinates compressed.
```

EXAMPLE

```    -- ST_Compress
With data As (
select 0.1 as delta_factor,
t_geometry(Sdo_Geometry(2002,2154,Null,
Sdo_Elem_Info_Array(1,2,1),
Sdo_Ordinate_Array(210124.235,6860562.134, 189291.0,6855606.0, 185644.0,6870204.0, 130465.0,6856274.0, 124851.0,6831829.0, 162802.0,6840716.0, 148600.0,6829212.0, 162326.0,6831137.0)),
0.005,2,1) as original,
t_vertex(
p_x=>210124.235,
p_y=>6860562.134,
p_id=>0,
p_sdo_gtype=>2001,
p_sdo_srid=>2154
) as origin
from dual
)
Select DBMS_LOB.GetLength(f.original.ST_AsText()  ) as originalSize,
DBMS_LOB.GetLength(f.compressed.ST_AsText()) as compressedSize,
f.compressed.ST_AsText()                     as compressed
From (Select a.original
.ST_Compress(
p_delta_factor => a.delta_factor,
P_origin       => a.origin
) As compressed,
a.original,
a.delta_factor,
a.origin
From data a
) f;

ORIGINALSIZE COMPRESSEDSIZE COMPRESSED
------------ -------------- ---------------------------------------------------------------------------------------------------------------------------------------
175            135 LINESTRING (0.0 0.0, -2083.3235 -495.6134, -364.7 1459.8, -5517.9 -1393.0, -561.4 -2444.5, 3795.1 888.7, -1420.2 -1150.4, 1372.6 192.5)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.24. T_GEOMETRY/ST_Concat_Line [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Concat_Line -- Adds supplied linestring to start/end of underlying linestring depending on geometric relationship.
```

DESCRIPTION

```   Joins two linestrings together depending on start/end relationships of the supplied
linestring and the underlying linestring.
Does not support point or polygon geometries.
```

ARGUMENTS

```    p_line (SDO_GEOMETRY) - Geometry to be added to underlying mdsys.sdo_geometry.
```

RESULT

```    linestring (T_GEOMETRY) - Line that is the result of concatenating the two linestrings.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

15.25. T_GEOMETRY/ST_CoordDimension [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_CoordDimension -- Returns Coordinate Dimension of mdsys.sdo_geometry object.
```

SYNOPSIS

```    Member Function ST_CoordDimension
Return Integer Deterministic,
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('POINT(0 0)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3001,NULL,SDO_POINT_TYPE(0,0,0),null,null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('MULTILINESTRING((-1 -1, 0 -1),(0 0,10 0,10 5,10 10,5 10,5 5))',null),0.005,3,1) as tgeom From Dual union all
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GeometryType()   as geomType,
a.tGeom.ST_GType()          as sdo_gtype,
a.tGeom.ST_CoordDimension() as coordDim,
a.tgeom.ST_Dimension()      as geomDim
from data a;

GEOMTYPE             SDO_GTYPE   COORDDIM    GEOMDIM
------------------- ---------- ---------- ----------
ST_POINT                     1          2          0
ST_POINT                     1          3          0
ST_LINESTRING                2          2          1
ST_LINESTRING                2          3          1
ST_MULTILINESTRING           6          2          1
ST_POLYGON                   3          2          2
ST_MULTIPOLYGON              7          2          2

7 rows selected
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry method SELF.GEOM.ST_CoordDimen().
Returns Coordinate Dimension of mdsys.sdo_geometry object.
```

RESULT

```    Coordinate Dimension (SMALLINT) -- 2 if 2001; 3 is 3001 etc.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.26. T_GEOMETRY/ST_Decompress [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```   ST_Decompress - Reverse Compress applied by ST_Compress with same p_factor_applied and p_origin.
```

SYNOPSIS

```    Member Function ST_Decompress(p_delta_factor in number default 1)
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    Starting point as abolute value is kept if p_origin is null.
p_origin could contain lower left ordinate of the MBR of the geometry.
Extracts pairs of adjacent vertex deltas, applies inverse delta factor to each, and creates new point.
p_delta_factor is scalar applied to difference between two vertices in a linestring.
Must be same p_delta_factor applied to original ST_Compress:
* 1.0 leaves delta XY alone
* 0.5 divides each delta x and y by 2
* 0.1 divides each delta x and y by 10
```

ARGUMENTS

```    p_delta_factor (number)   -- Coordinate delta multiplying factor.
p_origin       (t_vertex) -- Contains starting point for decompressing geometry cf MoveTo in SVG.
```

RESULT

```    Decompressed Linestring (t_geometry) - New polygon/linestring object with coordinates compressed.
```

EXAMPLE

```    -- ST_Decompress
With data As (
select 0.1 as delta_factor,
t_geometry(Sdo_Geometry(2002,2154,Null,
Sdo_Elem_Info_Array(1,2,1),
Sdo_Ordinate_Array(210124.235,6860562.134, 189291.0,6855606.0, 185644.0,6870204.0, 130465.0,6856274.0, 124851.0,6831829.0, 162802.0,6840716.0, 148600.0,6829212.0, 162326.0,6831137.0)),
0.005,2,1) as original,
t_vertex(
p_x=>210124.235,
p_y=>6860562.134,
p_id=>0,
p_sdo_gtype=>2001,
p_sdo_srid=>2154
) as origin
from dual
)
Select DBMS_LOB.GetLength(f.original.ST_AsText()  ) as originalSize,
DBMS_LOB.GetLength(f.compressed.ST_AsText()) as compressedSize,
f.compressed
.ST_Decompress(
p_delta_factor => f.delta_factor,
P_origin       => f.origin
).ST_Equals(
p_geometry    => f.original.geom,
p_z_precision => null,
p_m_precision => null
) as before_after_equals,
f.compressed.ST_AsText() as compressed
From (Select a.original
.ST_Compress(
p_delta_factor => a.delta_factor,
P_origin       => a.origin
) As compressed,
a.original,
a.delta_factor,
a.origin
From data a
) f;

ORIGINALSIZE COMPRESSEDSIZE BEFORE_AFTER_EQUALS COMPRESSED
------------ -------------- ------------------- --------------------------------------------------------------------------------------------------------------------------------------
175            135               EQUAL LINESTRING (0.0 0.0, -2083.3235 -495.6134, -364.7 1459.8, -5517.9 -1393.0, -561.4 -2444.5, 3795.1 888.7, -1420.2 -1150.4, 1372.6 192.5)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.27. T_GEOMETRY/ST_DeleteVertex [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_DeleteVertex -- Function which deletes the coordinate at position p_vertex_id from the underlying geometry.
```

SYNOPSIS

```   Member Function ST_DeleteVertex (p_vertex_id in integer)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Function that deletes the coordinate at position p_vertex_id in the underlying geometry.
p_verted_id Values:
1. null -> defaults to -1;
2. -1   -> maximum number of points ie ST_NumPoints()
3. Greater than ST_NumPoints() -> maximum number of points ie ST_NumPoints(p_geometry)
```

ARGUMENTS

```    p_vertex_id (integer) - Coordinate to be deleted.
```

RESULT

```    updated geom (geometry) - Geometry with coordinate deleted.
```

EXAMPLE

```    select t_geometry(
sdo_geometry('LINESTRING(0 0,1 1,2 2)',NULL),0.005,2,1
).ST_DeleteVertex(
p_vertex_id => 2
).ST_AsText() as updatedGeom
from dual;

UPDATEDGEOM
-------------------
LINESTRING(0 0,1 1)
```

ERRORS

```    Can throw one of the following exceptions:
1. ORA-20122: Deletion of vertex within an existing circular arc not allowed.
2. ORA-20123: Deletion vertex position is invalid.
3. ORA-20124: Vertex delete invalidated geometry, with reason of: <Reason>
Exception ORA-20124 will include result from SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM package.
Simon Greener - July 2011     - Port to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.28. T_GEOMETRY/ST_Densify [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Densify -- Implements a basic geometry densification algorithm.
```

SYNOPSIS

```    Member Function ST_Densify(p_distance In Number,
p_unit     In Varchar2 Default NULL)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function add vertices to an existing vertex-to-vertex described (m)linestring or (m)polygon sdo_geometry.
New vertices are added in such a way as to maintain existing vertices.
That is, no existing vertices are removed.
Densification occurs on a single vertex-to-vertex segment basis.
If segment length is < p_distance no vertices are added.
No vertex is ever added such that the distance to the next vertex is < SELF.tolerance.
The implementation does not guarantee that the added vertices will be exactly p_distance apart.
The final vertex separation will be BETWEEN p_distance AND p_distance * 2 .

The implementation honours 3D and 4D shapes and averages these dimension values
for the new vertices.

The function does not support compound objects or objects with circles,
optimised rectangles or described by arcs.

Any non (m)polygon/(m)linestring shape is simply returned as it is.
```

ARGUMENTS

```    p_distance (Number) -- The desired optimal distance between added vertices. Must be > SELF.tolerance.
p_unit   (varchar2) -- Unit of measure associated with p_distance and for calculations.
```

RESULT

```    geometry (T_GEOMETRY) -- Densified geometry.
```

EXAMPLE

```     -- Simple Straight line.
select t_geometry(
sdo_geometry(2002,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(100,100,900,900.0)),
0.005,2,1)
.ST_Densify(p_distance=>125.0,
p_unit=>null)
.ST_Round(3,3,2,1)
.geom as geom
from dual;

GEOM
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(188.889,188.889,277.778,277.778,366.667,366.667,455.556,455.556,544.444,544.444,633.333,633.333,722.222,722.222,811.111,811.111))

-- Simple Linestring with Z
select t_geometry(
sdo_geometry(3002,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(100,100,1.0, 900,900.0,9.0)),
0.005,2,1)
.ST_Densify(p_distance=>125.0,
p_unit=>null)
.ST_Round(3,3,2,1)
.geom as geom
from dual;

GEOM
-------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(100,100,1,188.889,188.889,1.89,277.778,277.778,2.78,366.667,366.667,3.67,455.556,455.556,4.56,
544.444,544.444,5.44,633.333,633.333,6.33,722.222,722.222,7.22,811.111,811.111,8.11,900,900,9))

-- Simple LineString with Z and Measures
select t_geometry(
sdo_geometry(4402,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(100,100,  -4.56,   0.99,
900,900.0,-6.73,1131.2)),
0.005,2,1)
.ST_Densify(p_distance=>125.0,
p_unit=>null)
.ST_Round(3,3,2,2)
.geom as geom
from dual;

GEOM
----------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(4402,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(100.0,100.0,-4.56,0.99, 166.667,166.667,-4.74,95.17, 233.333,233.333,-4.92,189.36, 300.0,300.0,-5.1,283.54,
366.667,366.667,-5.28,377.73, 433.333,433.333,-5.46,471.91, 500.0,500.0,-5.65,566.1, 566.667,566.667,-5.83,660.28,
633.333,633.333,-6.01,754.46, 700.0,700.0,-6.19,848.65, 766.667,766.667,-6.37,942.83, 833.333,833.333,-6.55,1037.02,
900.0,900.0,-6.73,1131.2))

with data as (
select t_geometry(
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
1100.765,964.286, 1161.99,739.796, 963.01,596.939, 677.296,775.51,
460.459,880.102, 253.827,793.367, 174.745,630.102, 228.316,497.449,
455.357,528.061, 718.112,446.429, 713.01,290.816, 598.214,125.0,
373.724,81.633, 67.602,267.857)),
0.05,2,1)
as "Original Geometry"
from dual
)
select a."Original Geometry".ST_Densify(p_distance=>25.0).ST_Round(2).geom as "Densified Geometry" from data a;

Densified Geometry
--------------------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(1100.77,964.29,1107.57,939.34,1114.37,914.4,1121.17,889.46,1127.98,864.51,
1134.78,839.57,1141.58,814.63,1148.38,789.68,1155.19,764.74,1161.99,739.8,1139.88,723.92,1117.77,708.05,1095.66,692.18,1073.55,676.3
1051.45,660.43,1029.34,644.56,1007.23,628.69,985.12,612.81,963.01,596.94,941.03,610.68,919.05,624.41,897.08,638.15,875.1,651.88,853.12,
665.62,831.14,679.36,809.16,693.09,787.19,706.83,765.21,720.57,743.23,734.3,721.25,748.04,699.27,761.77,677.3,775.51,653.2,787.13,629.11,
798.75,605.02,810.37,580.92,822,556.83,833.62,532.74,845.24,508.65,856.86,484.55,868.48,460.46,880.1,434.63,869.26,408.8,858.42,382.97,
847.58,357.14,836.73,331.31,825.89,305.49,815.05,279.66,804.21,253.83,793.37,242.53,770.04,231.23,746.72,219.93,723.4,208.64,700.07,197.34,
676.75,186.04,653.43,174.75,630.1,185.46,603.57,196.17,577.04,206.89,550.51,217.6,523.98,228.32,497.45,253.54,500.85,278.77,504.25,304,507.65,
329.22,511.05,354.45,514.46,379.68,517.86,404.9,521.26,430.13,524.66,455.36,528.06,479.24,520.64,503.13,513.22,527.02,505.8,550.9,498.38,574.79,
490.96,598.68,483.53,622.56,476.11,646.45,468.69,670.34,461.27,694.23,453.85,718.11,446.43,717.26,420.49,716.41,394.56,715.56,368.62,714.71,
342.69,713.86,316.75,713.01,290.82,698.66,270.09,684.31,249.36,669.96,228.64,655.61,207.91,641.26,187.18,626.91,166.45,612.56,145.73,598.21,125,
573.27,120.18,548.33,115.36,523.38,110.54,498.44,105.73,473.5,100.91,448.55,96.09,423.61,91.27,398.67,86.45,373.72,81.63,351.86,94.93,329.99,
108.24,308.13,121.54,286.26,134.84,264.39,148.14,242.53,161.44,220.66,174.75,198.8,188.05,176.93,201.35,155.07,214.65,133.2,227.95,111.33,241.25,
89.47,254.56,67.6,267.86))
```

NOTES

```    Only supports stroked (m)linestrings and (m)polygon rings.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June   2006 - Original coding in GEOM package.
Simon Greener - August 2018 - Port/Rewrite to T_GEOMETRY object function member.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.29. T_GEOMETRY/ST_Difference [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Difference -- Returns the spatial difference between two sdo_geometry objects.
```

SYNOPSIS

```    Member Function ST_Difference(p_geometry in mdsys.sdo_geometry,
p_order    in varchar2 Default 'FIRST')
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function determines the difference between two linestrings, polygons or a mix of either.
The p_order parameter determines whether SELF.geom is the first argument to sdo_difference or second.
```

ARGUMENTS

```    p_geometry (sdo_geometry) -- A linestring or polygon.
p_order        (varchar2) -- Should be FIRST or SECOND.
```

RESULT

```    geometry (T_GEOMETRY) -- Result of differencing the geometries.
```

NOTES

```    Uses MDSYS.SDO_GEOM.SDO_DIFFERENCE if Oracle database version is 12cR1 or above
or if the customer is licensed for the Spatial object before 12c.
```

ERRORS

```    Will throw exception if the user is not licensed to call MDSYS.SDO_GEOM.SDO_DIFFERENCE.
-20102  MDSYS.SDO_GEOM.SDO_DIFFERENCE only supported for Locator users from 12c onwards.';
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.30. T_GEOMETRY/ST_Dimension [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Dimension -- Returns spatial dimension of underlying geometry.
```

SYNOPSIS

```    Member Function ST_Dimension
Return Integer Deterministic,
```

NOTES

```    Is an implementation of OGC ST_Dimension method.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('POINT(0 0)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('MULTILINESTRING((-1 -1, 0 -1),(0 0,10 0,10 5,10 10,5 10,5 5))',null),0.005,3,1) as tgeom From Dual union all
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom From Dual union all
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom From Dual
)
select a.tGeom.ST_GType()        as sdo_gtype,
a.tgeom.ST_GeometryType() as geomType,
a.tgeom.ST_Dimension()    as geomDim
from data a;

SDO_GTYPE GEOMTYPE             GEOMDIM
--------- -------------------- -------
1 ST_POINT                   0
2 ST_LINESTRING              1
6 ST_MULTILINESTRING         1
3 ST_POLYGON                 2
7 ST_MULTIPOLYGON            2
7 ST_MULTIPOLYGON            2

6 rows selected
```

DESCRIPTION

```    Is OGC method that returns the geometric dimension of the underlying geometry.
The dimensions returned are:
GeometryType Dimension
------------ ---------
Point         0
LineString         1
Polygon         2
OGC Dimension is not to be confused with coordinate dimension ie number of ordinates. See ST_CoordDimension.
```

RESULT

```    Dimension (Integer) -- 0 if 2001/3 if 3001; 1 if 2002/3302/3002; 2 if 2003/2007/3003/3007 etc.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.31. T_GEOMETRY/ST_DimInfo2Rectangle [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_DimInfo2Rectangle -- Converts diminfo structure in XXX_SDO_GEOM_METADATA to a polygon with an optimized rectangle exterior ring.
```

SYNOPSIS

```    Static Function ST_DimInfo2Rectangle (
p_dim_array in mdsys.sdo_dim_array,
p_srid      in integer default NULL
)
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

DESCRIPTION

```    Converts any DIMINFO structure to a polygon by converted its SDO_DIM_ELEMENT X/Y sdo_lb/sdo_ub values to a single optimized rectangle exterior ring.
```

RESULT

```    polygon (T_GEOMETRY) -- Returns polygon with single optimized rectangle exterior ring.
```

EXAMPLE

```    select u.table_name, u.column_name, t_geometry.ST_DimInfo2Rectangle(u.diminfo,u.srid).geom as tgeom

TABLE_NAME               COLUMN_NAME TGEOM
------------------------ ----------- --------------------------------------------------------------------------------------------------------------------------------------------------------
LAND_PARCELS             GEOM        SDO_GEOMETRY(2003,2872,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(5979462.12680312,2085800.17222035,6024838.75881869,6024838.75881869))
BUILDING_FOOTPRINTS      GEOM        SDO_GEOMETRY(2003,2872,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(5980643.24426599,2086024.32003938,6024465.06003997,6024465.06003997))
WATER_AREAS              GEOM        SDO_GEOMETRY(2003,8307,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(-122.698410000002,37.44539000205,-122.049420001407,-122.049420001407))
BANKS_3785               GEOM        SDO_GEOMETRY(2003,3785,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(16805978.88835578,-4028254.329242822,16823678.019474965,16823678.019474965))
FEDERAL_LOWER_HOUSE_2016 GEOM        SDO_GEOMETRY(2003,4283,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(96.816766,-43.74051,159.109219,159.109219))
PROJPOINT3D              GEOM        SDO_GEOMETRY(3003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(358312.903,-140.5,-140.5,5406991.847,5406991.847,359370.628))
PROJPOINT2D              GEOM        SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(358312.903,359370.628,5406991.847,5406991.847))
LAND_PARCELS             CENTROID    SDO_GEOMETRY(2003,2872,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(5979545.39704517,2085843.32119355,6022727.95207985,6022727.95207985))

10 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.32. T_GEOMETRY/ST_Dims [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Dims -- Returns number of ordinate dimensions
```

SYNOPSIS

```    Member Function ST_Dims
Return Integer Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry get_dims() method ie SELF.GEOM.Get_Dims()
```

RESULT

```    dimension (Integer) -- 2 if data 2D; 3 if 3D; 4 if 4D
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.33. T_GEOMETRY/ST_Distance [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Distance -- Returns distance from current T_geometry (SELF) to supplied T_GEOMETRY.
```

SYNOPSIS

```    Member Function ST_Distance(p_geom  in &&INSTALL_SCHEMA..T_GEOMETRY,
p_unit  in varchar2 default NULL,
p_round in integer  default 0 )
Return Number Deterministic
```

ARGUMENTS

```    p_geom  (T_GEOMETRY) - A T_GEOMETRY to which a distance is calculated.
p_unit    (VarChar2) - Oracle Unit of Measure eg unit=M.
p_round        (BIT) - Whether to round result using PRECISION of T_GEOMETRY
```

DESCRIPTION

```    This function computes a distance from the current object (SELF) to the supplied T_Geometry.
Result is in the distance units of the SDO_SRID, or in p_units where supplied.
Result is rounded to SELF.PRECISION if p_round is true (1), otherwise false(0) no rounding.
With data as (
Select T_GEOMETRY(sdo_geometry('POINT(0 0)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3001,NULL,SDO_POINT_TYPE(0,0,0),null,null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,1, 10,0,2, 10,5,3, 10,10,4, 5,10,5, 5,5,6, 0,0,0)),0.005,3,1) as tgeom From Dual union all
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',28356),0.0005,3,1) as tgeom From Dual
)
select a.tGeom.ST_GeometryType() as geometryType,
a.tgeom.ST_Srid()         as srid,
case when a.tGeom.ST_Srid() = 28356 then 'CM' else 'M' end as unit,
a.tgeom.ST_Distance(sdo_geometry('POINT(51 41)',a.tGeom.ST_Srid()),
case when a.tGeom.ST_Srid() = 28356 then 'unit=CM' else null end,
0) as distance,
a.tgeom.ST_Distance(sdo_geometry('POINT(51 41)',a.tGeom.ST_Srid()),
case when a.tGeom.ST_Srid() = 28356 then 'unit=CM' else null end,
1) as round_distance
from data a;

GEOMETRYTYPE   SRID UNIT     DISTANCE ROUND_DISTANCE
-------------- ------ ---- ------------ --------------
ST_POINT       (NULL)    M   65.4369926         65.437
ST_POINT       (NULL)    M   65.4369926         65.437
ST_LINESTRING  (NULL)    M   51.4003891           51.4
ST_LINESTRING  (NULL)    M   51.4003891           51.4
ST_POLYGON     (NULL)    M   51.4003891           51.4
ST_POLYGON      28356   CM  3744.329045       3744.329

6 rows selected
```

RESULT

```    distance (Number) -- Distance in SRID unit of measure or in supplied units (p_unit)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.34. T_GEOMETRY/ST_Dump [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Dump -- Extracts all parts of a multipart linestring, polygon, or collection geometry.
```

SYNOPSIS

```    Member Function ST_Dump(p_subElements IN integer Default 0)
Return &&INSTALL_SCHEMA..T_Geometries Pipelined
```

DESCRIPTION

```    Extracts all parts of an underlying geometry object.
If p_subElemets is set to TRUE (1), all subElements of a complex element
(eg compound outer ring of polygon) are extracted and returned as mdsys.sdo_geometry objects.
Individual sdo_gemetry objects are returned in a T_GEOMETRY_ROW structure that has three fields: GID, GEOMETRY and TOLERANCE.
GID values are generated in the order the elements appears in the sdo_elem_info structure.
```

EXAMPLE

```    with GEOMETRIES as (
select t_geometry(
mdsys.sdo_geometry(2007,null,null,
sdo_elem_info_array( 1,1003,1,11,2003,1,21,2003,1,
31,1005,2,31,2,1,37,2,2,43,1003,3),
sdo_ordinate_array(0,0, 20,0, 20,20, 0,20, 0,0, 10,10, 10,11, 11,11, 11,10, 10,10, 5,5, 5,7, 7,7, 7,5, 5,5,
110,128, 110,125, 120,125, 120,128, 115,130, 110,128,112,0, 113,10))
,0.005,3,1) as tPolygon
From dual
)
GID GEOMETRY                                                                                                            TOLERANCE
--- ------------------------------------------------------------------------------------------------------------------- ---------
1 mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,20,0,20,20,0,20,0,0,10,10))          0.005
2 mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(10,10,10,11,11,11,11,10,10,10,5,5))      0.005
3 mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(5,5,5,7,7,7,7,5,5,5))                    0.005
1 mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(110,128,110,125,120,125,120,128))        0.005
2 mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(120,128,115,130,110,128))                0.005
1 mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,3),SDO_ORDINATE_ARRAY(112,0,113,10))                           0.005

6 rows selected
```

RESULT

```    Geometry (T_GEOMETRY_ROW) -- Table (T_GEOMETRIES) of T_GEOMETRY_ROW objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.35. T_GEOMETRY/ST_Elem_Info_Equal [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Elem_Info_Equal -- Compares current object (SELF) geometry's GEOM.SDO_ELEM_INFO object with supplied p_elem_info mdsys.sdo_elem_info_array.
```

SYNOPSIS

```    Member Function ST_Elem_Info_Equal(p_elem_info in mdsys.sdo_elem_info_array)
Return Integer Deterministic
```

DESCRIPTION

```    This function compares current t_geometry object's SELF.GEOM.SDO_ELEM_INFO object to supplied p_sdo_elem_info object.
Result can be one of the following:
0 if one or other sdo_elem_info_array structures are null but not both.
1 if two non-null structures and all offset/etype/interpretation ordinates are equal;
-1 if sdo_elem_info not all offset/etype/interpretation ordinates are equal
```

ARGUMENTS

```    p_elem_info (sdo_elem_info_array) -- sdo_elem_info array that is to be compared to current object geometry's SELF.GEOM.sdo_elem_info object.
```

RESULT

```    -1,0,1 (Integer) --  0 if one or other sdo_elem_info_array structures are null but not both.
--  1 if two non-null structures and all offset/etype/interpretation ordinates are equal;
-- -1 if sdo_elem_info not all offset/etype/interpretation ordinates are equal
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.36. T_GEOMETRY/ST_ElementTypeAt [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_ElementTypeAt -- Element_Type value in Sdo_Elem_Info triplet index.
```

SYNOPSIS

```    Member Function ST_ElementTypeAt
Return &&INSTALL_SCHEMA..T_ElemInfo
```

DESCRIPTION

```    If a geometry is coded with an SDO_ELEM_INFO_ARRAY this function will extract the triplet at index p_element,
and return the element type (etype) stored in that triplet.
An T_ElemInfo object is:
CREATE TYPE &&INSTALL_SCHEMA..T_ElemInfo AS OBJECT (
offset           Number,
etype            Number,  <--- This is returned.
interpretation   Number
);
```

EXAMPLE

```    with data as (
Select T_Geometry(
SDO_GEOMETRY(2007,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1005,2, 1,2,1, 5,2,2,
11,2005,2, 11,2,1, 15,2,2,
21,1005,2, 21,2,1, 25,2,2),
SDO_ORDINATE_ARRAY(  6,10, 10,1, 14,10, 10,14,  6,10,
13,10, 10,2,  7,10, 10,13, 13,10,
106,110, 110,101, 114,110, 110,114,106,110)
),0.005,2,1) as tgeom
from dual
)
select a.tGeom.geom.sdo_elem_info           as elem_info,
a.tGeom.ST_NumElementInfo()          as numElemInfos,
t.IntValue                           as element_id,
a.tgeom.ST_ElementTypeAt(t.IntValue) as elem_type_at
from data a,
TABLE(tools.generate_series(1,a.tgeom.ST_NumSubElements(),1)) t;

ELEM_INFO                                                                                 NUMELEMINFOS ELEMENT_ID ELEM_TYPE_AT
----------------------------------------------------------------------------------------- ------------ ---------- ------------
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          1         1005
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          2            2
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          3            2
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          4         2005
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          5            2
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          6            2
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          7         1005
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          8            2
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,5,2,2,11,2005,2,11,2,1,15,2,2,21,1005,2,21,2,1,25,2,2)            9          9            2

9 rows selected
```

RESULT

```    Element Type (Integer)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2006 - Original coding in GEOM package.
Simon Greener - Jan 2013 - Port to T_GEOMETRY object.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.37. T_GEOMETRY/ST_ElemInfo [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_ElemInfo -- Returns underlying mdsys.sdo_geometry's SDO_ELEM_INFO array as a Set of T_ElemInfo objects.
```

SYNOPSIS

```    Member Function ST_ElemInfo
Return &&INSTALL_SCHEMA..T_ElemInfoSet pipelined
```

DESCRIPTION

```    If a geometry is coded with an SDO_ELEM_INFO_ARRAY this function will extract the triplets that describe
each element and returns them as a set of T_ELEM_INFO objects.
The T_ElemInfo object is:
CREATE TYPE &&INSTALL_SCHEMA..T_ElemInfo AS OBJECT (
offset           Number,
etype            Number,
interpretation   Number
);
```

RESULT

```    Set of T_ElemInfo objects (Integer)
```

NOTES

```    Function is pipelined
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2006 - Original coding in GEOM package.
Simon Greener - Jan 2013 - Port to T_GEOMETRY object.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.38. T_GEOMETRY/ST_EndPoint [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_EndPoint -- Returns last Point in underlying geometry.
```

SYNOPSIS

```    Member Function ST_EndPoint
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    Returns last point in underlying geometry.
```

EXAMPLE

```    With data As (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,20 0,20 20,10 20,0 20)',null),0.005,3,1) as tLine
From Dual
)
select a.tLine.ST_EndPoint().ST_AsText() as end_Point
from data a;

END_POINT
----------------
POINT (0.0 20.0)
```

RESULT

```    Point (T_GEOMETRY) -- First point in underlying geometry.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.39. T_GEOMETRY/ST_EndSegment [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_EndSegment -- Returns last Segment in underlying geometry.
```

SYNOPSIS

```    Member Function ST_EndSegment
Return &&INSTALL_SCHEMA..T_Segment Deterministic,
```

DESCRIPTION

```    Returns last segment in underlying geometry.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GeometryType()           as geometryType,
a.tGeom.ST_EndSegment().ST_AsText() as end_segment
from data a;

GEOMETRYTYPE  END_SEGMENT
------------- -----------------------------------------------------------------------------------------------------------
ST_LINESTRING SEGMENT(1,1,5,Start(5,10,NULL,NULL,5,2001,NULL),End(5,5,NULL,NULL,6,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON    SEGMENT(1,2,4,Start(11,10,NULL,NULL,4,2001,NULL),End(10,10,NULL,NULL,5,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
```

RESULT

```    Segment (T_GEOMETRY) -- Last segment in underlying geometry.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.40. T_GEOMETRY/ST_EndVertex [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_EndVertex -- Returns last vertex in underlying geometry.
```

SYNOPSIS

```    Member Function ST_EndVertex
Return T_Vertex Deterministic
```

RESULT

```    Vertex (T_Vertex) -- Vertex at end of geometry.
```

DESCRIPTION

```    Returns last vertex describing underlying geometry.
Actual end vertex ID is provided in returned T_Vertex object.
```

EXAMPLE

```    With data As (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,20 0,20 20,10 20,0 20)',null),0.005,3,1) as tLine
From Dual
)
select a.tLine.ST_EndVertex().ST_AsText() as end_vertex
from data a;

VERTEX
-----------------------------------------------------------
T_Vertex(X=0.0,Y=20.0,Z=NULL,W=NULL,ID=5,GT=2001,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.41. T_GEOMETRY/ST_Envelope [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Envelope - Returns lower left and upper right coordinates of underlying geometry's envelope.
```

SYNOPSIS

```    Member Function ST_Envelope
Return T_GEOMETRY Determinsitic
```

RESULT

```    MBR Geometry (T_GEOMETRY) -- Single Polygon with Optimized Rectangle Exterior Ring.
```

DESCRIPTION

```    Supplied with a non-NULL geometry, this function returns the envelope or minimum bounding rectangle as a polygon geometry with one optimized rectangle exterior ring.
```

EXAMPLE

```    select T_Geometry(sdo_geometry('LINESTRING(0 0,0.1 0.1,0.5 0.5,0.8 0.8,1 1)',NULL),0.005,2,1).ST_Envelope().geom as mbrGeom
from dual;

MBRGEOM
--------------------------------------------------------------------------------------
SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(0,0,1,1))
```

NOTES

```    Wrapper over T_GEOMETRY.ST_MBR.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2005 - Original coding for GEOM package.
Simon Greener - July 2011    - Converted to T_GEOMETRY from GEOM package.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.42. T_GEOMETRY/ST_Equals [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Equals -- Compares current object (SELF) with supplied T_GEOMETRY.
```

SYNOPSIS

```    Member Function ST_Equals(p_geometry    in mdsys.sdo_geometry,
p_z_precision in integer default 2,
p_m_precision in integer default 3)
Return varchar2 deterministic
```

DESCRIPTION

```    This function compares current t_geometry object's sdo_geometry (SELF.GEOM) to supplied p_geometry object.
Only compares SDO_GEOMETRY objects.
Result can be one of the following:
EQUAL
FAIL:DIMS
FAIL:SDO_ELEM_INFO
FAIL:SDO_ELEM_INFO
FAIL:SDO_GTYPE
FAIL:SDO_POINT
FAIL:SDO_SRID
FALSE:NULL
```

ARGUMENTS

```    p_geometry (SDO_GEOMETRY) -- SDO_GEOMETRY that is to be compared to current object geometry (SELF.GEOM).
p_z_precision   (integer) -- Z Ordinate precision for comparison using ROUND
p_m_precision   (integer) -- M Ordinate precision for comparison using ROUND
```

RESULT

```    EQUAL/FAIL     (VarChar2) -- EQUAL or FAIL:{Reason}
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.43. T_GEOMETRY/ST_Extend [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Extend -- Function that lengthens underlying linestring at one or both ends.
```

SYNOPSIS

```    Member Function ST_Extend (p_length    in number,
p_start_end in varchar2 default 'START',
p_unit      in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Function that extends the supplied linestring at either its start or end (p_end).
p_length should alway be positive. If it is negative ST_Reduce is called: see ST_Reduce documentation.
And extension occurs in the direction of a line formed by the first and second vertices (if START) or last and second last vertices (if END).
p_end value of BOTH means line is extended at both ends.
```

TODO

```    Add p_keep parameter:
If p_keep is set to 1, the start or end vertex is kept and a new vertex added at the extended length from the start/end.
If p_keep is 0, the actual first or last vertex is moved.
```

EXAMPLE

```    -- Extend linestring at start 50 feet.
select T_GEOMETRY(
SDO_GEOMETRY(2002,2872,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(5995293.06,2105941.35, 5995094.87,2105871.28,
5995044.46,2105492.80, 5995033.03,2105411.14,
5995012.60,2105371.13, 5994950.04,2105332.47)),
0.005,2,1)
as tgeom
from dual
)
SELECT round(rl.tgeom.ST_Length('unit=U.S. Foot'),2) as original_Length,
round(rl.tgeom
.ST_Extend(90,'START','unit=U.S. Foot')
.ST_Round()
.ST_Length('unit=U.S. Foot'),2) as new_length,
rl.tgeom
.ST_Extend(90,'START','unit=U.S. Foot')
.ST_Round()
.ST_AsText() as sGeom

ORIGINAL_LENGTH NEW_LENGTH SGEOM
--------------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------
792.96     882.96 LINESTRING (5995377.91274448 2105971.34965591, 5995094.87 2105871.28, 5995044.46 2105492.8, 5995033.03 2105411.14, 5995012.6 2105371.13, 5994950.04 2105332.47)

-- MultiLineString Extend Example ...
With data As (
select T_Geometry(
sdo_geometry('MULTILINESTRING((1 1,2 2,3 3,4 4),(0 2,1 3,2 4,3 5))',null),
0.005,2,1) as tgeom
from dual
)
select Start_end,
seLength,
gLength as originalLength,
f.tGeom.ST_Length(p_round=>f.tGeom.dprecision) as newLength,
f.tGeom.ST_Round(f.tGeom.dprecision,1,1).ST_AsText() as geom
from (select a.tgeom.ST_Length(p_round=>a.tGeom.dprecision) as gLength,
'START' as Start_End,
1.414   as seLength,
a.tgeom.ST_Extend(1.414,'START') as tgeom
from data a
union all
select a.tgeom.ST_Length(p_round=>a.tGeom.dprecision) as gLength,
'BOTH' as Start_End,
1.414  as seLength,
a.tgeom.ST_Extend(1.414,'BOTH')  as tgeom
from data a
union all
select a.tgeom.ST_Length(p_round=>a.tGeom.dprecision) as gLength,
'END' as Start_End,
1.414 as seLength,
a.tgeom.ST_Extend(1.414,'END') as tgeom
from data a
) f;

START_END SELENGTH ORIGINALLENGTH  NEWLENGTH GEOM
--------- -------- -------------- ---------- ------------------------------------------------------------
START        1.414           8.49        9.9 MULTILINESTRING ((0 0, 2 2, 3 3, 4 4), (0 2, 1 3, 2 4, 3 5))
BOTH         1.414           8.49      11.31 MULTILINESTRING ((0 0, 2 2, 3 3, 4 4), (0 2, 1 3, 2 4, 4 6))
END          1.414           8.49        9.9 MULTILINESTRING ((1 1, 2 2, 3 3, 4 4), (0 2, 1 3, 2 4, 4 6))
```

NOTES

```    Points, GeometryCollections, Polygons, MultiPolygons, CircularStrings are not supported.
Assumes planar projection eg UTM.
```

ARGUMENTS

```    p_length       (number) - If negative ST_Reduce is called on the linestring.
If positive the linestring is extended.
Distance must be expressed in SRID or p_unit units
p_start_end  (varchar2) - START means extend line at the start; END means extend at the end, and BOTH means extend at both START and END of line.
p_unit       (varchar2) - Allows default Oracle unit of measure (UoM) to be overridden eg if unit M is default for SRID then unit=CM will compute in centimeters.
p_keep            (int) - (Future) Keep existing first/last vertex and add new (1) vertices, or move (0) existing start/end vertex.
```

RESULT

```    linestring (t_geometry) - Input geometry extended as instructed.
```

ERRORS

```    The following exceptions can be thrown:
ORA-20120 - Geometry must not be null or empty (*ERR*)
Where *ERR* is replaced with specific error
ORA-20121 - Geometry must be a single linestring.
ORA-20122 - Start/End parameter value (*VALUE*) must be START, BOTH or END
Where *VALUE* is the supplied, incorrect, value.
ORA-20123 - p_length value must not be 0 or NULL.
```

AUTHOR

```    Simon Greener
Simon Greener - December 2006 - Original Coding for GEOM Package
Simon Greener - July 2011     - Port to T_GEOMETRY
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.44. T_GEOMETRY/ST_ExteriorRing [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_ExteriorRing -- Returns All Outer Rings of a polygon or multipolygon.
```

SYNOPSIS

```    Member Function ST_ExteriorRing()
Return T_GEOMETRY Deterministic,
```

DESCRIPTION

```    This function extracts all the exterior (outer) rings of a polygon/multipolygon and returns them as a T_GEOMETRY object.
```

NOTES

```    Is an implementation of OGC ST_ExteriorRing method.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_ExteriorRing().ST_AsText() as ExteriorRing
from data a;

EXTERIORRING
-----------------------------------------------------------------------------------------------
MULTIPOLYGON (((0 0, 20 0, 20 20, 0 20, 0 0)), ((100 100, 200 100, 200 200, 100 200, 100 100)))
```

RESULT

```    Exterior ring(s) (T_GEOMETRY) -- For example, if a single Polygon with 1 exterior and 1 interior ring is provided, then a single polygon with a single exterior ring is returned.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Aug 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.45. T_GEOMETRY/ST_Extract [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_ExtractRings -- Extracts all single geometry objects from geometry collection, multi linestring or multi polygon.
```

SYNOPSIS

```    Member Function ST_Extract
Return &&INSTALL_SCHEMA..T_GEOMETRIES Pipelined
```

DESCRIPTION

```    This function extracts all single geometry types (eg point, linestring, polygon) from the underlying geometry.
The underlying geometry object must be a geometry collection (x004), multi linestring (x006) or multi polygon (x007).
```

EXAMPLE

```    with data as (
select 1 as geomid, t_geometry(sdo_geometry(2004,null,null,sdo_elem_info_array(1,1,1, 3,2,1, 7,1003,1),       sdo_ordinate_array(10,5, 10, 10,20,10,10,105, 15,105, 20,110, 10,110, 10,105)),0.05) as tgeom
from dual union all
select 2 as geomid, t_geometry(sdo_geometry(2004,NULL,NULL,sdo_elem_info_array(1,1003,3,5,1, 1,9,2,1, 11,2,1),sdo_ordinate_array(0, 0,100,100,50,50, 0,  0,100,100,300,  0,310,  1        )),0.05) as tgeom
from dual union all
Select 3 as geomid, T_GEOMETRY(sdo_geometry('MULTILINESTRING((-1 -1, 0 -1),(0 0,10 0,10 5,10 10,5 10,5 5))',null),0.005,3,1) as tgeom
From Dual union all
Select 4 as geomid, T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.geomId,
t.gid,
t_geometry(t.geometry,t.tolerance,t.dPrecision,t.projected).ST_AsText() as tegeom
from data a,
table(a.tgeom.ST_Extract()) t;

GEOMID GID TEGEOM
------ --- -------------------------------------------------------
1   1 POINT (10 5)
1   2 LINESTRING (10 10, 20 10)
1   3 POLYGON ((10 105, 15 105, 20 110, 10 110, 10 105))
2   1 POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0))
2   2 POINT (50 50)
2   3 LINESTRING (100 100)
2   4 LINESTRING (300 0, 310 1)
3   1 LINESTRING (-1 -1, 0 -1)
3   2 LINESTRING (0 0, 10 0, 10 5, 10 10, 5 10, 5 5)
4   1 POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))
4   2 POLYGON ((100 100, 200 100, 200 200, 100 200, 100 100))

11 rows selected
```

RESULT

```    polygon (T_GEOMETRY) -- All geometries are extracted and returned.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.46. T_GEOMETRY/ST_Extract(p_geomType) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_ExtractRings -- Extracts required geometry types (point, line, polygon) from underlying geometry collection.
```

SYNOPSIS

```    Member Function ST_Extract (
p_geomType in varchar2
)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

ARGUMENTS

```    p_geomType (varchar2) - GeometryType to be extracted must be one of POINT,ST_POINT,LINE,LINESTRING,ST_LINESTRING,POLY,POLYGON,ST_POLYGON
```

RESULT

```    polygon (T_GEOMETRY) -- Geometries of required Geometry_Type.
```

DESCRIPTION

```    This function allows a user to extract all geometries of a particular type from the underlying geometry collection (x004).
The resultant t_geometry object could be singular eg LINESTRING or multi eg MULTILINESTRING.
```

EXAMPLE

```    with data as (
select 1 as geomid, t_geometry(sdo_geometry(2004,null,null,sdo_elem_info_array(1,1,1, 3,2,1, 7,1003,1),       sdo_ordinate_array(10,5, 10, 10,20,10,10,105, 15,105, 20,110, 10,110, 10,105)),0.05) as tgeom from dual union all
select 2 as geomid, t_geometry(sdo_geometry(2004,NULL,NULL,sdo_elem_info_array(1,1003,3,5,1, 1,9,2,1, 11,2,1),sdo_ordinate_array(0, 0,100,100,50,50, 0,  0,100,100,300,  0,310,  1        )),0.05) as tgeom from dual
)
select geomId,
case t.IntValue
when 1 then 'Point'
when 2 then 'Line'
when 3 then 'Polygon'
end as geomType,
a.tgeom.ST_Extract(
case t.IntValue
when 1 then 'Point'
when 2 then 'Line'
when 3 then 'Polygon'
end
).ST_AsText() as geom
from data a,
table(tools.generate_series(1,3,1)) t

GEOMID GEOMTYPE GEOM
------ -------- --------------------------------------------------
1 Point    POINT (10 5)
1 Line     LINESTRING (10 10, 20 10)
1 Polygon  POLYGON ((10 105, 15 105, 20 110, 10 110, 10 105))
2 Point    POINT (50 50)
2 Line     MULTILINESTRING ((100 100), (300 0, 310 1))
2 Polygon  POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0))

6 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.47. T_GEOMETRY/ST_ExtractRings [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_ExtractRings -- Extracts all rings of a polygon/multipolygon into a set of simple T_GEOMETRY polygon objects.
```

SYNOPSIS

```    Member Function ST_ExtractRings()
Return &&INSTALL_SCHEMA..T_GEOMETRIES Pipelined
```

DESCRIPTION

```    This function allows a user to extract all outer and inner rings from a polygon/multipolygon. The resultant set of
individual inner or outer rings are accessible via the Oracle SQL TABLE function as in the example below.
```

EXAMPLE

```    With Data as (
Select 1 as geomId, T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0)),0.005,3,1) as tgeom
From Dual union all
Select 2 as geomId, T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1,11,2003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0, 5,5,5,10,10,10,10,5,5,5)),0.005,3,1) as tgeom
From Dual
union all
Select 3 as geomId, T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),
((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.geomid, t.gid as ringId, t_geometry(t.geometry,t.tolerance,t.dPrecision,t.projected).ST_AsText() as geom
from data a,
table(a.tgeom.ST_ExtractRings()) t;

GEOMID RINGID GEOM
------ ------ -------------------------------------------------------
1      1 POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))
2      1 POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))
2      2 POLYGON ((5 5, 10 5, 10 10, 5 10, 5 5))
3      1 POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))
3      2 POLYGON ((10 10, 11 10, 11 11, 10 11, 10 10))
3      3 POLYGON ((5 5, 7 5, 7 7, 5 7, 5 5))
3      1 POLYGON ((100 100, 200 100, 200 200, 100 200, 100 100))

7 rows selected
```

RESULT

```    polygon (T_GEOMETRY) -- All polygon rings retured as individual polygons.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.48. T_GEOMETRY/ST_FilterRings [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_FilterRings -- Removes rings from polygon/multipolygon below supplied area.
```

SYNOPSIS

```    Member Function ST_FilterRings(p_area in number,
p_unit in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    This function allows a user to remove inner rings from a polygon/multipolygon based on an area value.
Will remove both outer and inner rings.
```

ARGUMENTS

```    p_area (Number)   - Area in square SRID units below which an inner ring is removed.
p_unit (VarChar2) - Oracle Unit of Measure For SRID eg unit=M.
```

RESULT

```    polygon collection (T_GEOMETRIES) -- A set of one or more single rings derived from input polygon.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as TGeom
From Dual
Union All
Select T_GEOMETRY(sdo_geometry(2007,NULL,NULL,
sdo_elem_info_array(1,1005,2, 1,2,1, 7,2,2,13,1003,3),
sdo_ordinate_array (10,128, 10,125, 20,125, 20,128, 15,130, 10,128, 0,0, 10,10)),0.005,3,1) as TGeom
From Dual
)
Select a.tGeom.ST_Area()                          as originalArea,
a.tGeom.ST_FilterRings(50.0).ST_Area()     as filteredArea,
a.tGeom.ST_FilterRings(50.0).ST_Validate() as validate_geom
From data a;

ORIGINALAREA FILTEREDAREA VGEOM
------------ ------------ -----
395          400 TRUE
143.7507329          100 TRUE
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.49. T_GEOMETRY/ST_FixOrdinates [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_FixOrdinates -- Allows calculations expressed as formula to change the ordinates of the underlying Geometry
```

SYNOPSIS

```    Member Function ST_FixOrdinates(
p_x_formula in varchar2,
p_y_formula in varchar2,
p_z_formula in varchar2 := null,
p_w_formula in varchar2 := null
)
Return mdsys.sdo_geometry Deterministic,
```

ARGUMENTS

```    p_x_formula (varchar2) -- Mathematical formula to be applied to X ordinate
p_y_formula (varchar2) -- Mathematical formula to be applied to Y ordinate
p_z_formula (varchar2) -- Mathematical formula to be applied to Z ordinate
p_w_formula (varchar2) -- Mathematical formula to be applied to W/M ordinate
```

RESULT

```    Modified Geometry (T_Geometry) -- Original geometry with modified ordinates
```

DESCRIPTION

```    The formula may reference the ordinates of the geometry via the columns X, Y, Z and W
(the T_Vertex fields produced by SDO_Util.GetVertices function) keywords.
These keywords can be referred to multiple times in a formula
(see 'ROUND ( z / ( z * dbms_random.value(1,10) ), 3 )' in the example
that processes a 3D linestring below).
Since the formula are applied via SQL even Oracle intrinsic columns like ROWNUM
can be used (see '(rownum * w)' below). One can also use any Oracle function,
eg RANDOM: this includes functions in packages such as DBMS_RANDOM
eg 'ROUND ( Y * dbms_random.value ( 1,1000) ,3 )') as well.
```

EXAMPLE

```    select t_geometry(SDO_Geometry('POINT(1.25 2.44)'),0.005,2,1)
.ST_FixOrdinates(
'ROUND(X * 3.141592653,3)',
'ROUND(Y * dbms_random.value(1,1000),3)',
NULL
).ST_AsText() as point
from dual;

POINT
----------------------
POINT (3.927 1240.552)

select t_geometry(SDO_Geometry(3001,null,sdo_point_type(1.25,2.44,3.09),null,null),0.005,2,1)
.ST_FixOrdinates(
'ROUND(X * 3.141592653,3)',
'ROUND(Y * dbms_random.value(1,1000),3)',
'ROUND(Z / 1000,3)'
).geom as point
from dual;

POINT
----------------------------------------------------------------------
SDO_GEOMETRY(3001,NULL,SDO_POINT_TYPE(3.927,1317.816,0.003),NULL,NULL)

select t_geometry(SDO_Geometry('LINESTRING(1.12345 1.3445,2.43534 2.03998398)',NULL),0.005,2,1)
.ST_FixOrdinates(
'ROUND(X * 3.141592653,3)',
'ROUND(Y * dbms_random.value(1,1000),3)'
).ST_AsText() as line
from dual;

LINE
---------------------------------------
LINESTRING (3.529 49.26, 7.651 466.107)

select t_geometry(
SDO_Geometry(3006,null,null,
sdo_elem_info_array(1,2,1,10,2,1),
sdo_ordinate_array(1.12345,1.3445,9,2.43534,2.03998398,9,3.43513,3.451245,9,10,10,9,10,20,9)),0.005,2,1)
.ST_FixOrdinates(
NULL,
NULL,
'ROUND(Y * dbms_random.value(1,1000),3)'
).geom as line
from dual;

LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,10,2,1),SDO_ORDINATE_ARRAY(1.12345,1.3445,525.749,2.43534,2.03998398,952.99,3.43513,3.451245,948.895,10,10,2930.214,10,20,16775.12))

-- line string with 3 dimensions: X,Y,M
select t_geometry(
SDO_GEOMETRY(3302,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1), -- one line string, straight segments
SDO_ORDINATE_ARRAY(2,2,0,
2,4,2,
8,4,8,
12,4,12,
12,10,NULL,
8,10,22,
5,14,27)),0.005,2,1)
.ST_FixOrdinates(NULL,NULL,NULL,'(rownum * NVL(w,18))').geom as line
from dual;

LINE
---------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,0,2,4,4,8,4,24,12,4,48,12,10,90,8,10,132,5,14,189))
```

HISTORY

```    Simon Greener - February 2009 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.50. T_GEOMETRY/ST_Flip_Segments [ Functions ]

[ Top ] [ T_GEOMETRY ] [ Functions ]

NAME

```    ST_Flip_Segments - Turns linestring and polygon rings into segments and then flips each vector until all point in the same direction.
```

SYNOPSIS

```    Member Function ST_Flip_Vectors
Return geometry
```

EXAMPLE

```    With gc As (
select geometry::STGeomFromText(
'GEOMETRYCOLLECTION(
POLYGON((10 0,20 0,20 20,10 20,10 0)),
POLYGON((20 0,30 0,30 20,20 20,20 0)),
POINT(0 0))',0) as geom
)
select v.sx,v.sy,v.ex,v.ey,count(*)
from gc as a
cross apply
[dbo].[STVectorize] (
[dbo].[STFlipVectors] ( a.geom )
) as v
group by v.sx,v.sy,v.ex,v.ey
go
```

DESCRIPTION

```    This function extracts all vectors from supplied linestring/polygon rings, and then flips each vector until all point in the same direction.
This function is useful for such operations as finding "slivers" between two polygons that are supposed to share a boundary.
Once the function has flipped the vectors the calling function can analyse the vectors to do things like find duplicate segment
which are part of a shared boundaries that are exactly the same (no sliver).
RETURN
geometry (GeometryCollection) - The set of flipped vectors.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

15.51. T_GEOMETRY/ST_FromEWKT [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_FromEWKT -- Implements an import method for Extended Well Known Text including EWKT with Z and M ordinates..
```

SYNOPSIS

```    Static Function ST_FromEWKT(p_ewkt in clob)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Implements an import method for Extended Well Known Text including EWKT with Z and M ordinates..
Returns T_GEOMETRY with valid sdo_geometry object.
Will import SQL Server Spatial (AsTextZM) and PostGIS EWKT.
Supports EWKT like "POINT EMPTY".
```

NOTES

```    A description of the EWKT structure is available in the PostGIS documentation.
```

RESULT

```    New Geometry (T_GEOMETRY) -- T_GEOMETRY containing a valid sdo_geometry with 2, 3 or 4 dimensions.
```

EXAMPLE

```    with data as (
select 'SRID=28355;POINTZ (0.1 0.2 0.3)' as ewkt
from dual union all
select 'SRID=28355;POINTZM (0.1 0.2 0.3 0.4)' as ewkt
from dual union all
select 'LINESTRING (0.1 0.1,10 0,10 5,10 10,5 10,5 5)' as ewkt
from dual union all
select 'SRID=28355;LINESTRINGZ (0.1 0.1 1,10 0 2,10 5 3,10 10 4,5 10 5,5 5 6)' as ewkt
from dual union all
select 'MULTILINESTRINGM ((50.0 55.0 1, 50.0 60.0 2, 55.0 58.0 3, 50.0 55.0 4), (56.0 58.0 5, 60.0 55.0 6, 60.0 60.0 7, 56.0 58.0 8))' as ewkt
from dual union all
select 'CIRCULARSTRINGZ (10.0 15.0 3.0, 15.0 20.0 3.0, 20.0 15.0 3.0)' as ewkt
from dual union all
select 'CIRCULARSTRINGZM (10.0 15.0 3.0 0.0, 15.0 20.0 3.0 5.67, 20.0 15.0 3.0 9.84)' as ewkt
from dual union all
select 'CIRCULARSTRINGM (10.0 15.0 0.0, 15.0 20.0 5.67, 20.0 15.0 9.84)' as ewkt
from dual union all
select 'COMPOUNDCURVEZ ((10.0 45.0 0.0, 20.0 45.0 1.6), CIRCULARSTRING (20.0 45.0 1.8, 23.0 48.0 1.8, 20.0 51.0 1.8), (20.0 51.0 1.8, 10.0 51.0 1.8))' as ewkt
from dual union all
select 'SRID=28355;MULTICURVEZ (CIRCULARSTRING (50.0 35.0 3.2, 55.0 40.0 3.2, 60.0 35.0 3.2), CIRCULARSTRING (65.0 35.0 4.6, 70.0 30.0 5.6, 75.0 35.0 2.3))' as ewkt
from dual union all
select 'CURVEPOLYGON (COMPOUNDCURVE ((10.0 128.0, 10.0 125.0, 20.0 125.0, 20.0 128.0), CIRCULARSTRING (20.0 128.0, 15.0 130.0, 10.0 128.0)))' as ewkt
from dual union all
select 'MULTIPOLYGONZ (((1500.0 100.0 0.0, 1900.0 100.0 0.1, 1900.0 500.0 0.2, 1500.0 500.0 0.3, 1500.0 100.0 0.0)), ((1900.0 500.0 2.0, 2300.0 500.0 2.1, 2300.0 900.0 2.2, 1900.0 900.0 1.8, 1900.0 500.0 2.0)))' as ewkt
from dual union all
select 'GEOMETRYCOLLECTION (POINT (10.0 5.0), LINESTRING (10.0 10.0, 20.0 10.0), POLYGON ((10.0 105.0, 15.0 105.0, 20.0 110.0, 10.0 110.0, 10.0 105.0)))' as ewkt
from dual union all
select 'SRID=28355;GEOMETRYCOLLECTIONZ (POINT (10.0 5.0 1.0), LINESTRING (10.0 10.0 1.1, 20.0 10.0 1.2), POLYGON ((10.0 105.0 1.3, 15.0 105.0 1.3, 20.0 110.0 1.4, 10.0 110.0 1.2, 10.0 105.0 1.3)))' as ewkt
from dual
)
select T_GEOMETRY.ST_FromEWKT(a.ewkt).geom as geomFromEWkt
from data a;

GEOMFROMEWKT
----------------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3001,28355,SDO_POINT_TYPE(0.1,0.2,0.3),NULL,NULL)
SDO_GEOMETRY(4401,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,1,1),
SDO_ORDINATE_ARRAY(0.1,0.2,0.3,0.4))
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(0.1,0.1,10,0,10,5,10,10,5,10,5,5))
SDO_GEOMETRY(3002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(0.1,0.1,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6))
SDO_GEOMETRY(3306,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1,13,2,1),
SDO_ORDINATE_ARRAY(50,55,1,50,60,2,55,58,3,50,55,4,56,58,5,60,55,6,60,60,7,56,58,8))
SDO_GEOMETRY(3002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2),
SDO_ORDINATE_ARRAY(10,15,3,15,20,3,20,15,3))
SDO_GEOMETRY(4402,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2),
SDO_ORDINATE_ARRAY(10,15,3,0,15,20,3,5.67,20,15,3,9.84))
SDO_GEOMETRY(3302,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2),
SDO_ORDINATE_ARRAY(10,15,0,15,20,5.67,20,15,9.84))
SDO_GEOMETRY(3002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,4,3,1,2,1,4,2,2,10,2,1),
SDO_ORDINATE_ARRAY(10,45,0,20,45,1.6,20,45,1.8,23,48,1.8,20,51,1.8,20,51,1.8,10,51,1.8))
SDO_GEOMETRY(3006,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2,10,2,2),
SDO_ORDINATE_ARRAY(50,35,3.2,55,40,3.2,60,35,3.2,65,35,4.6,70,30,5.6,75,35,2.3))
SDO_GEOMETRY(2003,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,7,2,2),
SDO_ORDINATE_ARRAY(10,128,10,125,20,125,20,128,15,130,10,128))
SDO_GEOMETRY(3007,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1,16,1003,1),
SDO_ORDINATE_ARRAY(1500,100,0,1900,100,0.1,1900,500,0.2,1500,500,0.3,1500,100,0,1900,500,2,2300,500,2.1,2300,900,2.2,1900,900,1.8,1900,500,2))
SDO_GEOMETRY(2004,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1,1,3,2,1,7,1003,1),
SDO_ORDINATE_ARRAY(10,5,10,10,20,10,10,105,15,105,20,110,10,110,10,105))
SDO_GEOMETRY(3004,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,1,1,4,2,1,10,1003,1),
SDO_ORDINATE_ARRAY(10,5,1,10,10,1.1,20,10,1.2,10,105,1.3,15,105,1.3,20,110,1.4,10,110,1.2,10,105,1.3))

14 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.52. T_GEOMETRY/ST_FromText [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_FromText -- This is a wrapper function that has the ST_FromText name common to users of PostGIS.
```

SYNOPSIS

```    Static Function ST_FromText(p_wkt  in clob,
p_srid in integer default NULL)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Implements an import method for standard Well Known Text.
Returns T_GEOMETRY with valid sdo_geometry object.
Uses the SDO_GEOMETRY(CLOB,INTEGER) constructor to create a
T_GEOMETRY object with default tolerance, dPrecision and projected variable values.
```

RESULT

```    New Geometry (T_GEOMETRY) -- T_GEOMETRY containing a valid 2D sdo_geometry object with default parameters.
```

EXAMPLE

```    with data as (
select 'POINT (0.1 0.2)' as wkt from dual union all
select 'LINESTRING (0.1 0.1,10 0,10 5,10 10,5 10,5 5)' as wkt from dual union all
select 'MULTILINESTRING ((50.0 55.0, 50.0 60.0, 55.0 58.0, 50.0 55.0), (56.0 58.0, 60.0 55.0, 60.0 60.0, 56.0 58.0))' as wkt from dual union all
select 'CIRCULARSTRING (10.0 15.0, 15.0 20.0, 20.0 15.0)' as wkt from dual union all
select 'COMPOUNDCURVE ((10.0 45.0, 20.0 45.0), CIRCULARSTRING (20.0 45.0, 23.0 48.0, 20.0 51.0), (20.0 51.0, 10.0 51.0))' as wkt from dual union all
select 'MULTICURVE (CIRCULARSTRING (50.0 35.0, 55.0 40.0, 60.0 35.0), CIRCULARSTRING (65.0 35.0, 70.0 30.0, 75.0 35.0))' as wkt from dual union all
select 'CURVEPOLYGON (COMPOUNDCURVE ((10.0 128.0, 10.0 125.0, 20.0 125.0, 20.0 128.0), CIRCULARSTRING (20.0 128.0, 15.0 130.0, 10.0 128.0)))' as wkt from dual union all
select 'MULTIPOLYGON (((1500.0 100.0, 1900.0 100.0, 1900.0 500.0, 1500.0 500.0, 1500.0 100.0)), ((1900.0 500.0, 2300.0 500.0, 2300.0 900.0, 1900.0 900.0, 1900.0 500.0)))' as wkt from dual union all
select 'GEOMETRYCOLLECTION (POINT (10.0 5.0), LINESTRING (10.0 10.0, 20.0 10.0), POLYGON ((10.0 105.0, 15.0 105.0, 20.0 110.0, 10.0 110.0, 10.0 105.0)))' as wkt from dual
)
select T_GEOMETRY.ST_FromText(a.wkt).geom as geomFromWkt
from data a;

GEOMFROMWKT
---------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0.1,0.2,NULL),NULL,NULL)
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(0.1,0.1,10,0,10,5,10,10,5,10,5,5))
SDO_GEOMETRY(2006,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1,9,2,1),
SDO_ORDINATE_ARRAY(50,55,50,60,55,58,50,55,56,58,60,55,60,60,56,58))
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2),
SDO_ORDINATE_ARRAY(10,15,15,20,20,15))
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,4,3,1,2,1,3,2,2,7,2,1),
SDO_ORDINATE_ARRAY(10,45,20,45,23,48,20,51,10,51))
SDO_GEOMETRY(2006,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2,7,2,2),
SDO_ORDINATE_ARRAY(50,35,55,40,60,35,65,35,70,30,75,35))
SDO_GEOMETRY(2003,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1005,2,1,2,1,7,2,2),
SDO_ORDINATE_ARRAY(10,128,10,125,20,125,20,128,15,130,10,128))
SDO_GEOMETRY(2007,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1,11,1003,1),
SDO_ORDINATE_ARRAY(1500,100,1900,100,1900,500,1500,500,1500,100,1900,500,2300,500,2300,900,1900,900,1900,500))
SDO_GEOMETRY(2004,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1,1,3,2,1,7,1003,1),
SDO_ORDINATE_ARRAY(10,5,10,10,20,10,10,105,15,105,20,110,10,110,10,105))

9 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.53. T_GEOMETRY/ST_Geometry2DimInfo [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Geometry2DimInfo -- Converts any non-null geometry into an SDO_DIM_ARRAY capable of being written to USER_SDO_GEOM_METADATA by computing MBR of object.
```

SYNOPSIS

```    Static Function ST_Geometry2DimInfo (
p_dim_array in mdsys.sdo_dim_array,
p_srid      in integer default NULL
)
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

DESCRIPTION

```    Calculates a geometry's envelope and converts it to an SDO_DIM_ARRAY structure by populating its SDO_DIM_ELEMENT sdo_lb/sdo_ub values with computed envelope.
If T_GEOMETRY's projected attribute is 1, X/Y are returned for the SDO_DIM_NAMES; if 0, LONG/LAT are returned as the SDO_DIM_NAMES
```

RESULT

```    polygon (T_GEOMETRY) -- Returns polygon with single optimized rectangle exterior ring.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),
((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
Union All
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom
From Dual
Union All
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,projected=>0) as tgeom
From Dual
)
select a.tgeom.ST_Geometry2Diminfo() as dimInfo
from data a;

DIMINFO
-----------------------------------------------------------------------------------------------------------------------------
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X',   0,200,0.005), SDO_DIM_ELEMENT('Y',  0,200,0.005))
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X',   0, 10,0.005), SDO_DIM_ELEMENT('Y',  0, 10,0.005), SDO_DIM_ELEMENT('Z',1,6,0.005))
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('LONG',0, 10,0.005), SDO_DIM_ELEMENT('LAT',0, 10,0.005), SDO_DIM_ELEMENT('Z',1,6,0.005))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.54. T_GEOMETRY/ST_GeometryType [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_GeometryType -- Returns underlying mdsys.sdo_geometry's SQLMM Geometry Type.
```

SYNOPSIS

```    Member Function ST_GeometryType
Return VarChar2 Deterministic,
```

DESCRIPTION

```    Is a wrapper over the ST_GEOMETRY ST_GeometryType() method. Returns textual description of the geometry type
eg ST_Polygon for x003 mdsys.sdo_geometry object.
```

NOTES

```    Is an implementation of OGC ST_GeometryType method.
```

RESULT

```    geometry type (Integer) -- 1:Point; 2:Linestring; 3:Polygon; 4:Collection; 5:MultiPoint; 6:MultiLinestring; 7:MultiPolygon
```

EXAMPLE

```    With Geometries As (
select T_GEOMETRY(sdo_geometry(2001,NULL,sdo_point_type(10,11,null),null,null),0.005,2,1) as TGEOM
From Dual Union All
Select T_GEOMETRY(sdo_geometry(2002,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(10,45, 20,45, 23,48, 20,51, 10,51)),0.005,1,1) as TGEOM
From Dual Union All
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3),sdo_ordinate_array(0,0, 10,10)),0.005,1,1) as TGEOM
From Dual Union All
select t_geometry(sdo_geometry(2003,null,null,sdo_elem_info_array(1,1005,2, 1,2,1, 7,2,2),
SDO_ORDINATE_ARRAY (10,128, 10,125, 20,125, 20,128, 15,130, 10,128)),0.005,2,1) as TGEOM
From Dual Union All
Select T_GEOMETRY(sdo_geometry(2002,null,null,sdo_elem_info_array(1,4,3, 1,2,1, 3,2,2, 7,2,1),
sdo_ordinate_array(10,45, 20,45, 23,48, 20,51, 10,51)),0.005,2,1) as TGEOM
From Dual
)
select a.TGeom.ST_GTYPE() as gtype,
a.TGeom.ST_GeometryType() as Geometrytype
From Geometries a;

GTYPE GEOMETRYTYPE
----- ----------------
1 ST_POINT
2 ST_LINESTRING
3 ST_POLYGON
3 ST_CURVEPOLYGON
2 ST_COMPOUNDCURVE
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.55. T_GEOMETRY/ST_GType [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_GType -- Returns underlying mdsys.sdo_geometry's geometry type by executing mdsys.sdo_geometry method get_gtype().
```

SYNOPSIS

```    Member Function ST_GType
Return Integer Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry get_gtype() method ie SELF.GEOM.Get_Gtype()
```

RESULT

```    geometry type (Integer) -- 1:Point; 2:Linestring; 3:Polygon; 4:Collection; 5:MultiPoint; 6:MultiLinestring; 7:MultiPolygon
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.56. T_GEOMETRY/ST_hasCircularArcs [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_hasCircularArcs -- A function that tests whether underlying mdsys.sdo_geometry contains circular arcs.
```

SYNOPSIS

```    Member Function ST_hasCircularArcs
Return integer Deterministic,
```

DESCRIPTION

```    Examines sdo_elem_info to see if contains ETYPE/Interpretation that describes a circular arc, or even a full circle.
```

RESULT

```    BOOLEAN (Integer) -- 1 if has circular arcs.
```

EXAMPLE

```    with data as (
select 1 as geomId, T_GEOMETRY(sdo_geometry(2002,null,null,sdo_elem_info_array(1,4,2,1,2,1,3,2,2),sdo_ordinate_array(0,0,10,0,20,10,30,0)),0.005,2,1) as tgeom
From Dual union all
select 2 as geomId, t_geometry(sdo_geometry('LINESTRING (100.0 0.0, 400.0 0.0)',NULL),0.005,2,1) as tgeom
From Dual
)
select a.geomId, a.tgeom.ST_HasCircularArcs() as hasCircularArc
from data a;

GEOMID HASCIRCULARARC
------ --------------
1              1
2              0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Dec 2008 - Original coding within GEOM package.
Simon Greener - Jan 2013 - Recoded for T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.57. T_GEOMETRY/ST_HasDimension [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_HasDimension -- Returns spatial dimension of underlying geometry.
```

SYNOPSIS

```    Member Function ST_HasDimension (
p_dim  in integer default 2
)
Return Integer Deterministic,
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('POINT(0 0)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GType()           as sdo_gtype,
a.tgeom.ST_GeometryType()    as geomType,
a.tgeom.ST_CoordDimension()  as coordDim,
a.tgeom.ST_Dimension()       as geomDim,
a.tgeom.ST_HasDimension(1)   as hasDim1
from data a;

SDO_GTYPE GEOMTYPE       COORDDIM GEOMDIM HASDIM1
--------- -------------- -------- ------- -------
1 ST_POINT              2       0       0
2 ST_LINESTRING         2       1       1
3 ST_POLYGON            2       2       0
```

DESCRIPTION

```    This method inspects the underlying geometry and determines if has specified Geometric Dimension (ST_Dimension).
Returns 1 if geometry is of that dimension and 0 otherwise.
```

RESULT

```   true(1)/false(0) (Integer) -- If p_dim is 0 and underlying geometry is POINT then 1 is returned else 0.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.58. T_GEOMETRY/ST_hasM [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_hasM -- Tests geometry to see if coordinates include a measure.
```

SYNOPSIS

```    Member Function ST_hasM
Return Integer Deterministic,
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry(3301,NULL,SDO_POINT_TYPE(0,0,0),null,null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GType()          as sdo_gtype,
a.tgeom.ST_GeometryType()   as geomType,
a.tgeom.ST_CoordDimension() as coordDim,
a.tgeom.ST_HasM()           as hasM
from data a;

SDO_GTYPE GEOMTYPE       COORDDIM HASM
--------- -------------- -------- ----
1 ST_POINT              3    1
2 ST_LINESTRING         2    0
2 ST_LINESTRING         3    0
2 ST_LINESTRING         3    1
```

DESCRIPTION

```    Examines SELF.GEOM.SDO_GTYPE (DLNN etc) to see if sdo_gtype has measure ordinate eg 3302 not 3002.
Similar to SQL Server Spatial hasM method.
```

RESULT

```    BOOLEAN (Integer) -- 1 is measure ordinate exists, 0 otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.59. T_GEOMETRY/ST_hasRectangles [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_hasRectangles -- A function that tests whether underlying mdsys.sdo_geometry contains optimized rectangles.
```

SYNOPSIS

```    Member Function ST_hasRectanglles
Return integer Deterministic,
```

DESCRIPTION

```    Examines sdo_elem_info to see if contains ETYPE/Interpretation that describes an optimized rectangle.
eg SDO_ELEM_INFO_ARRAY(1,1003,3) ie the interpretation value of 3 means optimized rectangle.
```

RESULT

```    BOOLEAN (Integer) -- 1 if has optimized rectangles.
```

EXAMPLE

```    with data as (
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0))',null),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3),sdo_ordinate_array(0,0,20,20)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(0,0,20,20, 10,10,15,15)),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_HasRectangles() as numRectangles
from data a;

HASRECTANGLES
-------------
0
1
1
```

NOTES

```    Calls ST_NumRectangles and returns 1 if num is > 0 or 0 otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jun 2011 - Original coding for GEOM package.
Simon Greener - Jan 2013 - Recoded for T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.60. T_GEOMETRY/ST_HasZ [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_HasZ -- Checks if underlying geometry has z ordinate.
```

SYNOPSIS

```    Member Function ST_HasZ
Return Integer Deterministic,
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('POINT(0 0)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3001,NULL,SDO_POINT_TYPE(0,0,0),null,null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GType()          as sdo_gtype,
a.tgeom.ST_GeometryType()   as geomType,
a.tgeom.ST_CoordDimension() as coordDim,
a.tgeom.ST_HasZ()           as hasZ
from data a;

SDO_GTYPE GEOMTYPE       COORDDIM HASZ
--------- -------------- -------- ----
1 ST_POINT              2    0
1 ST_POINT              3    1
2 ST_LINESTRING         2    0
2 ST_LINESTRING         3    1
2 ST_LINESTRING         3    0
```

DESCRIPTION

```    This method inspects the underlying geometry and determines if has a Z ordinate (3D).
Returns 1 if geometry has Z ordinate and 0 otherwise.
```

RESULT

```   true(1)/false(0) (Integer) -- If 2001 POINT then 0; if 3001 then 1; if 3002 then1, if 3302 then 0.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.61. T_GEOMETRY/ST_inCircularArc [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_inCircularArc -- A function that checks if the provided point is part of a circular arc.
```

SYNOPSIS

```    Member Function ST_inCircularArc
Return integer Deterministic,
```

DESCRIPTION

```    Examines underlying geometry and checks to see if the provided point reference (id) is part of a circular arc or not.
Returns position in circular arc:
0 means not in a circular arc
1 means is first point in circular arc
2 means is second point in circular arc
3 means is third point in circular arc
```

RESULT

```    BOOLEAN (integer) -- Returns position of point in circular arc (0 if not part of a circular arc)
```

EXAMPLE

```    with data as (
select T_GEOMETRY(sdo_geometry(2002,null,null,sdo_elem_info_array(1,4,2,1,2,1,3,2,2),sdo_ordinate_array(0,0,10,0,20,10,30,0)),0.005,2,1) as tgeom
From Dual
)
select a.tgeom.ST_InCircularArc(t.IntValue) as positionInCircularArc
from data a,
table(tools.generate_series(1,a.tgeom.ST_NumPoints(),1)) t

POSITIONINCIRCULARARC
---------------------
0
1
2
3
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.62. T_GEOMETRY/ST_InsertVertex [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_InsertVertex -- Function which inserts new coordinate (p_vertex) at position p_vertex.id into the supplied geometry.
```

SYNOPSIS

```    Function ST_InsertVertex (
p_vertex T_Vertex
)
Returns T_Geometry
```

DESCRIPTION

```    Function that inserts the vertex p_vertex into into supplied geometry as position p_vertex.id.
All existing vertices are shuffled down ie Insert is "add before" except at end.
Supplied p_vertex must have Z and W coded correctly.
p_vertex.id values:
1. null -> defaults to 1;
2. -1   -> maximum number of points ie SELF.ST_NumPoints()
3. Greater than SELF.ST_NumPoints() -> maximum number of points ie SELF.ST_NumPoints()
The inserted coordinate's XY ordinates are rounded to SELF.dprecision number of decimal digits of dprecision.
```

ARGUMENTS

```    p_vertex    (t_vertex) -- Insert coordinate. p_vertex.id is position in geometry to insert new vertex: between 1 and SELF.ST_NumPoints.
```

RESULT

```    geometry -- Geometry with coordinate inserted.
```

EXAMPLE

```    -- Insert 2D vertex into 2D linestring
select t_geometry(sdo_geometry('LINESTRING(0 0,2 2)',null),0.005,2,1)
.ST_InsertVertex(
T_Vertex(p_id       =>2,
p_x        =>1,
p_y        =>1,
p_sdo_gtype=>2001,
p_sdo_srid =>NULL)
).ST_AsText() as newGeom
from dual;

NEWGEOM
--------------------------
LINESTRING (0 0, 1 1, 2 2)

-- Update 3D point....
select t_geometry(sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1, 2,2,2)),0.005,2,1)
.ST_InsertVertex(
T_Vertex(p_id       =>2,
p_x        =>1.5,
p_y        =>1.5,
p_z        =>1.5,
p_sdo_gtype=>3001,
p_sdo_srid =>NULL)
).geom as UpdatedGeom
from dual;

UPDATEDGEOM
---------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,1.5,1.5,1.5))

-- Insert 3D point into 3D linestring.
select t_geometry(sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,2,2,2)),0.005,2,1)
.ST_InsertVertex(
T_Vertex(p_id       =>2,
p_x        =>1,
p_y        =>1,
p_z        =>1.5,
p_sdo_gtype=>2001,
p_sdo_srid =>NULL)
).geom as newGeom
from dual;

NEWGEOM
-----------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,1,1,1.5,2,2,2))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM package.
Simon Greener - July 2011     - Port to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.63. T_GEOMETRY/ST_Intersection [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Intersection -- Returns the spatial intersection of two sdo_geometry objects.
```

SYNOPSIS

```    Member Function ST_Intersection(p_geometry in mdsys.sdo_geometry,
p_order    in varchar2 Default 'FIRST')
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function intersects two linestrings, polygons or a mix of either.
The p_order parameter determines whether SELF.geom is the first argument to sdo_intersection or second.
Intersection could result in a Point, Line, Polygon or GeometryCollection.
```

ARGUMENTS

```    p_geometry (sdo_geometry) -- A linestring or polygon.
p_order        (varchar2) -- Should be FIRST or SECOND.
```

RESULT

```    geometry (T_GEOMETRY) -- Result of intersecting the geometries.
```

NOTES

```    Uses MDSYS.SDO_GEOM.SDO_INTERSECTION if Oracle database version is 12cR1 or above
or if the customer is licensed for the Spatial object before 12c.
```

ERRORS

```    Will throw exception if the user is not licensed to call MDSYS.SDO_GEOM.SDO_INTERSECTION.
-20102  MDSYS.SDO_GEOM.SDO_INTERSECTION only supported for Locator users from 12c onwards.';
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.64. T_GEOMETRY/ST_isClosed [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isClosed -- Checks if underlying geometry object is simple as per the OGC.
```

SYNOPSIS

```    Member Function ST_isClosed
Return integer Deterministic,
```

DESCRIPTION

```    This function checks to see if the underlying linestring is closed.
A closed linestring is one whose start/end points are the same as in a polygon ring.
```

RESULT

```    1/0 (integer) -- 1 if Closed, 0 if not.
With data as (
select 'Simple 2 point line' as test,
t_geometry(sdo_geometry('LINESTRING(0 0,1 1)',null),0.005,2,1) as tGeom
from dual union all
select 'Line with 4 Points with two segments crossing' as test,
t_geometry(sdo_geometry('LINESTRING(0 0,1 1,1 0,0 1)',null),0.005,2,1) as tGeom
from dual union all
select 'Line whose start/end points are the same (closed)' as test,
t_geometry(sdo_geometry('LINESTRING(0 0,1 0,1 1,0 1,0 0)',null),0.005,2,1) as tGeom
from dual
)
Select a.test, a.tGeom.ST_Closed() as isSimple
from data a;

TEST                                              ISSIMPLE
------------------------------------------------- --------
Simple 2 point line                                      1
Line with 4 Points with two segments crossing            0
Line whose start/end points are the same (closed)        1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.65. T_GEOMETRY/ST_isEmpty [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isEmpty -- Checks if underlying geometry object is empty.
```

SYNOPSIS

```    Member Function ST_isEmpty
Return integer Deterministic,
```

NOTES

```    Is an implementation of OGC ST_isEmpty method.
cf "POINT EMPTY"/"LINESTRING EMPTY"/"POLYGON EMPTY" OGC
```

DESCRIPTION

```    This function checks to see if the underlying object is empty.
While some Spatial Types define empty via WKT string such as 'LINESTRING EMPTY', for oracle
we determine that an sdo_geometry object is Empty if:
1. The object is null;
2. The object exists but all of its 5 attributes (sdo_gtype, sdo_srid, sdo_point, sdo_elem_info, sdo_ordinates) are null.
3. Or the object exists but all of its 3 main geometric attributes (sdo_point, sdo_elem_info, sdo_ordinates) are null.
```

RESULT

```    1/0 (integer) -- 1 if Empty, 0 if not.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.66. T_GEOMETRY/ST_isOrientedPoint [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isOrientedPoint -- A function that tests whether underlying mdsys.sdo_geometry is an oriented point.
```

SYNOPSIS

```    Member Function ST_isOrientedPoint
Return integer Deterministic,
```

DESCRIPTION

```    Examines underlying point geometry to see if contains oriented points.
Single Oriented Point:
Sdo_Elem_Info = (1,1,1, 3,1,0), SDO_ORDINATE_ARRAY(12,14, 0.3,0.2)));
The Final 1,0 In 3,1,0 Indicates That This Is An Oriented Point.
Multi Oriented Point:
Sdo_Elem_Info_Array(1,1,1, 3,1,0, 5,1,1, 7,1,0), Sdo_Ordinate_Array(12,14, 0.3,0.2, 12,10, -1,-1)));
```

RESULT

```    BOOLEAN (Integer) -- 1 if has orientes points.
```

EXAMPLE

```    with data as (
select 1 as geomId, T_GEOMETRY(sdo_geometry(2001,null,null,sdo_elem_info_array(1,1,1, 3,1,0), sdo_ordinate_array(12,14, 0.3,0.2)),0.005,2,1) as tgeom
From Dual union all
select 2 as geomId, t_geometry(sdo_geometry('LINESTRING (100.0 0.0, 400.0 0.0)',NULL),0.005,2,1) as tgeom
From Dual Union All
select 3 as geomId, T_GEOMETRY(sdo_geometry(2005,null,null,Sdo_Elem_Info_Array(1,1,1, 3,1,0, 5,1,1, 7,1,0), Sdo_Ordinate_Array(12,14, 0.3,0.2, 12,10, -1,-1)),0.005,2,1) as tgeom
From Dual Union All
select 4 as geomId, T_GEOMETRY(sdo_geometry(2005,null,null,Sdo_Elem_Info_Array(1,1,1, 3,1,0, 5,1,1, 7,1,0, 9,1,1), Sdo_Ordinate_Array(12,14, 0.3,0.2, 12,10, -1,-1, -10,-10)),0.005,2,1) as tgeom
From Dual
)
select a.geomId, a.tgeom.ST_GeometryType() as geomType, a.tgeom.ST_isOrientedPoint() as isOrientedPoint
from data a;

GEOMID GEOMTYPE      ISORIENTEDPOINT
------ ------------- ---------------
1 ST_POINT                    1
2 ST_LINESTRING               0
3 ST_MULTIPOINT               1
4 ST_MULTIPOINT               1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Dec 2008 - Original coding within GEOM package.
Simon Greener - Jan 2013 - Recoded for T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.67. T_GEOMETRY/ST_isSimple [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isSimple -- Checks if underlying geometry object is simple as per the OGC.
```

SYNOPSIS

```    Member Function ST_isSimple
Return integer Deterministic,
```

NOTES

```    Is an implementation of OGC ST_isSimple method.
```

DESCRIPTION

```    This function checks to see if the underlying object is simple.
A simple linestring is one for which none of its segments cross each other.
This is not the same as a closed linestring whose start/end points are the same as in a polygon ring.
This function does this by using the Oracle MDSYS.ST_GEOMETRY.ST_isSimple method.
```

RESULT

```    1/0 (integer) -- 1 if Simple, 0 if not.

With data as (
select 'Simple 2 point line' as test,
t_geometry(sdo_geometry('LINESTRING(0 0,1 1)',null),0.005,2,1) as tGeom
from dual union all
select 'Line with 4 Points with two segments crossing' as test,
t_geometry(sdo_geometry('LINESTRING(0 0,1 1,1 0,0 1)',null),0.005,2,1) as tGeom
from dual union all
select 'Line whose start/end points are the same (closed)' as test,
t_geometry(sdo_geometry('LINESTRING(0 0,1 0,1 1,0 1,0 0)',null),0.005,2,1) as tGeom
from dual
)
Select a.test, a.tGeom.ST_isSimple() as isSimple
from data a;

TEST                                              ISSIMPLE
------------------------------------------------- --------
Simple 2 point line                                      1
Line with 4 Points with two segments crossing            0
Line whose start/end points are the same (closed)        1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.68. T_GEOMETRY/ST_isValid [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isValid -- Executes, and returns, result of mdsys.sdo_geometry method ST_isValid().
```

SYNOPSIS

```    Member Function ST_isValid
Return Integer Deterministic,
```

NOTES

```    Is an implementation of OGC ST_isValid method.
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry method SELF.GEOM.ST_isValid().
```

RESULT

```    BOOLEAN (Integer) -- If mdsys.sdo_geometry is valid (see SDO_GEOM.VALIDATE_GEOMETRY) returns 1 else 0.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.69. T_GEOMETRY/ST_isValidContext [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isValidContext -- Executes sdo_geom.validate_geometry_with_context against underlying geometry and returns value.
```

SYNOPSIS

```    Member Function ST_isValidContext
Return varchar2 Deterministic,
```

DESCRIPTION

```    This function executes the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function and returns the result.
```

RESULT

```    result (varchar2) -- Returns result of SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.70. T_GEOMETRY/ST_Length [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Length -- Returns length of underlying linestring or polygon (rings) sdo_geometry
```

SYNOPSIS

```    Member Function ST_Length (
p_unit  in varchar2 default NULL,
p_round in integer  default 0 )
)
Return Number Deterministic
```

ARGUMENTS

```    p_unit (varchar2) - Oracle Unit of Measure eg unit=M.
p_round (integer) - Whether to round result using PRECISION of T_GEOMETRY
```

DESCRIPTION

```    This function computes length of linestring or polygon boundary of underlying sdo_geometry.
Result is in the distance units of the SDO_SRID, or in p_units where supplied.
Result is rounded to SELF.PRECISION if p_round is true (1), otherwise false(0) no rounding.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual union all
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',28356),0.0005,3,1) as tgeom From Dual
)
select a.tgeom.ST_Length(case when a.tGeom.ST_Srid() = 28356 then 'unit=CENTIMETER' else null end,0) as length,
a.tgeom.ST_Length(case when a.tGeom.ST_Srid() = 28356 then 'unit=CENTIMETER' else null end,1) as round_length
from data a;

LENGTH ROUND_LENGTH
----------- ------------
30           30
30.44595368       30.446
30           30
8400         8400
```

NOTES

```    Length of 3D linestrings and polygons is an Enterprise Spatial feature.
The function detects if licensed and computes length using sdo_geom.sdo_length.
If the database is not licensed, the function computes 3D length itself (slower).
```

RESULT

```    length (Number) -- Length in SRID unit of measure or in supplied units (p_unit) possibly rounded to SELF.Precision
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.71. T_GEOMETRY/ST_Line2Cogo [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```   ST_Line2Cogo - Creates Cogo Instructions from linestring segments.
```

SYNOPSIS

```   Member Function ST_Line2Cogo
Return &&INSTALL_SCHEMA..T_BEARING_DISTANCES Pipeline,
```

DESCRIPTION

```    This function converts the underlying simple linestring to a set of bearings and distances in T_BEARINGS_DISTANCES array format.
The first T_BEARING_DISTANCE element will be the bearing and distance from an implied start point of 0,0.
```

ARGUMENTS

```    p_unit (varchar2) - For when SRID <> NULL, an oracle unit of measure eg unit=M.
```

RESULT

```    Cogo Instructions - Cogo instructions coded as T_BEARING_DISTANCES array of T_BEARING_DISTANCE
```

EXAMPLE

```    -- Create 2D Line from COGO then reverse back to COGO ....
With data as (
select f.line
from (select t_geometry(sdo_geometry(2001,null,sdo_point_type(0.0,3.5,null),null,null),0.005,2,1)
.ST_Cogo2Line (
t_bearing_distances(
t_bearing_distance(180.00,3.50,null),
t_bearing_distance( 90.00,3.50,null),
t_bearing_distance(  0.00,3.50,null),
t_bearing_distance( 43.02,5.43,null),
t_bearing_distance(270.00,9.50,null))
) as line
from dual
) f
)
select COGO.DD2DMS(COGO.ST_Degrees(t.bearing)) as bearing,
Round(t.distance,3) as distance
from data a,
table(a.line.ST_Line2Cogo()) t;

BEARING  DISTANCE
-------- --------
0°0'0"        3.5
180°0'0"      3.5
90°0'0"       3.5
0°0'0"        3.5
43°1'12"     5.43
270°0'0"      9.5

6 rows selected

-- Create 3D Line from COGO then reverse back to COGO ....
With data as (
select f.line
from (select t_geometry(sdo_geometry(3001,null,sdo_point_type(0.0,3.5,0.2),null,null),0.005,2,1)
.ST_Cogo2Line (
t_bearing_distances(
t_bearing_distance(180.00,3.50,1.1),
t_bearing_distance( 90.00,3.50,2.0),
t_bearing_distance(  0.00,3.50,3.0),
t_bearing_distance( 43.02,5.43,4.4),
t_bearing_distance(270.00,9.50,5.2))
) as line
from dual
) f
)
select COGO.DD2DMS(COGO.ST_Degrees(t.bearing)) as bearing,
Round(t.distance,3)                     as distance,
t.z
from data a,
table(a.line.ST_Line2Cogo()) t;

BEARING  DISTANCE   Z
-------- -------- ---
0°0'0"      3.506 0.2
180°0'0"    3.614 1.1
90°0'0"     3.614   2
0°0'0"      3.64    3
43°1'12"    5.608 4.4
270°0'0"    9.534 5.2

6 rows selected
NOTE
Measures not supported: see LRS functions.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.72. T_GEOMETRY/ST_LineShift [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LineShift -- Moves linestring parallel to imaginary line drawnn from first to last vertex.
```

SYNOPSIS

```    Member Function ST_LineShift(p_distance in number)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    Function that extracts the first and last vertex of a linestring, compute a single offset at right angles to an
imaginary line from first to last vertex, then apply offset to all vertices in the linestring.
Is a "simple" version of the more complex ST_Parallel.
```

ARGUMENTS

```    p_distance (Number)   - Value +/- integer value.
```

NOTES

```    Only supports linestrings.
```

TODO

```    Add support for SRID units of measure (ie parameter p_unit).
```

RESULT

```    geometry (T_GEOMETRY) -- Input linestring moved parallel by p_distance units
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2008 - Original coding in GEOM package.
Simon Greener - January 2013  - Port/Rewrite to T_GEOMETRY object function member.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Add_Measure -- Adds measures to 2D (multi)linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Add_Measure(p_start_measure IN Number Default NULL,
p_end_measure   IN Number Default NULL,
p_unit          IN VarChar2 Default NULL)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Takes a 2D geometry and assigns supplied measures to the start/end vertices
and adds proportioned measure values to all vertices in between.
```

ARGUMENTS

```    p_start_measure (Number)   - Measure defining start point for geometry.
p_end_measure   (Number)   - Measure defining end point for geometry.
p_unit          (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    geometry (T_GEOMETRY) -- Measured geometry
```

EXAMPLE

```    select t_geometry(SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)),
0.0005,3,1)
.ST_Round(3,3,1,2)
.geom as mGeom
from dual;

MGEOM
---------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3302,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.74. T_GEOMETRY/ST_LRS_Concatenate [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Concatenate -- Rescales geometry measures and optionally offsets them, stretching the geometry.
```

SYNOPSIS

```    Member Function ST_LRS_Concatenate(p_lrs_segment IN mdsys.sdo_geometry)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    This function appends the provided lrs segment to the SELF.
Ensures measures are updated.
```

ARGUMENTS

```    p_lrs_segment (MDSYS.SDO_GEOMETRY) - LRS Linestring.
RETURN
concatenated linestring (T_GEOMETRY)
```

AUTHOR

```    Simon Greener
```

HISTORY

```     Simon Greener - Aug 2017 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.75. T_GEOMETRY/ST_LRS_Dim [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Dim -- Tests underlying mdsys.sdo_geometry to see if coordinates include a measure ordinate and returns measure ordinate's position.
```

SYNOPSIS

```    Member Function ST_Lrs_Dim
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc) measure ordinate position (L) and returns it.
```

RESULT

```    BOOLEAN (Integer) -- L from DLNN.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.76. T_GEOMETRY/ST_LRS_End_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_End_Measure -- Returns M value of last vertex in measured geometry.
```

SYNOPSIS

```    Member Function ST_LRS_End_Measure
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Returns end measure associated with last vertex in a measured line-string.
If the line-string is not measured it returns the length of the linestring.
```

ARGUMENTS

```    p_unit (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    measure (Number)  - Measure value of first vertex in a measured line-string: 0 if not measured.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.77. T_GEOMETRY/ST_LRS_Find_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Find_Measure -- Snaps input point to measured linestring returning measure value(s)
```

SYNOPSIS

```    Member Function ST_LRS_Find_Measure(p_geom     in mdsys.sdo_geometry,
p_measureN in integer default 1,
p_unit     in varchar2    default null)
Return mdsys.sdo_ordinate_array Deterministic,
```

DESCRIPTION

```    Given a point near a measured linestring, this function returns the measures
of all lines that have same distance to the linestring.
```

ARGUMENTS

```    p_geom     (MDSYS.SDO_GEOMETRY) - Geometry for which a measure is needed.
p_measureN (Integer)            - Particular measure to be returned. 0 = all possible measures, 1 is the first etc.
p_unit     (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    measure (MDSYS.SDO_ORDINATE_ARRAY) -- All measures where more than one is closest to line.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.78. T_GEOMETRY/ST_LRS_Find_MeasureN [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Find_MeasureN -- Returns nominated measure nearest to supplied point if it exists.
```

SYNOPSIS

```    Member Function ST_LRS_Find_MeasureN(p_geom     in mdsys.sdo_geometry,
p_measureN in integer default 1,
p_unit     in varchar2    default null)
Return mdsys.sdo_ordinate_array Deterministic,
```

DESCRIPTION

```    Given a point near a measured linestring, this function returns the nominated
measure nearest to that point if it exists. For example, requesting p_measureN=2
may return NULL if only one measure exists that is closest to the linestring at some point.
```

ARGUMENTS

```    p_geom     (MDSYS.SDO_GEOMETRY) - Geometry for which a measure is needed.
p_measureN (Integer)            - Particular measure to be returned. 1..AllPossibleMeasures
p_unit     (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    measure (Number) - First measure on line closest to point.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.79. T_GEOMETRY/ST_LRS_Find_Offset [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Find_Offset -- Returns smallest (perpendicular) offset from supplied point to the linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Find_Offset(p_geom in mdsys.sdo_geometry,
p_unit in varchar2    default null)
Return Number Deterministic,
```

DESCRIPTION

```    Given a point this function returns the smallest (perpendicular) offset from
the point to the line-string.
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - Point geometry for which a measure is needed.
p_unit  (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    offset (Number) - Perpendicular offset distance from point to nearest point on line.
Value is negative if on left of line; positive if on right.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.80. T_GEOMETRY/ST_LRS_Get_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Get_Measure -- The function returns the measure of the T_GEOMETRY point object.
```

SYNOPSIS

```    Member Function ST_LRS_Get_Measure
Return number deterministic,
```

DESCRIPTION

```    Returns the measure value of a measured point.
If point 3301, the value of the Z attribute is returned etc.
```

RESULT

```    Measure Value (Number)       - Measure value of point (ie 3301, 4301, 4401). If n001 returns NULL.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.81. T_GEOMETRY/ST_LRS_Intersection [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Intersection -- Intersects input geometry against measured linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Intersection(P_GEOM In Mdsys.Sdo_Geometry,
P_unit in varchar2 default null)
Return t_geometry Deterministic,
```

DESCRIPTION

```    Takes as input a linestring, multi-linestring, polygon, MultiPolygon or point.
SELF must be a measured linestring.
```

ARGUMENTS

```    p_geom (mdsys.sdo_geometry) - Geometry for which a intersection calculation is needed.
p_unit           (VarChar2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    Geometry (T_GEOMETRY) - Measured Linestring or point
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jul 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.82. T_GEOMETRY/ST_LRS_Is_Measure_Decreasing [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Is_Measure_Decreasing -- Checks if M values decrease in value over all of the linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Is_Measure_Decreasing
Return varchar2 deterministic,
```

DESCRIPTION

```    Checks all measures of all vertices in a linestring from start to end.
Computes difference between each pair of measures. If all measure differences
decrease then TRUE is returned, otherwise FALSE. For non-measured line-strings
the value is always FALSE.
```

RESULT

```    True/False (VarChar2) - TRUE if measures are decreasing, FALSE otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.83. T_GEOMETRY/ST_LRS_Is_Measure_Increasing [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Is_Measure_Increasing -- Checks if M values increase in value over all of the linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Is_Measure_Increasing
Return varchar2 deterministic,
```

DESCRIPTION

```    Checks all measures of all vertices in a linestring from start to end.
Computes difference between each pair of measures. If all measure differences
increase then TRUE is returned, otherwise FALSE. For non-measured line-strings
the value is always TRUE.
```

RESULT

```    True/False (VarChar2) -- TRUE if measures are increasing, FALSE otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.84. T_GEOMETRY/ST_LRS_Is_Shape_Pt_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Is_Shape_Pt_Measure -- Checks if M value is associated with a vertex.
```

SYNOPSIS

```    Member Function ST_LRS_Is_Shape_Pt_Measure(p_measure in number)
Return varchar2 deterministic,
```

DESCRIPTION

```    Checks all measures of all vertices in a linestring from start to end to see
if a measure on a shape vertex has the same measure value as p_measure.
Uses measure increasing/decreasing to avoid having to test all vertices in linestring.
```

RESULT

```    True/False (VarChar2) -- TRUE if measure exists at a shape vertex.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2017 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.85. T_GEOMETRY/ST_LRS_isMeasured [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_isMeasured -- Tests geometry to see if coordinates include a measure.
```

SYNOPSIS

```    Member Function ST_LRS_isMeasured
Return Integer Deterministic,
With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GType()          as sdo_gtype,
a.tgeom.ST_GeometryType()   as geomType,
a.tgeom.ST_CoordDimension() as coordDim,
a.tgeom.ST_LRS_isMeasured() as isMeasured
from data a;

SDO_GTYPE GEOMTYPE       COORDDIM isMeasured
--------- -------------- -------- ----------
2 ST_LINESTRING         2          0
2 ST_LINESTRING         3          0
2 ST_LINESTRING         3          1
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc) to see if sdo_gtype has measure ordinate eg 3302 not 3002.
```

RESULT

```    BOOLEAN (Integer) -- 1 is measure ordinate exists, 0 otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.86. T_GEOMETRY/ST_LRS_Locate_Along [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Locate_Along -- Wrapper over ST_LRS_Locate_Measure
```

SYNOPSIS

```    Member Function ST_LRS_Locate_Along(p_measure in number,
p_offset  in number   default 0,
p_unit    in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

ARGUMENTS

```    p_measure (Number)   - Measure defining point to be located.
p_offset  (Number)   - Offset value left (negative) or right (positive) in p_units.
p_unit    (VarChar2) - Unit of measure for distance calculations when defining snap point
```

RESULT

```    point (T_GEOMETRY) - Point at measure/offset.
```

```    ST_Locate_Measure(p_measure in number, ...)
```

15.87. T_GEOMETRY/ST_LRS_Locate_Between [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Locate_Between -- Converts supplied measures into single point or linestring.
```

DESCRIPTION

```    Wrapper over ST_LRS_Locate_Between
```

ARGUMENTS

```    p_start_measure (Number)   - Measure defining start point of located geometry.
p_end_measure   (Number)   - Measure defining end point of located geometry.
p_offset        (Number)   - Offset value left (negative) or right (positive) in p_units.
p_unit          (VarChar2) - Unit of measure for distance calculations when defining snap point
```

RESULT

```    point (T_GEOMETRY) - Point or Line between start/end measure with offset.
```

```    ST_Locate_Measures(p_start_measure in number, ...)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

15.88. T_GEOMETRY/ST_LRS_Locate_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Locate_Measure -- Returns point geometry at supplied measure along linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Locate_Measure (p_measure in number,
p_offset  in number   default 0,
p_unit    in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Given a measure or length, this function returns a mdsys.sdo_geometry point
at that measure or offset the supplied amount.
```

NOTES

```    Handles line-strings with reversed measures.
```

ARGUMENTS

```    p_measure (Number)   - Measure defining point to be located.
p_offset  (Number)   - Offset value left (negative) or right (positive) in p_units.
p_unit    (VarChar2) - Unit of measure for distance calculations when defining snap point
```

RESULT

```    point (T_GEOMETRY) - Point at measure/offset.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.89. T_GEOMETRY/ST_LRS_Locate_Measures [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Locate_Measures -- Converts supplied measures into single point or linestring.
```

SYNOPSIS

```    Member Function ST_LRS_Locate_Measures(p_start_measure in number,
p_end_measure   in number,
p_offset        in number default 0,
p_unit          varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Given two measures or lengths, this function returns the point defined by
those measure (if equal) or a line-string if not. The geometry may be offset
the supplied amount.
```

NOTES

```    Currently does not handle line-strings with reversed measures.
```

ARGUMENTS

```    p_start_measure (Number)   - Measure defining start point of located geometry.
p_end_measure   (Number)   - Measure defining end point of located geometry.
p_offset        (Number)   - Offset value left (negative) or right (positive) in p_units.
p_unit          (VarChar2) - Unit of measure for distance calculations when defining snap point
```

RESULT

```    point (T_GEOMETRY) - Point at measure/offset.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

15.90. T_GEOMETRY/ST_LRS_Locate_Point [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Locate_Point -- Wrapper over ST_LRS_Locate_Measure
```

SYNOPSIS

```    Member Function ST_LRS_Locate_Point (p_measure in number,
p_offset  in number default 0)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Given a measure or length, this function returns a mdsys.sdo_geometry point
at that measure or offset the supplied amount.
```

NOTES

```    Handles line-strings with reversed measures.
```

ARGUMENTS

```    p_measure (Number)   - Measure defining point to be located.
p_offset  (Number)   - Offset value left (negative) or right (positive) in p_units.
```

RESULT

```    point (T_GEOMETRY) - Point at measure/offset.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2017 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.91. T_GEOMETRY/ST_LRS_Measure_Range [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Measure_Range -- Returns Last Vertex M Value - First Vertex M Value.
```

SYNOPSIS

```    Member Function ST_LRS_Measure_Range(p_unit in varchar2 default null)
Return Number deterministic,
```

DESCRIPTION

```    Returns end vertex measure value - start vertex measure value.
If line-string not measured, returns length of line.
```

ARGUMENTS

```    p_unit (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    measure (Number) -- Measure range for measured line-string: length if not measured.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.92. T_GEOMETRY/ST_LRS_Measure_To_Percentage [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Measure_To_Percentage -- Converts supplied M value to percentage of M range.
```

SYNOPSIS

```    Member Function ST_LRS_Measure_To_Percentage(p_measure IN Number DEFAULT 0,
p_unit    in varchar2 default null)
Return Number deterministic,
```

DESCRIPTION

```    The end measure minus the start measure of a measured line-string defines
the range of the measures (see ST_Measure_Range). The supplied measure is
divided by this range and multiplied by 100 to return the measure as a percentage.
For non measured line-strings all values are computed using lengths.
```

ARGUMENTS

```    p_percentage (Number)   - Value between 0 and 100
p_unit       (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    Percentage (Number) - Value between 0 and 100.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.93. T_GEOMETRY/ST_LRS_Percentage_To_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Percentage_To_Measure -- Converts supplied Percentage value to Measure.
```

SYNOPSIS

```    Member Function ST_LRS_Percentage_To_Measure(p_percentage IN Number DEFAULT 0,
p_unit       in varchar2 default null)
Return Number deterministic,
```

DESCRIPTION

```    The supplied percentage value (between 0 and 100) is multipled by
the measure range (see ST_Measure_Range) to return a measure value between
the start and end measures. For non measured line-strings all values are
computed using lengths.
```

ARGUMENTS

```    p_percentage (Number)   - Value between 0 and 100
p_unit       (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    Measure (Number) - Value between Start Measure and End Measure.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

15.94. T_GEOMETRY/ST_LRS_Project_Point [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Project_Point -- The function uses ST_Snap to snap a point to a linestring(2002) or multi-linestring (2006).
```

SYNOPSIS

```    Member Function ST_LRS_Project_Point(P_Point In Mdsys.Sdo_Geometry,
p_unit  In varchar2 Default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    This is a wrapper function for ST_Snap. The function uses ST_Snap to snap a point
to a linestring(2002) or multi-linestring (2006).
However, where ST_Snap may return more than one result point if p_point was
equidistant from two separate segments/segments of the line-string, ST_Project_Point
returns the first.
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - A point(2001) mdsys.sdo_geometry object describing the point for splitting the linestring.
p_unit  (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    snapped_points (T_GEOMETRIES) -- One or more points where supplied point has snapped to the linestring.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.95. T_GEOMETRY/ST_LRS_Reset_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Reset_Measure -- Wipes all existing assigned measures.
```

SYNOPSIS

```    Member Function ST_LRS_Reset_Measure
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Sets all measures of a measured linesting to null values leaving sdo_gtype
alone. So, 3302 remains 3302, but all measures are set to NULL eg
Coord 2 of 10.23,5.75,2.65 => 10.23,5.75,NULL
```

NOTES

```    This is not the same as ST_To2D which removes measures etc and returns a pure 2D (200x object).
```

RESULT

```    linestring (T_GEOMETRY) -- All measures reset
```

AUTHOR

```    Simon Greener
```

HISTORY

```     Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.96. T_GEOMETRY/ST_LRS_Reverse_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Reverse_Measure -- Reverses vertices measures: first becomes last, second becomes second last etc.
```

SYNOPSIS

```    Member Function ST_LRS_Reverse_Measure
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Reverses vertices measures: first becomes last, second becomes second last etc.
This is not the same as ST_Reverse_Linestring which reverses xy direction of whole linestring.
```

RESULT

```    linestring (T_GEOMETRY) - All measures reversed
```

AUTHOR

```    Simon Greener
```

HISTORY

```     Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.97. T_GEOMETRY/ST_LRS_Scale_Measures [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Scale_Measures -- Rescales geometry measures and optionally offsets them, stretching the geometry.
```

SYNOPSIS

```    Member Function ST_LRS_Scale_Measures
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    This function can redistribute measure values between the supplied
p_start_measure (start vertex) and p_end_measure (end vertex) by adjusting/scaling
the measure values of all in between coordinates. In addition, if p_shift_measure
is not 0 (zero), the supplied value is added to each modified measure value
performing a translation/shift of those values.
```

ARGUMENTS

```    p_start_measure (Number) - Measure defining start point for geometry.
p_end_measure   (Number) - Measure defining end point for geometry.
p_shift_measure (Number) - Unit of measure for distance calculations.
RETURN
linestring (T_GEOMETRY) - All measures scales.
```

AUTHOR

```    Simon Greener
```

HISTORY

```     Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.98. T_GEOMETRY/ST_LRS_Start_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Start_Measure -- Returns M value of first vertex in measured geometry.
```

SYNOPSIS

```    Member Function ST_LRS_Start_Measure
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Returns start measure associated with first vertex in a measured line-string.
If the line-string is not measured it returns 0.
```

RESULT

```    measure (Number) -- Measure value of first vertex in a measured line-string: 0 if 2D.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.99. T_GEOMETRY/ST_LRS_Update_Measures [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Update_Measures -- Updates existing measures.
```

SYNOPSIS

```    Member Function ST_LRS_Update_Measures(p_start_measure IN Number,
p_end_measure   IN Number,
p_unit          IN VarChar2 Default NULL)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Takes an existing measured linestring and updates all measures based on segment length/total length ratios.
```

NOTES

```    Does not currently handle circular arc segments
```

ARGUMENTS

```    p_start_measure (Number)   - Measure defining start point for geometry.
p_end_measure   (Number)   - Measure defining end point for geometry.
p_unit          (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    geometry (T_GEOMETRY) -- Measured geometry
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Aug 2017 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.100. T_GEOMETRY/ST_LRS_Valid_Geometry [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Valid_Geometry -- Checks if underlying LRS linestring is valid.
```

SYNOPSIS

```    Member Function ST_LRS_Valid_Geometry(p_diminfo in mdsys.sdo_dim_array)
Return varchar2 Deterministic,
```

DESCRIPTION

```    Function returns TRUE string if underlying linestring is a valid LRS linestring and FALSE otherwise.
The supplied SDO_DIM_ARRAY must have measure information with a SDO_DIMNAME of M (uppercase)
This function checks that the geometry type is measured eg 3302 and has the right number of dimensions (dL0N)
The function also checks that sdo_ordinate array has measure values within the range of the supplied diminfo structure.
```

ARGUMENTS

```    p_diminfo (mdsys.sdo_dim_array) - DIMINFO structure with a measure sdo_dim_element
```

TODO

```    Current implementation does NOT examine the supplied diminfo array.
```

RESULT

```    TRUE/FASE (string) - TRUE if LRS linestring is Valid, FALSE otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.101. T_GEOMETRY/ST_LRS_Valid_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Valid_Measure -- Checks if supplied measure falls within the linestring's measure range.
```

SYNOPSIS

```    Member Function ST_LRS_Valid_Measure(p_measure in number)
Return varchar2 Deterministic,
```

DESCRIPTION

```    Function returns TRUE string if measure falls within the underlying linestring's measure range
or the FALSE string if the supplied measure does not fall within the measure range.
```

ARGUMENTS

```    p_measure (number) - Measure value.
```

RESULT

```    TRUE/FASE (string) - TRUE if measure within range, FALSE otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.102. T_GEOMETRY/ST_LRS_Valid_Point [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Valid_Point -- Checks if underlying LRS point is valid.
```

SYNOPSIS

```    Member Function ST_LRS_Valid_Point(p_diminfo in mdsys.sdo_dim_array)
Return varchar2 Deterministic,
```

DESCRIPTION

```    Function returns TRUE string if point is valid and FALSE if point is not valid.
A valid LRS point has measure information. It is checkeds for the geometry type
(point) and the number of dimensions.
The Oracle equivalent for this function requires that "All LRS point data must be
stored in the SDO_ELEM_INFO_ARRAY and SDO_ORDINATE_ARRAY, and cannot be stored in
the SDO_POINT field in the SDO_GEOMETRY definition of the point", however, this
implementation allows for the storage of 3301 Points within the SDO_POINT_TYPE structure.
```

ARGUMENTS

```    p_diminfo (mdsys.sdo_dim_array) - DIMINFO structure with a measure sdo_dim_element
```

TODO

```    Current implementation does NOT examine the supplied diminfo array.
```

RESULT

```    TRUE/FASE (string) - TRUE if LRS POint is Valid, FALSE otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.103. T_GEOMETRY/ST_LRS_Valid_Segment [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_LRS_Valid_Segment -- Checks if underlying LRS linestring is valid.
```

SYNOPSIS

```    Member Function ST_LRS_Valid_Segment(p_diminfo in mdsys.sdo_dim_array)
Return varchar2 Deterministic,
```

DESCRIPTION

```    Function returns TRUE string if underlying linestring is a valid LRS linestring and FALSE otherwise.
The supplied SDO_DIM_ARRAY must have measure information with a SDO_DIMNAME of M (uppercase)
This function only checks that the geometry type is measured eg 3302 and the linestring dims (dL0N)
```

ARGUMENTS

```    p_diminfo (mdsys.sdo_dim_array) - DIMINFO structure with a measure sdo_dim_element
```

TODO

```    Current implementation does NOT examine the supplied diminfo array.
```

RESULT

```    TRUE/FASE (string) - TRUE if LRS linestring is Valid, FALSE otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.104. T_GEOMETRY/ST_MBR [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_MBR - Returns lower left and upper right coordinates of underlying geometry's minimum bounding rectangle (MBR).
```

SYNOPSIS

```    Member Function ST_MBR
Return T_GEOMETRY Determinsitic
```

EXAMPLE

```    select T_Geometry(sdo_geometry('LINESTRING(0 0,0.1 0.1,0.5 0.5,0.8 0.8,1 1)',NULL),0.005,2,1).ST_MBR().geom as mbrGeom
from dual;

MBRGEOM
--------------------------------------------------------------------------------------
SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(0,0,1,1))
```

DESCRIPTION

```    Supplied with a non-NULL geometry, this function returns the envelope or minimum bounding rectangle as a polygon geometry with one optimized rectangle exterior ring.
```

RESULT

```    MBR Geometry (T_GEOMETRY) -- Single Polygon with Optimized Rectangle Exterior Ring.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2011 - Converted to T_GEOMETRY from GEOM package.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.105. T_GEOMETRY/ST_Multi [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Multi -- Converts any single sdo_geometry (point, line or polygon) to its multi equivalent (multipoint, multiline, multipolygon).
```

SYNOPSIS

```    Member Function ST_Multi ()
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

RESULT

```    MultiGeometry (T_GEOMETRY) -- If not already a multi geometry, returns multi-geometry object with 1 geometry;
```

DESCRIPTION

```    Converts underlying sdo_geometry objects that are single geometries (eg sdo_gtype of X001, X002, X003) to its multi equivalent (X005,X006,X007).
Note that what is returned is a multi geometry with a one internal geometry.
```

EXAMPLE

```    With Data as (
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1,11,2003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0, 5,5,5,10,10,10,10,5,5,5)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),
((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select case when a.tgeom.ST_GType() = 1  -- ST_AsText() converts 2005 with one point to POINT()
then a.tgeom.ST_Multi().ST_AsTText()
else a.tgeom.ST_Multi().ST_AsText()
end as mGeom
from data a;

MGEOM
--------------------------------------------------------------------------------------------------------------
&&INSTALL_SCHEMA..T_GEOMETRY(SDO_GEOMETRY(2005,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(0,0)); TOLERANCE(05)
MULTILINESTRING ((0 0, 10 0, 10 5, 10 10, 5 10, 5 5))
MULTILINESTRING ((-1 -1, 0 -1), (0 0, 10 0, 10 5, 10 10, 5 10, 5 5))
MULTIPOLYGON (((0 0, 20 0, 20 20, 0 20, 0 0)))
MULTIPOLYGON (((0 0, 20 0, 20 20, 0 20, 0 0)), ((10 10, 10 11, 11 11, 11 10, 10 10)))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.106. T_GEOMETRY/ST_Multi_Centroid [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Multi_Centroid -- Computes centroid for all parts of supplied multilinestring or multipolygon.
```

SYNOPSIS

```      Member Function ST_Multi_Centroid(
p_method IN integer  := 1,
p_unit   IN varchar2 := NULL
)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic;
```

DESCRIPTION

```    For an underlying MultiPolygon this function creates a single centroid for each polygon in it, returning a MultiPoint geometry object.
For a MultiPolygon this function calls ST_Centroid_A with only the following p_method values:
0 = Use average of all Area's X Ordinates for starting centroid Calculation
10 = Use average of all Area's Y Ordinates for starting centroid Calculation
1 = Use centre X Ordinate of geometry MBR
11 = Use centre Y Ordinate of geometry MBR
3 = Use MDSYS.SDO_GEOM.SDO_CENTROID function
4 = Use MDSYS.SDO_GEOM.SDO_POINTONSURFACE function.
For an underlying MultiLineString this function creates a single centroid for each linestring in it, returning a MultiPoint geometry object.
For a MultiLineString this function calls ST_Centroid_L with the p_option set to 'MULTI'.
Since ST_Centroid_L can take a p_unit value, it is exposed in this function.
```

RESULT

```    multipoint (T_GEOMETRY) - Centroids of all parts of the supplied MultiPolygon/MultiLineString object.
```

EXAMPLE

```    -- MultiCentroid for MultiPolygon
with data as (
select t_geometry (
SDO_GEOMETRY(2007,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1,11,1003,1),
SDO_ORDINATE_ARRAY(0,0,100,0,100,100,0,100,0,0,1000,1000,1100,1000,1100,1100,1000,1100,1000,1000.0)),
0.005,2,1)
as tGeom
from dual
)
select a.tGeom
.ST_Multi_Centroid(p_method => 0)
.ST_AsText() as mCentroid
from data a;

MCENTROID
---------------------------------
MULTIPOINT ((40 50), (1040 1050))

-- MutiCentroid for MultiLineString
with data as (
select t_geometry (
SDO_GEOMETRY(2006,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1,11,2,1),
SDO_ORDINATE_ARRAY(0,0,100,0,100,100,0,100,0,0,1000,1000,1100,1000,1100,1100,1000,1100,1000,1000.0)),
0.005,2,1)
as tGeom
from dual
)
select a.tGeom
.ST_Multi_Centroid()
.ST_AsText() as mCentroid
from data a;

MCENTROID
-----------------------------------
MULTIPOINT ((100 100), (1100 1100))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2006 - Original coding.
Simon Greener - January 2012 - Added p_seed_x support.
Simon Greener - August  2018 - Added to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.107. T_GEOMETRY/ST_NumElementInfo [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumElementInfo -- Returns number of SDO_ELEM_INFO triplets that describe geometry.
```

SYNOPSIS

```    Member Function ST_NumElementInfo
Return Integer deterministic
```

DESCRIPTION

```    If a geometry is coded with an SDO_ELEM_INFO_ARRAY this function will count the number of triplets that describe the geometry.
For Example:
1. sdo_geometry(2002,null,null,sdo_element_info_array(1,2,1),sdo_ordinate_array(0,0,1,1)) is described by 1 triplet.
2. sdo_geometry(2003,null,null,sdo_element_info_array(1,1003,1,9,2003,1),sdo_ordinate_array(....)) is described by 2 triplets.
```

EXAMPLE

```    With GEOMETRIES As (
Select T_GEOMETRY(sdo_geometry(2007,NULL,NULL,sdo_elem_info_array (1,1005,2, 1,2,1, 7,2,2,13,1003,3),
sdo_ordinate_array (10,128, 10,125, 20,125, 20,128, 15,130, 10,128, 0,0, 10,10)),0.005,3,1) as TGEOM
From Dual Union All
Select T_GEOMETRY(sdo_geometry(2002,NULL,NULL,sdo_elem_info_array (1,4,3, 1,2,1, 3,2,2, 7,2,1),
sdo_ordinate_array (10,45, 20,45, 23,48, 20,51, 10,51)),0.005,3,1) as TGEOM
From Dual
)
Select a.TGEOM.ST_NumElementInfo() as NumElementInfoTriplets
From GEOMETRIES a;
```

RESULT

```    Number of sdo_elem_info triplets (Integer)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2006 - Original coding in GEOM package.
Simon Greener - Jan 2013 - Port to T_GEOMETRY object.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.108. T_GEOMETRY/ST_NumElements [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumELems -- Returns number of top level elements of the underlying mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_NumElements()
Return Number Deterministic
```

DESCRIPTION

```    Wrapper over SDO_UTIL.GETNUMELEM().
```

EXAMPLE

```    With GEOMETRIES As (
Select T_GEOMETRY(
mdsys.sdo_geometry(2007,NULL,NULL,mdsys.sdo_elem_info_array (1,1005,2, 1,2,1, 7,2,2,13,1003,3),
mdsys.sdo_ordinate_array (10,128, 10,125, 20,125, 20,128, 15,130, 10,128, 0,0, 10,10)),0.005,3,1) as TGEOM
From Dual Union All
Select T_GEOMETRY(
mdsys.sdo_geometry(2002,NULL,NULL,mdsys.sdo_elem_info_array (1,4,3, 1,2,1, 3,2,2, 7,2,1),
mdsys.sdo_ordinate_array (10,45, 20,45, 23,48, 20,51, 10,51)),0.005,3,1) as TGEOM
From Dual
)
Select a.TGEOM.ST_NumElements() as NumElements
From GEOMETRIES a;

NUMELEM
-------
2
1
```

RESULT

```    Required Element Count (Integer)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2006 - Original coding in GEOM package.
Simon Greener - Jan 2013 - Port to T_GEOMETRY object.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.109. T_GEOMETRY/ST_NumGeometries [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumGeometries -- Returns number of top level geometry elements in underlying mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_NumGeometries()
Return Integer Deterministic,
```

DESCRIPTION

```    This function is a wrapper over MdSys.SDO_Util.getNumElem().
Returns number of geometry elements (eg LineString in MultiLineString) that describe the underlying mdsys.sdo_geometry.
```

NOTES

```    Is an implementation of OGC ST_NumGeometies method.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_NumGeometries() as numGeometries
from data a;

NUMGEOMETRIES
-------------
2
```

RESULT

```    number of geometries (Integer) -- For example, if Point(2001), returns 1.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Aug 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.110. T_GEOMETRY/ST_NumInteriorRing [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumInteriorRing -- Returns number of interior rings in underlying polygon mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_NumInteriorRing()
Return Integer Deterministic,
```

DESCRIPTION

```    This function computes the number of interior rings by processing the sdo_elem_info array in the underlying sdo_geometry object.
Returns number of inner ring elements of a polygon or multipolygon.
```

NOTES

```    Is an implementation of OGC ST_NumInteriorRing method.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_NumInteriorRing() as NumInteriorRings
from data a;

NUMINTERIORRINGS
----------------
2
```

RESULT

```    Number of interior rings (Integer) -- For example, if Polygon with 1 exterior and 1 interior ring then 1 is returned.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Aug 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.111. T_GEOMETRY/ST_NumPoints [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumPoints -- Returns number of points (coordinates) in underlying mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_NumPoints()
Return Integer Deterministic,
```

DESCRIPTION

```    This function is the same as ST_NumVertices.
It is implemented using the MdSys.SDO_Util.GetNumVertices() function.
The function returns number of points (coordinates) that describe the underlying mdsys.sdo_geometry.
```

NOTES

```    Is an implementation of OGC ST_NumPoints method.
```

EXAMPLE

```    With Geometries As (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as TPolygon
From Dual
)
select a.TPolygon.ST_NumPoints() as NumPoints
from GEOMETRIES a;
NUMPOINTS
---------
15
```

RESULT

```    number of points (Integer) -- For example, if Point(2001), returns 1.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.112. T_GEOMETRY/ST_NumRectangles [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumRectangles -- A function that returns the number of optimized rectangles in the underlying (multi)polygon geometry.
```

SYNOPSIS

```    Member Function ST_NumRectangles
Return integer Deterministic,
```

DESCRIPTION

```    Examines sdo_elem_info ETYPE/Interpretation elements to count the number of optimized rectangles it finds.
eg SDO_ELEM_INFO_ARRAY(1,1003,3) ie the interpretation value of 3 means optimized rectangle.
```

RESULT

```    Count (integer) -- 0 if no optimized rectangles, n where n > 0 if optimized rectangles found.
```

EXAMPLE

```    with data as (
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0))',null),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3),sdo_ordinate_array(0,0,20,20)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(0,0,20,20, 10,10,15,15)),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_NumRectangles() as numRectangles
from data a;

NUMRECTANGLES
-------------
0
1
2
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jun 2011 - Original coding for GEOM package.
Simon Greener - Jan 2013 - Recoded for T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.113. T_GEOMETRY/ST_NumRings [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumRings -- Returns Number of Rings of specified type in a polygon/mutlipolygon.
```

SYNOPSIS

```    Member Function ST_NumRings (
p_ring_type in integer default 0
)
Return integer Deterministic,
```

DESCRIPTION

```    A polygon can have a single outer ring with no inner rings (holes) or it can have holes.
A multipolygon can have multiple outer rings each with/without inner rings.
This method counts the number of rings of the desired type as defined by the input parameter.
```

ARGUMENTS

```    p_ring_type : integer : 0 - Count all (inner and outer) rings; 1 Count only outer rings; 2 - Count only inner rings.
```

RESULT

```    Number Of Rings (Integer)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Dec 2008 - Original coding for GEOM package.
Simon Greener - Jan 2013 - Port to T_GEOMETRY object.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.114. T_GEOMETRY/ST_NumSegments [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumSegments -- Returns number of two-point segments in the underlying linear or polygon geometry.
```

SYNOPSIS

```    Member Function ST_NumSegments()
Return Integer Deterministic,
```

DESCRIPTION

```    Returns number of two-point segments of a polygon or multipolygon.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('MULTILINESTRING((-1 -1, 0 -1),(0 0,10 0,10 5,10 10,5 10,5 5))',null),0.005,3,1) as tgeom From Dual union all
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom From Dual union all
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GeometryType()    as gType,
a.tGeom.ST_NumGeometries()   as numGeoms,
a.tGeom.ST_NumInteriorRing() as numIRings,
a.tgeom.ST_NumPoints()       as numPoints,
a.tgeom.ST_NumSegments()     as NumSegments
from data a;

GTYPE               NUMGEOMS  NUMIRINGS  NUMPOINTS NUMSEGMENTS
------------------- -------- ---------- ---------- -----------
ST_LINESTRING              1          0          6           5
ST_MULTILINESTRING         2          0          8           6
ST_POLYGON                 1          1         10           8
ST_MULTIPOLYGON            2          0         10           8
ST_MULTIPOLYGON            2          2         20          16
```

RESULT

```    Number of 2-point segments (Integer) -- For example, if LINESTRING has 6 vertices it has 5 segments.
```

TODO

```    Support for CircularString elements.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Sept 2015 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.115. T_GEOMETRY/ST_NumSubElements [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumSubElements -- Interprets underlying mdsys.sdo_geometry's SDO_ELEM_INFO array returning either total count of elements or just underlying sub-elements.
```

SYNOPSIS

```    Member Function ST_NumSubElements(p_subArcs in integer default 0)
Return Number Deterministic
```

DESCRIPTION

```    If a geometry is coded with an SDO_ELEM_INFO_ARRAY this function will examine the triplets that describe
each element and returns one of counts depending on the input parameter.
If the input parameter is 0 all elements are counted: For example is a single polygon has a single outer ring (1),
but that ring is coded with vertex-connected and circular-arc segments (2), then 1 + 2 =3 is returned.
If 1 is the supplied input only the number of sub-elements that describe the outer ring are counted and returned.
```

EXAMPLE

```    With geometries as (
select t_geometry(sdo_geometry(2003,null,null,
sdo_elem_info_array (1,1005,2, 1,2,1, 7,2,2),
sdo_ordinate_array (10,128, 10,125, 20,125, 20,128, 15,130, 10,128)),
0.005,3,1) as tgeom
from dual
union all
select t_geometry(sdo_geometry(2002,null,null,
sdo_elem_info_array (1,4,3, 1,2,1, 3,2,2, 7,2,1),
sdo_ordinate_array (10,45, 20,45, 23,48, 20,51, 10,51)),
0.005,3,1) as tgeom
from dual
)
select a.tgeom.ST_GType() as gType,
a.tgeom.ST_NumSubElements(0) as allElems,
a.tgeom.ST_NumSubElements(1) as lowElems,
a.tgeom.ST_NumSubElements(0) - a.tgeom.ST_NumSubElements(1) as TopElems
from geometries a;

GTYPE   ALLELEMS   LOWELEMS   TOPELEMS
---------- ---------- ---------- ----------
3          3          2          1
2          4          3          1
```

RESULT

```    Required Element Count (Integer)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2006 - Original coding in GEOM package.
Simon Greener - Jan 2013 - Port to T_GEOMETRY object.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.116. T_GEOMETRY/ST_NumVertices [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_NumVertices -- Returns number of vertices (coordinates) in underlying mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_NumVertices()
Return Integer Deterministic,
```

DESCRIPTION

```    This function is a wrapper over MdSys.SDO_Util.GetNumVertices(). Returns number of vertices (coordinates) that describe the underlying mdsys.sdo_geometry.
```

EXAMPLE

```    With Geometries As (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as TPolygon
From Dual
)
select a.TPolygon.ST_NumVertices() as numVertices
from GEOMETRIES a;

NUMVERTICES
-----------
15
```

RESULT

```    number of vertices (Integer) -- For example, if Point(2001), returns 1.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.117. T_GEOMETRY/ST_OneSidedBuffer [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_OneSidedBuffer -- Creates a square buffer to left or right of a linestring.
```

SYNOPSIS

```    Member Function ST_OneSidedBuffer(p_distance in number,
p_curved   in number default 0,
p_unit     in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function creates a square buffer to left or right of a linestring.
```

ARGUMENTS

```    p_distance (Number)   - if < 0 then left side buffer; if > 0 then right sided buffer.
p_curved   (Number)   - 0 = no; 1 = yes for angles in linestring (See ST_Parallel)
p_unit     (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    polygon (T_GEOMETRY) - Result of one sided buffering of a linestring.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.118. T_GEOMETRY/ST_Ord2SdoPoint [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Ord2SdoPoint -- Changes point encoding from SDO_ELEM_INFO_ARRAY/SDO_ORDINATE_ARRAY to SDO_POINT_TYPE.
```

SYNOPSIS

```   Function ST_Ord2SdoPoint
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    Converts underlying point encoded in SDO_ELEM_INFO_ARRAY/SDO_ORDINATE_ARRAY
elements to one encoded in SDO_POINT_TYPE element.
Gives precidence to measure where exists and point is 4D.
```

RESULT

```    SELF (TO_GEOMETRY) -- Original Point with structure changed.
```

EXAMPLE

```    select &&INSTALL_SCHEMA..T_Geometry(SDO_GEOMETRY(2005, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(10.719, 8.644)),0.005,3,1)
.ST_Ord2SdoPoint()
.geom as geom
from dual;

GEOM
-------------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(10.719, 8.644, NULL), NULL, NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener, Jul 2017 - New Method.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.119. T_GEOMETRY/ST_Ordinates_Equal [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Ordinates_Equal -- Compares current object (SELF) geometry's GEOM.sdo_ordinates with supplied mdsys.sdo_ordinate_array
```

SYNOPSIS

```    Member Function ST_Ordinates_Equal(p_ordinates   in mdsys.sdo_ordinate_array,
p_z_precision in integer default 2,
p_m_precision in integer default 3)
Return Integer deterministic
```

DESCRIPTION

```    This function compares current t_geometry object' SELF.GEOM.SDO_ORDINATES object to supplied p_ordinates.
Result can be one of the following:
0 if one or other sdo_ordinates structures are null but not both.
1 if two non-null structures and all ordinates are equal;
-1 if sdo_ordinates's X/Y/Z/M ordinates not equal
```

ARGUMENTS

```    p_ordinates (sdo_ordinate_array) -- p_ordinate that is to be compared to current object geometry's SELF.GEOM.Sdo_Ordinate_Array element.
p_z_precision          (integer) -- Z Ordinate precision for comparison using ROUND
p_m_precision          (integer) -- M Ordinate precision for comparison using ROUND
```

RESULT

```    -1,0,1 (Integer) --  0 if one or other sdo_ordinates structure is null but not both.
--  1 if two non-null structures and all ordinates are equal;
-- -1 if any of the sdo_ordinates's X/Y/Z/M ordinates not equal.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.120. T_GEOMETRY/ST_Parallel [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Parallel -- Moves linestring parts of underlying Geometry left (-ve) or right (+ve)  depending of distance value.
```

SYNOPSIS

```    Member Function ST_Parallel(p_offset in number,
p_curved in number default 0,
p_unit   in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    Function that moves the linestring components of the underlying mdsys.sdo_geometry left/right by a fixed amount.
Bends in the linestring, when moved, can remain vertex-connected or be converted to curves.
Does not handle situations where supplied distance results in a segment disappearing.
```

ARGUMENTS

```    p_offset  (Number) - Value +/- integer value.
p_curved (Integer) - Boolean flag
p_unit  (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    geometry (T_GEOMETRY) -- Input geometry moved parallel by p_distance units
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2008 - Original coding in GEOM package.
Simon Greener - January 2013  - Port/Rewrite to T_GEOMETRY object function member.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.121. T_GEOMETRY/ST_PointN [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_PointN -- Returns point (coordinate) at position p_point in underlying geometry.
```

SYNOPSIS

```    Member Function ST_PointN(p_point in integer)
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

ARGUMENTS

```    p_point (integer) -- Point number between 1 and ST_NumPoints().
```

RESULT

```    Point (T_GEOMETRY) -- Point at position p_point.
```

DESCRIPTION

```    Returns p_point point within underlying geometry.
p_point should be between 1 and ST_NumPoints().
p_point can be -1 which means the last point.
```

EXAMPLE

```    With data As (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as TPolygon
From Dual
)
select a.TPolygon.ST_PointN(-1).ST_AsText() as PointN
from data a;

POINTN
---------------
POINT (5.0 5.0)

With data As (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,20 0,20 20,10 20,0 20)',null),0.005,3,1) as tLine
From Dual
)
select t.IntValue as PointId,
a.tLine.ST_PointN(t.IntValue).ST_AsText() as Point
from data a,
table(tools.generate_series(1,a.tLine.ST_NumVertices(),1)) t;

POINTID POINT
------- ------------------
1 POINT (0.0 0.0)
2 POINT (20.0 0.0)
3 POINT (20.0 20.0)
4 POINT (10.0 20.0)
5 POINT (0.0 20.0)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.122. T_GEOMETRY/ST_Polygon2Line [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Polygon2Line -- Converts Polygon or MultiPolygon rings to equivalent linestrings.
```

SYNOPSIS

```    Member Function ST_Polygon2Line()
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

RESULT

```    polygon (T_GEOMETRY) -- Returns polygon with rings converted to linestrings.
```

DESCRIPTION

```    Converts polygon rings to linestrings via MDSYS.SDO_UTIL.PolygonToLine function.
Behavious is identical to underlying function.
```

EXAMPLE

```    With Data as (
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1,11,2003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0, 5,5,5,10,10,10,10,5,5,5)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),
((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_Polygon2Line().ST_AsText() as line
from data a;

LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------------
LINESTRING (0 0, 20 0, 20 20, 0 20, 0 0)
MULTILINESTRING ((0 0, 20 0, 20 20, 0 20, 0 0), (5 5, 5 10, 10 10, 10 5, 5 5))
MULTILINESTRING ((0 0, 20 0, 20 20, 0 20, 0 0), (10 10, 10 11, 11 11, 11 10, 10 10), (5 5, 5 7, 7 7, 7 5, 5 5), (100 100, 200 100, 200 200, 100 200, 100 100))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.123. T_GEOMETRY/ST_Polygon2Rectangle [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Polygon2Rectangle -- Converts optimized rectangles (rings) coded as 5 vertex/point polygons to rectangles.
```

SYNOPSIS

```    Member Function ST_Polygon2Rectangle()
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

DESCRIPTION

```    Converts any optimized rectangle equivalent 4 point polygon rings to their optimized rectangle equivalent.
```

RESULT

```    polygon (T_GEOMETRY) -- Returns polygon with rings converted to optimized rectangles where possible.
```

EXAMPLE

```    With Data as (
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,1,11,2003,1),sdo_ordinate_array(0,0,20,0,20,20,0,20,0,0, 5,5,5,10,10,10,10,5,5,5)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),
((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
From Dual
)
select a.tgeom.ST_Polygon2Rectangle().geom as tPoly
from data a;

TPOLY
------------------------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(0,0,20,20))
SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3,5,2003,3),SDO_ORDINATE_ARRAY(0,0,20,20,5,5,10,10))
SDO_GEOMETRY(2007,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3, 5,2003,3, 9,2003,3, 13,1003,3),SDO_ORDINATE_ARRAY(0,0, 20,20, 10,10, 11,11, 5,5, 7,7, 100,100, 200,200))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.124. T_GEOMETRY/ST_Rectangle [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Rectangle -- Creates a rectangle polygon around all point objects within the underlying mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_Rectangle(p_length in number,
p_width  in number)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function that creates a rectangle/polygon geometry around each point in the underlying point/multipoint mdsys.sdo_geometry.
As there is no angle parameter, the rectangles are oriented to the XY axes.
If the rectangles need to be rotated, consider using ST_Rotate until such time that this function is modified to support angles.
```

ARGUMENTS

```    p_length (Number)   - +ve value that describes the longest side of the retangle.
p_width  (Number)   - +ve value that describes the shortest side of the retangle.
```

NOTES

```    Only supports point or multipoint geometries.
If geometry is measured, measure will be lost.
```

TODO

```    Add support for rotating the rectangles by adding a p_angle and a p_unit parameter.
```

RESULT

```    geometry (T_GEOMETRY) -- (Multi)Polygon geometry where all input vertices are converted to rectangles.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013  - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.125. T_GEOMETRY/ST_Rectangle2Polygon [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Rectangle2Polygon -- Converts Single Optimized Rectangle Exterior Ring Polygon element to its 5 vertex polygons.
```

SYNOPSIS

```    Member Function ST_Rectangle2Polygon()
Return &&INSTALL_SCHEMA..T_Geometry Determinstic
```

DESCRIPTION

```    Converts a single exterior ring polygon described by an optimized rectangle to its 5 vertex equivalent polygon equivalent.
```

EXAMPLE

```    with data as (
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3),sdo_ordinate_array(0,0,20,20)),0.005,3,1) as tgeom
From Dual union all
Select T_GEOMETRY(sdo_geometry(2003,NULL,NULL,sdo_elem_info_array(1,1003,3,5,2003,3),sdo_ordinate_array(0,0,20,20, 10,10,15,15)),0.005,3,1) as tgeom
From Dual Union All
Select T_GEOMETRY(sdo_geometry(2007,NULL,NULL,sdo_elem_info_array(1,1003,3, 5,2003,3, 9,2003,3, 13,1003,3),sdo_ordinate_array(0,0,20,20, 10,10,11,11, 5,5,7,7, 100,100,200,200)),0.005,1,1) as tgeom
From Dual
)
select a.tGeom.ST_NumElements()                   as numElements,
a.tGeom.ST_NumRings()                      as numRings,
a.tgeom.ST_Rectangle2Polygon().ST_AsText() as tPoly
from data a;

NUMELEMENTS NUMRINGS TPOLY
----------- -------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------
1          1 POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))
1          2 MULTIPOLYGON (((0 0, 20 0, 20 20, 0 20, 0 0), (10 10, 10 15, 15 15, 15 10, 10 10)))
2          4 MULTIPOLYGON (((0 0, 20 0, 20 20, 0 20, 0 0), (10 10, 10 11, 11 11, 11 10, 10 10), (5 5, 5 7, 7 7, 7 5, 5 5)), ((100 100, 200 100, 200 200, 100 200, 100 100)))
```

RESULT

```    polygon (T_GEOMETRY) -- Returns 5 vertex polygon.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.126. T_GEOMETRY/ST_Reduce [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Reduce -- Function that can shorten underlying linestring at one or both ends.
```

SYNOPSIS

```    Member Function ST_Reduce (p_length    in number,
p_start_end in varchar2 default 'START',
p_unit      in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Function that reduces the supplied linestring at either its start or end (p_start_end).
A p_start_end value of BOTH means line is reduced at both ends.
p_length is always assumed to be positive, any negative value is passed through the ABS function.
If p_length is 0 the geometry is returned unchanged.
A reduction can be thought of as the equivalent of extracting a new segment between two measures: p_length ... (SELF.ST_Length() - p_length).
```

ARGUMENTS

```    p_length       (number) - If negative the linestring is shortened.
If positive the linestring is extended via a call to ST_Extend.
Distance must be expressed in SRID or p_unit units
p_start_end  (varchar2) - START means reduce line at the start; END means reduce at the end, and BOTH means reduce at both START and END of line.
p_unit       (varchar2) - Allows default Oracle unit of measure (UoM) to be overridden eg if unit M is default for SRID then unit=CM will compute in centimeters.
```

RESULT

```    linestring (t_geometry) - Input geometry reduced as instructed.
```

EXAMPLE

```    -- Reduce more than length of line.
Select T_Geometry(
mdsys.sdo_geometry('LINESTRING(1 1,2 2)',NULL),
0.05,1,1
)
.ST_Reduce(0.708,'BOTH')
.geom
as geom
From dual;

SQL Error: ORA-20124: Reducing geometry of length (1.4142135623731) by (.708) at both ends would result in a zero length geometry.
ORA-06512: at "T_GEOMETRY", line 3450

-- Changes that remove whole segments.
With data As (
select -- Distance between all segments is 1.414
T_Geometry(
mdsys.sdo_geometry('LINESTRING(1 1,2 2,3 3,4 4)',NULL),0.05,1,1) as tgeom
from dual
)
select 1.414    as seLength,
'START'  as Start_end,
a.tgeom.ST_Reduce(1.414,'START').ST_Round(2,1,1).ST_AsText() as tgeom,
a.tgeom.ST_Length(p_round=>a.tGeom.dprecision) as gLength,
a.tgeom.ST_Reduce(1.414,'START').ST_Length(p_round=>a.tGeom.dPrecision) as newLength
from data a union all
select 1.414   as seLength,
'END'   as Start_end,
a.tgeom.ST_Reduce(1.414,'END').ST_Round(2,1,1).ST_AsText() as tgeom,
a.tgeom.ST_Length(p_round=>a.tGeom.dPrecision) as gLength,
a.tgeom.ST_Reduce(1.414,'END').ST_Length(p_round=>a.tGeom.dPrecision) as newLength
from data a union all
select 1.414  as seLength,
'BOTH' as Start_end,
a.tgeom.ST_Reduce(1.414,'BOTH').ST_Round(2,1,1).ST_AsText() as tgeom,
a.tgeom.ST_Length(p_round=>a.tGeom.dPrecision) as gLength,
a.tgeom.ST_Reduce(1.414,'BOTH').ST_Length(p_round=>a.tGeom.dPrecision) as newLength
from data a;

SELENGTH START_END TGEOM                      GLENGTH NEWLENGTH
-------- --------- -------------------------- ------- ---------
1.414 START     LINESTRING (2 2, 3 3, 4 4)     4.2       2.8
1.414 END       LINESTRING (1 1, 2 2, 3 3)     4.2       2.8
1.414 BOTH      LINESTRING (2 2, 3 3)          4.2       1.4
```

NOTES

```    Points, GeometryCollections, Polygons, MultiPolygons, CircularStrings are not supported.
Assumes planar projection eg UTM.
```

ERRORS

```    The following exceptions can be thrown:
ORA-20120 - Geometry must not be null or empty (*ERR*)
Where *ERR* is replaced with specific error
ORA-20121 - Geometry must be a single linestring.
ORA-20122 - Start/End parameter value (*VALUE*) must be START, BOTH or END
Where *VALUE* is the supplied, incorrect, value.
ORA-20123 - p_extend_dist value must not be 0 or NULL.
ORA-20124 - Reducing geometry of length (*GLEN*) by (*DIST*) at *STARTEND* would result in a zero length geometry.
Where *GLEN* is the length of the existing geometry, *DIST* is ABS(p_length), and *STARTEND* is p_start_end.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM Package
Simon Greener - July 2011     - Port to T_GEOMETRY
```

```    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

15.127. T_GEOMETRY/ST_Reflect(p_reflect_geom p_reflect_plane) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Reflect -- Function which reflects the underlying geometry to a new location using the provided parameters.
```

SYNOPSIS

```    Member Function ST_Reflect (p_reflect_geom  in mdsys.sdo_geometry,
p_reflect_plane in number default -1)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which reflects the underlying geometry to a new location, by reflecting around or across p_reflect_geom depending on p_reflect_plane.
```

ARGUMENTS

```    p_reflect_geom  (sdo_geometry) -- Reflection geometry
p_reflect_plane (number)       -- Whether to reflect underlying geometry across p_reflect_geom.
```

RESULT

```    geometry -- Input geometry reflected using supplied values.
```

NOTES

```    Is wrapper over mdsys.SDO_UTIL.AffineTransforms
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry('POINT(10 10)',null),0.005,2,1) as tgeom,
mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(10,0,0,10)) as reflect_geom
from dual
)
select 'ST_Reflect(p_reflect_geom,-1)' as ReflectTest,
a.tgeom.ST_Reflect(p_reflect_geom=>a.reflect_geom,p_reflect_plane=>-1)
.ST_Round(2,2,1,1)
.ST_AsText()  as geom
from testGeom a;

REFLECTTEST                   GEOM
----------------------------- ---------------
ST_Reflect(p_reflect_geom,-1) POINT (0.0 0.0)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.128. T_GEOMETRY/ST_Relate [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Relate - Determines spatial relations between two geometry instances.
```

SYNOPSIS

```    Member Function ST_Relate (
p_geom      sdo_geometry,
p_determine varchar2 default 'DETERMINE'
)
Return varchar2 deterministic
```

DESCRIPTION

```    Compares the first geometry against the second using SDO_GEOM.RELATE to discover if the two geometry objects have the required relationship.
The relationhip names (from the Oracle documentation are):

DISJOINT           : The boundaries and interiors do not intersect.
TOUCH              : The boundaries intersect but the interiors do not intersect.
OVERLAPBDYDISJOINT : The interior of one object intersects the boundary and interior of the other object, but the two boundaries do not intersect.
This relationship occurs, for example, when a line originates outside a polygon and ends inside that polygon.
OVERLAPBDYINTERSECT: The boundaries and interiors of the two objects intersect.
EQUAL              : The two objects have the same boundary and interior.
CONTAINS           : The interior and boundary of one object is completely contained in the interior of the other object.
COVERS             : The interior of one object is completely contained in the interior or the boundary of the other object and their boundaries intersect.
INSIDE             : The opposite of CONTAINS. A INSIDE B implies B CONTAINS A.
COVEREDBY          : The opposite of COVERS. A COVEREDBY B implies B COVERS A.
ON                 : The interior and boundary of one object is on the boundary of the other object.
This relationship occurs, for example, when a line is on the boundary of a polygon.
ANYINTERACT        : The objects are non-disjoint.

If one does not know what relationships might exist, set the parameter p_determine to the value DETERMINE to discover what relationships exist.
```

ARGUMENTS

```    p_geom   (sdo_geometry) - Non-null geometry instance.
p_determine  (varchar2) - One of the 9 Topological Relationship names (see above):
```

RESULT

```    Relationships (varchar) - Result of SDO_GEOM.RELATE()
```

NOTES

```    Uses MDSYS.SDO_GEOM.RELATE if Oracle database version is 12c or above,
or if the customer is licensed for the Spatial object before 12c.
```

ERRORS

```    With throw exception if the user is not licensed to call MDSYS.SDO_GEOM.RELATE.
-20102  MDSYS.SDO_GEOM.RELATE only supported for Locator users from 12c onwards.';
```

EXAMPLE

```    Select t_geometry(sdo_geometry('POLYGON ((100.0 0.0, 400.0 0.0, 400.0 480.0, 160.0 480.0, 160.0 400.0, 240.0 400.0,240.0 300.0, 100.0 300.0, 100.0 0.0))',NULL),0.005,2,1)
.ST_Relate ( sdo_geometry('POLYGON ((-175.0 0.0, 100.0 0.0, 0.0 75.0, 100.0 75.0, 100.0 200.0, 200.0 325.0, 200.0 525.0, -175.0 525.0, -175.0 0.0))',NULL),
'DETERMINE'
) as relations
from dual;

RELATIONS
-------------------
OVERLAPBDYINTERSECT

Select t_geometry(  sdo_geometry('LINESTRING (100.0 0.0, 400.0 0.0)',NULL),0.005,2,1)
.ST_Relate(sdo_geometry('LINESTRING (90.0 0.0, 100.0 0.0)',NULL),
'DETERMINE'
) as relations
from dual;

RELATIONS
---------
TOUCH

Select t_geometry(  sdo_geometry('POLYGON ((100.0 0.0, 400.0 0.0, 400.0 480.0, 160.0 480.0, 160.0 400.0, 240.0 400.0,240.0 300.0, 100.0 300.0, 100.0 0.0))',NULL),0.0005,2,1)
.ST_Relate(sdo_geometry('POINT (250 150)',NULL),
'DETERMINE'
) as relations
from dual;

RELATIONS
---------
CONTAINS

-- Example using different precision values and a specific "question": Are they equal?
Select t_geometry(  sdo_geometry('POINT (250.001 150)'    ,NULL),DECODE(t.IntValue,2,0.005,3,0.0005),t.IntValue,1)
.ST_Relate(sdo_geometry('POINT (250     150.002)',NULL),
'EQUAL'
) as relations
from table(tools.GENERATE_SERIES(2,3,1)) t

RELATIONS
---------
EQUAL
FALSE
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.129. T_GEOMETRY/ST_Release [ Functions ]

[ Top ] [ T_GEOMETRY ] [ Functions ]

NAME

```    ST_Release -- Returns Version Number for the code in the type.
```

SYNOPSIS

```    Static Function ST_Release
Return VarChar2
```

DESCRIPTION

```    This function returns a version or release number for the code when distributed.
Also includes versions of the databases the code was developed against .
```

EXAMPLE

```    select T_GEOMETRY.ST_Release()
from dual;

T_GEOMETRY.ST_Release()
-----------------------
2.1.1 Databases(11.2, 12.1)
```

RESULT

```    Code Release Number (VarChar2) - eg 2.2.1 Databases(11.2, 12.1)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - June 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.130. T_GEOMETRY/ST_RemoveCollinearPoints [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_RemoveCollinearPoints -- Removes any collinear points in a linestring
```

SYNOPSIS

```    Member Function ST_RemoveColliearPoints
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    Removes any collinear points in a linestring
Collinear points are any three points in a line allowing for the middle one to be removed.
SELF.dprecision is vital to determining collinearity.
```

NOTES

```    Only supports linestrings, multilinestrings.
Does not support linestrings with circular arcs.
```

RESULT

```    geometry (T_GEOMETRY) -- geometry with any collinear points removed.
```

TODO

```    Support polygon and multipolygons.
Support linestrings with circular arcs.
```

EXAMPLE

```    -- 1. ST_RemoveCollinearPoints
with data as (
select t_geometry(f.geom,0.005,2,1) as tGeom,
f.test
from (select 'Is Collinear 3D' as test, sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,0,10,10,10,20,20,20)) as geom
from dual
union all
select 'Is Collinear 2D' as test, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,10,10,20,20)) as geom
from dual
union all
select 'Not Collinear 3D' as test, sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,0, 10,11,10, 20,0,21)) as geom
from dual
union all
select 'Not Collinear 2D' as test,
sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,10,10,20,0)) as geom
from dual
) f
)
select a.tGeom.ST_Dims() as dims,
a.test,
a.tGeom.ST_RemoveCollinearPoints().geom as rcpGeom
from data a;

DIMS TEST             RCPGEOM
---- ---------------- --------------------------------------------------------------------------------------------------
3 Is Collinear 3D  SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,0,20,20,20))
2 Is Collinear 2D  SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,20,20))
3 Not Collinear 3D SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,0,10,11,10,20,0,21))
2 Not Collinear 2D SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,10,10,20,0))

-- 2. MultiLineString 3D Geometries.
with data as (
select t_geometry(f.geom,0.005,2,1) as tGeom,
f.test
from (select 'Collinear First and Second LineStrings (same Z)' as test,
sdo_geometry(3006,null,null,sdo_elem_info_array(1,2,1,10,2,1),
sdo_ordinate_array(  0,  0, 0,  10, 10, 0,  20, 20, 0,
100,100,90, 110,110,90, 200,200,90)) as geom
from dual
union all
select 'Multi: Collinear First Linestring (same Z), Not Collinear Second LineString (diff Z)' as test,
sdo_geometry(3006,null,null,sdo_elem_info_array(1,2,1,10,2,1),
sdo_ordinate_array(0,0,0,       10,10,10,   20, 20,20,
100,100,90, 110,120,90, 200,201,95)) as geom
from dual
union all
select 'Multi: Neither part with collinear points' as test,
sdo_geometry(3006,null,null,sdo_elem_info_array(1,2,1,10,2,1),
sdo_ordinate_array(0,0,0,       10,10,10,   20,  0,20,
100,100,90, 110,120,75, 200, 1,50)) as geom
from dual
) f
)
select a.tGeom.ST_Dims() as dims,
a.test,
a.tGeom.ST_RemoveCollinearPoints().geom as rcp
from data a;

DIMS TEST                                            RCP
---- ----------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------
3 Collinear First and Second LineStrings (same Z) SDO_GEOMETRY(3006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,7,2,1),SDO_ORDINATE_ARRAY(0,0,0,20,20,0,100,100,90,200,200,90))
3 Multi: Collinear First Linestring (same Z),
Not Collinear Second LineString (diff Z) SDO_GEOMETRY(3006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,7,2,1),SDO_ORDINATE_ARRAY(0,0,0,20,20,20,100,100,90,110,120,90,200,201,95))
3 Multi: Neither part with collinear points       SDO_GEOMETRY(3006,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1,10,2,1),SDO_ORDINATE_ARRAY(0,0,0,10,10,10,20,0,20,100,100,90,110,120,75,200,1,50))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - February 2018 - Original TSQL Coding for SQL Spatial.
Simon Greener - August 2018   - Port to Oracle.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.131. T_GEOMETRY/ST_RemoveDuplicateVertices [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_RemoveDuplicateVertices -- Function that removes duplicate points in underlying linear or polygonal geometry.
```

SYNOPSIS

```    Member Function ST_RemoveDuplicateVertices
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function that calls MDSYS.SDO_UTIL.REMOVE_DUPLICATE_VERTICES(sdo_geometry,tolerance);
Tolerance used is SELF.TOLERANCE or 0.005 if null.
```

RESULT

```    Modified linestring (geometry) - Input linestring/polygon with duplicate points removed.
```

EXAMPLE

```    -- Example of exception
select t_geometry(
sdo_geometry('POINT(0 0)',NULL),0.05,2,1
).ST_RemoveDuplicateVertices()
.ST_AsText() as updatedGeom
from dual;

SQL Error: ORA-20121: Geometry must be a linestring or polygon.
ORA-06512: at "T_GEOMETRY", line 2807

-- Linestring example
select t_geometry(
sdo_geometry('LINESTRING(0 0,1 1,1.004 1, 2 2)',NULL),0.005,2,1
).ST_RemoveDuplicateVertices()
.ST_AsText() as updatedGeom
from dual;

UPDATEDGEOM
-------------------
LINESTRING (0 0, 1 1, 2 2)

-- Polygon example
-- Example where tolerance is over-ridden
with data as (
select t_geometry(
sdo_geometry('POLYGON((0 0,1 0,1.004 0,1 2,0 2,0 0))',NULL),0.0005,3,1
) as tGeom
from dual
)
select a.tGeom
.ST_SetTolerance(0.05)
.ST_RemoveDuplicateVertices()
.ST_AsText()
as tolGeom,
a.tGeom
.ST_RemoveDuplicateVertices()
.ST_AsText()
as rGeom
from data a;

TOLGEOM                             RGEOM
----------------------------------- --------------------------------------------
POLYGON ((0 0, 1 0, 1 2, 0 2, 0 0)) POLYGON ((0 0, 1 0, 1.004 0, 1 2, 0 2, 0 0))
```

ERRORS

```    Can throw the following exception:
ORA--20121: Geometry must be a linestring or polygon.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - February 2011 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.132. T_GEOMETRY/ST_RemoveInnerRings [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_RemoveInnerRings -- Removes all interior/inner rings from polygon/multipolygon.
```

SYNOPSIS

```    Member Function ST_RemoveInnerRings
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    This function allows a user to remove all inner rings from a polygon/multipolygon.
```

RESULT

```    geometry (T_GEOMETRY) -- A (multi)polygon with exterior ring(s) only.
```

EXAMPLE

```    with data as (
Select T_GEOMETRY(sdo_geometry('MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5)),((100 100,200 100,200 200,100 200,100 100)))',null),0.005,3,1) as tgeom
from dual
union all
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as tgeom
from dual
)
select f.iRings                    as iRingBEfore,
f.geom.ST_NumInteriorRing() as iRingAfter,
f.geom.ST_AsText()          as eRingPolygon
from (select a.tgeom.ST_NumInteriorRing()  as iRings,
a.tgeom.ST_RemoveInnerRings() as geom
from data a
) f;

IRINGBEFORE IRINGAFTER ERINGPOLYGON
----------- ---------- --------------------------------------------------------------------------------------------------------------------------------
2          0 MULTIPOLYGON (((0.0 0.0, 20.0 0.0, 20.0 20.0, 0.0 20.0, 0.0 0.0)), ((100.0 100.0, 200.0 100.0, 200.0 200.0, 100.0 200.0, 100.0 100.0)))
2          0 POLYGON ((0.0 0.0, 20.0 0.0, 20.0 20.0, 0.0 20.0, 0.0 0.0))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Spetember 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.133. T_GEOMETRY/ST_Reverse_Geometry [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Reverse_Geometry -- Reverses non-point geometries
```

SYNOPSIS

```    Member Function ST_Reverse_Linestring
Return T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Reverses geometries.
```

RESULT

```    geometry (T_GEOMETRY) -- Reverse of SELF geom.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Aug 2017 - Port from GEOM.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.134. T_GEOMETRY/ST_Reverse_Linestring [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Reverse_Linestring -- Reverses linestring including multi-linestring.
```

SYNOPSIS

```    Member Function ST_Reverse_Linestring
Return T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Reverses linestring including multi-linestring. Honours circular arcs and measures.
```

RESULT

```    linestring (T_GEOMETRY) -- Reverse of input Linestring.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.135. T_GEOMETRY/ST_Rotate(p_angle p_dir p_rotate_point p_line1) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Rotate -- Function which rotates the underlying geometry.
```

SYNOPSIS

```    Member Function ST_Rotate (
p_angle        in number,
p_dir          in integer,
p_rotate_point in mdsys.sdo_geometry,
p_line1        in mdsys.sdo_geometry
)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which rotates the underlying geometry around a supplied rotation point p_rotate_point a required angle in radians.
See NOTES for valid parameter values.
Supports 2D and 3D geometry rotation.
```

ARGUMENTS

```    p_angle              (number) - Rotation angle expressed in degrees (see COGO.ST_Radians and COGO.ST_Degrees).
p_dir               (integer) - Rotation parameter for x(0), y(1), or z(2)-axis roll.
You cannot set p_dir => 0, 1 or 2, only -1, -2, -3. They don't see to affect the result.
p_rotate_point (sdo_geometry) - XY/2D Point geometry
p_line1        (sdo_geometry) - Y ordinate of rotation point.
```

RESULT

```    geometry -- Input geometry rotated by supplied values.
```

NOTES

```    Is wrapper over mdsys.SDO_UTIL.AffineTransforms
For 2D geometry rotation, p_angle and p_rotate_point must not be null.
For 3D geometry rotation, p_angle must not be null
For 3D geometry rotation, both p_dir and p_line1 cannot be null
For 3D geometries, rotation uses either:
1. the angle and dir values, or
2. the angle and line1 values.
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,4,8,4,12,4,12,10,8,10,5,14)),005,2,1) as geom,
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,0, 2,4,22.22, 8,4,374, 12,4,59.26, 12,10,747, 8,10,92.59, 5,14,100)) as geom3D,
mdsys.sdo_geometry(2001,null,sdo_point_type(2,2,null),null,null) as rotatePoint
from dual
)
select 'ST_Rotate(45/Dir/rPoint/Line1)' as rotate,
a.geom.ST_Rotate(p_angle=>45,p_dir=>-1,p_rotate_point=>rotatePoint, p_line1=>null)
.ST_Round(a.geom.dPrecision,a.geom.dPrecision,2,2).geom as geom
from testGeom a
Union All
select 'ST_Rotate3D(45/Dir/rPoint/Line1)' as rotate,
a.geom3d.ST_Rotate(p_angle=>45,p_dir=>-1,p_rotate_point=>rotatePoint, p_line1=>null)
.ST_Round(a.geom.dPrecision,a.geom.dPrecision,2,2).geom as geom
from testGeom a;

AFUNCTION                GEOM
-------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------
ST_Rotate(45/Dir/rPoint/line1)   SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,0.59,3.41,4.83,7.66,7.66,10.49,3.41,14.73,0.59,11.9,-4.36,12.61))
ST_Rotate3D(45/Dir/rPoint/line1) SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2.0,2.0,0.0, 0.59,3.41,22.22, 4.83,7.66,374.0, 7.66,10.49,59.26, 3.41,14.73,747.0, 0.59,11.9,92.59, -4.36,12.61,100.0))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.136. T_GEOMETRY/ST_Rotate(p_angle p_rotate_point) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Rotate -- Function which rotates the underlying geometry around a provided point or its centre.
```

SYNOPSIS

```    Member Function ST_Rotate (
p_angle        in number,
p_rotate_point in mdsys.sdo_geometry
)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which rotates the underlying geometry by the provided p_angle angle (degrees see COGO.ST_Radians and COGO.ST_Degrees) around a supplied rotation point p_rotate_point.
If p_rotate_point is null, the centre of the geometry's envelope/MBR is chosen.
Because of limited parameters this version only support 2D geometries.
If underlying geometry is a point and no p_rotate_point is provided, the same point is returned.
```

ARGUMENTS

```    p_angle (number) - Rotation angle expressed in radians.
p_rx    (number) - X ordinate of rotation point.
p_ry    (number) - Y ordinate of rotation point.
```

RESULT

```    geometry -- Input geometry rotated by supplied values.
```

NOTES

```    Is wrapper over ST_Rotate(p_angle,p_dir,p_rotate_point,p_line1)
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,4,8,4,12,4,12,10,8,10,5,14)),005,2,1) as geom,
mdsys.sdo_geometry(2001,null,sdo_point_type(2,2,null),null,null) as rotatePoint
from dual
)
select 'ST_Rotate(90,NULL)' as rotate,
a.geom.ST_Rotate(p_angle=>90,p_rotate_point=>null)
.ST_Round(a.geom.dprecision,a.geom.dprecision,2,2).geom as geom
From testGeom a
Union All
select 'ST_Rotate(90,POINT)' as rotate,
a.geom.ST_Rotate(p_angle=>90,p_rotate_point=>rotatePoint)
.ST_Round(a.geom.dprecision,a.geom.dprecision,2,2).geom as geom
from testGeom a ;

ROTATE              GEOM
------------------- -------------------------------------------------------------------------------------------------------------------
ST_Rotate(90,NULL)  SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(13,3, 11,3, 11,9, 11,13, 5,13, 5,9, 1,6))
ST_Rotate(90,POINT) SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2, 0,2, 0,8, 0,12, -6,12, -6,8, -10,5))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.137. T_GEOMETRY/ST_Rotate(p_angle p_rx p_rx) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Rotate -- Function which rotates the underlying geometry around a provided point or its centre.
```

SYNOPSIS

```    Member Function ST_Rotate (
p_angle in number,
p_rx    in number,
p_ry    in number
)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which rotates the underlying geometry by the provided p_angle angle around a supplied rotation point p_rx,p_rx.
If p_rx/p_ry is null, the centre of the geometry's envelope/MBR is chosen.
Because of limited parameters this version only support 2D geometries.
If underlying geometry is a point and no p_rx/p_rx values are provided, the same point is returned.
```

ARGUMENTS

```    p_angle (number) - Rotation angle expressed in degrees.
p_rx    (number) - X ordinate of rotation point.
p_ry    (number) - Y ordinate of rotation point.
```

RESULT

```    geometry -- Input geometry rotated by supplied values.
```

NOTES

```    Is wrapper over ST_Rotate(p_angle,p_dir,p_rotate_point,p_line1)
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,4,8,4,12,4,12,10,8,10,5,14)),005,2,1) as geom,
mdsys.sdo_geometry(2001,null,sdo_point_type(2,2,null),null,null) as rotatePoint
from dual
)
Select 'ST_Rotate(90,null,null)' as rotate,
a.geom.ST_Rotate(p_angle=>90,p_rx=>null,p_ry=>null)
.ST_Round(a.geom.dprecision,a.geom.dprecision,2,2).geom as geom
From testGeom a
Union All
Select 'ST_Rotate(90,2,2)' as rotate,
a.geom.ST_Rotate(p_angle=>90,p_rx=>a.rotatePoint.Sdo_Point.Y,p_ry=>a.rotatePoint.Sdo_Point.Y)
.ST_Round(a.geom.dprecision,a.geom.dprecision,2,2).geom as geom
From testGeom a;

ROTATE                  GEOM
----------------------- -------------------------------------------------------------------------------------------------------------
ST_Rotate(90,null,null) SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(13,3,11,3,11,9,11,13,5,13,5,9,1,6))
ST_Rotate(90,2,2)       SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,0,2,0,8,0,12,-6,12,-6,8,-10,5))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.138. T_GEOMETRY/ST_Rotate(p_angle) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Rotate -- Function which rotates the underlying geometry around the centre of its MBR.
```

SYNOPSIS

```    Member Function ST_Rotate (
p_angle in number
)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which rotates the underlying geometry by the provided p_angle angle (degrees see COGO.ST_Radians and COGO.ST_Degrees) around the centre of the geometry's MBR.
Because of limited parameters this version only support 2D geometries.
If underlying geometry is a point, the same point is returned.
```

ARGUMENTS

```    p_angle              (number) - Rotation angle expressed in radians.
p_rotate_point (sdo_geometry) - Point around which underlying geometry is rotated p_angle degrees
```

RESULT

```    geometry -- Input geometry rotated by supplied values.
```

NOTES

```    Is wrapper over ST_Rotate(p_angle,p_dir,p_rotate_point,p_line1)
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,4,8,4,12,4,12,10,8,10,5,14)),005,2,1) as geom
from dual
)
select 'ST_Rotate(90)' as rotate,
a.geom.ST_Rotate(p_angle=>90)
.ST_Round(a.geom.dprecision,a.geom.dprecision,2,2).geom as geom
From testGeom a ;

ROTATE            GEOM
----------------- -------------------------------------------------------------------------------------------------------------------
ST_Rotate(90)     SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(13,3, 11,3, 11,9, 11,13, 5,13, 5,9, 1,6))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.139. T_GEOMETRY/ST_RotTransScale(p_reflect_geom p_reflect_plane) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_RotTransScale -- Function which reflects the underlying geometry to a new location using the provided parameters.
```

SYNOPSIS

```    Member Function ST_RotTransScale (p_angle     in number,
p_rs_point  in mdsys.sdo_geometry,
p_sx        in number,
p_sy        in number,
p_sz        in number,
p_tx        in number,
p_ty        in number,
p_tz        in number)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which applies a Rotation/Scale and Translate to the underlying geometry as a single operation.
If equivalent of applying individual methods in one:
select a.tgeom.ST_Scale(....).ST_Translate(....).ST_Rotate(....) from ...
But is more efficient as it requires only one call to the mdsys.SDO_UTIL.AffineTransforms function.
```

ARGUMENTS

```    p_angle          (number) - Rotation angle expressed in radians.
p_rs_point (sdo_geometry) - Single Rotate and Scale point.
p_sx             (number) - Scale factor for X ordinates.
p_sy             (number) - Scale factor for Y ordinates.
p_sz             (number) - Scale factor for Z ordinates.
p_tx             (number) - Translation factor for X ordinates.
p_ty             (number) - Translation factor for Y ordinates.
p_tz             (number) - Translation factor for Z ordinates (if null, the Z ordinate is not changed).
geometry -- Input geometry transformed using supplied values.
```

NOTES

```    Is wrapper over mdsys.SDO_UTIL.AffineTransforms
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry('POINT(10 10)',null),0.005,2,1) as tgeom,
mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(10,0,0,10)) as reflect_geom
from dual
)
select 'ST_RotTransScale(p_reflect_geom,-1)' as ReflectTest,
a.tgeom.ST_RotTransScale(p_reflect_geom=>a.reflect_geom,p_reflect_plane=>-1)
.ST_Round(2,2,1,1)
.ST_AsText()  as geom
from testGeom a;

REFLECTTEST                   GEOM
----------------------------- ---------------
ST_RotTransScale(,-1)         POINT (0.0 0.0)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.140. T_GEOMETRY/ST_Round [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Round -- Rounds X,Y,Z and m (w) ordinates to passed in decimal digits of precision.
```

SYNOPSIS

```    Member Function ST_Round(p_dec_places_x in integer default null,
p_dec_places_y in integer default null,
p_dec_places_z in integer default null,
p_dec_places_m in integer default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Applies relevant decimal digits of precision value to ordinates of mdsys.sdo_geometry.
For example:
SELF.x := ROUND(SELF.x,p_dec_places_x);
```

ARGUMENTS

```    p_dec_places_x (integer) - value applied to x Ordinate.
p_dec_places_y (integer) - value applied to y Ordinate.
p_dec_places_z (integer) - value applied to z Ordinate.
p_dec_places_m (integer) - value applied to m Ordinate.
```

RESULT

```    geometry (T_GEOMETRY)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.141. T_GEOMETRY/ST_Scale(p_sx p_sy p_sz p_scale_point) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Scale -- Function which scales the ordinates of the underlying geometry.
```

SYNOPSIS

```    Member Function ST_Scale (p_sx          in number,
p_sy          in number,
p_sz          in number default null,
p_scale_point in mdsys.sdo_geometrydefault null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which scales the ordinates of the underlying geometry using the provided scale factors: p_sx, p_sy, p_sz.
If any of p_sx, p_sy, p_sz are null 0.0 is substituted for their value (no effect).
p_scale_point is a point on the input geometry about which to perform the scaling.
If p_scale_point is null a zero point (with 0,0 or 0,0,0 ordinates) is used to scale the geometry about the origin.
If p_scale_point is not null, it should be a nonzero point with ordinates for scaling about a point other than the origin.
```

ARGUMENTS

```    p_sx          (number)       - Scale factor for X ordinates.
p_sy          (number)       - Scale factor for Y ordinates.
p_sz          (number)       - Scale factor for Z ordinates.
p_scale_point (sdo_geometry) - Scale point.
```

RESULT

```    geometry -- Input geometry scaled using supplied values.
```

NOTES

```    Is wrapper over mdsys.SDO_UTIL.AffineTransforms
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,4,8,4,12,4,12,10,8,10,5,14)),0.005,2,1) as tgeom,
mdsys.sdo_geometry(2001,null,sdo_point_type(2,2,null),null,null) as scale_point
from dual
Union All
select T_GEOMETRY(mdsys.sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,1, 2,4,2, 8,4,3, 12,4,4, 12,10,5, 8,10,6, 5,14,7)),0.005,2,1) as tgeom,
mdsys.sdo_geometry(3001,null,sdo_point_type(2,2,2),null,null) as scale_point
from dual
)
select a.tgeom.ST_CoordDimension() as coordDimension,
'ST_Scale(p_sx,p_sy,p_sz,p_scale_point)' as ScaleTest,
a.tgeom.ST_Scale(p_sx=>2,p_sy=>2,p_sz=>case when a.tgeom.ST_CoordDimension()=2 then null else 0.1 end,p_scale_point=>a.scale_point).geom as geom
from testGeom a

COORDDIMENSION SCALETEST                              GEOM
-------------- -----------------------------------    ----------------------------------------------------------------------------------------------------------------------------------------
2 ST_Scale(p_sx,p_sy,p_sz,p_scale_point) SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,6,14,6,22,6,22,18,14,18,8,26))
3 ST_Scale(p_sx,p_sy,p_sz,p_scale_point) SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,1.9,2,6,2,14,6,2.1,22,6,2.2,22,18,2.3,14,18,2.4,8,26,2.5))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.142. T_GEOMETRY/ST_SDO_GType [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SDO_GType -- Returns underlying mdsys.sdo_geometry's SDO_GTYPE attribute.
```

SYNOPSIS

```    Member Function ST_SDO_GType
Return Integer Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry SELF.GEOM.SDO_GTYPE attribute.
```

RESULT

```    geometry type (Integer) -- eg 2001 for 2D single point etc.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.143. T_GEOMETRY/ST_Sdo_Point_Equal [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Sdo_Point_Equal -- Compares current object (SELF) geometry's GEOM.SDO_POINT with supplied mdsys.sdo_point_type
```

SYNOPSIS

```    Member Function ST_Sdo_Point_Equal(p_sdo_point   in mdsys.sdo_point_type,
p_z_precision in integer default 2)
Return varchar2 deterministic
```

DESCRIPTION

```    This function compares current t_geometry object' SELF.GEOM.SDO_POINT object to supplied p_sdo_point.
Result can be one of the following:
0 if one or other sdo_point structure is null but not both.
1 if two non-null structures and all ordinates are equal;
-1 if sdo_point's X/Y/Z ordinates not equal
```

ARGUMENTS

```    p_sdo_point   (SDO_POINT) -- SDO_Point that is to be compared to current object geometry's SELF.GEOM.Sdo_Point element.
p_z_precision   (integer) -- Z Ordinate precision for comparison using ROUND
```

RESULT

```    -1,0,1 (Integer) --  0 if one or other sdo_point structures are null but not both.
--  1 if two non-null structures and all ordinates are equal;
-- -1 if sdo_point's X/Y/Z ordinates not equal
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.144. T_GEOMETRY/ST_SdoPoint2Ord [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SdoPoint2Ord -- Changes point encoding from SDO_POINT_TYPE to SDO_ELEM_INFO_ARRAY/SDO_ORDINATE_ARRAY.
```

SYNOPSIS

```   Function ST_SdoPoint2Ord
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    Converts underlying Point encoded in SDO_POINT_TYPE structure to one
encoded in sdo_elem_info_array/sdo_ordinate_array elements.
Honours any measure
```

RESULT

```    SELF (TO_GEOMETRY) -- Original Point with structure changed.
```

EXAMPLE

```    select &&INSTALL_SCHEMA..T_Geometry(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(10.719,8.644,NULL),NULL,NULL),0.005,3,1)
.ST_SdoPoint2Ord()
.geom as geom
from dual;

GEOM
-----------------------------------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(10.719, 8.644))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener, Jan 2013 - Port to Object method.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.145. T_GEOMETRY/ST_Segmentize [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Segmentize -- This function processes underlying non-point geometries and returns all segments that fall within the defined parameters eg measures covered by range p_start_value .. p_end_value .
```

SYNOPSIS

```    Member Function ST_Segmentize(p_filter        in varchar2 default 'ALL',
p_id            in integer  default null,
p_vertex        in T_Vertex default null,
p_filter_value  in number   default null,
p_start_value   in number   default null,
p_end_value     in number   default null,
p_unit          in varchar2 default null)
Return T_Segments deterministic,
```

ARGUMENTS

```    p_filter     (varchar2) -- One of ALL, DISTANCE, ID, MEASURE, RANGE, X or Y
p_id          (integer) -- Segment id should be in range 1..SELF.ST_NumSegments. -1 means last.
p_vertex     (t_vertex) -- Point object used to return nearest segments/segments.
p_filter_value  (float) -- Single measure (or length) along line.
p_start_value   (float) -- Measure/Length defining start point of located geometry.
p_end_value     (float) -- Measure/Length defining end point of located geometry.
p_unit       (varchar2) -- Unit of measure (UoM eg Centimeter) for length/distance calculations.
```

RESULT

```    Set of segments (T_SEGMENTs) -- A table array of T_SEGMENT objects.
```

DESCRIPTION

```    Given a start and end length, this function breaks the underlying linestring into its fundamental 2 Point LineString or 3 Point CircularStrings.
What is returned depends on the value of p_filter. The following values are supported:
1. ALL      -- All other parameters are ignored, and all segments are extracted and returned.
2. DISTANCE -- Segments within shortest distance to p_vertex.
3. ID       -- Returns segment at this position in geometry.
4. MEASURE  -- All measured segments whose measure range contains p_filter_value value, or if not measured, all segments who length from start contains p_filter_value.
5. RANGE    -- All segments whose measure range overlaps p_start_value .. p_end_value.
If the underlying geometry is not measured, p_start_value .. p_end_value are interpreted as lengths from the staring point ie p_start_Length..p_end_length.
6. X        -- Find and return all segments whose X ordinate range (eg end.x = start.x) contains the supplied (p_filter_value) X ordinate value.
7. Y        -- Find and return all segments whose Y ordinate range (eg end.Y = start.Y) contains the supplied (p_filter_value) Y ordinate value.
If a segment's end point = p_start_value then it is not returned but the next segment, whose StartPoint = p_start_value is returned.
```

NOTES

```    Supports linestrings with CircularString elements.
Return is NOT Pipelined
```

EXAMPLE

```    -- Compound line string
with data as (
select t_geometry(
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,4,2, 1,2,1, 3,2,2), -- compound line string
SDO_ORDINATE_ARRAY(252000,5526000,
252700,5526700, 252644.346,5526736.414,
252500,5526700, 252280.427,5526697.167, 252230.478,5526918.373
)
),0.05,1,1) as tgeom
from dual
)
SELECT a.tgeom.ST_Sdo_Gtype() as sdo_gtype,
t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter => 'ALL' ) ) t;

SDO_GTYPE SEGMENT
--------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2002 SEGMENT(1,1,1,Start(252000,5526000,NULL,NULL,1,2001,NULL),End(252700,5526700,NULL,NULL,2,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
2002 SEGMENT(1,1,2,Start(252700,5526700,NULL,NULL,2,2001,NULL),Mid(252644.346,5526736.414,NULL,NULL,3,2001,NULL),End(252500,5526700,NULL,NULL,4,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
2002 SEGMENT(1,1,3,Start(252500,5526700,NULL,NULL,4,2001,NULL),Mid(252280.427,5526697.167,NULL,NULL,5,2001,NULL),End(252230.478,5526918.373,NULL,NULL,6,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)

-- Extract second circular arc in linestring
WITH data as (
SELECT t_geometry(geom,0.0005,3,1) as tGeom
FROM (SELECT SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,4,2, 1,2,1, 3,2,2), -- compound line string
SDO_ORDINATE_ARRAY(
252000,5526000,
252700,5526700, 252644.346,5526736.414, 252500,5526700,
252280.427,5526697.167, 252230.478,5526918.373
)
) as geom
FROM DUAL
) f
)
SELECT 3 as p_id, t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter => 'ID',
p_id     => 3) ) t;

P_ID SEGMENT
---------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 SEGMENT(1,1,3,Start(252500,5526700,NULL,NULL,4,2001,NULL),Mid(252280.427,5526697.167,NULL,NULL,5,2001,NULL),End(252230.478,5526918.373,NULL,NULL,6,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)

-- All sides of an optimized rectangle with rings
WITH data as (
SELECT t_geometry(geom,0.0005,3,1) as tGeom
FROM (SELECT SDO_GEOMETRY(2003,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3,5,2003,3),
SDO_ORDINATE_ARRAY(0,0,10,10,200,100,100,200)) AS GEOM
FROM DUAL
) f
)
SELECT t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter => 'ALL') ) t;

SEGMENT
----------------------------------------------------------------------------------------------------------------------
SEGMENT(1,1,1,Start(0,0,NULL,NULL,1,2001,28355),End(10,0,NULL,NULL,2,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,1,2,Start(10,0,NULL,NULL,2,2001,28355),End(10,10,NULL,NULL,3,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,1,3,Start(10,10,NULL,NULL,3,2001,28355),End(0,10,NULL,NULL,4,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,1,4,Start(0,10,NULL,NULL,4,2001,28355),End(0,0,NULL,NULL,5,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,2,1,Start(100,200,NULL,NULL,1,2001,28355),End(200,200,NULL,NULL,2,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,2,2,Start(200,200,NULL,NULL,2,2001,28355),End(200,100,NULL,NULL,3,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,2,3,Start(200,100,NULL,NULL,3,2001,28355),End(100,100,NULL,NULL,4,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,2,4,Start(100,100,NULL,NULL,4,2001,28355),End(100,200,NULL,NULL,5,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)

8 rows selected

-- specific side in optimized rectangle
WITH data as (
SELECT t_geometry(geom,0.0005,3,1) as tGeom
FROM (SELECT SDO_GEOMETRY(2003,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3,5,2003,3),
SDO_ORDINATE_ARRAY(0,0,10,10,200,100,100,200)) AS GEOM
FROM DUAL
) f
)
SELECT 3 as p_id, t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter => 'ID',
p_id     => 3) ) t;

P_ID SEGMENT
---------- -----------------------------------------------------------------------------------------------------------------
3 SEGMENT(1,1,3,Start(10,10,NULL,NULL,3,2001,28355),End(0,10,NULL,NULL,4,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)

-- All segments of a 2D and 3D stroked linestring
WITH data as (
select t_geometry(geom,0.0005,3,1) as tGeom
FROM (select SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) AS GEOM
from dual UNION ALL
select SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88)) as geom
from dual
) f
)
select a.tgeom.ST_Sdo_Gtype() as sdo_gtype, t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter      => 'ALL',
p_vertex      => NULL,
p_filter_value=> NULL,
p_start_value => NULL,
p_end_value   => NULL,
p_unit        => null)) t;

SDO_GTYPE segment
--------- --------------------------------------------------------------------------------------------------------------------------------------------------------
2002 segment(1,1,1,Start(571303.231,321126.963,NULL,NULL,1,2001,28355),End(571551.298,321231.412,NULL,NULL,2,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,2,Start(571551.298,321231.412,NULL,NULL,2,2001,28355),End(572765.519,321322.805,NULL,NULL,3,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,3,Start(572765.519,321322.805,NULL,NULL,3,2001,28355),End(572739.407,321845.051,NULL,NULL,4,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,4,Start(572739.407,321845.051,NULL,NULL,4,2001,28355),End(572752.463,322641.476,NULL,NULL,5,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,5,Start(572752.463,322641.476,NULL,NULL,5,2001,28355),End(573209.428,323398.732,NULL,NULL,6,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,6,Start(573209.428,323398.732,NULL,NULL,6,2001,28355),End(573796.954,323555.406,NULL,NULL,7,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,7,Start(573796.954,323555.406,NULL,NULL,7,2001,28355),End(574436.705,323790.416,NULL,NULL,8,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,8,Start(574436.705,323790.416,NULL,NULL,8,2001,28355),End(574945.895,324051.539,NULL,NULL,9,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,9,Start(574945.895,324051.539,NULL,NULL,9,2001,28355),End(575128.681,324652.122,NULL,NULL,10,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,10,Start(575128.681,324652.122,NULL,NULL,10,2001,28355),End(575128.681,325161.311,NULL,NULL,11,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,11,Start(575128.681,325161.311,NULL,NULL,11,2001,28355),End(575898.993,325213.536,NULL,NULL,12,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,12,Start(575898.993,325213.536,NULL,NULL,12,2001,28355),End(576238.453,324521.56,NULL,NULL,13,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,13,Start(576238.453,324521.56,NULL,NULL,13,2001,28355),End(576251.509,321048.626,NULL,NULL,14,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,14,Start(576251.509,321048.626,NULL,NULL,14,2001,28355),End(575259.242,322615.364,NULL,NULL,15,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 segment(1,1,15,Start(575259.242,322615.364,NULL,NULL,15,2001,28355),End(574306.144,321296.693,NULL,NULL,16,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
3302 segment(1,1,1,Start(571303.231,321126.963,110,NULL,1,3301,28355),End(571551.298,321231.412,377.21,NULL,2,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,2,Start(571551.298,321231.412,377.21,NULL,2,3301,28355),End(572765.519,321322.805,1586.05,NULL,3,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,3,Start(572765.519,321322.805,1586.05,NULL,3,3301,28355),End(572739.407,321845.051,2105.16,NULL,4,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,4,Start(572739.407,321845.051,2105.16,NULL,4,3301,28355),End(572752.463,322641.476,2895.92,NULL,5,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,5,Start(572752.463,322641.476,2895.92,NULL,5,3301,28355),End(573209.428,323398.732,3773.96,NULL,6,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,6,Start(573209.428,323398.732,3773.96,NULL,6,3301,28355),End(573796.954,323555.406,4377.62,NULL,7,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,7,Start(573796.954,323555.406,4377.62,NULL,7,3301,28355),End(574436.705,323790.416,5054.23,NULL,8,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,8,Start(574436.705,323790.416,5054.23,NULL,8,3301,28355),End(574945.895,324051.539,5622.33,NULL,9,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,9,Start(574945.895,324051.539,5622.33,NULL,9,3301,28355),End(575128.681,324652.122,6245.56,NULL,10,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,10,Start(575128.681,324652.122,6245.56,NULL,10,3301,28355),End(575128.681,325161.311,6751.06,NULL,11,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,11,Start(575128.681,325161.311,6751.06,NULL,11,3301,28355),End(575898.993,325213.536,7517.55,NULL,12,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,12,Start(575898.993,325213.536,7517.55,NULL,12,3301,28355),End(576238.453,324521.56,8282.72,NULL,13,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,13,Start(576238.453,324521.56,8282.72,NULL,13,3301,28355),End(576251.509,321048.626,11730.53,NULL,14,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,14,Start(576251.509,321048.626,11730.53,NULL,14,3301,28355),End(575259.242,322615.364,13571.62,NULL,15,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 segment(1,1,15,Start(575259.242,322615.364,13571.62,NULL,15,3301,28355),End(574306.144,321296.693,15186.88,NULL,16,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)

30 rows selected

-- Extract 3rd/8th segment of 2D/3D stroked linestring
WITH data as (
SELECT t_geometry(geom,0.0005,3,1) as tGeom
FROM (SELECT SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) AS GEOM
FROM DUAL
UNION ALL
SELECT SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,4,2, 1,2,1, 3,2,2), -- compound line string
SDO_ORDINATE_ARRAY(
252000,5526000,
252700,5526700, 252644.346,5526736.414,
252500,5526700, 252280.427,5526697.167, 252230.478,5526918.373
)
) as geom
FROM DUAL
) f
)
SELECT case when a.tGeom.ST_HasCircularArcs()=1 then 3 else 8 end as id,
a.tgeom.ST_Sdo_Gtype() as sdo_gtype,
t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter => 'ID',
p_id     => case when a.tGeom.ST_HasCircularArcs()=1 then 3 else 8 end )) t;

ID SDO_GTYPE SEGMENT
-- --------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8      2002 SEGMENT(1,1,8,Start(574436.705,323790.416,NULL,NULL,1,2001,28355),End(574945.895,324051.539,NULL,NULL,2,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
3      2002 SEGMENT(1,1,3,Start(252700,5526700,NULL,NULL,1,2001,NULL),Mid(252644.346,5526736.414,NULL,NULL,2,2001,NULL),End(252500,5526700,NULL,NULL,3,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)

WITH data as (
select t_geometry(
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)),
0.0005,3,1) as tGeom
from dual
)
select a.tgeom.ST_Sdo_Gtype() as sdo_gtype, t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter      => 'DISTANCE',
p_vertex      => NULL,
p_filter_value=> NULL,
p_start_value => NULL,
p_end_value   => NULL,
p_unit        => null)) t;

Error report:
SQL Error: ORA-20102: If p_filter DISTANCE, then p_vertex must not be NULL.
ORA-06512: at "&&INSTALL_SCHEMA..T_GEOMETRY", line 1901
ORA-06512: at line 1

-- Find nearest segment to supplied vertex.
WITH data as (
select t_geometry(geom,0.0005,3,1) as tGeom
FROM (select SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56,  576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) as geom
from dual UNION ALL
select SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88)) as geom
from dual
) f
)
select a.tgeom.ST_Sdo_Gtype() as sdo_gtype, t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter => 'DISTANCE',
p_vertex => T_Vertex(SDO_GEOMETRY(2001,28355,SDO_POINT_TYPE(572804.687,323424.844,NULL),NULL,NULL)) )) t;

SDO_GTYPE segment
--------- -------------------------------------------------------------------------------------------------------------------------------------------------------
2002 segment(1,1,5,Start(572752.463,322641.476,NULL,NULL,5,2001,28355),End(573209.428,323398.732,NULL,NULL,6,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
3302 segment(1,1,5,Start(572752.463,322641.476,2895.92,NULL,5,3301,28355),End(573209.428,323398.732,3773.96,NULL,6,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)

-- Find segments containing measure value
WITH data as (
select t_geometry(geom,0.0005,3,1) as tGeom
FROM (select SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) AS GEOM
from dual UNION ALL
select SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88)) as geom
from dual
) f
)
select a.tgeom.ST_Sdo_Gtype() as sdo_gtype,
t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter      => 'MEASURE',
p_filter_value=> 2100.0 )) t;

SDO_GTYPE segment
--------- -------------------------------------------------------------------------------------------------------------------------------------------------------
2002 segment(1,1,4,Start(572739.407,321845.051,NULL,NULL,4,2001,28355),End(572752.463,322641.476,NULL,NULL,5,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
3302 segment(1,1,3,Start(572765.519,321322.805,1586.05,NULL,3,3301,28355),End(572739.407,321845.051,2105.16,NULL,4,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)

-- Find data within measure range if measured or length range if not
WITH data as (
select t_geometry(geom,0.0005,3,1) as tGeom
FROM (select SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) AS GEOM
from dual UNION ALL
select SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88)) as geom
from dual
) f
)
select a.tgeom.ST_Sdo_Gtype() as sdo_gtype, t.segment.ST_SdoGeometry(a.tGeom.ST_Dims()) as geom
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter      => 'RANGE',
p_start_value => 2100.0,
p_end_value   => 4300.0
)) t;

SDO_GTYPE GEOM
--------- ----------------------------------------------------------------------------------------------------------------------------------------
2002 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(572739.407,321845.051,572752.463,322641.476))
2002 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(572752.463,322641.476,573209.428,323398.732))
2002 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(573209.428,323398.732,573796.954,323555.406))
2002 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(573796.954,323555.406,574436.705,323790.416))
3302 SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(572765.519,321322.805,1586.05,572739.407,321845.051,2105.16))
3302 SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(572739.407,321845.051,2105.16,572752.463,322641.476,2895.92))
3302 SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(572752.463,322641.476,2895.92,573209.428,323398.732,3773.96))
3302 SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(573209.428,323398.732,3773.96,573796.954,323555.406,4377.62))

8 rows selected

-- Select segments which cross X ordinate value
WITH data as (
SELECT t_geometry(geom,0.0005,3,1) as tGeom
FROM (SELECT SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) AS GEOM
FROM DUAL UNION ALL
SELECT SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88)) as geom
FROM DUAL
) f
)
SELECT a.tgeom.ST_Sdo_Gtype() as sdo_gtype,
t.segment.ST_AsText() as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter      => 'X',
p_filter_value=> 571551.0)) t;

SDO_GTYPE SEGMENT
---------- --------------------------------------------------------------------------------------------------------------------------------------------------
2002 SEGMENT(1,1,1,Start(571303.231,321126.963,NULL,NULL,1,2001,28355),End(571551.298,321231.412,NULL,NULL,2,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
3302 SEGMENT(1,1,1,Start(571303.231,321126.963,110,NULL,1,3301,28355),End(571551.298,321231.412,377.21,NULL,2,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)

-- Find segments containing X ordinate value
WITH data as (
SELECT t_geometry(geom,0.0005,3,1) as tGeom
FROM (SELECT SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)) AS GEOM
FROM DUAL UNION ALL
SELECT SDO_GEOMETRY(3302,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88)) as geom
FROM DUAL
) f
)
SELECT a.tgeom.ST_Sdo_Gtype() as sdo_gtype,
t.segment.ST_AsText() as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter      => 'Y',
p_filter_value=> 321231.412)) t;

SDO_GTYPE SEGMENT
---------- ------------------------------------------------------------------------------------------------------------------------------------------------------------
2002 SEGMENT(1,1,1,Start(571303.231,321126.963,NULL,NULL,1,2001,28355),End(571551.298,321231.412,NULL,NULL,2,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 SEGMENT(1,1,2,Start(571551.298,321231.412,NULL,NULL,2,2001,28355),End(572765.519,321322.805,NULL,NULL,3,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
2002 SEGMENT(1,1,14,Start(576251.509,321048.626,NULL,NULL,14,2001,28355),End(575259.242,322615.364,NULL,NULL,15,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
3302 SEGMENT(1,1,1,Start(571303.231,321126.963,110,NULL,1,3301,28355),End(571551.298,321231.412,377.21,NULL,2,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 SEGMENT(1,1,2,Start(571551.298,321231.412,377.21,NULL,2,3301,28355),End(572765.519,321322.805,1586.05,NULL,3,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)
3302 SEGMENT(1,1,14,Start(576251.509,321048.626,11730.53,NULL,14,3301,28355),End(575259.242,322615.364,13571.62,NULL,15,3301,28355),SDO_GTYPE=3302,SDO_SRID=28355)

6 rows selected

-- Circular arc test showing mid point involved in determining if segment is selected for X ordinates.
WITH data as (
SELECT t_geometry(
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)
),0.0005,3,1)
as tGeom
FROM DUAL
)
SELECT t.segment.ST_AsText()  as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter       => 'X',
p_filter_value => 252309.544 ) ) t;

SEGMENT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SEGMENT(1,1,1,Start(252230.478,5526918.373,NULL,NULL,1,2001,NULL),Mid(252400.08,5526918.373,NULL,NULL,2,2001,NULL),End(252230.478,5527000,NULL,NULL,3,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)

-- Circular arc test showing mid point involved in determining if segment is selected for Y ordinates.
WITH data as (
SELECT t_geometry(
SDO_GEOMETRY(2002,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252700,5526700, 252644.346,5526736.414, 252500,5526700)
),0.0005,3,1)
as tGeom
FROM DUAL
)
SELECT t.segment.ST_AsText() as segment
FROM data a,
table(a.tgeom.ST_Segmentize(p_filter       => 'Y',
p_filter_value => 5526724.224 ) ) t;

SEGMENT
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SEGMENT(1,1,1,Start(252700,5526700,NULL,NULL,1,2001,NULL),Mid(252644.346,5526736.414,NULL,NULL,2,2001,NULL),End(252500,5526700,NULL,NULL,3,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)

-- Circle
With data As (
SELECT t_geometry(
SDO_GEOMETRY(2003,28355,null,
sdo_elem_info_array(1,1003,4),
SDO_ORDINATE_ARRAY(252315.279,5526865.07512246, 252409.390377544,5526959.1865, 252315.279,5527053.29787754)
),
0.0005,3,1) as circlePoly
FROM Dual
)
select t.segment.ST_AsText() as segment
from data a,
table(a.circlePoly.ST_Segmentize()) t;

SEGMENT
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SEGMENT(1,1,1,
Start(1,252315.279,5526865.07512246,NULL,NULL,2001,28355),
Mid(2,252409.39037754,5526959.1865,NULL,NULL,2001,28355),
End(3,252315.279,5527053.29787754,NULL,NULL,2001,28355),
SDO_GTYPE=2002,SDO_SRID=28355)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2017 - Original PLSQL Coding for Oracle
```

15.146. T_GEOMETRY/ST_SegmentN [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SegmentN -- Returns the segment referenced by p_segment in the underlying linear or polygonal geometry.
```

SYNOPSIS

```    Member Function ST_SegmentN(p_segment in integer)
Return &&INSTALL_SCHEMA..T_Segment Deterministic,
```

DESCRIPTION

```    Returns the 2-point segment identified by p_segment in a polygon or linestring.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GeometryType() as gType,
(row_number() over (partition by a.tgeom.ST_GeometryType() order by 1)) ||
' of ' ||
a.tGeom.ST_NumSegments() as reference,
a.tGeom.ST_SegmentN(t.IntValue).ST_AsText()  as segment
from data a,
table(TOOLS.generate_series(1,a.tgeom.ST_NumSegments(),1)) t;

GTYPE         REFERENCE SEGMENT
------------- --------- --------------------------------------------------------------------------------------------------------------
ST_LINESTRING    1 of 5 SEGMENT(1,1,1,Start(0,0,NULL,NULL,1,2001,NULL),End(10,0,NULL,NULL,2,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_LINESTRING    2 of 5 SEGMENT(1,1,2,Start(10,0,NULL,NULL,2,2001,NULL),End(10,5,NULL,NULL,3,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_LINESTRING    3 of 5 SEGMENT(1,1,3,Start(10,5,NULL,NULL,3,2001,NULL),End(10,10,NULL,NULL,4,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_LINESTRING    4 of 5 SEGMENT(1,1,4,Start(10,10,NULL,NULL,4,2001,NULL),End(5,10,NULL,NULL,5,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_LINESTRING    5 of 5 SEGMENT(1,1,5,Start(5,10,NULL,NULL,5,2001,NULL),End(5,5,NULL,NULL,6,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       1 of 8 SEGMENT(1,1,1,Start(0,0,NULL,NULL,1,2001,NULL),End(20,0,NULL,NULL,2,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       2 of 8 SEGMENT(1,1,2,Start(20,0,NULL,NULL,2,2001,NULL),End(20,20,NULL,NULL,3,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       3 of 8 SEGMENT(1,1,3,Start(20,20,NULL,NULL,3,2001,NULL),End(0,20,NULL,NULL,4,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       4 of 8 SEGMENT(1,1,4,Start(0,20,NULL,NULL,4,2001,NULL),End(0,0,NULL,NULL,5,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       5 of 8 SEGMENT(1,2,1,Start(10,10,NULL,NULL,1,2001,NULL),End(10,11,NULL,NULL,2,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       6 of 8 SEGMENT(1,2,2,Start(10,11,NULL,NULL,2,2001,NULL),End(11,11,NULL,NULL,3,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       7 of 8 SEGMENT(1,2,3,Start(11,11,NULL,NULL,3,2001,NULL),End(11,10,NULL,NULL,4,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON       8 of 8 SEGMENT(1,2,4,Start(11,10,NULL,NULL,4,2001,NULL),End(10,10,NULL,NULL,5,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)

13 rows selected
```

RESULT

```    A 2 point segment (T_SEGMENT) -- Function supplied with p_segment of 3 will return 3rd segment composed of 4th and 5th points.
```

TODO

```    Support for CircularString elements.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Sept 2015 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.147. T_GEOMETRY/ST_SetPoint [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SetPoint -- Sets, or replaces, SDO_POINT_TYPE element of underlying SDO_GEOMETRY.
```

SYNOPSIS

```    Member Function ST_SetPoint (p_point in mdsys.sdo_point_type),
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Replaces any, or no, SDO_POINT within underlying SDO_GEOMETRY object.
```

ARGUMENTS

```    p_point : mdsys.sdo_point_type : Any valid mdsys.sdo_point_type object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jun 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.148. T_GEOMETRY/ST_SetPrecision [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SetPrecision -- Sets dPrecision property value of object after construction.
```

SYNOPSIS

```    Member Function ST_SetPrecision (p_dPrecision in integer default 3),
```

DESCRIPTION

```    The dPrecision object property is normally set when the object is constructed.
This member function allows the user to change the value dynamically.
```

ARGUMENTS

```    p_dPrecision : integer : Any valid integer value for the Oracle ROUND function.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jun 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.149. T_GEOMETRY/ST_SetProjection [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SetProjection -- Sets projected property of object after query of MDSYS CS metadata.
```

SYNOPSIS

```    Member Procedure ST_SetProjection  (SELF in out &&INSTALL_SCHEMA..T_GEOMETRY),
```

DESCRIPTION

```    The projected object property is used by the methods of the T_GEOMETRY object
when executing SDO functions that require knowledge of whether the mdsys.sdo_geometry is
coordinate system is projected or geodetic. If the property is not set by a constructor,
on instantiation, this function can be used to set that property at any time.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.150. T_GEOMETRY/ST_SetSdoGtype [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SetSdoGtype -- Sets SDO_GTYPE for underlying geometry object.
```

SYNOPSIS

```    Member Function ST_SetSdoGtype (p_sdo_gtype in integer),
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    If the SDO_GTYPE property is not set by a constructor on instantiation,
this Function can be used to set that property at any time.
```

ARGUMENTS

```    p_sdo_gtype (integer) : A valid sdo_gtype number.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jul 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.151. T_GEOMETRY/ST_SetSRID [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SetSRID -- Sets SDO_SRID for underlying geometry object.
```

SYNOPSIS

```    Member Function ST_SetSRID (SELF in out &&INSTALL_SCHEMA..T_GEOMETRY),
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    If the SDO_SRID property is not set by a constructor on instantiation,
this Function can be used to set that property at any time.
```

ARGUMENTS

```    p_srid (integer) - Any valid sdo_srid number;
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jul 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.152. T_GEOMETRY/ST_SetTolerance [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SetTolerance -- Sets tolerance value of object after construction.
```

SYNOPSIS

```    Member Function ST_SetTolerance (p_tolerance in integer default 0.005),
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    The tolerance object property is normally set when the object is constructed.
This member function allows the user to change the value dynamically.
```

ARGUMENTS

```    p_tolerance : number : Any valid Oracle Spatial tolerance. Default is 5cm as per geodetic value.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jun 2017 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.153. T_GEOMETRY/ST_SmoothTile [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SmoothTile -- Smoothly polygon created from raster to segment conversion
```

SYNOPSIS

```    Member Function ST_SmoothTile
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    A polygon created from raster to segment conversion, will have many vertices falling
along the same straight line. And whose sides will be "stepped".
This function removes coincident points on a side so that a side will be defined by
only a start and end vertex. The stepped sies will be replaced with vertices in the midpoint of each step
so that any consistent stepped side will be replaced by a single line.
```

NOTES

```    Only supports polygons and multipolygons.
```

RESULT

```    geometry (T_GEOMETRY) -- Grid shaped polygon replaced by polygons with straight sides.
```

NOTES

```    Uses
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original Coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.154. T_GEOMETRY/ST_Snap [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Snap -- The function snaps a point to a linestring(2002) or multi-linestring (2006).
```

SYNOPSIS

```    Member Function ST_Snap (p_point in mdsys.sdo_geometry,
p_unit  in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRIES Deterministic,
```

DESCRIPTION

```    The function snaps a point to a linestring(2002) or multi-linestring (2006).
More than one result point may be returned if p_point was equidistant from two
separate segments/segments of the line-string.
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - A point(2001) mdsys.sdo_geometry object describing the
point for splitting the linestring.
p_unit  (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    snapped_points (T_GEOMETRIES) -- One or more points where supplied point has snapped to the linestring.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.155. T_GEOMETRY/ST_SnapN [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SnapN -- The function snaps a point to a (multi)linestring (2002/2006) and returns the requested point as a single geometry.
```

SYNOPSIS

```    Member Function ST_SnapN(p_point in mdsys.sdo_geometry,
p_id    in integer,
p_unit  in varchar2 default null)
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    The function snaps a point to a linestring(2002) or multi-linestring (2006).
ST_Snap which is called by this function can return more than one point if p_point was equidistant from two
separate segments/segments of the line-string: this function allows the caller to select a single geometry.
```

ARGUMENTS

```    p_point (Sdo_Geometry) -- A point(2001) mdsys.sdo_geometry object describing the
point for splitting the linestring.
p_id         (integer) -- Point to return. If p_id is null or > number of geometries the last is returned.
p_unit      (VarChar2) -- Unit of measure for distance calculations.
```

RESULT

```    Single Snap Point (T_Geometry) -- Nominated snapped point is returned.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.156. T_GEOMETRY/ST_Split(p_measure p_unit) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Split -- Splits linestring or multi-linestring object at measure point.
```

SYNOPSIS

```    Member Function ST_Split (p_measure in number,
p_unit    in varchar2  DEFAULT null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Wrapper member function allowing split point to be determined by a measure
```

```    ST_Split(p_vetex in T_VERTEX...);
```

ARGUMENTS

```    p_measure (Number)   - Measure defining split point.
p_unit    (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    geometry (T_GEOMETRIES) - One or more geometry objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Apr 2014 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.157. T_GEOMETRY/ST_Split(p_point p_unit) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Split -- Splits linestring or multi-linestring object at closest point on linestring to supplied point mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_Split (p_point in mdsys.sdo_geometry,
p_unit  in varchar2 DEFAULT null)
Return &&INSTALL_SCHEMA..T_GEOMETRIES Deterministic,
```

DESCRIPTION

```    Wrapper member function allowing mdsys.sdo_geometry 2001 point rather than T_Vertex.
```

```    ST_Split(p_vertex in T_VERTEX...);
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - A point used to split the linestring.
p_unit  (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    geometry (T_GEOMETRIES) - One or more geometry objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2014 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.158. T_GEOMETRY/ST_Split(p_vertex p_unit) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Split -- Splits linestring or multi-linestring object at closest point on linestring to supplied T_Vertex.
```

SYNOPSIS

```    Member Function ST_Split (p_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_unit   in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRIES Deterministic,
```

DESCRIPTION

```    Using supplied point, this function splits a linestring or multi-linestring object
at its closest point on linestring. Since the closest point may occur more than once,
multiple linestrings may be returned. Normally the point should lie on the linestring at
a vertex or between two vertices but the algorithm used will split a line even if
the point does not lie on the line. Where the point does not lie on the linestring
the algorithm approximates the nearest point on the linestring to the supplied point
and splits it there: the algorithm is ratio based and will not necessarily be accurate
for geodetic data. The function supports linestrings with circular arcs.
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - A point(2001) mdsys.sdo_geometry object describing the point for splitting the linestring.
p_unit  (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    geometry (T_GEOMETRIES) - One or more geometry objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.159. T_GEOMETRY/ST_Split_Segments(p_point p_unit p_pairs) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Split_Segments -- Splits geometry at nearest point to supplied mdsys.sdo_geometry 2001 point.
```

SYNOPSIS

```    Member Function ST_Split_Segments  (p_point in mdsys.sdo_geometry,
p_unit  in varchar2    DEFAULT null,
p_pairs in integer DEFAULT 0)
Return &&INSTALL_SCHEMA..T_SEGMENTs Deterministic,
```

DESCRIPTION

```    Wrapper member function allowing mdsys.sdo_geometry 2001 point rather than T_Vertex.
```

```    ST_Split_Segments(p_vertex t_vertex...);
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - A point used to split the linestring.
p_unit  (VarChar2)           - Unit of measure for distance calculations.
p_pairs (Integer)            - 0 : Return first split point's segments if more than one exists;
1 : Return all split point segments.
```

RESULT

```    segments (T_SEGMENTS) - One or more segment objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
DEPRECATED
April 30th. Use ....
```

15.160. T_GEOMETRY/ST_Split_Segments(p_vertex p_unit p_pairs) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Split_Segments -- Splits geometry at nearest point on the geometry to supplied vertex.
```

SYNOPSIS

```    Member Function ST_Split_Segments(p_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_unit   in varchar2    DEFAULT null,
p_pairs  in integer DEFAULT 0)
Return &&INSTALL_SCHEMA..T_SEGMENTs Deterministic,
```

DESCRIPTION

```    Using supplied vertex, the geometry is split at the nearest point on the geometry.
Normally the vertex should lie on the linestring at a specific vertex or between two
vertices but the algorithm used will split a line even if the supplied vertex does not
lie on the line. Where the point does not lie on the linestring the algorithm approximates
the nearest point on the linestring to the supplied point and splits it there.
Where a linestring splits an existing segment between two vertices, two halfs of the segment
are returned. If the split point is at an exact vertex the segment before and after are returned.
If the linestring is split at the start, the previous segment returned is null, and for the end
point the second segment returns is null. Two segments are always returned.
Since the closest point may occur more than once because the supplied vertex is perfectly between
two line-string segments all possible results are returned. The first pair occurs earlier in the
linestring than the later ones.
If p_pairs is set to 0, only the first split segments are returned.
The algorithm is ratio based and will not necessarily be accurate for geodetic data.
The function supports linestrings with circular arcs.
```

ARGUMENTS

```    p_vertex (T_VERTEX) - A vertex point used to split the linestring.
p_unit   (VarChar2) - Unit of measure for distance calculations.
p_pairs  (Integer)  - 0 : Return first split point's segments if more than one exists;
1 : Return all split point segments.
```

RESULT

```    segments (T_SEGMENTS) - One or more segment objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
DEPRECATED
April 30th. Use ...
```

15.161. T_GEOMETRY/ST_SquareBuffer [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SquareBuffer -- Creates a square buffer around (multi)linestrings.
```

SYNOPSIS

```    Member Function ST_SquareBuffer(p_distance in number,
p_curved   in number default 0,
p_unit     in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic
```

DESCRIPTION

```    This function creates a square buffer around all linestrings in an object.
A negative buffer is not possible.
```

ARGUMENTS

```    p_distance (Number)   - value > 0.0
p_curved   (Number)   - 0 = no; 1 = yes for angles in linestring (See ST_Parallel)
p_unit     (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    polygon (T_GEOMETRY) - Result of square buffering linestrings
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.162. T_GEOMETRY/ST_SRID [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SRID -- Returns underlying mdsys.sdo_geometry's SDO_SRID attribute.
```

SYNOPSIS

```    Member Function ST_SRID
Return Integer Deterministic,
```

DESCRIPTION

```    Is a wrapper over the mdsys.sdo_geometry SELF.GEOM.SDO_SRID attribute.
```

RESULT

```    spatial reference id (Integer) -- eg 8311 etc.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.163. T_GEOMETRY/ST_StartPoint [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_StartPoint -- Returns first Point in underlying geometry.
```

SYNOPSIS

```    Member Function ST_StartPoint
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    Returns first point in underlying geometry.
```

EXAMPLE

```    With data As (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as TPolygon
From Dual
)
select a.TPolygon.ST_StartPoint().ST_AsText() as Start_Point
from data a;

START_POINT
---------------
POINT (0.0 0.0)
```

RESULT

```    Point (T_GEOMETRY) -- First point in underlying geometry.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.164. T_GEOMETRY/ST_StartSegment [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_StartSegment -- Returns first Segment in underlying geometry.
```

SYNOPSIS

```    Member Function ST_StartSegment
Return &&INSTALL_SCHEMA..T_Segment Deterministic,
```

DESCRIPTION

```    Returns first segment in underlying geometry.
```

EXAMPLE

```    With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10))',null),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GeometryType()             as geometryType,
a.tGeom.ST_StartSegment().ST_AsText() as start_segment
from data a;

GEOMETRYTYPE  START_SEGMENT
------------- ------------------------------------------------------------------------------------------------------------
ST_LINESTRING SEGMENT(1,1,1,Start(0,0,NULL,NULL,1,2001,NULL),End(10,0,NULL,NULL,2,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
ST_POLYGON    SEGMENT(1,1,1,Start(0,0,NULL,NULL,1,2001,NULL),End(20,0,NULL,NULL,2,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
```

RESULT

```    Segment (T_GEOMETRY) -- First segment in underlying geometry.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.165. T_GEOMETRY/ST_StartVertex [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_StartVertex -- Returns first vertex in underlying geometry.
```

SYNOPSIS

```    Member Function ST_StartVertex
Return T_Vertex Deterministic
```

RESULT

```    Vertex (T_Vertex) -- Vertex at start of geometry.
```

DESCRIPTION

```    Returns first vertex at start of underlying geometry.
```

EXAMPLE

```    With data As (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,20 0,20 20,10 20,0 20)',null),0.005,3,1) as tLine
From Dual
)
select a.tLine.ST_StartVertex().ST_AsText() as start_vertex
from data a;

VERTEX
----------------------------------------------------------
T_Vertex(X=0.0,Y=0.0,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.166. T_GEOMETRY/ST_SwapOrdinates [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_SwapOrdinates - Allows for swapping ordinate pairs in a geometry.
```

SYNOPSIS

```    Member Function ST_SwapOrdinates (p_pair in varchar2 default 'XY' )
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Sometimes the ordinates of a geometry can be swapped such as latitude for X and Longitude for Y when it should be reversed.
This function allows for the swapping of pairs of ordinates controlled by the p_pair parameter.
The following pairs can be swapped in one call:
* XY, XZ, XM, YZ, YM, ZM
```

ARGUMENTS

```    p_pair (varchar2) - One of XY, XZ, XM, YZ, YM, ZM
```

RESULT

```    Changed geometry (sdo_geometry) - T_Geometry whose internal geom has had its ordinates swapped.
```

EXAMPLE

```    select T_GEOMETRY(sdo_geometry(3001,null,sdo_point_type(1,20,30),null,null),0.005).ST_SwapOrdinates('XY').geom as Geom
from dual;

GEOM
---------------------------------------------------------
SDO_GEOMETRY(3001,null,SDO_POINT_TYPE(20,1,30),null,null)

select T_GEOMETRY(sdo_geometry(3001,null,sdo_point_type(1,20,30),null,null),0.005).ST_SwapOrdinates('XZ').geom as Geom
from dual;

GEOM
---------------------------------------------------------
SDO_GEOMETRY(3001,null,SDO_POINT_TYPE(30,20,1),null,null)

select T_GEOMETRY(sdo_geometry(3001,null,sdo_point_type(1,20,30),null,null),0.005).ST_SwapOrdinates('YZ').geom as Geom
from dual;

GEOM
---------------------------------------------------------
SDO_GEOMETRY(3001,null,SDO_POINT_TYPE(1,30,20),null,null)

select T_GEOMETRY(sdo_geometry('LINESTRING (-32 147, -33 180)'),0.005).ST_SwapOrdinates('XY').geom as Geom
from dual;

GEOM
--------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,null,null,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147,-32, 180,-33))

select T_GEOMETRY(sdo_geometry('LINESTRING (0 50, 10 50, 10 55, 10 60, 20 50)'),0.005).ST_SwapOrdinates('XY').geom as Geom
from dual;

GEOM
------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,null,null,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(50,0, 50,10, 55,10, 60,10, 50,20))

select T_GEOMETRY(
sdo_geometry(3002,null,null,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(0,50,105, 10,50,110, 10,55,115, 10,60,120, 20,50,125)
),
0.005)
.ST_SwapOrdinates('XZ').geom as Geom
from dual;

GEOM
--------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,null,null,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(105,50,0, 110,50,10, 115,55,10, 120,60,10, 125,50,20))

select T_GEOMETRY(
sdo_geometry(3002,null,SDO_POINT_TYPE(1,20,30),
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(0,50,105, 10,50,110, 10,55,115, 10,60,120, 20,50,125)
),
0.005)
.ST_SwapOrdinates('YZ').geom as Geom
from dual;

GEOM
---------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,null,SDO_POINT_TYPE(1,30,20),SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,105,50, 10,110,50, 10,115,55, 10,120,60, 20,125,50))

select T_GEOMETRY(
sdo_geometry(3302,null,null,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(5,10,0, 20,5,NULL, 35,10,NULL, 55,10,100)
),
0.005)
.ST_SwapOrdinates('XM').geom as Geom
from dual;

GEOM
--------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,10,5, null,5,20, null,10,35, 100,10,55))

select T_GEOMETRY(
sdo_geometry(4402,null,null,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(5,10,500,0, 20,5,501,NULL, 35,10,502,NULL, 55,10,503,100)
),
0.005)
.ST_SwapOrdinates('ZM').geom as Geom
from dual;

GEOM
------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(4402,null,null,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(5,10,0,500, 20,5,null,501, 35,10,null,502, 55,10,100,503))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2009 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.167. T_GEOMETRY/ST_Tile [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Tile -- Covers envelope of supplied goemetry with a mesh of tiles of size p_Tile_X and p_Tile_Y.
```

SYNOPSIS

```    Member Function ST_Tile (
p_tile_X    in number,
p_tile_Y    in number,
p_grid_type in varchar2 Default 'TILE',
p_option    in varchar2 default 'TOUCH',
p_unit      in varchar2 default NULL
)
Returns T_GRIDS PIPELINED
```

USAGE

```    With poly As (
select t_geometry(sdo_geometry('POLYGON ((0 0,10 0,10 10,0 10,0 0))',null),0.005,2,1) as poly from dual
)
select row_number() over (order by t.gcol, t.grow) as rid,
t.gCol, t.gRow, t.geom.get_wkt()  as geom
FROM poly a,
TABLE(a.poly.ST_Tile(5.0,5.0,'TILE','TOUCH',NULL)) t;

RID GCOL GROW GEOM
--- ---- ---- ---------------------------------------
1    0    0 POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))
2    0    1 POLYGON ((0 5, 5 5, 5 10, 0 10, 0 5))
3    1    0 POLYGON ((5 0, 10 0, 10 5, 5 5, 5 0))
4    1    1 POLYGON ((5 5, 10 5, 10 10, 5 10, 5 5))
```

DESCRIPTION

```    Function that computes spatial extent of internal geometry, then uses the
p_tile_x and p_tile_y extents to compute the number of tiles that cover it.
The number of columns and rows (tiles) that cover this area is calculated using p_Tile_X/p_Tile_Y which are in SRID units.
The tiles are written out with their col/row reference using the T_GRID object type
All rows and columns are visited, with geometry objects being created that represent each tile.
Geometry object created can be:
TILE  -- Single polygon per grid cell/Tile (optimized rectangle).
BOTH  -- Single polygon per grid cell/Tile (optimized rectangle) with centre point coded in SDO_POINT_TYPE structure.
When polygon tiles are to be returned, they can represent:
MBR       -- The entire extent of the underlying geometry;
TOUCH     -- Just those touching the input geometry (Intersects);
CLIP      -- Where tile has geometric intersection with the underlying geometry it is clipped to the underlying geometry.
HALFCLIP  -- Clipped tiles that touch boundary where area is > 1/2 tile
HALFTOUCH -- Tiles that touch boundary where area is > 1/2 tile
```

ARGUMENTS

```    p_Tile_X      (number) -- Size of a Tile's X dimension in real world units.
p_Tile_Y      (number) -- Size of a Tile's Y dimension in real world units.
p_grid_type (varchar2) -- Returned geometry is either 'TILE','POINT' or 'BOTH'
p_option    (varchar2) -- MBR       -- Tiles for all geometry's MBR
TOUCH     -- Only tiles that touch geometry
CLIP      -- Return tiles for geometry only but clip using geometry boundary
HALFCLIP  -- Return clipped tiles that touch boundary where area is > 1/2 tile
HALFTOUCH -- Return tiles that touch boundary where area is > 1/2 tile
p_unit      (varchar2) -- Unit of measure for distance calculations.
```

RESULT

```    A Table of the following is returned
(
gcol Integer      -- The column reference for a tile
grow Integer      -- The row reference for a tile
geom sdo_geometry -- The polygon geometry covering the area of the Tile.
)
```

NOTES

```    Following exceptions can the thrown:
-20120 'Geometry must not be null or empty (*ERR*)'
-20121 'Unsupported geometry type (*GTYPE*)'
-20122 'p_grid_type parameter value (*VALUE*) must be TILE, POINT or BOTH'
-20123 'p_option value (*VALUE*) must be MBR, TOUCH, CLIP, HALFCLIP or HALFTOUCH.'
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM package.
Simon Greener - July 2011     - Port to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.168. T_GEOMETRY/ST_To2D [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_To2D -- Converts underlying 3D or 4D mdsys.sdo_geometry to 2D (xy).
```

SYNOPSIS

```    Member Function ST_To2D
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    This Function checks if underlying mdsys.sdo_geometry is 2D and returns unchanged.
If mdsys.sdo_geometry has more than xy ordinates (ie xyz or xym or xyzm) the geometry
is stripped of its non-xy ordinates, returning a 2D mdsys.sdo_geometry with only XY ordinates.
```

RESULT

```    SELF (TO_GEOMETRY) -- With 2D Underlying mdsys.sdo_geometry.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Albert Godfrind, July 2006, Original Coding
Bryan Hall,      July 2006, Modified to handle points
Simon Greener,   July 2006, Integrated into geom with GF.
Simon Greener,   Aug  2009, Removed GF; Modified Byan Hall's version to handle compound elements.
Simon Greener,   Jan 2013 - Port to Object method.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.169. T_GEOMETRY/ST_To3D(p_default_z) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_FixZ -- Replaces and measure/elevation NULL values with supplied value eg -9999
```

SYNOPSIS

```    Member Function ST_FixZ(p_default_z IN Number := -9999 )
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    It is not uncommon to see linear geometries having a Z or W/M value encoded as NULL while others have numeric values.
This function allows for the replacement of the NULL values with a provided value.
```

ARGUMENTS

```    p_default_z (Number) -- New geometry with all Z ordinates to the supplied value.
```

RESULT

```    SELF (TO_GEOMETRY) -- Corrected mdsys.sdo_geometry object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener,   May 2007 Original coding in GEOM package.
Simon Greener,   Aug 2009 Added support for interpolating Z values
Simon Greener,   Jan 2013 - Port to Object method.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.170. T_GEOMETRY/ST_To3D(p_start_z p_end_z p_unit) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_To3D -- Converts underlying 2D or 4D geometry to a 3D geometry.
```

SYNOPSIS

```    Member Function ST_To3D(p_start_z IN Number,
p_end_z   IN Number,
p_unit    IN varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    If underlying mdsys.sdo_geometry object is a 2D line, it converts it to 3D with supplied start and end z values.
If mdsys.sdo_geometry is 4D it is reduced to 3D with any measures being removed.
Z ordinates are using start and end values ie result is XYZ.
```

ARGUMENTS

```    p_start_z (Number) -- Assigned to first coordinates' new Z ordinate.
p_end_z   (Number) -- Assigned to last coordinate's new Z ordinate.
p_unit  (VarChar2) -- Unit of measure for distance calculations.
```

RESULT

```    New Geom (TO_GEOMETRY) -- 3D mdsys.sdo_geometry line encoded with start and end z ordinate vakyes.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener,   May 2007 Original coding in GEOM package.
Simon Greener,   Aug 2009 Added support for interpolating Z values
Simon Greener,   Jan 2013 - Port to Object method.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.171. T_GEOMETRY/ST_To3D(p_zOrdToKeep) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_To3D -- Converts underlying 2D or 4D geometry to a 3D geometry.
```

SYNOPSIS

```    Member Function ST_To3D (p_zOrdToKeep IN Integer)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    This Function checks if underlying mdsys.sdo_geometry is 2D, converts it to 3D with NULL Z ordinates.
If mdsys.sdo_geometry is 4D it is reduced to 3D with p_zordtokeep indicating which non-2D ordinate
to keep eg if 4 then result is XYW; if 3 then XYZ.
```

ARGUMENTS

```    p_zOrdToKeep -- Ignored if 2D, otherwise if moving down from 4D to 3D indicates which ord to keep ie 3 or 4 (cf LRS)
```

RESULT

```    New 3D Geom (T_GEOMETRY) -- Underlying mdsys.sdo_geometry reduced or increased to 3D.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener,   May 2007 Original coding in GEOM package.
Simon Greener,   Aug 2009 Added support for interpolating Z values
Simon Greener,   Jan 2013 - Port to Object method.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.172. T_GEOMETRY/ST_toMultiPoint [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_toMultiPoint -- Adds SDO_POINT_TYPE to existing SDO_ORDINATE_ARRAY.
```

SYNOPSIS

```   Function ST_toMultiPoint
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic
```

DESCRIPTION

```    Converts underlying geometry by adding ordinate data in SDO_POINT_TYPE structure
to point data held in sdo_elem_info_array/sdo_ordinate_array elements.
Honours any measure (if measure is Z ordinate in SDO_POINT_TYPE.
```

RESULT

```    SELF (TO_GEOMETRY) -- Original geometry with SDO_POINT added to SDO_ORDINATES
```

EXAMPLE

```    select &&INSTALL_SCHEMA..T_Geometry(SDO_GEOMETRY(2005,NULL,SDO_POINT_TYPE(10.719,8.644,NULL),SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(8,10)),0.005,3,1)
.ST_ToMultiPoint()
.geom as geom
from dual;

GEOM
---------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2005,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,2),SDO_ORDINATE_ARRAY(8,10,10.719,8.644))
```

NOTES

```    See also ST_SdoPoint2Ord and ST_Ord2SdoPoint.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener, January 2013 - Port to Object method.
Simon Greener, August 2019  - Documented and fixed operation.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.173. T_GEOMETRY/ST_Translate(p_tx p_ty p_tz) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Translate -- Function which translates the underlying geometry to a new location.
```

SYNOPSIS

```    Member Function ST_Translate (p_tx in number,
p_ty in number,
p_tz in number default null )
Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic,
```

DESCRIPTION

```    Function which translates the underlying geometry to a new location, by applying the translation values to its ordinates.
The function MOVES the geometry to a new location.
```

ARGUMENTS

```    p_tx (number) - Translation factor for X ordinates.
p_ty (number) - Translation factor for Y ordinates.
p_tz (number) - Translation factor for Z ordinates (if null, the Z ordinate is not changed).
```

RESULT

```    geometry -- Input geometry translated (moved) using supplied values.
```

NOTES

```    Is wrapper over mdsys.SDO_UTIL.AffineTransforms
```

EXAMPLE

```    With testGeom as (
select T_GEOMETRY(mdsys.sdo_geometry(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,2,4,8,4,12,4,12,10,8,10,5,14)),0.005,2,1) as tgeom
from dual
Union All
select T_GEOMETRY(mdsys.sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(2,2,1, 2,4,2, 8,4,3, 12,4,4, 12,10,5, 8,10,6, 5,14,7)),0.005,2,1) as tgeom
from dual
)
select a.tgeom.ST_CoordDimension() as coordDimension,
'ST_Translate(p_tx,p_ty,p_tz)' as TranslateTest,
a.tgeom.ST_Translate(p_tx=>10.0,p_ty=>10.0,p_tz=>case when a.tgeom.ST_CoordDimension()=2 then null else 5.0 end).geom as geom
from testGeom a;

COORDDIMENSION TRANSLATETEST                GEOM
-------------- ---------------------------- --------------------------------------------------------------------------------------------------------------------------------------
2 ST_Translate(p_tx,p_ty,p_tz) SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(12,12,12,14,18,14,22,14,22,20,18,20,15,24))
3 ST_Translate(p_tx,p_ty,p_tz) SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(12,12,6,12,14,7,18,14,8,22,14,9,22,20,10,18,20,11,15,24,12))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2015 - New implementation to replace original PLSQL based rotation function.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.174. T_GEOMETRY/ST_TravellingSalesman [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_TravellingSalesman - Constructs a path through a set of points.
```

SYNOPSIS

```    Member Function ST_TravellingSalesman(p_start_gid   in integer,
p_start_point in mdsys.sdo_point_type,
p_geo_fence   in mdsys.sdo_geometry,
p_unit        in varchar2 default 'Meter' )
Return &&INSTALL_SCHEMA..T_Geometry Deterministic,
```

DESCRIPTION

```    This function implements a very simple traveling salesman's route through a set of points.
The underlying geometry must be a MultiPoint object.
The starting point may be a point within the existing underlying geometry or a user provided point.
When p_geo_fence is provided it should be a MultiLineString object eg a set of street centrelines aggregated using SDO_AGGR_UNION.
If p_geo_fence is 2D all linestrings in it are of equal weight.
If p_geo_fence has a Z ordinate, its values define an order in the geofences.
The value that must be assigned to the z ordinate of a linestring which forms a hard boundary (such as a physical fence) must be 9.
All other Z values should be given values below 9. So, z=5 could denote a major road, while z=1 is a local street, and z=0 might mean a walking track.
When determining the next point to move to, this z ordering is used in determining where to move.
If the set of nearby objects contained a z=9 object, it would be removed from the set and the next highest chosen.
```

ARGUMENTS

```    p_start_gid          (integer) - A vertex that exists in the underlying geometry whose Z has this value.
p_start_point (sdo_point_type) - A vertex that may not exist in the underlying geometry, algorithm finds nearest point in underlying geometry to start.
p_geo_fence     (sdo_geometry) - A collection of linestrings (multilinestring) containing fences or objects that cannot be crossed unless there is nowhere else to go,
when determining the shortest path.
p_unit              (varchar2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    linestring (t_geometry) - New linestring object which is contains the directed set of points defining the salesman's path.
```

EXAMPLE

```    With data As (
SELECT SDO_GEOMETRY(2005,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1,50),
SDO_ORDINATE_ARRAY(1597.39,170.16,1374.14,4381.71,7720.98,338.55,
9288.02,4197.86,99.25,3835.6,4486.08,769.94,
1172.92,4010.55,7203.14,227.14,4946.58,3065.22,
3922.71,2841.87,2114.37,1038.88,633.82,2754.83,
4911.44,3446.1,4227.88,3860.79,6007.5,2562.07,
109.36,4410.63,7965.02,4621.98,6552.41,4739.78,
2105.39,956.52,7707.73,4672.84,2853.76,424.77,
6436.58,41.46,882.33,4735.71,1196.23,1433.89,
247.33,1300.91,2305.01,4556.07,5322.28,3006.77,
7840.55,2048.4,5852.83,3900.91,7725.62,4559.27,
707.68,0,6445.65,3296.85,9618.51,2502.49,293.1,
900.11,7373.91,4209.42,1707.32,3876.35,6503.14,
1959.38,0,3205.12,139.89,4699.76,5526.69,4247.66,
1165.67,1553.33,6049.36,2047.12,1562.06,1562.93,
3773.35,732.55,8844.67,2498.88,2714.68,3630.44,446.82,
3063.99,727.39,47.89,4120.27,1188.79,6328.6,2695.57)) as geom
FROM dual
)
select T_Geometry(a.geom,0.005,2,1).ST_TravellingSalesman(3,null).geom as tsGeom
from data a;

TSGEOM
--------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(7720.98,338.55,7203.14,227.14,6436.58,41.46,6503.14,1959.38,6049.36,2047.12,6007.5,2562.07,
6328.6,2695.57,6445.65,3296.85,5852.83,3900.91,5526.69,4247.66,4911.44,3446.1,4946.58,3065.22,
5322.28,3006.77,4227.88,3860.79,3922.71,2841.87,2714.68,3630.44,2305.01,4556.07,1707.32,3876.35,
1172.92,4010.55,1374.14,4381.71,882.33,4735.71,139.89,4699.76,109.36,4410.63,99.25,3835.6,0,
3205.12,446.82,3063.99,633.82,2754.83,1165.67,1553.33,1196.23,1433.89,1562.06,1562.93,2114.37,1038.88,
2105.39,956.52,2853.76,424.77,3773.35,732.55,4120.27,1188.79,4486.08,769.94,1597.39,170.16,727.39,47.89,
707.68,0,293.1,900.11,247.33,1300.91,6552.41,4739.78,7373.91,4209.42,7725.62,4559.27,7707.73,4672.84,
7965.02,4621.98,9288.02,4197.86,9618.51,2502.49,8844.67,2498.88,7840.55,2048.4))

With data As (
SELECT SDO_GEOMETRY(2005,NULL,NULL,
SDO_ELEM_INFO_ARRAY(1,1,50),
SDO_ORDINATE_ARRAY(1597.39,170.16,1374.14,4381.71,7720.98,338.55,
9288.02,4197.86,99.25,3835.6,4486.08,769.94,
1172.92,4010.55,7203.14,227.14,4946.58,3065.22,
3922.71,2841.87,2114.37,1038.88,633.82,2754.83,
4911.44,3446.1,4227.88,3860.79,6007.5,2562.07,
109.36,4410.63,7965.02,4621.98,6552.41,4739.78,
2105.39,956.52,7707.73,4672.84,2853.76,424.77,
6436.58,41.46,882.33,4735.71,1196.23,1433.89,
247.33,1300.91,2305.01,4556.07,5322.28,3006.77,
7840.55,2048.4,5852.83,3900.91,7725.62,4559.27,
707.68,0,6445.65,3296.85,9618.51,2502.49,293.1,
900.11,7373.91,4209.42,1707.32,3876.35,6503.14,
1959.38,0,3205.12,139.89,4699.76,5526.69,4247.66,
1165.67,1553.33,6049.36,2047.12,1562.06,1562.93,
3773.35,732.55,8844.67,2498.88,2714.68,3630.44,446.82,
3063.99,727.39,47.89,4120.27,1188.79,6328.6,2695.57)) as geom
FROM dual
)
select T_Geometry(a.geom,0.005,2,1).ST_TravellingSalesman(null,Sdo_Point_Type(359052.5,5407258.2,NULL)).geom as tsGeom
from data a;

TSGEOM
------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(359052.5,5407258.2,7707.73,4672.84,7725.62,4559.27,7965.02,4621.98,7373.91,
4209.42,6552.41,4739.78,5852.83,3900.91,5526.69,4247.66,4911.44,3446.1,4946.58,
3065.22,5322.28,3006.77,6007.5,2562.07,6328.6,2695.57,6445.65,3296.85,6049.36,2047.12,
6503.14,1959.38,7840.55,2048.4,8844.67,2498.88,9618.51,2502.49,9288.02,4197.86,7720.98,338.55,
7203.14,227.14,6436.58,41.46,4486.08,769.94,4120.27,1188.79,3773.35,732.55,2853.76,424.77,
2105.39,956.52,2114.37,1038.88,1562.06,1562.93,1196.23,1433.89,1165.67,1553.33,247.33,
1300.91,293.1,900.11,727.39,47.89,707.68,0,1597.39,170.16,633.82,2754.83,446.82,3063.99,0,
3205.12,99.25,3835.6,109.36,4410.63,139.89,4699.76,882.33,4735.71,1374.14,4381.71,1172.92,
4010.55,1707.32,3876.35,2305.01,4556.07,2714.68,3630.44,3922.71,2841.87,4227.88,3860.79))
NOTE
This is a naive, simple, and inefficient algorithm.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2016 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.175. T_GEOMETRY/ST_UpdateVertex( p_old_vertex p_new_vertex ) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_UpdateVertex -- Function that updates (replaces) all geometry points that are equal to the supplied point with the replacement point.
```

SYNOPSIS

```    Member Function ST_UpdateVertex (p_old_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_new_vertex in &&INSTALL_SCHEMA..T_Vertex)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Function that updates all coordinates that equal p_old_vertex with the supplied p_old_vertex.
SELF.dprecision is used when comparing geometry point's XY ordinates to p_old_vertex's.
Note that this version of ST_UpdateVertex allows for the update of the first and last vertex in a polygon thereby not invalidating it.
```

ARGUMENTS

```    p_old_vertex (T_Vertex) - Original coordinate to be replaced.
p_new_vertex (T_Vertex) - Replacement coordinate
```

RESULT

```    geometry (geometry) - Underlying geometry with one or more coordinates replaced.
```

EXAMPLE

```    select t_geometry(sdo_geometry('POLYGON((0 0,10 0,10 10,0 10,0 0))',NULL),0.005,2,1)
.ST_UpdateVertex(
T_Vertex(p_x         => 0.0,
p_y         => 0.0,
p_id        => 1,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL),
T_Vertex(p_x         => 1.0,
p_y         => 1.0,
p_id        => 1,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL)
).ST_AsText() as updatedGeom
from dual;

UPDATEDGEOM
---------------------------------------
POLYGON ((1 1, 10 0, 10 10, 0 10, 1 1))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM package.
Simon Greener - July 2011     - Port to T_GEOMETRY.
```

```    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener
```

15.176. T_GEOMETRY/ST_UpdateVertex(p_vertex) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_UpdateVertex -- Function which updates the coordinate at position v_vertex.id of the underlying geometry with ordinates in v_vertex.x etc.
```

SYNOPSIS

```   Member Function ST_UpdateVertex (p_vertex in &&INSTALL_SCHEMA..T_Vertex)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

EXAMPLE

```    select t_geometry(sdo_geometry('LINESTRING(0 0,2 2)',NULL),0.005,2,1)
.ST_UpdateVertex(
T_Vertex(p_x         => 1.0,
p_y         => 1.0,
p_id        => 2,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL)
).ST_AsText() as updatedGeom
from dual;

UPDATEDGEOM
-------------------
LINESTRING(0 0,1 1)
```

DESCRIPTION

```    Function that updates coordinate in the underlying geometry identified by p_vertex.id with the ordinate values in p_vertex.
p_verted.id Values:
1. null -> defaults to 1;
2. -1   -> maximum number of points ie STNumPoints(p_geometry)
3. Greater than ST_NumPoints(p_geometry) -> maximum number of points ie ST_NumPoints(p_geometry)
```

ARGUMENTS

```    p_vertex (t_vertex) - Replacement coordinate.
```

RESULT

```    updated geom (geometry) - Geometry with coordinate replaced.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM package.
Simon Greener - July 2011     - Port to T_GEOMETRY.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.177. T_GEOMETRY/ST_Validate [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_isValid -- Executes sdo_geom.validate_geometry or validate_geometry_with_context against underlying geometry and returns value.
```

SYNOPSIS

```    Member Function ST_Validate
Return varchar2 Deterministic,
```

DESCRIPTION

```    If p_context = 0 then this function executes the SDO_GEOM.VALIDATE_GEOMETRY function and returns the result.
If p_context = 1 then this function executes the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function and returns the result.
```

ARGUMENTS

```    p_context (integer) -- Value of 0 (no context); 1 (context)
```

RESULT

```    result (varchar2) -- Returns result of SDO_GEOM.VALIDATE_GEOMETRY/SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.178. T_GEOMETRY/ST_VertexN [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_VertexN -- Returns number of vertices (coordinates) in underlying mdsys.sdo_geometry.
```

SYNOPSIS

```    Member Function ST_VertexN (p_vertex in integer)
Return T_Vertex Deterministic
```

ARGUMENTS

```    p_vertex (integer) -- Vertex number between 1 and ST_NumVertices().
```

RESULT

```    Vertex (T_Vertex) -- Vertex at position p_vertex.
```

DESCRIPTION

```    Returns p_vertex vertex within underlying geometry.
p_vertex can be -1 which means the last vertex.
If p_vertex is -1, the actual point id of the last vertex is returned in the T_Vertex structure.
```

EXAMPLE

```    With data As (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),0.005,3,1) as TPolygon
From Dual
)
select a.TPolygon.ST_VertexN(-1).ST_AsText() as VertexN
from data a;

VERTEXN
-----------------------------------------------------------
T_Vertex(X=5.0,Y=5.0,Z=NULL,W=NULL,ID=15,GT=2001,SRID=NULL)

With data As (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,20 0,20 20,10 20,0 20)',null),0.005,3,1) as tLine
From Dual
)
select a.tLine.ST_VertexN(t.IntValue).ST_AsText() as vertex
from data a,
table(tools.generate_series(1,a.tLine.ST_NumVertices(),1)) t;

VERTEX
------------------------------------------------------------
T_Vertex(X=0.0,Y=0.0,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=20.0,Y=0.0,Z=NULL,W=NULL,ID=2,GT=2001,SRID=NULL)
T_Vertex(X=20.0,Y=20.0,Z=NULL,W=NULL,ID=3,GT=2001,SRID=NULL)
T_Vertex(X=10.0,Y=20.0,Z=NULL,W=NULL,ID=4,GT=2001,SRID=NULL)
T_Vertex(X=0.0,Y=20.0,Z=NULL,W=NULL,ID=5,GT=2001,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.179. T_GEOMETRY/ST_Vertices [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Vertices -- Extracts all vertices of the underlying geometry, and outputs them as a pipelined set of T_Vertex objects.
```

SYNOPSIS

```    Member Function ST_Vertices()
Return &&INSTALL_SCHEMA..T_VERTICES Pipelined
```

DESCRIPTION

```    This function allows a user to extract all the vertices of the underlying geometry as a set of T_VERTEX objects.
```

EXAMPLE

```    With geometries As (
Select T_GEOMETRY(sdo_geometry('POLYGON((0 0,20 0,20 20,0 20,0 0),(10 10,10 11,11 11,11 10,10 10),(5 5,5 7,7 7,7 5,5 5))',null),
0.005,3,1) as tPolygon
From dual
)
Select t.ST_AsText() as vertex
from GEOMETRIES a,
Table(a.tPolygon.ST_Vertices()) t;

VERTEX
-------------------------------------
T_Vertex(X=0.0,Y=0.0,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=20.0,Y=0.0,Z=NULL,W=NULL,ID=2,GT=2001,SRID=NULL)
T_Vertex(X=20.0,Y=20.0,Z=NULL,W=NULL,ID=3,GT=2001,SRID=NULL)
T_Vertex(X=0.0,Y=20.0,Z=NULL,W=NULL,ID=4,GT=2001,SRID=NULL)
T_Vertex(X=0.0,Y=0.0,Z=NULL,W=NULL,ID=5,GT=2001,SRID=NULL)
T_Vertex(X=10.0,Y=10.0,Z=NULL,W=NULL,ID=6,GT=2001,SRID=NULL)
T_Vertex(X=10.0,Y=11.0,Z=NULL,W=NULL,ID=7,GT=2001,SRID=NULL)
T_Vertex(X=11.0,Y=11.0,Z=NULL,W=NULL,ID=8,GT=2001,SRID=NULL)
T_Vertex(X=11.0,Y=10.0,Z=NULL,W=NULL,ID=9,GT=2001,SRID=NULL)
T_Vertex(X=10.0,Y=10.0,Z=NULL,W=NULL,ID=10,GT=2001,SRID=NULL)
T_Vertex(X=5.0,Y=5.0,Z=NULL,W=NULL,ID=11,GT=2001,SRID=NULL)
T_Vertex(X=5.0,Y=7.0,Z=NULL,W=NULL,ID=12,GT=2001,SRID=NULL)
T_Vertex(X=7.0,Y=7.0,Z=NULL,W=NULL,ID=13,GT=2001,SRID=NULL)
T_Vertex(X=7.0,Y=5.0,Z=NULL,W=NULL,ID=14,GT=2001,SRID=NULL)
T_Vertex(X=5.0,Y=5.0,Z=NULL,W=NULL,ID=15,GT=2001,SRID=NULL)

15 rows selected
```

RESULT

```    vertices (T_VERTICES) -- Table of T_Vertex objects.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

15.180. T_GEOMETRY/ST_Which_Side [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

```    ST_Which_Side -- Returns the side the supplied point lies on.
```

SYNOPSIS

```    Member Function ST_Which_Side(p_point in mdsys.sdo_geometry,
p_unit  in varchar2 default null)
Return &&INSTALL_SCHEMA..T_GEOMETRY Deterministic,
```

DESCRIPTION

```    Given a point this function returns the side the point lies on.
Wrapper over ST_Find_Offset
```

```    ST_Find_Offset(p_point in mdsys.sdo_geometry...);
```

ARGUMENTS

```    p_point (MDSYS.SDO_GEOMETRY) - Point geometry for which a measure is needed.
p_unit  (VarChar2)           - Unit of measure for distance calculations.
```

RESULT

```    side (VarChar2) - L if negative offset; R is positive offset; O if on line.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

16. OBJECT TYPE/T_GEOMETRY_ROW [ Types ]

[ Top ] [ Types ]

NAME

```    T_GEOMETRY_ROW - Object Type used when returning sdo_geometry objects in a pipelined function.
```

DESCRIPTION

```    An object type that allows for a SDO_GEOMETRY geometry object to be represented as a single object.
Mainly for use in PIPELINED Functions.
If one PIPES a single sdo_geometry object, it appears at the end of the pipeline as the individual 5 attributes of an sdo_geometry object and not a single sdo_geometry attribute object.
```

NOTES

```    No methods are declared on this type.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package for &&INSTALL_SCHEMA..
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

16.1. T_GEOMETRY_ROW/ATTRIBUTES(T_GEOMETRY_ROW) [ Variables ]

[ Top ] [ T_GEOMETRY_ROW ] [ Variables ]

ATTRIBUTES

```    gid        number,             -- geometry id (cf rownum).
geometry   mdsys.sdo_geometry, -- geometry object.
tolerance  number,             -- Tolerance value associated with geometry object (normally T_GEOMETRY.tolerance object)
dPrecision integer,            -- Decimal digits of precision value associated with geometry object (normally T_GEOMETRY.dPrecision object)
projected  integer,            -- Projected value associated with geometry object (normally T_GEOMETRY.projected object)
```

SOURCE

```   gid        number,
geometry   mdsys.sdo_geometry,
Tolerance  number,
dPrecision integer,
projected  integer
```

17. OBJECT TYPE/T_GRID [ Types ]

[ Top ] [ Types ]

NAME

```    T_GRID -- Object type representing a single cell in a matrix of non-overlapping (no gaps) cells.
```

DESCRIPTION

```    An object type that represents a single cell within an array of
optimized rectanges representing a grid or matrix of "raster" style objects.
Used mainly with T_GRIDS in PIPELINED T_GEOMETRY methods.
```

NOTES

```    No methods are declared on this type.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

17.1. T_GRID/ATTRIBUTES(T_GRID) [ Variables ]

[ Top ] [ T_GRID ] [ Variables ]

ATTRIBUTES

```    gCol -- Column Reference
gRow -- Row Reference
geom -- SDO_GEOMETRY coded as Optimized Rectangle.
```

SOURCE

```  gcol  number,
grow  number,
geom  mdsys.sdo_geometry
```

18. OBJECT TYPE/T_INTVALUE [ Types ]

[ Top ] [ Types ]

NAME

```    T_INTVALUE -- Object type representing a single integer in a series of integers.
```

DESCRIPTION

```    An object type that gives a name (IntValue) to a single integer within a series of integers generated by TOOLS.Generate_Series.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

18.1. T_INTVALUE/ATTRIBUTES(T_INTVALUE) [ Variables ]

[ Top ] [ T_INTVALUE ] [ Variables ]

ATTRIBUTES

```    IntValue -- Integer value returned by generate_series
```

SOURCE

```  IntValue Integer
```

19. OBJECT TYPE/T_MBR [ Types ]

[ Top ] [ Types ]

NAME

```    T_MBR - Object Type representing a Minimum Bounding Rectangle (MBR) or a geometry Envelope
```

DESCRIPTION

```    An object type that represents an MBR/Envelope of a geometry.
Includes methods to manipulate eg Expand/Contract, convert to SDO_DIM_ARRAY.
```

NOTES

```    Only supports Planar / 2D ordinates.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

19.1. T_MBR/ATTRIBUTES(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

ATTRIBUTES

```    MinX -- X Ordinate of lower left (LL) corner of MBR.
MinY -- Y Ordinate of lower left (LL) corner of MBR.
MaxX -- X Ordinate of upper right (UR) corner of MBR.
MaxY -- Y Ordinate of upper right (UR) corner of MBR.
```

SOURCE

```   MinX  Number,
MinY  Number,
MaxX  Number,
MaxY  Number,
```

19.2. T_MBR/CONSTRUCTORS(T_MBR) [ Methods ]

[ Top ] [ T_MBR ] [ Methods ]

NAME

```    A collection of &&INSTALL_SCHEMA..T_MBR Constructors.
```

SOURCE

```   Constructor Function T_MBR(SELF IN OUT NOCOPY T_MBR)
Return SELF as Result,

Constructor Function T_MBR(SELF IN OUT NOCOPY T_MBR,
p_mbr in &&INSTALL_SCHEMA..T_MBR)
Return SELF as Result,

Constructor Function T_MBR( SELF        IN OUT NOCOPY T_MBR,
p_geometry  IN MDSYS.SDO_GEOMETRY,
p_tolerance IN NUMBER DEFAULT 0.005)
Return SELF as Result,

Constructor Function T_MBR( SELF       IN OUT NOCOPY T_MBR,
p_geometry IN MDSYS.SDO_GEOMETRY,
p_dimarray IN MDSYS.SDO_DIM_ARRAY )
Return SELF as Result,

Constructor Function T_MBR( SELF      IN OUT NOCOPY T_MBR,
p_Vertex  In &&INSTALL_SCHEMA..T_Vertex,
p_dExtent In Number)
Return SELF as Result,

Constructor Function T_MBR( SELF      IN OUT NOCOPY T_MBR,
p_dX      In NUMBER,
p_dY      In Number,
p_dExtent In Number)
Return SELF as Result,
```

19.3. T_MBR/Inspectors(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

```  -- @property  : X
-- @version   : 1.0
-- @precis    : Returns the centre X ordinate of the MBR.
-- @return    : (maxx - minx) / 2
-- @returntype: Number
-- @history   : SGG August 2006 - Original Coding
Member Function X
Return Number Deterministic,

-- @property  : Y
-- @version   : 1.0
-- @precis    : Returns the centre Y ordinate of the MBR.
-- @return    : (maxy - miny) / 2
-- @returntype: Number
-- @history   : SGG August 2006 - Original Coding
Member Function Y
Return Number Deterministic,

-- @property  : Width
-- @version   : 1.0
-- @precis    : Returns the width of the MBR.
--              Width is defined as the difference between the maximum and minimum x values.
-- @return    : width (ie maxx - minx) or Empty if MBR has not been set.
-- @returntype: Number
-- @history   : SGG November 2004 - Original Coding
Member Function Width
Return Number Deterministic,

-- @property  : Height
-- @version   : 1.0
-- @precis    : Returns the height of the current MBR.
--              Height is defined as the difference between the maximum and minimum y values.
-- @return    : height (ie maxy - miny) or Empty if MBR has not been set.
-- @returntype: Number
-- @history   : SGG November 2004 - Original Coding
Member Function Height
Return Number Deterministic,

Member Function Area
Return Number Deterministic,

-- @property  : Centre
-- @version   : 1.0
-- @precis    : Returns the centre via a T_Vertex.
-- @return    : xy
-- @returntype: T_Vertex
-- @history   : SGG August 2006 - Original Coding
Member Function Centre
Return &&INSTALL_SCHEMA..T_Vertex Deterministic,

-- @property  : Center
-- @version   : 1.0
-- @precis    : Returns the center via a T_Vertex.
-- @return    : xy
-- @returntype: T_Vertex
-- @history   : SGG August 2006 - Original Coding
Member Function Center
Return &&INSTALL_SCHEMA..T_Vertex Deterministic,

-- @function  : AsDimArray
-- @version   : 1.0
-- @precis    : Method that returns MBR as a MdSys.Sdo_Dim_Array
-- @return    : SELF
-- @returntype: MdSys.Sdo_Dim_Array
-- @history   : SGG September 2005 - Original Coding
Member Function AsDimArray
Return MDSYS.SDO_DIM_ARRAY Deterministic,

-- @function  : AsString
-- @version   : 1.0
-- @precis    : Method that returns MBR as a <MBR> XML
-- @return    : <MBR...> XML
-- @returntype: VarChar2
-- @history   : SGG April 2002 - Original Coding
Member Function AsString
Return VarChar2 Deterministic,

-- @function  : AsCSV
-- @version   : 1.0
-- @precis    : Provides a comma delimited string representation.
-- @return    : Comma delimited MBR string
-- @returntype: VarChar2
-- @history   : SJH Feb 2003 - Original Coding
Member Function AsCSV
Return VarChar2 Deterministic,

Member Function AsWKT
Return VARCHAR2 Deterministic,

-- @function  : AsSVG
-- @version   : 1.0
-- @precis    : Returns MBR object as SVG <rect > xml
-- @return    : SVG <rect> XML
-- @returntype: VarChar2
-- @history   : SGG April 2002 - Original Coding
Member Function AsSVG
Return VarChar2 Deterministic,

-- @function  : getCentreAsSVG
-- @version   : 1.0
-- @precis    : Returns centre coordinate of MBR object as SVG <point> xml
-- @return    : SVG <point> XML
-- @returntype: VarChar2
-- @history   : SGG April 2002 - Original Coding
Member Function getCentreAsSVG
Return VarChar2 Deterministic,
```

19.4. T_MBR/Modifiers(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

```  Member Procedure SetEmpty(SELF IN OUT NOCOPY T_MBR),

-- ----------------------------------------------------------------------------------------
-- @procedure  : SetToPart
-- @precis     : initialiser that sets SELF to MBR of the smallest/largest part in a multi-part shape.
-- @version    : 1.0
-- @description: Occasionally the MBR of the smallest/largest part of a multi-part shape is
--               needed - see sdo_centroid.  SELF.function iterates over all the parts of
--               a multi-part (SDO_GTYPE == 2007) shape, computes their individual MBRs
--               and returns the smallest/largest.
-- @usage      : FUNCTION SetToPart ( p_geometry IN MDSYS.SDO_GEOMETRY );
--               eg SetToPart(shape,diminfo);
-- @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A shape.
-- @param      : p_which     : integer        : Flag indicating smallest (0) part required or largest (1)
-- @history    : Simon Greener - Feb 2012 - Original coding.
-- @copyright  : GPL - Free for public use
Member Function SetToPart(p_geometry in mdsys.sdo_geometry,
p_which    in integer /* 0 smallest, 1 largest */ )
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

-- ----------------------------------------------------------------------------------------
-- @procedure  : SetSmallestPart
-- @precis     : initialiser that sets SELF to MBR of the smallest part in a multi-part shape.
-- @version    : 1.0
-- @description: Occasionally the MBR of the smallest part of a multi-part shape is
--               needed - see sdo_centroid.  SELF.function iterates over all the parts of
--               a multi-part (SDO_GTYPE == 2007) shape, computes their individual MBRs
--               and returns the smallest.
-- @usage      : FUNCTION SetSmallestPart ( p_geometry IN MDSYS.SDO_GEOMETRY );
--               eg SetSmallestPart(shape,diminfo);
-- @param      : p_geometry  : A shape.
-- @paramtype  : p_geomery   : MDSYS.SDO_GEOMETRY
-- @history    : Simon Greener - Feb 2012 - Original coding.
-- @copyright  : GPL - Free for public use
Member Function SetSmallestPart(p_geometry IN MDSYS.SDO_GEOMETRY )
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

-- ----------------------------------------------------------------------------------------
-- @procedure  : SetLargestPart
-- @precis     : initialiser that sets SELF to MBR of the largest part in a multi-part shape.
-- @version    : 1.0
-- @description: Occasionally the MBR of the largest part of a multi-part shape is
--               needed - see sdo_centroid.  SELF.function iterates over all the parts of
--               a multi-part (SDO_GTYPE == 2007) shape, computes their individual MBRs
--               and returns the largest.
-- @usage      : FUNCTION SetLargestPart ( p_geometry IN MDSYS.SDO_GEOMETRY );
--               eg SetLargestPart(shape,diminfo);
-- @param      : p_geometry  : A shape.
-- @paramtype  : p_geomery   : MDSYS.SDO_GEOMETRY
-- @history    : Simon Greener - Apr 2003 - Original coding.
-- @copyright  : GPL - Free for public use
Member Function SetLargestPart(p_geometry IN MDSYS.SDO_GEOMETRY )
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

Member Function Intersection(p_other In &&INSTALL_SCHEMA..T_MBR )
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

Member Function Expand(p_Vertex IN &&INSTALL_SCHEMA..T_Vertex)
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

-- @function  : Expand
-- @version   : 1.0
-- @precis    : Enlarges the boundary of the Current MBR so that it contains (x,y).
--              Does nothing if (x,y) is already on or within the boundaries.
-- @param     : dX - the value to lower the minimum x to or to raise the maximum x to
-- @paramType : double
-- @param     : dY -  the value to lower the minimum y to or to raise the maximum y to
-- @paramType : double
-- @history   : SGG November 2004 - Original Coding
Member Function Expand(p_dX IN NUMBER,
p_dY IN NUMBER)
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

-- @procedure : Expand
-- @version   : 1.0
-- @precis    : Enlarges the boundary of the Current MBR so that it contains another MBR.
--              Does nothing if other is wholly on or within the boundaries.
-- @param     : p_other - MBR to merge with
-- @paramType : T_MBR
-- @history   : SGG November 2004 - Original Coding
Member Function Expand(p_other IN &&INSTALL_SCHEMA..T_MBR)
Return &&INSTALL_SCHEMA..T_MBR Deterministic,

-- @function  : Normalize(ratio)
-- @version   : 1.0
-- @precis    : Method that adjusts width/height etc based on passed ratio eg imageWidth/imageHeight.
--              If > 0 then the MBR's width is changed to height * ratio.
--              If < 0 then the MBR's height is changed to width * ratio.
-- @history   : SGG August 2006 - Original Coding
Member Function Normalize(p_dRatio In Number)
Return &&INSTALL_SCHEMA..T_MBR Deterministic,
```

19.5. T_MBR/Sorting(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

```  -- @function  : Equals
-- @version   : 1.0
-- @precis    : Tests to see if an MBR is equal to another.
-- @return    : True if p_other is equal to Current else false
-- @returntype: Boolean
-- @history   : SGG November 2004 - Original Coding
Member Function Equals(   p_other In &&INSTALL_SCHEMA..T_MBR )
Return Boolean Deterministic,

-- @function  : Evaluate
-- @version   : 1.0
-- @precis    : Returns value that can be used to company two MBRs in an expression of type MBR < OTHER MBR
-- @return    : Computed number.
-- @returntype: Number
-- @history   : SGG August 2006 - Original Coding
Order
Member Function Evaluate(p_other In &&INSTALL_SCHEMA..T_MBR)
Return Integer
```

19.6. T_MBR/Testers(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

```   Member Function isEmpty
Return Boolean Deterministic,

-- @function  : contains
-- @version   : 1.0
-- @precis    : Returns true if all points on the boundary of p_other
--              lie in the interior or on the boundary of current MBR.
-- @return    : True or False
-- @returntype: Boolean
-- @history   : SGG November 2004 - Original Coding
Member Function Contains( p_other In &&INSTALL_SCHEMA..T_MBR )
Return Boolean Deterministic,

-- @function  : Contains
-- @version   : 1.0
-- @precis    : Method that tests if a point is within the current MBR
-- @return    : True or False
-- @returntype: Boolean
-- @history   : SGG November 2004 - Original Coding
Member Function Contains( p_dX In Number,
p_dY In Number )
Return Boolean Deterministic,

Member Function Contains( p_vertex In mdsys.vertex_type )
Return Boolean Deterministic,

Member Function Contains( p_vertex In &&INSTALL_SCHEMA..T_Vertex )
Return Boolean Deterministic,

-- @function  : Compare
-- @version   : 1.0
-- @precis    : compares 2 MBRs and returns percentage area of overlap.
-- @return    : 0 (don't overlap) - 100 (equal)
-- @returntype: Number
-- @history   : SGG May 2005 - Original Coding
--
Member Function Compare( p_other In spdba.T_MBR )
Return Integer Deterministic,

-- @function  : Overlap
-- @version   : 1.0
-- @precis    : Returns true if any points on the boundary of another MBR
--              coincide with any points on the boundary of SELF.MBR.
-- @return    : True or False
-- @returntype: Boolean
-- @history   : SGG November 2004 - Original Coding
Member Function Overlap( p_other in &&INSTALL_SCHEMA..T_MBR )
Return Boolean Deterministic,

-- @function : Intersects
-- @version  : 1.0
-- @precis   : Test the point q to see whether it intersects the Envelope defined by p1-p2
-- @param    : p1 one extremal point of the envelope
-- @param    : p2 another extremal point of the envelope
-- @param    : q the point to test for intersection
-- @return   : true if q intersects the envelope p1-p2
Static Function Intersects(p1 in spdba.T_Vertex, p2 in spdba.T_Vertex, q in spdba.T_Vertex)
Return boolean Deterministic,

/**
* Tests whether the envelope defined by p1-p2
* and the envelope defined by q1-q2
* intersect.
*
* @param p1 one extremal point of the envelope P
* @param p2 another extremal point of the envelope P
* @param q1 one extremal point of the envelope Q
* @param q2 another extremal point of the envelope Q
* @return <code>true</code> if Q intersects P
*/
Static Function Intersects (
p1 in spdba.t_vertex, p2 in spdba.T_Vertex,
q1 in spdba.t_vertex, q2 in spdba.t_vertex)
Return boolean Deterministic,
```

20. OBJECT TYPE/T_PrecisionModel [ Types ]

[ Top ] [ Types ]

NAME

```    T_PrecisionModel -- Object type holding ordinate precision values
```

DESCRIPTION

```    JTS has a PrecisionModel class. With the use of NUMBER data type most of the JTS PrecisionModel types (eg FIXED, FLOATING_SINGLE etc)
are not neded. What is needed is a single place one can record XY, Z and M ordinate precision (scale) values.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21. OBJECT TYPE/T_SEGMENT [ Types ]

[ Top ] [ Types ]

NAME

```    T_SEGMENT -- Object type representing a single 2-point linestring or single 3 point circular arc.
```

DESCRIPTION

```    An object type that represents a single segment of a linestring.
A segment is composed of a minimum of two T_VERTEX objects with Implied director (SEGMENT) from start to end.
When a segment/segment contains a mid coordinate, that segment defines a circular arc.
Includes Methods on that type.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.1. T_SEGMENT/ATTRIBUTES [ Variables ]

[ Top ] [ T_SEGMENT ] [ Variables ]

ATTRIBUTES

```    element_id    -- Top level part identifier of multi-part geometry
eg multi-linestring composed of two lines generates element_ids 1 and 2.
subelement_id -- Part id of any sub-elements of a single geometry part
eg inner ring of a single polygon; circular curve of single linestring.
segment_id    -- Id of segments in sequential order appears in original geometry
startCoord    -- Ordinates of start point
midCoord      -- Ordinates of mid point of circular arc
endCoord      -- Ordinates of end point
sdo_gtype     -- Geometry Type of segment
sdo_srid      -- Spatial Reference ID of segment
projected      -- If planar then 1 else 0
precisionModel -- Holds precision information for object
```

SOURCE

```  element_id     integer,
subelement_id  integer,
segment_Id     Integer,
startCoord     &&INSTALL_SCHEMA..T_Vertex,
midCoord       &&INSTALL_SCHEMA..T_Vertex, /* If circular arc */
endCoord       &&INSTALL_SCHEMA..T_Vertex,
sdo_gtype      integer,
sdo_srid       integer,
projected      integer,
PrecisionModel &&INSTALL_SCHEMA..T_PrecisionModel,  /* Holds XYZM ordinate scale/precision values */
```

21.2. T_SEGMENT/ATTRIBUTES(T_SEGMENT) [ Variables ]

[ Top ] [ T_SEGMENT ] [ Variables ]

ATTRIBUTES

```           XY -- Single scale/precision value for X and Y ordinates.
Z -- Scale/precision value for the Z ordinate.
W -- Scale/precision value for the W ordinate.
tolerance -- Standard Oracle Spatial tolerance value eg 0.005.
```

SOURCE

```  xy        integer,
z         integer,
w         integer,
tolerance number
```

21.3. T_SEGMENT/CONSTRUCTORS(T_SEGMENT) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    A collection of T_SEGMENT Constructors.
```

SOURCE

```  -- Useful as an "Empty" constructor.
Constructor Function T_SEGMENT(SELF IN OUT NOCOPY T_SEGMENT)
Return Self As Result,

Constructor Function T_SEGMENT(SELF     IN OUT NOCOPY T_SEGMENT,
p_segment in &&INSTALL_SCHEMA..T_SEGMENT)
Return Self As Result,

Constructor Function T_SEGMENT(SELF         IN OUT NOCOPY T_SEGMENT,
p_line       in mdsys.sdo_geometry,
p_segment_id in integer default 0,
p_precision  in integer default 3,
p_tolerance  in number default 0.005
)
Return Self As Result,

Constructor Function T_SEGMENT(SELF        IN OUT NOCOPY T_SEGMENT,
p_sdo_gtype In Integer,
p_sdo_srid  In Integer,
p_projected in integer default 1,
p_precision in integer default 3,
p_tolerance in number  default 0.005)
Return Self As Result,

-- T_VERTEX Constructors
Constructor Function T_SEGMENT(SELF         IN OUT NOCOPY T_SEGMENT,
p_segment_id In Integer,
p_startCoord In &&INSTALL_SCHEMA..T_Vertex,
p_endCoord   In &&INSTALL_SCHEMA..T_Vertex,
p_sdo_gtype  In Integer default null,
p_sdo_srid   In Integer default null,
p_projected  in integer default 1,
p_precision  in integer default 3,
p_tolerance  in number  default 0.005)
Return Self As Result,

Constructor Function T_SEGMENT(SELF         IN OUT NOCOPY T_SEGMENT,
p_segment_id In Integer,
p_startCoord In &&INSTALL_SCHEMA..T_Vertex,
p_midCoord   In &&INSTALL_SCHEMA..T_Vertex,
p_endCoord   In &&INSTALL_SCHEMA..T_Vertex,
p_sdo_gtype  In Integer default null,
p_sdo_srid   In Integer default null,
p_projected  in integer default 1,
p_precision  in integer default 3,
p_tolerance  in number  default 0.005 )
Return Self As Result,

Constructor Function T_SEGMENT(SELF            IN OUT NOCOPY T_SEGMENT,
p_element_id    In Integer,
p_subelement_id In Integer,
p_segment_id    In Integer,
p_startCoord    In &&INSTALL_SCHEMA..T_Vertex,
p_endCoord      In &&INSTALL_SCHEMA..T_Vertex,
p_sdo_gtype     In Integer default null,
p_sdo_srid      In Integer default null,
p_projected     in integer default 1,
p_precision     in integer default 3,
p_tolerance     in number default 0.005)
Return Self As Result,

Constructor Function T_SEGMENT(SELF            IN OUT NOCOPY T_SEGMENT,
p_element_id    In Integer,
p_subelement_id In Integer,
p_segment_id    In Integer,
p_startCoord    In &&INSTALL_SCHEMA..T_Vertex,
p_midCoord      In &&INSTALL_SCHEMA..T_Vertex,
p_endCoord      In &&INSTALL_SCHEMA..T_Vertex,
p_sdo_gtype     In Integer default null,
p_sdo_srid      In Integer default null,
p_projected     in integer default 1,
p_precision     in integer default 3,
p_tolerance     in number default 0.005)
Return Self As Result,

-- MDSYS.VERTEX_TYPE Constructors
Constructor Function T_SEGMENT(SELF         IN OUT NOCOPY T_SEGMENT,
p_segment_id In Integer,
p_startCoord In mdsys.vertex_type,
p_endCoord   In mdsys.vertex_type,
p_sdo_gtype  In Integer default null,
p_sdo_srid   In Integer default null,
p_projected  in integer default 1,
p_precision  in integer default 3,
p_tolerance  in number default 0.005
)
Return Self As Result,

Constructor Function T_SEGMENT(SELF         IN OUT NOCOPY T_SEGMENT,
p_segment_id In Integer,
p_startCoord In mdsys.vertex_type,
p_midCoord   In mdsys.vertex_type,
p_endCoord   In mdsys.vertex_type,
p_sdo_gtype  In Integer default null,
p_sdo_srid   In Integer default null,
p_projected  in integer default 1,
p_precision  in integer default 3,
p_tolerance  in number  default 0.005)
Return Self As Result,
```

21.4. T_SEGMENT/OrderBy [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    OrderBy -- Implements ordering function that can be used to sort a collection of T_Vertex objects.
```

SYNOPSIS

```    Order Function OrderBy(p_segment in &&INSTALL_SCHEMA..T_SEGMENT)
Return Number deterministic
```

ARGUMENTS

```    p_segment (T_SEGMENT) - Order pair
```

DESCRIPTION

```    This order by function allows a collection of T_Vertex objects to be sorted.
For example in the ORDER BY clause of a SELECT statement.
Comparison only uses ordinates: X, Y, Z and W.
If precision is an issue, the two segments have to be rounded before this method can be used.
```

EXAMPLE

```    With segments as (
select T_SEGMENT(p_segment_id=> LEVEL,
p_startCoord=>T_Vertex(p_x=>dbms_random.value(0,level),
p_y=>dbms_random.value(0,level),
p_id=>1,
p_sdo_gtype=>2001,
p_sdo_srid=>null),
p_endCoord=>T_Vertex(p_x=>dbms_random.value(0,level),
p_y=>dbms_random.value(0,level),
p_id=>2,
p_sdo_gtype=>2001,
p_sdo_srid=>null),
p_sdo_gtype=>3002,
p_sdo_srid=>null
) as segment
from dual
connect by level < 5
)
select a.segment.st_astext(2) as segment
from segments a
order by a.segment;

SEGMENT
---------------------------------------------------------------------------------------------------------------------------
SEGMENT(NULL,NULL,1,Start(.51,.86,NULL,NULL,1,2001,NULL),End(.2,.43,NULL,NULL,2,2001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)
SEGMENT(NULL,NULL,2,Start(1.3,1.31,NULL,NULL,1,2001,NULL),End(.96,1.56,NULL,NULL,2,2001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)
SEGMENT(NULL,NULL,3,Start(.84,2.03,NULL,NULL,1,2001,NULL),End(.55,.23,NULL,NULL,2,2001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)
SEGMENT(NULL,NULL,4,Start(2.69,1.34,NULL,NULL,1,2001,NULL),End(2.65,1.37,NULL,NULL,2,2001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)

4 rows selected
```

RESULT

```    order value (NUMBER) - -1 less than; 0 equal; 1 greater than
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_AddCurveBetweenSegments -- Adds Circular Curve between two segments
```

SYNOPSIS

```    Member Function ST_AddCurveBetweenSegments(
p_segment   In &&INSTALL_SCHEMA..T_Segment,
p_iVertex   in &&INSTALL_SCHEMA..T_Verex default NULL,
p_unit      In varchar2      default NULL)
Return mdsys.sdo_Geometry Deterministic,
```

DESCRIPTION

```    Adds Circular Curve between two segments.
The segments can be 2 point linestrings or 3 point circular curves.
How the circular cuve is added depends on the parameters.
1. If SELF and p_segment do not meet, and the intersectoin point between
SELF.endCoord and p_segment.startCoord is not provided, the intersection point
is computed using ST_IntersectDetail.
3. If p_iVertex, p_radius are not provided, the best circular arc is fittd.
The implementation honours 3D and 4D shapes and averages these dimension values
for the new vertices.
```

ARGUMENTS

```    p_segment (T_Segment) -- Other, unconnected, segment
p_iVertex  (T_Vertex) -- The intersectoin point between the two segments.
p_unit     (Varchar2) -- If NULL, the calculations are done using the underlying projection default units.
If an Oracle Unit of Measure is supplied (eg unit=M) that is value for the SRID,
this value is used when calculating the p_offset distance.
```

RESULT

```    geometry (sdo_geometry) -- sdo_geometry with self and p_segment joined by circular arc.
```

EXAMPLE

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 -- Original coding.
Simon Greener - August 2018  -- Ensure all cases correct esp for 3D (XYZ)
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.6. T_SEGMENT/ST_Angle [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Angle -- Computes the angle that the vector defined by this segment makes with the X-axis.
```

SYNOPSIS

```      Member Function ST_Angle
Return number Deterministic,
```

DESCRIPTION

```    Computes the angle that the vector defined by this segment makes with the X-axis.
The angle will be in the range [ -PI, PI ] radians.
```

RESULT

```    angle (Number) -- The angle this segment makes with the X-axis (in radians)
```

EXAMPLE

```    -- Simple angle
select round(
T_Segment(
sdo_geometry('LINESTRING(0 0,10 10)',null)
).ST_Angle(),
3
) as angle
from dual;

ANGLE
----------
.785
```

```    T_SEGMENT.ST_Bearing
COGO.ST_Degrees
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.7. T_SEGMENT/ST_AsText [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_AsText -- Returns text Description of underlying segment
```

SYNOPSIS

```    Member Function ST_AsText
Return Varchar2 Deterministic,
```

DESCRIPTION

```    Returns textual description of segment.
```

RESULT

```    String - T_SEGMENT in text format.
```

EXAMPLE

```    with data as (
select sdo_geometry(4402,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,1.3456,0.0005, 10.87365,11.983645,1.98434,14.38573)) as geom
From Dual
Union all
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,1.3456,10.87365,11.983645,1.98434)) as geom
From Dual
Union all
select sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,       10.87365,11.983645        )) as geom
from dual
)
select T_Segment(a.geom).ST_AsText() as geomText
from data a;

GEOMTEXT
------------------------------------------------------------------------------------------------------------------------------------------------
SEGMENT(NULL,NULL,0,Start(1,.0023763,.18349,1.346,.001,4401,NULL),End(2,10.87365,11.983645,1.984,14.386,4401,NULL),SDO_GTYPE=4402,SDO_SRID=NULL)
SEGMENT(NULL,NULL,0,Start(1,.0023763,.18349,1.346,NULL,3001,NULL),End(2,10.87365,11.983645,1.984,NULL,3001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)
SEGMENT(NULL,NULL,0,Start(1,.0023763,.18349,NULL,NULL,2001,NULL),End(2,10.87365,11.983645,NULL,NULL,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
```

TODO

```    Create Function, ST_FromText(), to create T_Segment from ST_AsText representation.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.8. T_SEGMENT/ST_AsWKT [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_AsWKT -- Exports T_SEGMENT object to its Extended Well Known Text (EWKT).
```

SYNOPSIS

```    Member Function ST_AsWKT
Return varchar2 Deterministic,
```

DESCRIPTION

```    Returns Extended Well Known Text representation of underlying T_GEOEMTRY.
Supports 2D/3D/4D t_segments.
Formatting of ordinates supported by supplied p_format_model eg TM9 or FM999999999999990D0
```

RESULT

```    WKT (CLOB) -- eg Well Known Text encoding of mdsys.sdo_geometry object.
```

EXAMPLE

```    With data as (
select t_segment(sdo_geometry(2002,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.4743434348,5526918.37343433, 252400.034348,5526918.33434333473,252230.4434343378,5527000.433445660))) as segment
from dual union all
select t_segment(SDO_GEOMETRY(3002,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.478,5526918.373,1.5, 252400.08,5526918.373,1.5, 252230.478,5527000.0,1.5))) as segment
from dual union all
select t_segment(SDO_GEOMETRY(3302,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.478,5526918.373,0.0, 252400.08,5526918.373,417.4, 252230.478,5527000.0,506.88))) as segment
from dual union all
select t_segment(SDO_GEOMETRY(4402,28355,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.478,5526918.373,1.5,0.0, 252400.08,5526918.373,1.5,417.4, 252230.478,5527000.0,1.5,506.88))) as segment
from dual union all
select t_segment(sdo_geometry(2002,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(100,100,900,900.0))) as segment
from dual union all
select t_segment(sdo_geometry(3002,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(0,0,1, 10,0,2))) as segment
from dual union all
select t_segment(sdo_geometry(3302,NULL,NULL,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(0,0,1.5, 10,0,1.5, 10,5,1.5 ))) as segment
from dual union all
select t_segment(sdo_geometry(4402,4283,null,
sdo_elem_info_array(1,2,1),
sdo_ordinate_array(147.5,-42.5,849.9,102.0, 147.6,-42.5,1923.0,2100.0))) as segment
From Dual
)
select a.segment.sdo_gtype as gtype,
a.segment
.ST_Round(3)
.ST_AsEWKT('TM9') as ewkt
from data a;

GTYPE EWKT
----- ------------------------------------------------------------------------------------------------------------------------
2002 SRID=28355;CIRCULARSTRING (252230.474 5526918.373,252400.034 5526918.334,252230.443 5527000.433)
3002 SRID=28355;CIRCULARSTRINGZ (252230.478 5526918.373 1.5,252400.08 5526918.373 1.5,252230.478 5527000 1.5)
3302 SRID=28355;CIRCULARSTRINGM (252230.478 5526918.373 0,252400.08 5526918.373 417.4,252230.478 5527000 506.88)
4402 SRID=28355;CIRCULARSTRINGZM (252230.478 5526918.373 1.5 0,252400.08 5526918.373 1.5 417.4,252230.478 5527000 1.5 506.88)
2002 LINESTRING (100 100,900 900)
3002 LINESTRINGZ (0 0 1,10 0 2)
3302 LINESTRINGM (0 0 1.5,10 0 1.5)
4402 SRID=4283;LINESTRINGZM (147.5 -42.5 849.9 102,147.6 -42.5 1923 2100)

8 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.9. T_SEGMENT/ST_Bearing [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Bearing -- Returns Bearing, in degrees, from start to end (possibly normalized to 0..360 degree range.
```

SYNOPSIS

```    Member Function ST_Bearing(p_normalize in integer default 1)
Return Number Deterministic
```

DESCRIPTION

```    This function computes a bearing from the current object point's startCoord to its EndCoord.
ST_Bearing returns a whole circle bearing in range 0..360 is normalize flag is set.
```

ARGUMENTS

```    p_normalize (integer) -- 1 is normalise bearing to 0..360 degree range, 0 leave as calculated
```

RESULT

```    bearing (Number) -- Bearing in Degrees.
```

EXAMPLE

```    -- Simple bearing for projected data
select round(
T_Segment(
sdo_geometry('LINESTRING(0 0,10 10)',null)
).ST_Bearing(
),3) as bearing
from dual;

BEARING
-------
45

-- Simple geodetic bearing (2D)
select COGO.DD2DMS(
T_Segment(
sdo_geometry(2002,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5,-42.5, 147.6,-42.5))
).ST_Bearing(
)) as bearing
from dual;

BEARING
-----------
90°2'1.606"
```

```    T_VERTEX.ST_Bearing
COGO.ST_Degrees
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.10. T_SEGMENT/ST_CheckZ [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_CheckZ -- Checks Z values on linString or CircularArc
```

SYNOPSIS

```    Member Function ST_CheckZ
Return Integer Deterministic,
```

DESCRIPTION

```    The circularArc mathematics are considered to be 2D;
If a circularArc coordinate contains a Z ordinate, then its value has to be the same for all coordinates to remain in the same plane;
If the segment is a lineString, its Z values don't need checking;.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 if segment's Z ordinates pass checking.
```

NOTES

```    See also t_segment constructors that take a valid midCoord t_vertex parameter value.
Where ST_CheckZ fails for a t_segment constructor, the error message is the same as for SQL Server Spatial.
```

EXAMPLE

```    -- Check ST_CheckZ for valid planar circularArc segment
select T_Segment(
SDO_GEOMETRY(3002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252230.478,5526918.373,1.0, 252400.08,5526918.373,1.0, 252230.478,5527000.0,1.0))
).ST_CheckZ() as tsegment
from dual;

TSEGMENT
----------
1

-- Test ST_CheckZ built in to circularArc segment constructors
select T_Segment(
SDO_GEOMETRY(3002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252230.478,5526918.373,2.0, 252400.08,5526918.373,2.5, 252230.478,5527000.0,3.0))
) as tsegment
from dual;

Error starting at line 129 in command:
select T_Segment(SDO_GEOMETRY(3002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252230.478,5526918.373,2.0, 252400.08,5526918.373,2.5, 252230.478,5527000.0,3.0)))
as geom from dual
Error report:
SQL Error: ORA-20214: Circular arc segments with Z values must have equal Z value for all 3 points.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.11. T_SEGMENT/ST_Closest(p_geometry p_unit) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Closest -- Finds nearest point on line where supplied geometry comes closest (snap to).
```

SYNOPSIS

```    Member Function ST_Closest(p_geometry  in mdys.sdo_geometry,
p_unit      In varchar2 DEFAULT NULL
)
Return &&INSTALL_SCHEMA..T_Vertex Deterministic
```

DESCRIPTION

```    Finds nearest point on segment where supplied geometry comes closest (snap).
Computations respect SRID and unit as uses SDO_GEOM.SDO_CLOSEST_POINTS.
If SDO_GEOM.SDO_CLOSEST_POINTS fails, a result is calculated using planar arithmetic.
This function handles fact that SDO_GEOM function does not support measured segments.
```

ARGUMENTS

```    p_geometry (sdo_geometry) - Any sdo_geometry object.
p_unit    (Varchar2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    vertex    (T_Vertex) -- Nearest point on line supplied vertex is nearest to.
```

EXAMPLE

```    -- Planar
-- Planar 3D
With tGeom as (
select sdo_geometry(3001,90000006,Sdo_point_type(562038.848,1013262.454,0.0),NULL,NULL) as geometry,
t_geometry(SDO_GEOMETRY(3002,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
562046.642,1013077.602,0, 562032.193,1013252.074,0.035,
562028.848,1013292.454,0.043, 562018.682,1013424.977,0.07,
562007.163,1013575.247,0.099, 561981.686,1013900.825,0.16,
561971.702,1014043.346,0.187, 561968.808,1014089.436,0.196,
561966.077,1014146.249,0.207, 561957.494,1014376.425,0.25,
561941.333,1014879.5,0.345,   561934.844,1015013.849,0.37,
561930.843,1015108.115,0.388, 561926.975,1015245.592,0.414,
561922.233,1015468.243,0.456, 561918.631,1015586.912,0.478,
561912.301,1015756.343,0.51,  561910.44,1015825.101,0.523,
561909.946,1015874.059,0.532, 561910.027,1015909.594,0.539,
561910.765,1015948.408,0.547, 561913.6,1016019.49,0.561,
561917.047,1016069.767,0.57,  561919.944,1016103.33,0.577,
561927.81,1016171.894,0.59,   561934.889,1016220.292,0.599,
561939.73,1016249.091,0.605,  561949.697,1016302.867,0.615,
561965.347,1016374.268,0.629, 561972.535,1016402.687,0.634
)),
0.0005,3,1)
as lrs_tgeom
from dual
)
select t.segment
.ST_Closest(
p_geometry  => a.geometry,
p_unit      => 'unit=M'
)
.ST_Round(3)
.ST_AsText() as closestPoint
from tGeom a,
table(a.lrs_tgeom.ST_Segmentize(p_filter=>'DISTANCE',
p_vertex=>SELF.T_Vertex(a.geometry)) t;

CLOSESTPOINT
----------------------------------------------------------
T_Vertex(562031.384,1013261.836,.037,NULL,NULL,3001,90000006)

-- Geodetic
With data as (
select SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(147.439,-43.195,NULL),NULL,NULL) as point,
sdo_geometry(3002,4326,NULL,sdo_elem_info_array(1,2,1),
sdo_ordinate_array(147.50,-43.132,100.0, 147.41,-43.387,30000.0)) as line
from dual
)
select T_Segment(a.line)
.ST_Closest(
p_vertex    => T_Vertex(a.point),
p_unit      => 'unit=M'
)
.ST_Round(8)
.ST_AsText() as closestPoint
from data a;

CLOSESTPOINT
------------------------------------------------------------
T_Vertex(147.47543293,-43.20182579,NULL,NULL,NULL,2001,4326)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.12. T_SEGMENT/ST_ComputeDeflectionAngle [ Functions ]

[ Top ] [ T_SEGMENT ] [ Functions ]

NAME

```   ST_ComputeDeflectionAngle - Computes deflection angle between two segments.
```

SYNOPSIS

```    Member Function ST_ComputeDeflectionAngle
p_segment   t_segment default null,
)
Return Number
```

DESCRIPTION

```    This function computes the deflection angle between two segments: SELF.start->(bearing)->SELF.end deflect p_segment.start->(bearing)->p_segment.end
The deflection angle from the projection of the first line to the direction(bearing) of the first line.
If the underlying segment is a circular arc, p_segment is ignored and a deflection angle is computed between the circular arc's three vertices.
If p_segment is supplied its first coordinate is assumed to be the same as the last point of SELF; if not a "virtual" deflection is computed.
If SELF.projected = 0 deflection angle is computed using geodetic math (see MDSYS.SDO_UTIL.BEARING_TILT_FOR_POINTS)
```

INPUTS

```    p_segment (t_segment) - A linestring segment
```

RESULT

```    angle        (number) - Deflection angle in degrees.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - April 2019 - Original coding.
```

```    (c) 2008-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.13. T_SEGMENT/ST_ComputeTangentLine [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_ComputeTangentLine -- Computes point that would define a tangential line at the nominated position on the circular arc
```

SYNOPSIS

```    Member Function ST_ComputeTangentLine(p_position  in VarChar2,
p_fraction  In Number   default 0.0,
p_unit      IN varchar2 default NULL)
Return T_Segment Deterministic,
```

DESCRIPTION

```    There is a need to be able to create a tangent line at any point on a circular arc.
This function computes a tangential line at the start/mid or end coord.
```

INPUTS

```    p_position (varchar2) -- Requests tangent point for 'START', 'MID', 'END' point, or 'FRACTION' of circular arc.
p_fraction   (number) -- Fractional value between 0.0 and 1.0 (length)
p_unit     (varchar2) -- If NULL, the calculations are done using the underlying projection default units.
If an Oracle Unit of Measure is supplied (eg unit=M) that is value for the SRID.
```

RESULT

```    line      (T_Segment) -- A tangent line.
```

EXAMPLE

```    with data as (
select T_Segment(
SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',null)
) as circular_string
from dual
)
select a.circular_string.ST_SdoGeometry() as geom
from data a
union all
select b.circular_string
.ST_ComputeTangentLine(
p_position=>case t.IntValue
when 1 then 'START'
when 2 then 'MID'
when 3 then 'END'
end
).ST_SdoGeometry() as geom
from data b,
table(tools.generate_series(1,3,1)) t;

GEOM
----------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373, 252230.478,5527000.0))
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252250.88475,5526875.9725))
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252400.08,5526918.373, 252420.48675,5526960.7735))
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252230.478,5527000.0, 252250.88475,5527042.4005))

-- Fraction.
with data as (
select T_Segment(
SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',28355)
) as circular_string
from dual
)
select CAST(NULL AS Number) as fraction,
a.circular_string.ST_SdoGeometry() as geom
from data a
union all
select CAST(t.IntValue as number) / 10.0 as fraction,
b.circular_string
.ST_ComputeTangentLine(
p_position  =>'FRACTION',
p_fraction  => CAST(t.IntValue as number) / 10.0,
p_unit      => 'unit=M' )
.ST_Round(3)
.ST_SdoGeometry() as tangentLine
from data b,
table(tools.generate_series(0,10,1)) t;

FRACTION GEOM
---------- --------------------------------------------------------------------------------------------------------------------------------------------
NULL SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252230.478,5526918.373,252400.08,5526918.373,252230.478,5527000))
0 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252230.478,5526918.373,252250.885,5526875.973))
0.1 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252221.549,5526967.649,252217.318,5526920.784))
0.2 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252239.159,5527014.529,252211.488,5526976.469))
0.3 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252278.323,5527045.738,252235.047,5527027.261))
0.4 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252327.951,5527052.441,252281.324,5527058.777))
0.5 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252373.991,5527032.738,252337.215,5527062.094))
0.6 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252403.406,5526992.209,252419.918,5526948.146))
0.7 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252407.868,5526942.33,252399.44,5526896.035))
0.8 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252386.114,5526897.224,252355.132,5526861.806))
0.9 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252344.302,5526869.662,252299.54,5526855.151))
1 SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(252294.273,5526867.449,252248.404,5526877.953))

12 rows selected
```

NOTES

```    If SELF.projected is 1 then calculations are PLANAR or PROJECTED, otherwise GEODETIC/GEOGRAPHIC.
```

AUTHOR

```    Simon Greener
```

HISTORY

```   Simon Greener - June 2011 - Original Coding
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.14. T_SEGMENT/ST_ComputeTangentPoint [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_ComputeTangentPoint -- Computes point that would define a tandential line at the start, mid or end point of a circular arc
```

SYNOPSIS

```    Member Function ST_ComputeTangentPoint(p_position  In VarChar2,
p_fraction  In Number   default 0.0,
p_unit      IN varchar2 default NULL)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    There is a need to be able to compute an angle between a linestring and a circularstring.
To do this, one needs to compute a tangential line at the start, mid, end or user fraction of a circularstring.
This function computes point that would define a tangential line at the start, mid or end of a circular arc.
```

INPUTS

```    p_position (varchar2) -- Requests tangent point for 'START', 'MID', 'END' point, or 'FRACTION' of circular arc.
p_fraction   (number) -- Fractional value between 0.0 and 1.0 (length)
p_unit     (varchar2) -- If NULL, the calculations are done using the underlying projection default units.
If an Oracle Unit of Measure is supplied (eg unit=M) that is value for the SRID.
```

RESULT

```    point      (T_Vertex) -- A tangent point that combined with the start, mid or end of the circularstring creates a tangential line.
```

EXAMPLE

```    select T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_midCoord   => T_Vertex(
p_id        =>  2,
p_x         => 15,
p_y         =>  5,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_ComputeTangentPoint(p_position =>'START')
.ST_AsText() as tangentPoint
from dual;

TANGENTPOINT
------------------------------------
T_Vertex(10,5,NULL,NULL,1,2001,NULL)

-- Circular String all points tangent
with data as (
select T_Segment(
SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',null)
) as circular_string
from dual
)
select a.circular_string.ST_SdoGeometry() as geom
from data a
union all
select b.circular_string
.ST_ComputeTangentPoint(
p_position=>cast(case t.IntValue
when 1 then 'START'
when 2 then 'MID'
when 3 then 'END'
end as varchar(5))
).ST_SdoGeometry() as geom
from data b,
table(tools.generate_series(1,3,1)) t;

GEOM
-------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252230.478,5526918.373,252400.08,5526918.373,252230.478,5527000))
SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(252189.6645,5527003.174,NULL),NULL,NULL)
SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(252440.8935,5527003.174,NULL),NULL,NULL)
SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(252189.6645,5526915.199,NULL),NULL,NULL)

-- Fraction
select CAST(t.IntValue as number) / 10.0 as fraction,
T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_midCoord   => T_Vertex(
p_id        =>  2,
p_x         => 15,
p_y         =>  5,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_ComputeTangentPoint(p_position  =>'FRACTION',
p_fraction  => CAST(t.IntValue as number) / 10.0)
.ST_Round(3)
.ST_SdoGeometry() as tangentPoint
from table(tools.generate_series(0,10,1)) t;

FRACTION TANGENTPOINT
---------- -------------------------------------------------------------------
0 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(10,-2.5,NULL),NULL,NULL)
0.1 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(9.472,-0.833,NULL),NULL,NULL)
0.2 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(9.485,0.916,NULL),NULL,NULL)
0.3 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(10.039,2.576,NULL),NULL,NULL)
0.4 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(11.077,3.983,NULL),NULL,NULL)
0.5 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(12.5,5,NULL),NULL,NULL)
0.6 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(18.923,3.983,NULL),NULL,NULL)
0.7 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(19.961,2.576,NULL),NULL,NULL)
0.8 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(20.515,0.916,NULL),NULL,NULL)
0.9 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(20.528,-0.833,NULL),NULL,NULL)
1 SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(20,-2.5,NULL),NULL,NULL)

11 rows selected
```

NOTES

```    If SELF.projected is 1 then calculations are PLANAR or PROJECTED, otherwise GEODETIC/GEOGRAPHIC.
```

AUTHOR

```    Simon Greener
```

HISTORY

```   Simon Greener - June 2011 - Original Coding
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.15. T_SEGMENT/ST_Densify [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Densify -- Implements a basic geometry densification algorithm.
```

SYNOPSIS

```    Member Function ST_Densify(p_distance in number)
p_unit      IN varchar2 default NULL)
Return mdsys.sdo_Geometry Deterministic
```

DESCRIPTION

```    This function add vertices to an existing vertex-to-vertex described geometry segment.
New vertices are added in such a way as to ensure that no two vertices will
ever fall with SELF.PrecisionModel.XY.
Also, because of the nature of the implementation there is no guarantee that the
added vertices will be p_distance apart.
The implementation prefers to balance the added vertices across a complete segment
such that an even number are added. The final vertex separation will be
BETWEEN p_distance AND p_distance * 2 .

The implementation honours 3D and 4D shapes and averages these dimension values
for the new vertices.
```

ARGUMENTS

```    p_distance     (Number) -- The desired optimal distance between added vertices. Must be > SELF.tolerance.
```

RESULT

```    geometry (sdo_geometry) -- Densified geometry.
```

EXAMPLE

NOTES

```    Does not support CircularArc segments.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 -- Original coding.
Simon Greener - August 2018  -- Ensure all cases correct esp for 3D (XYZ)
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.16. T_SEGMENT/ST_Dims [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Dims -- Returns number of ordinate dimensions
```

SYNOPSIS

```    Member Function ST_Dims
Return INTEGER Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (2XXX etc) and extracts coordinate dimensions.
If SDO_GTYPE is null, examines ordinates eg XY not null, Z null -> 2.
```

RESULT

```    BOOLEAN (INTEGER) -- 2 if data 2D; 3 if 3D; 4 if 4D
```

EXAMPLE

```    with data as (
select T_Segment(
SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',28355)
) as circular_segment
from dual
)
select a.circular_segment.ST_Dims() as Dims
from data a;

DIMS
----
2
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.17. T_SEGMENT/ST_Distance(p_segment p_unit) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Distance -- Returns Distance from segment to the supplied segment (T_Segment)
```

SYNOPSIS

```    Member Function ST_Distance(p_segment    in &&INSTALL_SCHEMA..T_Segment,
p_unit       in varchar2 DEFAULT NULL)
Return Number Deterministic
```

DESCRIPTION

```    (Wrapper over sdo_geometry ST_Distance method).
This function computes a distance from the input T_Segment object to the underlying T_SEGMENT.
Result is in the distance units of the SDO_SRID, or in p_units where supplied.
```

ARGUMENTS

```    p_segment  (T_SEGMENT) - A single T_Segment from which a distance to the segment is calculated.
p_unit      (VARCHAR2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    distance (Number) -- Distance in SRID unit of measure or in supplied units (p_unit)
```

EXAMPLE

```    -- Examples of ST_Distance to T_Vertex single poins
with data as (
select 'Planar LineString to Point' as test,
sdo_geometry('LINESTRING(0 0,10 10)',null) as geom,
sdo_geometry('POINT(5 0)',null) as dGeom
from dual
union all
select 'Geo LineString to Point' as test,
sdo_geometry('LINESTRING(147.50 -43.132,147.41 -43.387)',4326) as geom,
sdo_geometry('POINT(147.3 -43.2)',4326) as dGeom
from dual
union all
select 'Planar CircularString to Point' as test,
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)) as geom,
SDO_GEOMETRY('POINT(252429.706 5527034.024)',28355) as dGeom
from dual
)
select a.test,
T_Segment(a.geom).ST_Distance(p_vertex=>T_Vertex(a.dGeom),p_unit=>NULL) as d_in_meters,
T_Segment(a.geom).ST_Distance(p_vertex=>T_Vertex(a.dGeom),p_unit=>'unit=KM') as l_in_km
from data a;

TEST                           D_IN_METERS    L_IN_KM
------------------------------ ----------- ----------
Planar LineString to Point        3.535534   3.535534
Geo LineString to Point        13820.16185  13.820162
Planar CircularString to Point    42.61532   0.042615
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.18. T_SEGMENT/ST_Distance(p_vertex p_unit) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Distance -- Returns Distance from segment supplied T_Vertex (Wrapper)
```

SYNOPSIS

```    Member Function ST_Distance(p_vertex     in &&INSTALL_SCHEMA..T_Vertex,
p_unit       in varchar2 DEFAULT NULL)
Return Number Deterministic
```

DESCRIPTION

```    (Wrapper over sdo_geometry ST_Distance method).
This function computes a distance from the input T_Vertex object to the underlying T_SEGMENT.
Result is in the distance units of the SDO_SRID, or in p_units where supplied.
```

ARGUMENTS

```    p_geom      (T_VERTEX) - A single vertex from which a bearing to the segment is calculated.
p_unit      (VARCHAR2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    distance (Number) -- Distance in SRID unit of measure or in supplied units (p_unit)
```

EXAMPLE

```    -- Examples of ST_Distance to T_Vertex single poins
with data as (
select 'Planar LineString to Point' as test,
sdo_geometry('LINESTRING(0 0,10 10)',null) as geom,
sdo_geometry('POINT(5 0)',null) as dGeom
from dual
union all
select 'Geo LineString to Point' as test,
sdo_geometry('LINESTRING(147.50 -43.132,147.41 -43.387)',4326) as geom,
sdo_geometry('POINT(147.3 -43.2)',4326) as dGeom
from dual
union all
select 'Planar CircularString to Point' as test,
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)) as geom,
SDO_GEOMETRY('POINT(252429.706 5527034.024)',28355) as dGeom
from dual
)
select a.test,
T_Segment(a.geom).ST_Distance(p_vertex=>T_Vertex(a.dGeom),p_unit=>NULL) as d_in_meters,
T_Segment(a.geom).ST_Distance(p_vertex=>T_Vertex(a.dGeom),p_unit=>'unit=KM') as l_in_km
from data a;

TEST                           D_IN_METERS    L_IN_KM
------------------------------ ----------- ----------
Planar LineString to Point        3.535534   3.535534
Geo LineString to Point        13820.16185  13.820162
Planar CircularString to Point    42.61532   0.042615
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.19. T_SEGMENT/ST_Equals [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Equals -- Compares current object (SELF) with supplied segment.
```

SYNOPSIS

```    Member Function ST_Equals(p_segment    in &&INSTALL_SCHEMA..T_SEGMENT,
p_coords     In Integer default 1)
Return Integer deterministic
```

DESCRIPTION

```    This function compares current segment object (SELF) to supplied segment (p_vertex).
If all ordinates (to supplied precision) are equal, returns True (1) else False (0).
SDO_GTYPE, SDO_SRID and ID are not compared uinless p_coords = 0
```

NOTES

```    To compare all 4 ordinates, use ST_Round on both segments before calling ST_Equals
```

ARGUMENTS

```    p_segment  (T_Segment) -- Segment that is to be compared to current object (SELF).
p_coords     (Integer) -- Boolean. If 1, only coordinates are compared; if 0, then all elements including segment_id etc are compared.
```

RESULT

```    BOOLEAN (INTEGER) - 1 is True (Equal); 0 is False.
```

EXAMPLE

```    set serveroutput on size unlimited
Declare
v_segment1 T_Segment;
v_segment2 T_Segment;
Begin
v_segment1 :=
T_Segment(
p_segment_id => 0,
p_startCoord => t_Vertex(
p_id=>1,
p_x=>0.0023763,
p_y=>0.18349,
p_z=>1.346,
p_w=>0.001,
p_sdo_gtype=>4401,
p_sdo_srid=>NULL
),
p_EndCoord   => T_Vertex(
p_id=>2,
p_x=>10.87365,
p_y=>11.983645,
p_z=>1.984,
p_w=>14.386,
p_sdo_gtype=>4401,
p_sdo_srid=>NULL
),
p_sdo_gtype=>4402,
p_sdo_srid =>NULL
);
v_segment2 := T_Segment(v_segment1);
v_segment2.segment_id := 2;
v_segment1.ST_Equals(p_segment    =>v_segment2,
p_coords     => 0 ));
dbms_output.put_line('Equals(Only Coords): ' ||
v_segment1.ST_Equals(p_segment    =>v_segment2,
p_coords     => 1 ));
END;

anonymous block completed
Equals(Only Coords): 1
```

TODO

```    Consider extending to support precision for xy, z and W.
Need to do so in all other objects (T_Geometry currently only supports SELF.precision not SELF.precision XY/Z/W).
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.20. T_SEGMENT/ST_FindCircle [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_FindCircle -- Finds a centre X and Y and Radius from three points of underlying circular arc.
```

SYNOPSIS

```    Member Function ST_FindCircle (
```

DESCRIPTION

```    If the underlying object is a circular arc segment, then this function computes the centre and radius defining it.
If segment is not a circular arc, null is returned.
```

NOTES

```    Assumes planar projection eg UTM.
Works only on 2D circular segments
```

RESULT

```    Circle Properties (T_Vertex) : X ordinate of centre of circle.
Y ordinate of centre of circle.
Z ordinate contains radius of circle.
SRID as underlying T_SEGMENT.
```

EXAMPLE

```    -- Compute measure of point
with data as (
select 'LineString' as test,
sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),sdo_ordinate_array(0,0,5,5,10,0)) as geom
from dual
union all
select 'CircularString' as test,
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)) as geom
from dual
)
select a.test,
T_Segment(a.geom)
.ST_FindCircle()
.ST_AsText() as circle_params
from data a;

TEST           CIRCLE_PARAMS
-------------- ----------------------------------------------------------
LineString     T_Vertex(5,0,5,NULL,0,2001,NULL)
CircularString T_Vertex(252315.279,5526959.1865,94.111,NULL,0,2001,28355)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.21. T_SEGMENT/ST_GetProjected [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_getProjected -- Rerturns whether underlying segment is planar/projected (1) or geographic/geodetic (0).
```

SYNOPSIS

```    Static Function ST_GetProjection
Return integer deterministic,
```

DESCRIPTION

```    This function can be used to discover whether the underlying SRID is projeccted/planar or not.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.22. T_SEGMENT/ST_hasM [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_hasM -- Tests segment to see if coordinates include a measure.
```

SYNOPSIS

```    Member Function ST_hasM
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc) to see if sdo_gtype has measure ordinate eg 3302 not 3002.
If SDO_GTYPE is null, examines coordinates to see if W ordinate is not null.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 means segment has measure ordinate, 0 otherwise.
```

EXAMPLE

```    select T_Segment(sdo_geometry(3302,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5, -42.5,0.0, 147.6, -42.5, 10923.0))).ST_hasM() as hasM
from dual;

HASM
----
1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.23. T_SEGMENT/ST_hasZ [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_hasZ -- Tests segment to see if coordinates include a Z ordinate.
```

SYNOPSIS

```    Member Function ST_hasZ
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc). If D position is 2 then segment does not have a Z ordinate.
If D position is 3 and measure ordinate position (L) is 0 then segment has Z ordinate.
If D position is 3 and measure ordinate position (L) is not equal to 0 then segment does not have a Z ordinate.
If D position is 4 and measure ordinate position (L) is equal to 0 or equal to D (4) then segment has a Z ordinate.
If D position is 4 and measure ordinate position (L) is equal to 3 then segment does not have a Z ordinate.
If SDO_GTYPE is null, examines Z and W ordinates of the segment's coordinates to determine if segment has Z ordinate.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 means segment has Z ordinate, 0 otherwise.
```

EXAMPLE

```    select T_Segment(sdo_geometry(3002,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5, -42.5,10.0, 147.6, -42.5, 10.0))).ST_hasZ() as hasZ
from dual;

HASZ
----
1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.24. T_SEGMENT/ST_Intersect [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Intersect -- Computes intersection point between two 2D or 3D segments, returning a single intersection vertex.
```

SYNOPSIS

```    Member Function ST_Intersect(p_segment   IN T_SEGMENT,
p_unit      IN varchar2 default NULL)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    This function computes the intersection point between the underlying 2D/3D segment and the provided 2D/3D segment.
The intersection point computed is always physical ie a physical intersection or an empty vertex is returned if no intersection is computed.
If segments are parallel an empty T_VERTEX is returned with T_VERTEX.id set to -9.
Intersection between a linestring segment and circular arc segment is supported.
However, the intersection between two circular arc segments is not yet supported.
```

INPUTS

```    p_segment (T_Segment) -- Second segment for which an intersection with current is computed.
p_unit     (varchar2) -- Oracle Unit of Measure eg unit=M.
```

RESULT

```    Intersection (T_Vertex) -- The intersection point or empty point with id = -9 for parallel segments.
```

EXAMPLE

```    select T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_Intersect(p_segment =>
.ST_AsText() as Intersection3D
from dual;

INTERSECTION3D
------------------------------------
T_Vertex(10,5,NULL,NULL,1,2001,NULL)

-- ST_Intersect of line segment and circular arc segment
With data As (
SELECT SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',null) as cString,
SDO_GEOMETRY('LINESTRING(252257.745 5526951.808, 252438.138 5526963.252)',null) as lString
FROM Dual
)
select t_geometry(SDO_GEOM.SDO_Intersection(cString,lString,0.005),0.005,3,1)
.ST_Round(3,3,1)
.geom as iGeom,
T_Segment(lString)
.ST_Intersect(T_Segment(cString),3)
.ST_Round(3)
.ST_SdoGeometry() as iPoint
from data a;

IGEOM
IPOINT
-------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2001,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(252409.364,5526961.427))
SDO_GEOMETRY(2001,NULL,                                    SDO_POINT_TYPE(252409.364,5526961.427,NULL),NULL,NULL)

-- ST_Intersect two 3D segments: No intersection in Z
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(  0,0, 500, 100,100,1000)) as line1,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,0,1000,   0,100, 501)) as line2
from dual
)
select f.intersection.ST_IsNull() as intersectAlwaysNull,
f.intersection.id          as intersectMarker,
f.intersection.ST_AsText() as IntersectCoordValues
from (select T_Segment(line1)
.ST_Intersect(
T_Segment(line2)
) as intersection
from data a
) f;

INTERSECTALWAYSNULL INTERSECTMARKER INTERSECTCOORDVALUES
------------------- --------------- ----------------------------------------
1             -99 T_Vertex(NULL,NULL,NULL,NULL,-99,1,NULL)

-- ST_Intersect 3D has intersection in Z
-- Compare to SDO_GEOM.SDO_Intersection
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,  0, 0, 100,100,10)) as line1,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,100,10, 100,  0, 0)) as line2
from dual
)
select sdo_geom.sdo_intersection(line1,line2,0.005) as geom from data
union all
select T_Segment(line1)
.ST_Intersect(
T_Segment(line2)
)
.ST_Round(3,3)
.ST_SdoGeometry(3) as int3D
from data a;

GEOM
---------------------------------------------------------------------------------------------
SDO_GEOMETRY(3001,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(50,50,0))
SDO_GEOMETRY(3001,NULL,                                    SDO_POINT_TYPE(50,50,5),NULL,NULL)
```

NOTES

```    Calculations are always planar.
3D computations use T_Vector3D object methods.
```

TODO

```    Enable calculation of intersection between geodetic/geographic segments.
Support intersections including circular arcs
```

AUTHOR

```    Simon Greener
```

HISTORY

```   Simon Greener - June 2011 - Original Coding
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.25. T_SEGMENT/ST_Intersect2CircularArcs [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Intersect2CircularArcs -- Computes intersecton point between two 2D CircularArc segments.
```

SYNOPSIS

```    Member Function ST_Intersect2CircularArcs(
p_segment   in &&INSTALL_SCHEMA..T_Segment,
p_unit      in varchar2 default NULL)
Return &&INSTALL_SCHEMA..T_Segment Deterministic(
```

DESCRIPTION

```    This function computes the intersection point between the underlying circularArc segment and the provided circularArc segment.
If one of the segments is a LineString, ST_Intersect is called.
```

ARGUMENTS

```    p_segment  (T_Segment) -- CircularArc Segment that is to be intersected with the current CircularArc object (SELF).
p_unit      (varchar2) -- Oracle Unit of Measure for functions such as SDO_DISTANCE.
```

RESULT

```    intersection (T_Vertex) -- The intersection point.
```

EXAMPLE

```    select &&INSTALL_SCHEMA..t_segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),sdo_ordinate_array(0,0,10,10,20,0)))
.ST_Intersect2CircularArcs(
p_segment => &&INSTALL_SCHEMA..t_segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),SDO_ORDINATE_ARRAY(9.959,-0.004, 14.719,5.245, 8.133,13.623))),
p_unit    => null)
.ST_Round(3) as intersection
from dual;

INTERSECTION
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
&&INSTALL_SCHEMA..T_SEGMENT(NULL,NULL,1,&&INSTALL_SCHEMA..T_VERTEX(14.477,8.942,NULL,NULL,1,2001,NULL,0),NULL,&&INSTALL_SCHEMA..T_VERTEX(1.189,4.729,NULL,NULL,3,2001,NULL,0),2002,NULL,1,&&INSTALL_SCHEMA..T_PRECISIONMODEL(3,3,3,0.005))
```

NOTES

```    Two intersections are returned for the two possible points where two circles defined by CircularArcs intersect.
Calculations are always planar.
```

TODO

```    Enable calculation of intersection between geodetic/geographic segments.
Return only the actual intersections.
```

AUTHOR

```    Simon Greener
```

HISTORY

```   Simon Greener - 2011 - Original Coding nuary 2018\
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.26. T_SEGMENT/ST_IntersectCircularArc [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_IntersectCircularArc -- Computes intersecton point between a CircularArc and a LineString segment.
```

SYNOPSIS

```    Member Function ST_IntersectCircularArc(
p_segment   in &&INSTALL_SCHEMA..T_Segment,
p_unit      in varchar2 default NULL)
Return &&INSTALL_SCHEMA..T_Segment Deterministic(
```

DESCRIPTION

```    This function computes the intersection point between a CircularArc and a LineString.
If both of the segments is a LineString, ST_Intersect is called.
```

ARGUMENTS

```    p_segment  (T_Segment) -- CircularArc Segment that is to be intersected with the current CircularArc object (SELF).
p_unit      (varchar2) -- Oracle Unit of Measure for functions such as SDO_DISTANCE.
```

RESULT

```    intersection (T_Vertex) -- The intersection point.
```

EXAMPLE

```    select &&INSTALL_SCHEMA..t_segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),sdo_ordinate_array(0,0,10,10,20,0)))
.ST_IntersectCircularArc(
p_segment => &&INSTALL_SCHEMA..t_segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),SDO_ORDINATE_ARRAY(10,0,10,12))),
p_unit    => null)
.ST_Round(3)
.ST_SdoGeometry() as intersection
from dual;

INTERSECTION
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(10,-10,0,0))
```

NOTES

```    Two intersections are returned for the two possible points where two circles defined by CircularArcs intersect.
Calculations are always planar.
```

TODO

```    Fix as result is incorrect.
Enable calculation of intersection between geodetic/geographic segments.
Return only the actual intersections.
```

AUTHOR

```    Simon Greener
```

HISTORY

```   Simon Greener - 2011 - Original Coding nuary 2018\
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.27. T_SEGMENT/ST_IntersectDescription [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_IntersectDescription -- Interprets intersection that results from a call to STIntersectionDetail with same parameter values.
```

SYNOPSIS

```    Member Function ST_IntersectDescription(p_segment    in T_SEGMENT,
p_unit       in varchar2 default NULL)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    Describes intersection point between two lines.
Internal code is same as STIntersectionDetail with same parameters so see its documentation.
Determines intersections as per STIntersectionDetail but determines nature of intersection ie whether physical, virtual, nearest point on segment etc.
Returned interpretation is one of:
Intersection at End 1 End 2
Intersection at End 1 Start 2
Intersection at Start 1 End 2
Intersection at Start 1 Start 2
Intersection within both segments
Parallel
Unknown
Virtual Intersection Near End 1 and End 2
Virtual Intersection Near End 1 and Start 2
Virtual Intersection Near Start 1 and End 2
Virtual Intersection Near Start 1 and Start 2
Virtual Intersection Within 1 and Near End 2
Virtual Intersection Within 1 and Near Start 2
Virtual Intersection Within 2 and Near End 1
Virtual Intersection Within 2 and Near Start 1
```

ARGUMENTS

```    p_segment  (T_Segment) -- Segment that is to be intersections with current object (SELF).
p_unit      (varchar2) -- Oracle Unit of Measure for functions such as SDO_DISTANCE.
```

RESULT

```    intersection (varchar2) -- Intersection description as in DESCRIPTION above.
```

EXAMPLE

```    select T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_IntersectDescription(p_segment =>
.ST_AsText() as Intersection
from dual;

INTERSECTION
------------------------------------
T_Vertex(10,5,NULL,NULL,1,2001,NULL)

select T_Segment(
sdo_geometry('LINESTRING(0 0,10 10)',null)
).ST_IntersectDescription(
T_Segment(
sdo_geometry('LINESTRING(0 10,10 0)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(5,5,NULL,NULL,0,2001,NULL),
Mid(5,5,NULL,NULL,-1,2001,NULL),
End(5,5,NULL,NULL,-2,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)

-- Physical 1, virtual 2
select T_Segment(
sdo_geometry('LINESTRING(0 0,10 0)',null)
).ST_IntersectDescription(
T_Segment(
sdo_geometry('LINESTRING(-5 10,-2 7)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(5,0,NULL,NULL,0,2001,NULL),
Mid(5,0,NULL,NULL,-1,2001,NULL),
End(-2,7,NULL,NULL,-2,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)

-- Virtual 1, Virtual 2
select T_Segment(
sdo_geometry('LINESTRING(10 10,5 5)',null)
).ST_IntersectDescription(
T_Segment(
sdo_geometry('LINESTRING(-10 10,-5 5)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(0,0,NULL,NULL,0,2001,NULL),
Mid(5,5,NULL,NULL,-1,2001,NULL),
End(-5,5,NULL,NULL,-2,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)

-- Parallel
select T_Segment(
sdo_geometry('LINESTRING(10 10,0 10)',null)
).ST_IntersectDescription(
T_Segment(
sdo_geometry('LINESTRING(-10 5,-5 5)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(,,NULL,NULL,-9,2001,NULL),
Mid(,,NULL,NULL,NULL,2001,NULL),
End(,,NULL,NULL,NULL,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)
```

NOTES

```    Calculations are always planar.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - March 2018 - Original TSQL Coding for SQL Server.
Simon Greener - June 2011 - Original Coding
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.28. T_SEGMENT/ST_IntersectDetail [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_IntersectDetail -- Computes intersecton point between two 2D segments.
```

SYNOPSIS

```    Member Function ST_IntersectDetail(p_segment   in T_SEGMENT,
p_unit      in varchar2 default NULL)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    This function computes the intersection point between the underlying segment and the provided segment.
If segments are parallel an empty T_VERTEX is returned with T_VERTEX.id set to -9.
The intersection point is always returned in startCoord of returned T_Segment.
This version of ST_Intersect returns details about the nature of the Intersection.
These details include the coding of the returned midCoord and endCoords as follows:
1.  If intersection is physical both are set to startCoord (cf ST_Intersect).
2.  If intersection is physical in SELF but virtual in p_segment, midCoord is set to physical intersection point, and endCoord is set to projected (virtual) point from p_segment.
3.  If intersection is physical in p_segment but virtual in SELF, midCoord is set to projected (virtual) point from SELF, and endCoord is set to physical intersection point in p_segment.
4.  If intersection is virtual in p_segment and SELF, midCoord and endCoord are both set to virtual point (same as startCoord).
```

ARGUMENTS

```    p_segment  (T_Segment) -- Segment that is to be intersections with current object (SELF).
p_unit      (varchar2) -- Oracle Unit of Measure for functions such as SDO_DISTANCE.
```

RESULT

```    intersection (T_Vertex) -- The intersection point or empty point with id = -9 for parallel segments.
```

EXAMPLE

```    select T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_IntersectDetail(p_segment =>
.ST_AsText() as Intersection
from dual;

INTERSECTION
------------------------------------
T_Vertex(10,5,NULL,NULL,1,2001,NULL)

select T_Segment(
sdo_geometry('LINESTRING(0 0,10 10)',null)
).ST_IntersectDetail(
T_Segment(
sdo_geometry('LINESTRING(0 10,10 0)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(5,5,NULL,NULL,0,2001,NULL),
Mid(5,5,NULL,NULL,-1,2001,NULL),
End(5,5,NULL,NULL,-2,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)

-- Physical 1, virtual 2
select T_Segment(
sdo_geometry('LINESTRING(0 0,10 0)',null)
).ST_IntersectDetail(
T_Segment(
sdo_geometry('LINESTRING(-5 10,-2 7)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(5,0,NULL,NULL,0,2001,NULL),
Mid(5,0,NULL,NULL,-1,2001,NULL),
End(-2,7,NULL,NULL,-2,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)

-- Virtual 1, Virtual 2
select T_Segment(
sdo_geometry('LINESTRING(10 10,5 5)',null)
).ST_IntersectDetail(
T_Segment(
sdo_geometry('LINESTRING(-10 10,-5 5)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(0,0,NULL,NULL,0,2001,NULL),
Mid(5,5,NULL,NULL,-1,2001,NULL),
End(-5,5,NULL,NULL,-2,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)

-- Parallel
select T_Segment(
sdo_geometry('LINESTRING(10 10,0 10)',null)
).ST_IntersectDetail(
T_Segment(
sdo_geometry('LINESTRING(-10 5,-5 5)',null)
)
).ST_AsText() as iPoint
from dual;

IPOINT
-----------------------------------------
SEGMENT(NULL,NULL,1,
Start(,,NULL,NULL,-9,2001,NULL),
Mid(,,NULL,NULL,NULL,2001,NULL),
End(,,NULL,NULL,NULL,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)
```

NOTES

```    Calculations are always planar.
```

TODO

```    Enable calculation of intersection between geodetic/geographic segments.
Support intersections including circular arcs
```

AUTHOR

```    Simon Greener
```

HISTORY

```   Simon Greener - June 2011 - Original Coding
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.29. T_SEGMENT/ST_isCircularArc [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isCircularArc -- Checks if segment is a CircularArc
```

SYNOPSIS

```    Member Function ST_isCircularArc
Return Integer Deterministic,
```

DESCRIPTION

```    If segment start/mid/end coordinates are all not null then is CircularString.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 if segment is CircularArc.
```

EXAMPLE

```    with data as (
select T_Segment(
SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',null)
) as circular_segment
from dual
)
select a.circular_segment.ST_isCircularArc() as isCString
from data a;

ISCSTRING
---------
1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.30. T_SEGMENT/ST_isCollinear [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isCollinear -- Checks if two segments' coordinates are collinar.
```

SYNOPSIS

```    Member Function ST_isCollinear(p_segment in &&INSTALL_SCHEMA..T_SEGMENT)
Return Integer Deterministic
```

DESCRIPTION

```    This function determines if the two segments (underlying and supplied) have coordinates that fall in a line (collinear)
The segments should touch with a end/start relationship.
Supplied segments cannot be CircularArcs.
```

ARGUMENTS

```    p_segment  (T_Segment) -- Other, possibly connected, segment (LineString not CircularString)
```

RESULT

```    boolean      (integer) -- 1 is true (collinear) 0 if false.
```

NOTES

```    Ignores any measure ordinates.
Calculations are always planar.
```

EXAMPLE

```    -- 0. Uses T_Vector3D to compute whether segments can be merged by sharing vertex and having same normalized vectors.
with data as (
select sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(  0,  0, 100,100)) as line1,
sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,100, 200,200)) as line2
from dual
UNION ALL
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(  0,  0, 0, 100,100,10)) as line1,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,100,10, 200,200,20)) as line2
from dual
)
select T_Segment(a.line1)
.ST_IsCollinear(p_segment=>T_Segment(a.line2)) as isCollinear
from data a;

MS2
----------------
0
1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 -- Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.31. T_SEGMENT/ST_isEmpty [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isEmpty -- Checks if segment has any valid data.
```

SYNOPSIS

```    Member Function ST_isEmpty
Return INTEGER Deterministic,
```

DESCRIPTION

```    If segment object data values are NULL returns 1 (TRUE) ie is Empty; else 0 (False)
cf "LINESTRING EMPTY" EKT.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 if segment has no non null values; 0 if has values
```

EXAMPLE

```    select T_Segment().ST_AsText()  as TSegment,
T_Segment().ST_isEmpty() as isEmpty
from dual;

TSEGMENT
-------------------------------------------------------------------------------------------------------------------------------------- --------
SEGMENT(NULL,NULL,NULL,Start(NULL,NULL,NULL,NULL,NULL,2001,NULL),End(NULL,NULL,NULL,NULL,NULL,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)        0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.32. T_SEGMENT/ST_isHorizontal [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isHorizontal - Returns true if the segment is horizonal or parallel to X axis.
```

SYNOPSIS

```    Member Function ST_isHorizontal
Return integer Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function checks if segment is horizontal or parallel to X axis
```

RESULT

```    true/false (integer) -- 1 is horizontal 0 otherwise
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,10 0)',NULL)).ST_isHorizontal() as isHorizontal
from dual;

ISHORIZONTAL
------------
1

select T_Segment(sdo_geometry('LINESTRING(0 0,10 10)',NULL)).ST_isHorizontal() as isHorizontal
from dual;

ISHORIZONTAL
------------
0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.33. T_SEGMENT/ST_isPointOnSegment [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isPointOnSegment -- Checks if supplied point falls on the underlying segment.
```

SYNOPSIS

```    ST_isPointOnSegment(p_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_unit   in varchar2)
Return integer deterministic
```

DESCRIPTION

```    This function checks if the supplied point falls on the underlying segment.

Computes for LineString or CircularString.
```

NOTES

```    Geodetic/geographic CircularArc segments treated as planar
```

INPUTS

```    p_vertex (t_vertex) - Point on to linestring or CircularString.
p_unit   (varchar2) - Unit of measure for SRID.
```

RESULT

```    booelan (integer) -- 1 if point on segment; 0 otherwise
```

EXAMPLE

```    select T_Segment(MDSYS.SDO_GEOMETRY(3302,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(147.41,-43.132,100, 147.5,-43.387,30000)))
.ST_isPointOnSegment (
t_vertex(SDO_GEOMETRY(3301,8307,SDO_POINT_TYPE(147.44551945,-43.23290209,11930.116),NULL,NULL))
) as is_on
from dual union all
select T_Segment(MDSYS.SDO_GEOMETRY(3302,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(147.41,-43.132,100, 147.5,-43.387,30000)))
.ST_isPointOnSegment (
t_vertex(SDO_GEOMETRY(3301,8307,SDO_POINT_TYPE(147.445,-43.232,11930.116),NULL,NULL))
) as is_on
from dual;

IS_ON
----------
1
0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2008-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.34. T_SEGMENT/ST_isReversed [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isReversed -- Returns 1 (true) if the underlying segment has its start/end coordinates reversed to supplied segment.
```

SYNOPSIS

```    Member Function ST_isReversed(p_other     IN &&INSTALL_SCHEMA..T_SEGMENT)
Return Integer Deterministic,
```

DESCRIPTION

```    Compares underlying T_SEGMENT's start and end coordinates against those of the supplied segment parameter.
If self.start = p_other.end and self.end = p_other.start, the function returns 1 (True) otherwise 0 (False).
If SDO_GTYPE is null, examines coordinates to see if W ordinate is not null.
```

ARGUMENTS

```    p_other   (T_Segment) -- Compared to SELF with return of 1 if reversed start/end coordinates
```

RESULT

```    True/False  (Integer) -- 1 if two segments have opposite direction.
select T_Segment(
sdo_geometry('LINESTRING(0 0,10 10)',null)
).ST_isReversed(
p_other    =>T_Segment(sdo_geometry('LINESTRING(10 10,0 0)',null))
) as isReversed
from dual;

ISREVERSED
----------
1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.35. T_SEGMENT/ST_isVertical [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_isVertical - Returns true if the segment is Vertical or parallel to Y axis.
```

SYNOPSIS

```    Member Function ST_isVertical
Return integer Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function checks if segment is vertical or parallel to Y axis
```

RESULT

```    true/false (integer) -- 1 is Vertical 0 otherwise
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,0 10)',NULL)).ST_isVertical() as isVertical
from dual;

ISVERTICAL
----------
1

select T_Segment(sdo_geometry('LINESTRING(0 0,10 10)',NULL)).ST_isVertical() as isVertical
from dual;

ISVERTICAL
----------
0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.36. T_SEGMENT/ST_Length [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Length -- Returns Length of the segment
```

SYNOPSIS

```    Member Function ST_Length(p_unit      in varchar2 DEFAULT NULL)
Return Number Deterministic
```

DESCRIPTION

```    This function computes a length from the underlying T_SEGMENT.
Result is in the distance units of the SDO_SRID, or in p_units where supplied.
```

ARGUMENTS

```    p_unit      (VARCHAR2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    distance (Number) -- Distance in SRID unit of measure or in supplied units (p_unit)
```

EXAMPLE

```    TO DO
-- Simple length for mixed planar and geodetic data
with data as (
select 'Planar LineString' as test, sdo_geometry('LINESTRING(0 0,10 10)',null) as geom
from dual
union all
select 'Geo LineString' as test, sdo_geometry('LINESTRING(147.50 -43.132,147.41 -43.387)',4326) as geom
from dual
union all
select 'Planar CircularString' as test,
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)) as geom
from dual
)
select a.test,
T_Segment(a.geom).ST_Length(p_unit=>NULL)      as l_in_meters,
T_Segment(a.geom).ST_Length(p_unit=>'unit=KM') as l_in_km
from data a;

TEST                  L_IN_METERS    L_IN_KM
--------------------- ----------- ----------
Planar LineString     14.14213562 14.14213562
Geo LineString        29257.27111 29.25727111
Planar CircularString 506.8892138 0.5068892138
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.37. T_SEGMENT/ST_LineSubstring [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_LineSubstring -- Creates a new segment by cutting out the line defined by p_start_fraction and p_end_fraction.
```

SYNOPSIS

```    Member Function ST_LineSubstring(p_start_fraction In Number   Default 0.0,
p_end_fraction   In Number   Default 1.0,
p_unit           In Varchar2 Default NULL)
Return &&INSTALL_SCHEMA..T_Segment Deterministic
```

DESCRIPTION

```    Supplied with two ratio values between (0.0 -> 1.0), this function uses those values to find the
points along its segment where they lie. If offset values of 0.0 and 1.0 are supplied, the underlying
segment is returned. Otherwise, the function finds the position of the point defined by p_start_fraction
and the point defined by p_end_fraction and creates a new segment based on those points.
For circular arcs a new midCoord is created at position p_start_fraction + (p_end_fraction-p_start_Fraction)/2.0.
If p_start_fraction == p_end_fraction a single point is returned in the T_Segment's startCoord with the others being NULL.
The substring operation uses length and not LRS measure.
Any Z and M ordinates are calculated by ratio.
```

ARGUMENTS

```    p_start_fraction (Number) -- A value between 0 and 1, from the start vertex of the segment,
which describes the position of the first point in the substring.
p_end_fraction   (Number) -- A value > p_start_fraction, from the start vertex of the segment,
which describes the position of the last point in the substring.
p_unit         (Varchar2) -- If NULL, the calculations are done using the underlying projection default units.
If an Oracle Unit of Measure is supplied (eg unit=M) that is value for the SRID,
this value is used when calculating the p_offset distance.
```

RESULT

```    segment  (T_Segment)  - - New segment between the start and end measures.
```

EXAMPLE

```    -- Substring of XYZ LineString.
With data as (
select SDO_GEOMETRY(3002,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(562046.642,1013077.602,0, 562032.193,1013252.074,0.035)) as geom
from dual
)
select T_Segment(a.geom)
.ST_LineSubstring(p_start_fraction => 0.25,
p_end_fraction   => 0.75,
p_unit           => 'unit=M'
)
.ST_Round(3)
.ST_SdoGeometry() as substring
from data a;

SUBSTRING
---------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(562043.03,1013121.22,0.009,562035.805,1013208.456,0.026))

-- Fractions equal...
With data as (
select SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(562046.642,1013077.602,0, 562032.193,1013252.074,0.035)) as geom
from dual
)
select T_Segment(a.geom)
.ST_LineSubstring(p_start_fraction => 0.5,
p_end_fraction   => 0.5,
p_unit           => 'unit=M'
)
.ST_Round(3)
.ST_SdoGeometry() as substring
from data a;

SUBSTRING
----------------------------------------------------------------------------------
SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562039.418,1013164.838,0.018),NULL,NULL)

-- Geodetic.
With data as (
select sdo_geometry(2002,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,147.41,-43.387)) as geom
from dual
union all
select sdo_geometry(3302,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,100.0,147.41,-43.387,30000.0)) as geom
from dual
union all
select sdo_geometry(3002,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,100.0, 147.41,-43.387,30000.0)) as geom
from dual
)
select T_Segment(a.geom)
.ST_LineSubstring(p_start_fraction => 0.5,
p_end_fraction   => 0.9,
p_unit           => 'unit=M'
)
.ST_Round(8)
.ST_SdoGeometry() as substring
from data a;

SUBSTRING
-------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.455,-43.2595,147.419,-43.3615))
SDO_GEOMETRY(3302,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.455,-43.2595,15050,147.419,-43.3615,27010))
SDO_GEOMETRY(3002,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.455,-43.2595,15050,147.419,-43.3615,27010))

-- Circular Arc line string
With data as (
select sdo_geometry(2002,NULL,NULL,
sdo_elem_info_array(1,2,2),
sdo_ordinate_array(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)) as geom
from dual
)
select T_Segment(a.geom)
.ST_LineSubstring(p_start_fraction => 0.25,
p_end_fraction   => 0.75,
p_unit           => 'unit=M'
)
.ST_Round(3)
.ST_SdoGeometry() as substring
from data a;

SUBSTRING
------------------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252256.627,5527032.786,252373.991,5527032.738,252400.046,5526918.303))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_LRS_Add_Measure -- Adds measures to 2D segment linestring/circularString
```

SYNOPSIS

```    Member Function ST_LRS_Add_Measure(p_start_measure IN Number Default NULL,
p_end_measure   IN Number Default NULL,
p_unit          IN VarChar2 Default NULL)
Return &&INSTALL_SCHEMA..T_Segment deterministic,
```

DESCRIPTION

```    Takes a 2D geometry and assigns supplied measures to the start/end vertices
and adds proportioned measure values to all vertices in between.
If p_start_measure/p_end_measure are null, length is used to add measures.
```

ARGUMENTS

```    p_start_measure (Number)   - Measure defining start point for segment .
p_end_measure   (Number)   - Measure defining end point for segment.
p_unit          (VarChar2) - Unit of measure for distance calculations.
```

RESULT

```    segment (T_segment) -- Measured segment
```

EXAMPLE

```    select t_geometry(SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963, 571551.298,321231.412, 572765.519,321322.805, 572739.407,321845.051,
572752.463,322641.476, 573209.428,323398.732, 573796.954,323555.406, 574436.705,323790.416,
574945.895,324051.539, 575128.681,324652.122, 575128.681,325161.311, 575898.993,325213.536,
576238.453,324521.56, 576251.509,321048.626, 575259.242,322615.364, 574306.144,321296.693)),
0.0005,3,1)
.ST_Round(3,3,1,2)
.geom as mGeom
from dual;

MGEOM
---------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3302,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(
571303.231,321126.963,110.0,   571551.298,321231.412,377.21,   572765.519,321322.805,1586.05,  572739.407,321845.051,2105.16,
572752.463,322641.476,2895.92, 573209.428,323398.732,3773.96,  573796.954,323555.406,4377.62,  574436.705,323790.416,5054.23,
574945.895,324051.539,5622.33, 575128.681,324652.122,6245.56,  575128.681,325161.311,6751.06,  575898.993,325213.536,7517.55,
576238.453,324521.56,8282.72,  576251.509,321048.626,11730.53, 575259.242,322615.364,13571.62, 574306.144,321296.693,15186.88))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original Coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.39. T_SEGMENT/ST_LRS_Compute_Measure [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_LRS_Compute_Measure -- Computes measure for supplied p_vertex against underlying LRS measured T_SEGMENT.
```

SYNOPSIS

```    Member Function ST_LRS_Compute_Measure(p_vertex    In &&INSTALL_SCHEMA..T_Vertex,
p_unit      IN varchar2 Default null)
Return Number Deterministic
```

DESCRIPTION

```    This function computes a measure value for the supplied point (must be a point
on the underlying segment). All calculations are done on 2D versions of segment
and point.
```

ARGUMENTS

```    p_vertex  (T_VERTEX) - Finds p_vertex on LRS Segment and computes M ordinate
p_unit    (VARCHAR2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    -- Compute measure of point
with data as (
select 'Planar LineString' as test,
sdo_geometry(3302,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,1,1.1,6,6,5.95)) as geom,
sdo_geometry('POINT(5 4.9)',null) as dGeom
from dual
union all
select 'Geo LineString' as test,
sdo_geometry(3302,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,100.0,147.41,-43.387,30000.0)) as geom,
sdo_geometry('POINT(147.3 -43.2)',4326) as dGeom
from dual
)
select a.test,
T_Segment(a.geom).ST_LRS_Compute_Measure(p_vertex=>T_VERTEX(a.dGeom),p_unit=>NULL) as measure
from data a;

TEST              MEASURE
----------------- ----------
Planar LineString 4.93180695
Geo LineString     18427.043
```

TODO

```    Support CircularString (Circular Arcs).
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.40. T_SEGMENT/ST_LRS_Dim [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_LRS_Dim -- Tests segment to see if coordinates include a measure ordinate and returns measure ordinate's position.
```

SYNOPSIS

```    Member Function ST_LRS_Dim
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc) measure ordinate position (L) and returns it.
If SDO_GTYPE is null, examines coordinates to see if W ordinate is not null.
```

RESULT

```    dimension (integer) -- L from DLNN.
```

EXAMPLE

```    select T_Segment(sdo_geometry(3302,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5, -42.5,0.0, 147.6, -42.5, 10923.0))).ST_LRS_Dim() as lrs_dim
from dual;

LRS_DIM
-------
3
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.41. T_SEGMENT/ST_LRS_isMeasured [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_LRS_isMeasured -- Tests to see if segment is measured.
```

SYNOPSIS

```    Member Function ST_LRS_isMeasured
Return Integer Deterministic,
With data as (
Select T_GEOMETRY(sdo_geometry('LINESTRING(0 0,10 0,10 5,10 10,5 10,5 5)',null),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual UNION ALL
Select T_GEOMETRY(sdo_geometry(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0,0,1,10,0,2,10,5,3,10,10,4,5,10,5,5,5,6)),0.005,3,1) as tgeom From Dual
)
select a.tgeom.ST_GType()          as sdo_gtype,
a.tgeom.ST_LRS_isMeasured() as isMeasured
from data a;

SDO_GTYPE GEOMTYPE       COORDDIM isMeasured
--------- -------------- -------- ----------
2 ST_LINESTRING         2          0
2 ST_LINESTRING         3          0
2 ST_LINESTRING         3          1
```

DESCRIPTION

```    Examines SDO_GTYPE (ST_LRS_Dim) to see if sdo_gtype has measure ordinate eg 3302 not 3002.
```

RESULT

```    BOOLEAN (Integer) -- 1 is measure ordinate exists, 0 otherwise.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.42. T_SEGMENT/ST_LRS_Measure_Length [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_LRS_Measure_Length -- Returns difference between end measure and start measure of segment.
```

SYNOPSIS

```    Member Function ST_LRS_Measure_Length( p_unit IN VARCHAR2 Default NULL )
Return Number Deterministic
```

DESCRIPTION

```    This function computes length by subtracting end and start measure ordinates.
If segment is without measures length is returned.
```

RESULT

```    distance (Number) -- Difference between end and start measure ordinates (delta) or segment length.
```

EXAMPLE

```    with data as (
select 'Planar LineString' as test,
sdo_geometry(3302,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,1,1.1,6,6,5.95)) as geom
from dual
union all
select 'Geo LineString' as test,
sdo_geometry(3302,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,100.0,147.41,-43.387,30000.0)) as geom
from dual
)
select a.test,
T_Segment(a.geom)
.ST_LRS_Measure_Length() as measureLength
from data a;

TEST              MEASURELENGTH
----------------- -------------
Planar LineString          4.85
Geo LineString            29900
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.43. T_SEGMENT/ST_MaxX [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_MaxX - Returns the largest X ordinate value from the underlying segments minimum bounding rectangle (MBR).
```

SYNOPSIS

```    Member Function ST_MaxX
Return SDO_GEOMETRY Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function returns the largest X ordinate value held by the startCoord,midCoord or endCoord vertices.
```

RESULT

```    ordinate (number) -- Largest x ordinate value
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,0.8 0.8)',NULL)).ST_MaxX() as maxX
from dual;

MAXX
----
0.8
```

```    T_MBR object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2011 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.44. T_SEGMENT/ST_MaxY [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_MaxY - Returns the largest Y ordinate value from the underlying segments minimum bounding rectangle (MBR).
```

SYNOPSIS

```    Member Function ST_MaxY
Return SDO_GEOMETRY Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function returns the largest Y ordinate value held by the startCoord,midCoord or endCoord vertices.
```

RESULT

```    ordinate (number) -- Largest x ordinate value
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,0.8 0.8)',NULL)).ST_MaxY() as maxX
from dual;

MAXX
----
0.8
```

```    T_MBR object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2011 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.45. T_SEGMENT/ST_MBR [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_MBR - Returns optimized rectangle sdo_geometry representnig the underlying segment's minimum bounding rectangle (MBR).
```

SYNOPSIS

```    Member Function ST_MBR
Return SDO_GEOMETRY Determinsitic
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,0.8 0.8)',NULL)).ST_MBR() as mbrGeom
from dual;

MBRGEOM
--------------------------------------------------------------------------------------
SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(0,0,0.8,0.8))
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function returns the envelope or minimum bounding rectangle as a polygon geometry with one optimized rectangle exterior ring.
```

RESULT

```    MBR Geometry (sdo_geometry) -- Single Polygon with Optimized Rectangle Exterior Ring.
```

```    T_MBR object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2011 - Converted to T_GEOMETRY from GEOM package.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.46. T_SEGMENT/ST_Merge [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Merge -- Merge two straight line segments - does not support circular arc segments
```

SYNOPSIS

```    Member Function ST_Merge(p_segment in &&INSTALL_SCHEMA..T_SEGMENT)
Return t_segment Deterministic
```

DESCRIPTION

```    This function determines if the two segments (underlying and supplied) for a straight line (no bend)
and touch as a start/end coordinate pair.
New segment is created from start/end coordinates.
```

ARGUMENTS

```    p_segment  (T_Segment) -- Other, possibly connected, segment
```

RESULT

```    segment   (T_Segment) -- New segment.
```

NOTES

```    Ignores any measure ordinates.
Calculations are always planar.
```

EXAMPLE

```    -- 0. Uses T_Vector3D to compute whether segments can be merged by sharing vertex and having same normalized vectors.
with data as (
select sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(  0,  0, 100,100)) as line1,
sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,100, 200,200)) as line2
from dual
UNION ALL
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(  0,  0, 0, 100,100,10)) as line1,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(100,100,10, 200,200,20)) as line2
from dual
)
select a.line1.get_Dims() as dims,
t_vector3d(T_Segment(a.line1))
.Normalize()
.Subtract(
t_vector3d(
T_Segment(a.line2))
.Normalize())
.AsText()as ms2
from data a;

DIMS MS2
---- ----------------
2 T_VECTOR3D(x=0,y=0,z=NULL}
3 T_VECTOR3D(x=0,y=0,z=0}

-- 1. ST_Merge End/Start collinear in 2D and 3D
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array( 0, 0, 0, 10,10,10)) as first_line,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(10,10,10, 20,20,20)) as second_line
from dual
)
select 2 as dims,
T_Segment( a.first_line,  1 ).ST_To2D()
.ST_Merge( T_Segment( a.second_line, 2 ).ST_To2D() ).ST_AsText() as mergedSegment
from data a
union all
select 3 as dims,
T_Segment( a.first_line, 1 ).ST_Merge( T_Segment( a.second_line, 2 ) ).ST_AsText() as mergedSegment
from data a;

DIMS MERGEDSEGMENT
---- -------------------------------------------------------------------------------------------------------------------
2 SEGMENT(NULL,NULL,1,Start(1,0,0,NULL,NULL,2001,NULL),End(2,20,20,NULL,NULL,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
3 SEGMENT(NULL,NULL,1,Start(1,0,0,0,NULL,3001,NULL),End(2,20,20,20,NULL,3001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)

-- 2. ST_Merge End/Start collinear in 2D but not 3D
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array( 0, 0, 0, 10,10,10)) as first_line,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(10,10,10, 20,20,21)) as second_line
from dual
)
select 2 as dims,
T_Segment( a.first_line, 1 ).ST_To2D()
.ST_Merge( T_Segment( a.second_line, 2 ).ST_To2D() ).ST_AsText() as mergedSegment
from data a
union all
select 3 as dims,
T_Segment( a.first_line ).ST_Merge( T_Segment( a.second_line, 2 ) ).ST_AsText() as mergedSegment
from data a;

DIMS MERGEDSEGMENT
---- ---------------------------------------------------------------------------------------------------------------------------------------------
2 SEGMENT(NULL,NULL,1,Start(1,0,0,NULL,NULL,2001,NULL),End(2,20,20,NULL,NULL,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
3 SEGMENT(NULL,NULL,0,Start(1,0,0,0,NULL,3001,NULL),Mid(2,10,10,10,NULL,3001,NULL),End(2,20,20,21,NULL,3001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)

-- 3. ST_Merge where relationship is end/end collinear
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array( 0, 0, 0, 10,10,10)) as first_line,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(20,20,20, 10,10,10)) as second_line
from dual
)
select 2 as dims,
T_Segment( a.first_line,  1 ).ST_To2D()
.ST_Merge( T_Segment( a.second_line, 2 ).ST_To2D() ).ST_AsText() as mergedSegment
from data a
union all
select 3 as dims,
T_Segment( a.first_line, 1 ).ST_Merge( T_Segment( a.second_line, 2 ) ).ST_AsText() as mergedSegment
from data a;

DIMS MERGEDSEGMENT
---- -------------------------------------------------------------------------------------------------------------------
2 SEGMENT(NULL,NULL,1,Start(1,0,0,NULL,NULL,2001,NULL),End(1,20,20,NULL,NULL,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
3 SEGMENT(NULL,NULL,1,Start(1,0,0,0,NULL,3001,NULL),End(1,20,20,20,NULL,3001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)

-- 4. ST_Merge where relationship is start/start collinear
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(10,10,10,  0, 0, 0)) as first_line,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(20,20,20, 10,10,10)) as second_line
from dual
)
select 2 as dims,
T_Segment( a.first_line, 1 ).ST_To2D()
.ST_Merge( T_Segment( a.second_line, 2 ).ST_To2D() ).ST_AsText() as mergedSegment
from data a
union all
select 3 as dims,
T_Segment( a.first_line, 1 ).ST_Merge( T_Segment( a.second_line, 2 ) ).ST_AsText() as mergedSegment
from data a;

DIMS MERGEDSEGMENT
---- --------------------------------------------------------------------------------------------------------------------------------------
2 SEGMENT(NULL,NULL,NULL,Start(NULL,NULL,NULL,NULL,NULL,NULL,NULL),End(NULL,NULL,NULL,NULL,NULL,NULL,NULL),SDO_GTYPE=NULL,SDO_SRID=NULL)
3 SEGMENT(NULL,NULL,NULL,Start(NULL,NULL,NULL,NULL,NULL,NULL,NULL),End(NULL,NULL,NULL,NULL,NULL,NULL,NULL),SDO_GTYPE=NULL,SDO_SRID=NULL)

-- 5. ST_Merge where identical (returns first_line)
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,0, 10,10,10)) as first_line,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,0, 10,10,10)) as second_line
from dual
)
select 2 as dims,
T_Segment( a.first_line,  1 ).ST_To2D()
.ST_Merge( T_Segment( a.second_line, 2 ).ST_To2D() ).ST_AsText() as mergedSegment
from data a
union all
select 3 as dims,
T_Segment( a.first_line, 1 ).ST_Merge( T_Segment( a.second_line, 2 ) ).ST_AsText() as mergedSegment
from data a;

DIMS MERGEDSEGMENT
---- -------------------------------------------------------------------------------------------------------------------
2 SEGMENT(NULL,NULL,1,Start(1,0,0,NULL,NULL,2001,NULL),End(2,10,10,NULL,NULL,2001,NULL),SDO_GTYPE=2002,SDO_SRID=NULL)
3 SEGMENT(NULL,NULL,1,Start(1,0,0,0,NULL,3001,NULL),End(2,10,10,10,NULL,3001,NULL),SDO_GTYPE=3002,SDO_SRID=NULL)

-- 6. ST_Merge where no spatial relationship (Returns Empty Segment)
with data as (
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,0,    10,10,10)) as first_line,
sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(11,11,11, 20,20,21)) as second_line
from dual
)
select 2 as dims,
T_Segment( a.first_line,  1 ).ST_To2D()
.ST_Merge( T_Segment( a.second_line, 2 ).ST_To2D() ).ST_AsText() as mergedSegment
from data a
union all
select 3 as dims,
T_Segment( a.first_line, 1 ).ST_Merge( T_Segment( a.second_line, 2 ) ).ST_AsText() as mergedSegment
from data a;

DIMS MERGEDSEGMENT
---- --------------------------------------------------------------------------------------------------------------------------------------
2 SEGMENT(NULL,NULL,NULL,Start(NULL,NULL,NULL,NULL,NULL,NULL,NULL),End(NULL,NULL,NULL,NULL,NULL,NULL,NULL),SDO_GTYPE=NULL,SDO_SRID=NULL)
3 SEGMENT(NULL,NULL,NULL,Start(NULL,NULL,NULL,NULL,NULL,NULL,NULL),End(NULL,NULL,NULL,NULL,NULL,NULL,NULL),SDO_GTYPE=NULL,SDO_SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 -- Original coding.
Simon Greener - August 2018  -- Ensure all cases correct esp for 3D (XYZ)
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.47. T_SEGMENT/ST_MidPoint [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_MidPoint - Computes, and returns, the midpoint of the segment
```

SYNOPSIS

```    Member Function ST_MidPoint
Return t_vertex Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function computes and returns its mid Point.
If CircularArc, mid point is point at mid length distance from start.
```

RESULT

```    point (t_vertex) -- The midpoint of the segment
```

EXAMPLE

```    select &&INSTALL_SCHEMA..T_Segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,1)))
.ST_midPoint()
.ST_SdoGeometry() as mPoint
from dual;

MPOINT
--------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(0.5, 0.5, NULL), NULL, NULL)

select &&INSTALL_SCHEMA..T_Segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),sdo_ordinate_array(0,0,10,10,20,0)))
.ST_midPoint()
.ST_SdoGeometry() as mPoint
from dual;

MPOINT
------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(10, 10, NULL), NULL, NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.48. T_SEGMENT/ST_MinX [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_MinX - Returns the smallest X ordinate value from the underlying segments minimum bounding rectangle (MBR).
```

SYNOPSIS

```    Member Function ST_MinX
Return SDO_GEOMETRY Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function returns the smallest X ordinate value held by the startCoord,midCoord or endCoord vertices.
```

RESULT

```    ordinate (number) -- Smallest
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,0.8 0.8)',NULL)).ST_MinX() as minX
from dual;

MINX
----
0
```

```    T_MBR object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2011 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.49. T_SEGMENT/ST_MinY [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_MinY - Returns the smallest Y ordinate value from the underlying segments minimum bounding rectangle (MBR).
```

SYNOPSIS

```    Member Function ST_MinY
Return SDO_GEOMETRY Determinsitic
```

DESCRIPTION

```    Supplied with a non-NULL segment, this function returns the smallest Y ordinate value held by the startCoord,midCoord or endCoord vertices.
```

RESULT

```    ordinate (number) -- Smallest
```

EXAMPLE

```    select T_Segment(sdo_geometry('LINESTRING(0 0,0.8 0.8)',NULL)).ST_MinY() as minX
from dual;

MINY
----
0
```

```    T_MBR object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2011 - Original coding
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.50. T_SEGMENT/ST_OffsetBetween [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_OffsetBetween - Computes offset point on the bisector between two vertices.
```

SYNOPSIS

```    Member Function ST_OffsetBetween(p_segment   in number,
p_offset    in number,
p_unit      In Integer Default NULL)
Return &&INSTALL_SCHEMA..T_Vertex Deterministic
```

DESCRIPTION

```    Supplied with a second segment (p_segment), this function computes the bisector
between the two segments and then creates a new vertex at a distance of p_offset
from the intersection point.  If an offset value of 0.0 is supplied, the
intersection point is returned. If the p_offset value is <> 0, the function computes a new
position for the point at a distance of p_offset on the left (-ve) or right (+ve) side
of the segment.
The returned vertex's ordinate values are rounded using the supplied tolerance.
```

ARGUMENTS

```    p_segment (number) - A segment that touches the current segment at one end point.
p_offset       (number) - The perpendicular distance to offset the point generated using p_ratio.
A negative value instructs the function to offet the point to the left (start-end),
and a positive value to the right.
p_unit       (varchar2) - If NULL, the calculations are done using the underlying projection default units.
If an Oracle Unit of Measure is supplied (eg unit=M) that is value for the SRID,
- this value is used when calculating the p_offset distance.
```

RESULT

```    point        (T_Vertex) - New point on bisection point or along bisector line with optional perpendicular offset.
```

EXAMPLE

```    -- Planar
With data as (
select SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(561981.279,1013120.171,0.00, 562044.981,1013076.691,77.1))  as sGeom,
SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(562044.981,1013076.691,77.1, 562024.253,1013138.371,142.2)) as nGeom
from dual
)
select 3                  as dims,
CAST('Start Segment'
as
varchar2(30)) as description,
a.sGeom            as offsetBetween
from data a
Union All
select 3                  as dims,
CAST('Next Segment'
as
varchar2(30)) as description,
a.nGeom            as offsetBetween
from data a
Union All
select a.sGeom.get_dims() as dims,
CAST('Offset Point @' || t.IntValue
as
varchar2(30)) as description,
T_Segment(a.sGeom)
.ST_OffsetBetween(
p_segment => T_Segment(a.nGeom),
p_offset       => t.IntValue,
p_unit         => 'unit=M')
.ST_Round(3)
.ST_SdoGeometry() as OffsetBetween
from data a,
table(tools.generate_series(-5,5,5)) t;

DIMS DESCRIPTION       OFFSETBETWEEN
---- ----------------- ----------------------------------------------------------------------------------------------------------------------------------------
3 Start Segment     SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(561981.279,1013120.171,0,562044.981,1013076.691,77.1))
3 Next Segment      SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(562044.981,1013076.691,77.1,562024.253,1013138.371,142.2))
3 Offset Point @-5  SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562041.963,1013080.677,77.1),NULL,NULL)
3 Offset Point @0   SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562044.981,1013076.691,77.1),NULL,NULL)
3 Offset Point @5   SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562047.999,1013072.705,77.1),NULL,NULL)

-- Geodetic
With data as (
select SDO_GEOMETRY(3302,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.7868589596,-45.0326616056,0.0, 147.7876729555,-45.0330473956,77.1)) as sGeom,
SDO_GEOMETRY(3302,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.7876729555,-45.0330473956,77.1, 147.787402221,-45.032494027,142.2)) as nGeom
from dual
)
select 3                  as dims,
CAST('Start Segment'
as
varchar2(20)) as description,
a.sGeom            as offsetBetween
from data a
Union All
select 3                  as dims,
CAST('Next Segment'
as
varchar2(20)) as description,
a.nGeom            as offsetBetween
from data a
Union All
select a.sGeom.get_dims() as dims,
CAST('Offset Point @' || t.IntValue
as
varchar2(20)) as description,
T_Segment(a.sGeom)
.ST_OffsetBetween(
p_segment => T_Segment(a.nGeom),
p_offset       => t.IntValue,
p_unit         => 'unit=M') -- if 3D geodetic, compute as planar otherwise Oracle error
.ST_Round(8)
.ST_SdoGeometry() as OffsetBetween
from data a,
table(tools.generate_series(-5,5,5)) t;

DIMS DESCRIPTION      OFFSETBETWEEN
---- ---------------- ------------------------------------------------------------------------------------------------------------------------------------------------
3 Start Segment    SDO_GEOMETRY(3302,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.7868589596,-45.0326616056,0,147.7876729555,-45.0330473956,77.1))
3 Next Segment     SDO_GEOMETRY(3302,4326,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.7876729555,-45.0330473956,77.1,147.787402221,-45.032494027,142.2))
3 Offset Point @-5 SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(147.78763353,-45.03301215,NULL),NULL,NULL)
3 Offset Point @0  SDO_GEOMETRY(3301,4326,SDO_POINT_TYPE(147.78767296,-45.0330474,77.1),NULL,NULL)
3 Offset Point @5  SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(147.78771238,-45.03308265,NULL),NULL,NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.51. T_SEGMENT/ST_OffsetPoint [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_OffsetPoint -- Creates a point described by a ratio along the
segment and with a perpendicular offset.
```

SYNOPSIS

```    Member Function ST_OffsetPoint(p_ratio     in Number,
p_offset    in Number,
p_unit      In Integer Default NULL)
Return &&INSTALL_SCHEMA..T_Vertex Deterministic
```

DESCRIPTION

```    Supplied with a ratio value (0.0 -> 1.0), this function uses that value to find the
point along its segment where it lies. If an offset value of 0.0 is supplied, the
discovered point is returned. If the p_offset value is <> 0, the function computes a new
position for the point at a distance of p_offset on the left (-ve) or right (+ve) side
of the segment.
The returned vertex's ordinate values are rounded using the supplied tolerance.
```

ARGUMENTS

```    p_ratio     (number) - A value between 0 and 1, from the start vertex of the segment,
which describes the position of the point to be offset.
p_offset    (number) - The perpendicular distance to offset the point generated using p_ratio.
A negative value instructs the function to offet the point to the left (start-end),
and a positive value to the right.
p_unit    (VARCHAR2) - If NULL, the calculations are done using the underlying projection default units.
If an Oracle Unit of Measure is supplied (eg unit=M) that is value for the SRID,
this value is used when calculating the p_offset distance.
```

RESULT

```    vertex     (T_VERTEX)   - New point on line with optional perpendicular offset.
```

EXAMPLE

```    With data as (
select sdo_geometry(3302,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,100.0,147.41,-43.387,30000.0)) as geom
from dual
UNION ALL
select sdo_geometry(2002,4326,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.50,-43.132,147.41,-43.387)) as geom
from dual
)
select a.geom.get_dims() as dims,
t.IntValue        as offset,
T_Segment(a.geom)
.ST_OffsetPoint(p_ratio     => 0.25,
p_offset    => t.IntValue,
p_unit      => 'unit=M')
.ST_Round(8)
.ST_SdoGeometry() as offsetPoint
from data a,
table(tools.generate_series(-5,5,5)) t;

DIMS OFFSET OFFSETPOINT
---- ------ --------------------------------------------------------------------------------
3     -5 SDO_GEOMETRY(3301,4326,SDO_POINT_TYPE(152.19245167,-44.85985059,7575),NULL,NULL)
3      0 SDO_GEOMETRY(3301,4326,SDO_POINT_TYPE(147.4775,-43.19575,7575),NULL,NULL)
3      5 SDO_GEOMETRY(3301,4326,SDO_POINT_TYPE(142.76254833,-41.53164941,7575),NULL,NULL)
2     -5 SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(152.19245167,-44.85985059,NULL),NULL,NULL)
2      0 SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(147.4775,-43.19575,NULL),NULL,NULL)
2      5 SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(142.76254833,-41.53164941,NULL),NULL,NULL)

6 rows selected
With data as (
select SDO_GEOMETRY(3302,90000006,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(562046.642,1013077.602,0, 562032.193,1013252.074,0.035)) as geom
from dual
)
select t.IntValue as offset,
T_Segment(a.geom)
.ST_OffsetPoint(p_ratio     => 0.25,
p_offset    => t.IntValue,
p_unit      => 'unit=M')
.ST_Round(3)
.ST_SdoGeometry() as offsetPoint
from data a,
table(tools.generate_series(-5,5,5)) t;

OFFSET OFFSETPOINT
---------- ----------------------------------------------------------------------------------
-5 SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562038.047,1013120.807,0.009),NULL,NULL)
0 SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562043.03,1013121.22,0.009),NULL,NULL)
5 SDO_GEOMETRY(3301,90000006,SDO_POINT_TYPE(562048.013,1013121.633,0.009),NULL,NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.52. T_SEGMENT/ST_Parallel [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Parallel -- Moves segment parallel the provided p_offset distance.
```

SYNOPSIS

```    Member Function ST_Parallel(p_offset in Number)
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Computes parallel offset, left or right of underlying geometry.
Circular arcs are not yet correctly handled.
```

ARGUMENTS

```    p_offset     (Number) -- Value +/- numeric value.
```

RESULT

```    New segment (T_SEGMENT) -- Input segment moved parallel by p_offset units
```

TODO

```    Check Circular Arc Calculations
```

EXAMPLE

```    with data as (
select 'Planar LineString' as test,
sdo_geometry(3302,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,1,1.1,6,6,5.95)) as geom,
5.0 as offset
from dual
union all
select 'Planar CircularString' as test,
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,2), -- Circular Arc line string
SDO_ORDINATE_ARRAY(252230.478,5526918.373, 252400.08,5526918.373,252230.478,5527000.0)) as geom,
-5.0 as offset
from dual
)
select a.test,
T_Segment(a.geom)
.ST_Parallel(p_offset=>a.offset)
.ST_Round(3,3,2,1)
.ST_SdoGeometry() as pGeom
from data a;

TEST                  PGEOM
--------------------- -------------------------------------------------------------------------------------------------------------------------------------------------
Planar LineString     SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(4.536,-2.536,1.1,9.536,2.464,5.95))
Planar CircularString SDO_GEOMETRY(2002,28355,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(252321.904,5527048.051,252318.419,5527048.243,252323.295,5527047.937))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2008 - Original coding in GEOM package.
Simon Greener - January 2013  - Port/Rewrite to T_GEOMETRY object function member.
Simon Greener - January 2014  - Port/Rewrite to T_SEGMENT object function member.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.53. T_SEGMENT/ST_PointAlong [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_PointAlong -- Computes the vertex that lies a given fraction along the line defined by this segment.
```

SYNOPSIS

```    Member Function ST_pointAlong(segmentLengthFraction in Number)
Return &&INSTALL_SCHEMA..T_Vertex deterministic
```

DESCRIPTION

```    A fraction of <code>0.0</code> returns the start point of the segment;
a fraction of <code>1.0</code> returns the end point of the segment.
If the fraction is null; 0.0 or null; 1.0 the point returned
will lie before the start or beyond the end of the segment.
```

INPUTS

```    p_segmentLengthFraction (number) -- The fraction of the segment length along the line
```

RESULT

```    Returns the vertex at that distance along the segment
```

EXAMPLE

```    select &&INSTALL_SCHEMA..T_Segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,1)))
.ST_PointAlong(p_segmentLengthFraction=>0.5)
.ST_SdoGeometry() as mPoint
from dual;

MPOINT
--------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(0.5, 0.5, NULL), NULL, NULL)

select &&INSTALL_SCHEMA..T_Segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,1)))
.ST_PointAlong(p_segmentLengthFraction=>0.9)
.ST_SdoGeometry() as mPoint
from dual;

MPOINT
--------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(0.9, 0.9, NULL), NULL, NULL)

select &&INSTALL_SCHEMA..T_Segment(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),sdo_ordinate_array(0,0,10,10,20,0)))
.ST_PointAlong(p_segmentLengthFraction=>0.5)
.ST_SdoGeometry() as mPoint
from dual;

MPOINT
------------------------------------------------------------------
SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(10, 10, NULL), NULL, NULL)
```

NOTES

```    From JTS LineSegment.java
2D only; no circular arcs.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.54. T_SEGMENT/ST_PointAlongOffset [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_PointAlongOffset -- Computes the vertex that lies a given fraction along the line defined by this segment and offset from the segment by a given distance.
```

SYNOPSIS

```    Member Function ST_pointAlongOffset(
p_segmentLengthFraction in Number,
p_offsetDistance in Number
)
Return &&INSTALL_SCHEMA..T_Vertex deterministic
```

DESCRIPTION

```    A fraction of 0.0 offsets from the start point of the segment;
a fraction of 1.0 offsets from the end point of the segment.
The computed point is offset to the left of the line if the offset distance is
positive, to the right if negative.
```

INPUTS

```    p_segmentLengthFraction (number) -- The fraction of the segment length along the line
p_offsetDistance        (number) -- The distance the point is offset from the segment (positive is to the left, negative is to the right)
```

RESULT

```    Returns the vertex at that distance and offset along the segment
```

NOTES

```    From JTS LineSegment.java
2D only; no circular arcs.
Throws Exception if the segment has zero length
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.55. T_SEGMENT/ST_ProjectPoint [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_ProjectPoint -- Return a measured point by snapping provided point to the underlying LineString or circularString
```

SYNOPSIS

```    ST_ProjectPoint(p_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_unit   in varchar2)
Return &&INSTALL_SCHEMA..T_Vertex deterministic
```

DESCRIPTION

```    This function snaps supplied point to underlying LineString or CircularString, returning the snapped point.

Computes Z and M values if exist on underlying LineString or CircularString.

If input circularString is 2D, length from start of LineString or CircularString to point is returned in M ordinate of snapped point.
```

NOTES

```    Supports geodetic/geographic data.
```

INPUTS

```    p_vertex (t_vertex) - Point near to linestring or CircularString.
```

RESULT

```    snapped point (t_vetex) -- First point found on LineString.
```

EXAMPLE

```    select 'Point is on centre of the XYZ circular arc (returns start point)' as test,
t_segment(SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.3246,-1, 0,7,-1, -3,6.3246,-1)))
.ST_ProjectPoint (
t_vertex(SDO_GEOMETRY('POINT(0 0)',NULL)),
null
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point does not have relationship with XYM LineString' as test,
t_segment(SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,0, 0,7,3.08, -3,6.325,6.15)))
.ST_ProjectPoint (
t_vertex(SDO_GEOMETRY('POINT(8 8)',NULL))
).ST_AsEWKT() as project_point
from dual union all
select 'Point projects on to point half way along XY circular arc (returns measure as length)' as test,
t_segment(SDO_GEOMETRY('CIRCULARSTRING (3 6.3246, 0 7, -3 6.3246)',NULL))
.ST_ProjectPoint (
t_vertex(SDO_GEOMETRY('POINT(0 3.5)',NULL)),
null
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point has relationship with XYM LineString' as test,
t_segment(SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,0, 0,7,3.08, -3,6.325,6.15)))
.ST_ProjectPoint (
t_vertex(SDO_GEOMETRY('POINT(2 8)',NULL))
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point has relationship with XYZM circular arc' as test,
t_segment(SDO_GEOMETRY(4402,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,-2.1,0, 0,7,-2.1,3.08, -3,6.325,-2.1,6.15)))
.ST_ProjectPoint (
t_vertex(SDO_GEOMETRY('POINT(2 8)',NULL)),
null
).ST_Round(3).ST_AsEWKT() as project_point
from dual union all
select 'Geodetic Point has relationship with XYZM Geodetic LineString' as test,
T_Segment(MDSYS.SDO_GEOMETRY(3302,4326,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(147.5,-43.132,100,147.41,-43.387,30000)))
.ST_ProjectPoint (
t_vertex(SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(147.509,-43.221,NULL),NULL,NULL))
).ST_Round(3).ST_AsEWKT() as project_point
from dual ;

TEST                                                                                  PROJECT_POINT
------------------------------------------------------------------------------------- ---------------------------------
Point is on centre of the XYZ circular arc (returns start point)                      POINTZ (3 6.325 -1)
Point does not have relationship with XYM CircularSring                               NULL
Point projects on to point half way along XY circular arc (returns measure as length) POINTM (0 7 3.1)
Point has relationship with XYM CircularSring                                         POINTM (1.698 6.791 1.374)
Point has relationship with XYZM circular arc                                         POINTZM (1.698 6.791 -2.1 1.374)
Geodetic Point has relationship with XYZM Geodetic LineString                         SRID=8307;POINTM (147.44551945 -43.23290209 11930.116)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2008-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.56. T_SEGMENT/ST_Reverse [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Reverse -- Reverses underlying segment's start and end coordinates.
```

SYNOPSIS

```    Member Function ST_Reverse
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Constructs new segment by swapping start and end coordinates of underlying segment.
If underlying segment has a middle coordinate it is left in place.
```

RESULT

```    segment (T_SEGMENT) -- segment that has reverse direction to the original segment.
```

EXAMPLE

```    select T_Segment(
sdo_geometry(2002,NULL,NULL,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,10,10))
).ST_Reverse()
.ST_SdoGeometry() as rSegment
from dual;

RSEGMENT
-------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(10,10,0,0))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.57. T_SEGMENT/ST_Round [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Round -- Rounds X,Y,Z and m(w) ordinates of segment's coordinates usoing object's PrecisionModel.
```

SYNOPSIS

```    Member Function ST_Round
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Applies internal object's precisionModel decimal digits of precision value to ordinates of object.
If internal PrecisionModel is null, the object is returned unchanged.
If an internal PrecisionModel element is null the default values for the called ST_Round are applied.
```

RESULT

```    segment (T_SEGMENT) -- T_Segment with rounded ordinates using SELF.PrecisionModel values.
```

NOTES

```    Is wrapper over ST_Round( y, y, z, m );
```

EXAMPLE

```    with data as (
select sdo_geometry(4402,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,1.3456,0.0005, 10.87365,11.983645,1.98434,14.38573)) as geom
From Dual
Union all
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,1.3456,10.87365,11.983645,1.98434)) as geom
From Dual
Union all
select sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,       10.87365,11.983645        )) as geom
from dual
)
select T_Segment(a.geom)
.ST_Round().ST_SdoGeometry() as rGeom
from data a;

RGEOM
-------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(4402,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.002,0.183,1.3,0,10.874,11.984,2,14.39))
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.002,0.183,1.3,10.874,11.984,2))
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.002,0.183,10.874,11.984))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.58. T_SEGMENT/ST_Round(x y z m) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Round -- Rounds X,Y,Z and m(w) ordinates of segment's coordinates to passed in precision.
```

SYNOPSIS

```    Member Function ST_Round(p_dec_places_x in integer,
p_dec_places_y in integer default NULL,
p_dec_places_z in integer default 3,
p_dec_places_m in integer default 3)
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Applies relevant decimal digits of precision value to ordinate.
For example:
SELF.x := ROUND(SELF.x,p_dec_places_x);
```

ARGUMENTS

```    p_dec_places_x (integer) - value applied to x Ordinate.
p_dec_places_y (integer) - value applied to y Ordinate.
p_dec_places_z (integer) - value applied to z Ordinate.
p_dec_places_m (integer) - value applied to m Ordinate.
```

RESULT

```    segment (T_SEGMENT)
```

EXAMPLE

```    with data as (
select sdo_geometry(4402,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,1.3456,0.0005, 10.87365,11.983645,1.98434,14.38573)) as geom
From Dual
Union all
select sdo_geometry(3002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,1.3456,10.87365,11.983645,1.98434)) as geom
From Dual
Union all
select sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0.0023763,0.18349,       10.87365,11.983645        )) as geom
from dual
)
select T_Segment(a.geom)
.ST_Round(p_dec_places_x=>3,
p_dec_places_y=>3,
p_dec_places_z=>1,
p_dec_places_m=>2
).ST_SdoGeometry() as rGeom
from data a;

RGEOM
-------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(4402,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.002,0.183,1.3,0,10.874,11.984,2,14.39))
SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.002,0.183,1.3,10.874,11.984,2))
SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.002,0.183,10.874,11.984))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.59. T_SEGMENT/ST_SdoGeometry [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_SdoGeometry -- Returns segment as a suitably encoded MDSYS.SDO_GEOMETRY object.
```

SYNOPSIS

```    Member Function ST_SdoGeometry(p_dims in integer default null)
Return MDSYS.sdo_geometry Deterministic,
```

DESCRIPTION

```    Geometry depends on how the segment is described (vertex-connected or circular arc).
Also, p_dims can force 3D linestring to be returned as a 2D linestring.
```

ARGUMENTS

```    p_dims in integer default null - A dimension value that will override SELF.ST_Dims() eg to return 2D from a 3D segment.
```

RESULT

```    linestring (MDSYS.SDO_GEOMETRY) -- Two (or three) point linestring.
```

EXAMPLE

```    select T_Segment(
p_segment_id => 0,
p_startCoord => t_Vertex(
p_id=>1,
p_x=>0.0023763,
p_y=>0.18349,
p_z=>1.346,
p_w=>0.001,
p_sdo_gtype=>4401,
p_sdo_srid=>NULL
),
p_EndCoord   => T_Vertex(
p_id=>2,
p_x=>10.87365,
p_y=>11.983645,
p_z=>1.984,
p_w=>14.386,
p_sdo_gtype=>4401,
p_sdo_srid=>NULL
),
p_sdo_gtype=>4402,
p_sdo_srid=>NULL
).ST_SdoGeometry() as geom
from dual;

GEOM
-----------------------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(4402,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(0.0023763,0.18349,1.346,0.001,10.87365,11.983645,1.984,14.386))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.60. T_SEGMENT/ST_Self [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_Self -- Handy method for use with TABLE(T_Segments) to return element as T_Segment object.
```

SYNOPSIS

```    Member Function ST_Self
Return T_Segment Deterministic,
```

DESCRIPTION

```    When segmentizing linear geometries into T_Segment objects via a TABLE function call to T_GEOMETRY.T_SEGMENTIZE()
it is handy to have a method which allows access to the result as a single object.
In a sense this method allows access similar to t.COLUMN_VALUE for atmoic datatype access from TABLE functions.
```

RESULT

```    segment (T_SEGMENT) -- A single T_Segment object.
```

EXAMPLE

```    set serveroutput on
BEGIN
FOR rec IN (select seg.segment_id, seg.ST_Self() as line
from table(t_geometry(
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(252282.861,5526962.496,252282.861,5526882.82, 252315.91,5526905.639, 252287.189,5526942.228)) )
.ST_Segmentize('ALL')) seg
)
LOOP
dbms_output.put_line(rec.line.ST_AsText());
END LOOP;
END;
/
anonymous block completed
SEGMENT(1,1,1,Start(1,252282.861,5526962.496,NULL,NULL,2001,28355),End(2,252282.861,5526882.82,NULL,NULL,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,1,2,Start(2,252282.861,5526882.82,NULL,NULL,2001,28355),End(3,252315.91,5526905.639,NULL,NULL,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
SEGMENT(1,1,3,Start(3,252315.91,5526905.639,NULL,NULL,2001,28355),End(4,252287.189,5526942.228,NULL,NULL,2001,28355),SDO_GTYPE=2002,SDO_SRID=28355)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.61. T_SEGMENT/ST_SetCoordinates(vertex vertex vertex) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_SetCoordinates -- Allows user to set a segment's start/mid/end coordinates
```

SYNOPSIS

```    Member Procedure ST_SetCoordinates(SELF IN OUT NOCOPY T_SEGMENT,
p_startCoord in &&INSTALL_SCHEMA..T_VERTEX,
p_midCoord   in &&INSTALL_SCHEMA..T_VERTEX,
p_endCoord   in &&INSTALL_SCHEMA..T_VERTEX),
```

DESCRIPTION

```    This procedure allows a user to set a segment's coordinates without creating a new segment.
If a NULL value is provided for the midCoord parameter its associated coordinate will be set to NULL.
If a NULL value is provided for the startCoord or endCoord it is ignored as it would otherwise invalidate the object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.62. T_SEGMENT/ST_SetCoordinates(vertex vertex) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_SetCoordinates -- Allows user to set object's start or end coordinates.
```

SYNOPSIS

```    Member Procedure ST_SetCoordinates(SELF IN OUT NOCOPY T_SEGMENT,
p_startCoord in &&INSTALL_SCHEMA..T_VERTEX,
p_endCoord   in &&INSTALL_SCHEMA..T_VERTEX),
```

DESCRIPTION

```    This procedure allows a user to set a segment's coordinates without creating a new segment.
If a NULL value is provided for a parameter it is ignored as it would otherwise invalidate the object.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.63. T_SEGMENT/ST_SetPrecisionModel [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_SetPrecisionModel -- Allows user to set object's t_precision object.
```

SYNOPSIS

```    Member Procedure ST_SetPrecisionModel(SELF IN OUT NOCOPY T_SEGMENT,
p_precision &&INSTALL_SCHEMA..T_PrecisionModel),
```

DESCRIPTION

```    This procedure allows a user to set the object's precision values in its t_precision object.
If a NULL value is provided for a precision object element, the existing value is maintained.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.64. T_SEGMENT/ST_SRID [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_SRID -- Returns the object's SDO_SRID attribute value.
```

SYNOPSIS

```    Member Function ST_SRID
Return INTEGER Deterministic,
```

DESCRIPTION

```    Returns sdo_srid object attribute.
```

RESULT

```    spatial reference id (INTEGER) -- eg 8311 etc.
```

EXAMPLE

```    with data as (
select T_Segment(
SDO_GEOMETRY('CIRCULARSTRING(252230.478 5526918.373, 252400.08 5526918.373, 252230.478 5527000.0)',28355)
) as circular_segment
from dual
)
select a.circular_segment.ST_Srid() as Srid
from data a;

SRID
-----
28355
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.65. T_SEGMENT/ST_To2D [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_To2D -- Constructs a 2D segment from the underlying segment which can have any dimension.
```

SYNOPSIS

```    Member Function ST_To2D
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Constructs new segment by discarding any z and w ordinates.
SDO_GTYPE returned will be 2001.
If segment already 2D it is returned unchanged.
```

RESULT

```    segment (T_SEGMENT) -- 2d segment.
```

EXAMPLE

```    select T_Segment(sdo_geometry(3002,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5, -42.5,10.0, 147.6, -42.5, 10.0)))
.ST_To2D()
.ST_SdoGeometry(2) as geom2D
from dual;

GEOM2D
---------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,4283,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.5,-42.5,147.6,-42.5))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.66. T_SEGMENT/ST_To3D [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_To3D -- Constructs a 3D segment from the underlying segment which can have any dimension.
```

SYNOPSIS

```    Member Function ST_To3D(p_keep_measure in integer default 0,
p_default_z    in number  default null)
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Constructs new 3D segment.
If segment 2D is has any p_default_z values added to the new segment's z ordinates.
If segment is 3D with no measure it is returned without change.
If segment is 3D with Measure it is returned as an unmeasured 3D segment with the Z ordinates
being the original measure values if p_keep_measure = 1, otherwise, the Z values are set to p_default_z.
If segment is 4D with Measure it is returned as an unmeasured 3D segment with the Z ordinates
being the original measure values if p_keep_measure = 1, otherwise, the Z values are set to p_default_z.
```

RESULT

```    segment (T_SEGMENT) -- 3D segment.
```

EXAMPLE

```    -- Convert 2D segment to 3D with constant Z value of 10.0
select T_Segment(sdo_geometry(2002,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5, -42.5, 147.6,-42.5)))
.ST_To3D(p_keep_measure => 0,
p_default_z    => 10.0)
.ST_SdoGeometry(3) as geom3D
from dual;

GEOM3D
---------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,4283,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(147.5,-42.5,10,147.6,-42.5,10))

-- Convert measured segment (no Z) to 3D with Z
select T_Segment(sdo_geometry(3302,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5, -42.5,0.0, 147.6, -42.5, 10923.0)))
.ST_To3D(p_keep_measure => 1)
.ST_SdoGeometry(3) as geom3D
from dual;

GEOM3D
-----------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,4283,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(147.5,-42.5,0,147.6,-42.5,10923))

-- Convert measured segment with Z to 3D with Z (throw M away)
select T_Segment(sdo_geometry(4402,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5,-42.5,849.9,2000.0, 147.6,-42.5,1923.0,4000.0)))
.ST_To3D(p_keep_measure => 0)
.ST_SdoGeometry(3) as geom3D
from dual;

GEOM3D
--------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,4283,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.5,-42.5,849.9,147.6,-42.5,1923))

-- Convert measured segment with Z to 3D with M becoming Z (throw Z away)
select T_Segment(sdo_geometry(4402,4283,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(147.5,-42.5,849.9,2000.0, 147.6,-42.5,1923.0,4000.0)))
.ST_To3D(p_keep_measure => 1)
.ST_SdoGeometry(3) as geom3D
from dual;

GEOM3D
-------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(3002,4283,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(147.5,-42.5,2000,147.6,-42.5,4000))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.67. T_SEGMENT/ST_UpdateCoordinate(p_vertex) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_UpdateCoordinate -- Function which updates the start, mid or end coordinate depending on p_which.
```

SYNOPSIS

```    Member Function ST_UpdateCoordinate(p_coordinate in &&INSTALL_SCHEMA..T_Vertex,
p_which      in varchar2 default 'S' )
Return &&INSTALL_SCHEMA..T_SEGMENT Deterministic,
```

DESCRIPTION

```    Function that updates start, mid or end coordinate the underlying T_Segment which value in p_coordinate depending on position identified by p_which.
p_which can have one of 6 values. See Arguments.
```

ARGUMENTS

```    p_coordinate (T_Vertex) -- Replacement coordinate which must not be null otherwise T_Segment is unchanged.
p_which      (varchar2) -- Can be one of the following values:
- NULL : defaults to 'S'
- 'S' or '1' : StartCoord
- 'M' or '2' :   midCoord
- 'E' or '3' :   endCoord
```

RESULT

```    updated segment (T_Segment) - Geometry with coordinate replaced.
```

EXAMPLE

```    select T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_UpdateCoordinate(
p_coordinate => T_Vertex(
p_x         => 99.0,
p_y         => 100.0,
p_id        => 1,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL),
p_which => 1
)
.startCoord
.ST_AsText() as updatedSegment
from dual;

UPDATEDSEGMENT
--------------------------------------
T_Vertex(99,100,NULL,NULL,1,2001,NULL)

-- Create midCoord where doesn't exist.
select T_Segment(
p_Segment_id => 0,
p_startCoord => T_Vertex(
p_id        =>  1,
p_x         => 10,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_endCoord   => T_Vertex(
p_id        =>  3,
p_x         => 20,
p_y         =>  0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
),
p_sdo_gtype  => 2002,
p_sdo_srid   => NULL
)
.ST_UpdateCoordinate(
p_coordinate => T_Vertex(
p_x         => 99.0,
p_y         => 100.0,
p_id        => 2,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL),
p_which => '2'
)
.ST_AsText() as updatedSegment
from dual;

UPDATEDSEGMENT
------------------------------------------
SEGMENT(NULL,NULL,0,
Start(10,0,NULL,NULL,1,2001,NULL),
Mid(99,100,NULL,NULL,2,2001,NULL),
End(20,0,NULL,NULL,3,2001,NULL),
SDO_GTYPE=2002,SDO_SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - December 2006 - Original Coding for GEOM package.
Simon Greener - July 2011     - Port to T_GEOMETRY.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

21.68. T_SEGMENT/STPointToCircularArc [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_PointToCircularArc -- Return a measured point by snapping provided point to the provided circularstring
```

SYNOPSIS

```    ST_PointToCircularArc(p_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_unit   in varchar2 default null)
Return &&INSTALL_SCHEMA..T_Vertex deterministic
```

DESCRIPTION

```    This function snaps supplied point to underlying circularString, returning the snapped point.

Computes Z and M values if exist on underlying CircularString.

If input circularString is 2D, length from start of circularString to point is returned in M ordinate of snapped point.
```

NOTES

```    Supports CircularString geometries only.
```

INPUTS

```    p_vertex (t_vertex) - Point near to linestring.
p_unit   (varchar2) - Unit of measure (depends on SRID)
```

RESULT

```    snapped point (t_vetex) -- First point found on circularString.
```

EXAMPLE

```    select 'Point is on centre of the XYZ circular arc (returns start point)' as test,
t_segment(SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.3246,-1, 0,7,-1, -3,6.3246,-1)))
.ST_PointToCircularArc (
t_vertex(SDO_GEOMETRY('POINT(0 0)',NULL)),
null
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point does not have relationship with XYM CircularSring' as test,
t_segment(SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,0, 0,7,3.08, -3,6.325,6.15)))
.ST_PointToCircularArc (
t_vertex(SDO_GEOMETRY('POINT(8 8)',NULL))
).ST_AsEWKT() as project_point
from dual union all
select 'Point projects on to point half way along XY circular arc (returns measure as length)' as test,
t_segment(SDO_GEOMETRY('CIRCULARSTRING (3 6.3246, 0 7, -3 6.3246)',NULL))
.ST_PointToCircularArc (
t_vertex(SDO_GEOMETRY('POINT(0 3.5)',NULL)),
null
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point has relationship with XYM CircularSring' as test,
t_segment(SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,0, 0,7,3.08, -3,6.325,6.15)))
.ST_PointToCircularArc (
t_vertex(SDO_GEOMETRY('POINT(2 8)',NULL))
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point has relationship with XYZM circular arc' as test,
t_segment(SDO_GEOMETRY(4402,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,-2.1,0, 0,7,-2.1,3.08, -3,6.325,-2.1,6.15)))
.ST_PointToCircularArc (
t_vertex(SDO_GEOMETRY('POINT(2 8)',NULL)),
null
).ST_Round(3).ST_AsEWKT() as project_point
from dual ;

TEST                                                                                  PROJECT_POINT
------------------------------------------------------------------------------------- -----------------------------
Point is on centre of the XYZ circular arc (returns start point)                      POINTZ (3 6.325 -1)
Point does not have relationship with XYM CircularSring                               NULL
Point projects on to point half way along XY circular arc (returns measure as length) POINTM (0 7 3.1)
Point has relationship with XYM CircularSring                                         POINTM (1.698 6.791 1.374)
Point has relationship with XYZM circular arc                                         POINTZM (1.698 6.791 -2.1 1.374)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2008-2019 by TheSpatialDBAdvisor/Simon Greener
```

21.69. T_SEGMENT/STPointToLineString [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

```    ST_PointToLineString -- Return a measured point by snapping provided point to the underlying LineString
```

SYNOPSIS

```    ST_PointToLineString(p_vertex in &&INSTALL_SCHEMA..T_Vertex)
Return &&INSTALL_SCHEMA..T_Vertex deterministic
```

DESCRIPTION

```    This function snaps supplied point to underlying LineString, returning the snapped point.

Computes Z and M values if exist on underlying LineString.

If input circularString is 2D, length from start of LineString to point is returned in M ordinate of snapped point.
```

NOTES

```    Supports LineString geometries only.
```

INPUTS

```    p_vertex (t_vertex) - Point near to linestring.
```

RESULT

```    snapped point (t_vetex) -- First point found on LineString.
```

EXAMPLE

```    select 'Point is on centre of the XYZ circular arc (returns start point)' as test,
t_segment(SDO_GEOMETRY(3002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.3246,-1, 0,7,-1, -3,6.3246,-1)))
.ST_PointToLineString (
t_vertex(SDO_GEOMETRY('POINT(0 0)',NULL)),
null
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point does not have relationship with XYM LineString' as test,
t_segment(SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,0, 0,7,3.08, -3,6.325,6.15)))
.ST_PointToLineString (
t_vertex(SDO_GEOMETRY('POINT(8 8)',NULL))
).ST_AsEWKT() as project_point
from dual union all
select 'Point projects on to point half way along XY circular arc (returns measure as length)' as test,
t_segment(SDO_GEOMETRY('CIRCULARSTRING (3 6.3246, 0 7, -3 6.3246)',NULL))
.ST_PointToLineString (
t_vertex(SDO_GEOMETRY('POINT(0 3.5)',NULL)),
null
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point has relationship with XYM LineString' as test,
t_segment(SDO_GEOMETRY(3302,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,0, 0,7,3.08, -3,6.325,6.15)))
.ST_PointToLineString (
t_vertex(SDO_GEOMETRY('POINT(2 8)',NULL))
).ST_Round(3,3,3,3).ST_AsEWKT() as project_point
from dual union all
select 'Point has relationship with XYZM circular arc' as test,
t_segment(SDO_GEOMETRY(4402,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,2),SDO_ORDINATE_ARRAY(3,6.325,-2.1,0, 0,7,-2.1,3.08, -3,6.325,-2.1,6.15)))
.ST_PointToLineString (
t_vertex(SDO_GEOMETRY('POINT(2 8)',NULL)),
null
).ST_Round(3).ST_AsEWKT() as project_point
from dual ;

TEST                                                                                  PROJECT_POINT
------------------------------------------------------------------------------------- -----------------------------
Point is on centre of the XYZ circular arc (returns start point)                      POINTZ (3 6.325 -1)
Point does not have relationship with XYM CircularSring                               NULL
Point projects on to point half way along XY circular arc (returns measure as length) POINTM (0 7 3.1)
Point has relationship with XYM CircularSring                                         POINTM (1.698 6.791 1.374)
Point has relationship with XYZM circular arc                                         POINTZM (1.698 6.791 -2.1 1.374)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2008-2019 by TheSpatialDBAdvisor/Simon Greener
```

22. OBJECT TYPE/T_TOKEN [ Types ]

[ Top ] [ Types ]

NAME

```    T_TOKEN -- Object type representing a single cell in a matrix of non-overlapping (no gaps) cells.
```

DESCRIPTION

```    An object type that represents a single cell within an array of
optimized rectanges representing a grid or matrix of "raster" style objects.
Used mainly with T_TOKENs in PIPELINED T_GEOMETRY methods.
```

NOTES

```    No methods are declared on this type.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2005 - Original coding.
Simon Greener - Jan 2013 - Port from GEOM Package.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

22.1. T_TOKEN/ATTRIBUTES(T_TOKEN) [ Variables ]

[ Top ] [ T_TOKEN ] [ Variables ]

ATTRIBUTES

```    id        -- unique identifier associated with token: starts from 1 for first token extracted through to max for last.
token     -- The actual token.
separator -- The trailing separator that was immediately after the token in the string.
```

SOURCE

```  id        integer,
token     varchar2(30000),
separator varchar2(30000)
```

23. OBJECT TYPE/T_VECTOR3D [ Types ]

[ Top ] [ Types ]

NAME

```    T_VECTOR3D -- Object type representing a mathematical segment
```

DESCRIPTION

```    An object type that represents a single mathematical segment.
Includes methods on segments.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2015 - Original coding.
```

```    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    AddV -- Constructs segment as segment sum of SELF and v1 parameter.
```

SYNOPSIS

```   Member Function AddV(v1 in &&INSTALL_SCHEMA..T_VECTOR3D)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.2. T_VECTOR3D/Angle [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Angle -- Returns the angle in radians between this segment and the segment parameter; the return value is constrained to the range [0-PI].
```

SYNOPSIS

```    Member Function Angle(v1 in &&INSTALL_SCHEMA..T_VECTOR3D)
Return Number Deterministic,
```

PARAMETERS

```    v1 (T_Vector3D) - Second segment
RETURNS
The angle in radians in the range [0-PI]
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.3. T_VECTOR3D/AsSdoGeometry [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    AsSdoGeometry -- Creates an SDO_GEOMETRY equivalent of T_VECTOR3D.
```

SYNOPSIS

```    Member Function AsSdoGeometry(p_srid in integer default null)
Return mdsys.sdo_geometry Deterministic
```

PARAMETERS

```    p_srid (integer) - Value for sdo_geometry.sdo_srid.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.4. T_VECTOR3D/AsText [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    AsText -- Creates an textual representation of a T_VECTOR3D object.
```

SYNOPSIS

```    Member Function AsText(p_round IN integer DEFAULT 9)
Return Varchar2 Deterministic,
```

PARAMETERS

```    p_round (integer) -- Value for use in ROUND to compare XYZ values.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.5. T_VECTOR3D/ATTRIBUTES(T_VECTOR3D) [ Variables ]

[ Top ] [ T_VECTOR3D ] [ Variables ]

ATTRIBUTES

```   x -- X Ordinate
y -- Y Ordinate
z -- Z Ordinate
```

SOURCE

```   x number,
y number,
z number,
```

23.6. T_VECTOR3D/CONSTRUCTORS(T_VECTOR3D) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    A collection of T_VECTOR3D Constructors.
```

SOURCE

```  Constructor Function T_VECTOR3D( SELF      IN OUT NOCOPY T_VECTOR3D,
p_SEGMENT IN &&INSTALL_SCHEMA..T_SEGMENT)
Return Self As Result,

Constructor Function T_VECTOR3D( SELF      IN OUT NOCOPY T_VECTOR3D,
p_SEGMENT IN &&INSTALL_SCHEMA..T_VECTOR3D)
Return Self As Result,

Constructor Function T_VECTOR3D( SELF     IN OUT NOCOPY T_VECTOR3D,
p_vertex IN &&INSTALL_SCHEMA..T_Vertex)
Return Self As Result,

Constructor Function T_VECTOR3D( SELF           IN OUT NOCOPY T_VECTOR3D,
p_start_vertex IN &&INSTALL_SCHEMA..T_Vertex,
p_end_vertex   IN &&INSTALL_SCHEMA..T_Vertex)
Return Self As Result,
```

23.7. T_VECTOR3D/Cross [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Cross -- Creates a new segment that is the segment cross product of segments SELF and v1.
```

SYNOPSIS

```    Member Function Cross(v1 in &&INSTALL_SCHEMA..T_VECTOR3D)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    v1 (T_Vector3D) - Second segment
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.8. T_VECTOR3D/Distance(t_vector3d) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Distance -- Returns the distance between this T_VECTOR3D the specified point.
```

SYNOPSIS

```    Member Function Distance(p_point in &&INSTALL_SCHEMA..T_VECTOR3D)
Return Number Deterministic,
```

PARAMETERS

```    p_point (T_Vector3D) - The point.
RETURNS
The distance between the segment and p_point.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.9. T_VECTOR3D/Distance(t_vertex) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Distance -- Returns the distance between this T_VECTOR3D the specified point.
```

SYNOPSIS

```    Member Function Distance(p_point in &&INSTALL_SCHEMA..T_Vertex )
Return Number Deterministic,
```

PARAMETERS

```    v1 (T_Vector3D) - Second segment
RETURNS
The distance between the segment and p_point.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.10. T_VECTOR3D/DistanceSquared(T_Vector3D) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    DistanceSquared -- Returns the square of the distance between the specified points.
```

SYNOPSIS

```    Member Function DistanceSquared(p_point in &&INSTALL_SCHEMA..T_VECTOR3D)
Return Number Deterministic,
```

PARAMETERS

```    p_point (T_Vector3D) - Point.
RETURNS
The square of the distance between the segment and point1.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.11. T_VECTOR3D/DistanceSquared(t_vertex) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    DistanceSquared -- Returns the square of the distance between the specified points.
```

SYNOPSIS

```    Member Function DistanceSquared(p_point in &&INSTALL_SCHEMA..T_Vertex)
Return Number Deterministic,
```

PARAMETERS

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.12. T_VECTOR3D/Divide [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Divide -- Returns the components of the current segment divided by the specified scalar.
```

SYNOPSIS

```    Member Function Divide(p_scalar in Number)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    p_scalar (number) - The scalar value.
RETURNS
The components of value1 divided by the p_scalar.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.13. T_VECTOR3D/Dot [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Dot -- Returns the dot product of the current segment and the provided parameter.
```

SYNOPSIS

```    Member Function Dot(v1 in &&INSTALL_SCHEMA..T_VECTOR3D)
Return Number Deterministic,
```

PARAMETERS

```    v1 (T_Vector3D) - Another segment
RETURNS
The dot product of this and v1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.14. T_VECTOR3D/Equals [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Equals -- Compares two vectors for equality (in magnitude and direction)
```

SYNOPSIS

```    Member Function Equals(p_vector3D IN T_Vector3D)
Return Integer Deterministic,
```

PARAMETERS

```    p_vector3D (t_vector3D) - Second vector for comparison with SELF (underlying)
RETURNS
True(1)/False(0) -- 1 if True, 0 if False.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.15. T_VECTOR3D/Magnitude [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Magnitude -- Returns the Magnitude of this segment.
```

SYNOPSIS

``` Member Function Magnitude
Return Number Deterministic,
RETURNS
The Magnitude of this segment
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.16. T_VECTOR3D/MagnitudeSquared [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    MagnitudeSquared -- Returns the squared Magnitude of this segment.
```

SYNOPSIS

```    Member Function MagnitudeSquared
Return Number Deterministic,
RETURNS
The squared Magnitude of this segment
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.17. T_VECTOR3D/Multiply [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Multiply -- Returns the components of the specified segment multiplied by the specified scalar.
```

SYNOPSIS

```    Member Function Multiply(p_scalar in Number)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    p_scalar (number) - The scalar value.
RETURNS
The components of the value1 multiplied by the p_scalar
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.18. T_VECTOR3D/Negate [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Negate -- Computes a segment with the same magnitude as SELF but pointing to the opposite direction.
```

SYNOPSIS

```    Member Function Negate
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
RETURNS
A segment with the same magnitude as SELF but pointing to the opposite
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.19. T_VECTOR3D/Normalize [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Normalize -- Normalizes the current segment returning a new one.
```

SYNOPSIS

```    Member Function Normalize
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.20. T_VECTOR3D/Normalize(t_vector3d) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Normalize -- Creates a new segment that is the value of this segment to the normalization of segment v1.
```

SYNOPSIS

```    Member Function Normalize(v1 in &&INSTALL_SCHEMA..T_VECTOR3D )
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    v1 (T_Vector3D) - param v1 the un-normalized segment
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.21. T_VECTOR3D/ProjectOnLine(t_segment) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    ProjectOnLine -- Computes the current segment projected on p_line.
```

SYNOPSIS

```    Member Function ProjectOnLine(p_line in &&INSTALL_SCHEMA..T_SEGMENT)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    p_line (T_Segment) - Second segment
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.22. T_VECTOR3D/ProjectOnLine(t_vector t_vector) [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    ProjectOnLine -- Computes the current segment projected on the specified line.
```

SYNOPSIS

```    Member Function ProjectOnLine(pointOnLine1 in &&INSTALL_SCHEMA..T_VECTOR3D,
pointOnLine2 in &&INSTALL_SCHEMA..T_VECTOR3D)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    Second segment
pointOnLine1 (T_Vector3D) - A point on the line.
pointOnLine2 (T_Vector3D) - A point on the line.
RETURNS
Value projected on the line defined by pointOnLine1 pointOnLine2.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.23. T_VECTOR3D/Subtract [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Subtract -- Sets the value of this segment to the segment difference of itself and segment (this = this - segment).
```

SYNOPSIS

```    Member Function Subtract(v1 in &&INSTALL_SCHEMA..T_VECTOR3D)
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

PARAMETERS

```    v1 (T_Vector3D) - Second segment
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

23.24. T_VECTOR3D/Zero [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

```    Zero -- Sets all the values in this segment to zero.
```

SYNOPSIS

```    Member Function zero
Return &&INSTALL_SCHEMA..T_VECTOR3D Deterministic,
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - January 2011 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24. OBJECT TYPE/T_VERTEX [ Types ]

[ Top ] [ Types ]

NAME

```    T_VERTEX -- Represents a single coordinate object with variable ordinate dimensions.
```

DESCRIPTION

```    An object type that represents a single vertex/coordinate of a geometry object.
Includes Methods on that type.
NOTE
T_Vertex is provided for two reasons:
1. The mdsys constructor for MDSYS.VERTEX_TYPE has changed with each version, making code stability an issue.
2. This object allows for the provision of specific methods on a single vertex.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.1. T_VERTEX/ATTRIBUTES(T_VERTEX) [ Variables ]

[ Top ] [ T_VERTEX ] [ Variables ]

ATTRIBUTES

```    X         -- X Ordinate
Y         -- Y Ordinate
Z         -- Z Ordinate
W         -- W Ordinate (Normally Measure)
ID        -- Identifier
sdo_gtype -- Geometry Type of Vertex
sdo_srid  -- Spatial Reference ID of Vertex
deleted   -- Flag for use in collections like varrays or T_Vertices
```

SOURCE

```  x         number,
y         number,
z         number,
w         number,
id        integer,
sdo_gtype integer,
sdo_srid  integer,
deleted   integer,
```

24.2. T_VERTEX/CONSTRUCTORS(T_VERTEX) [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    A collection of T_VERTEX Constructors.
```

SOURCE

```  Constructor Function T_Vertex( SELF IN OUT NOCOPY T_Vertex)
Return Self As Result,

Constructor Function T_Vertex( SELF    IN OUT NOCOPY T_Vertex,
p_vertex In &&INSTALL_SCHEMA..T_vertex )
Return Self As Result,

Constructor Function T_Vertex( SELF    IN OUT NOCOPY T_Vertex,
p_point in mdsys.sdo_geometry )
Return Self As Result,

/*  EXAMPLE
*    SELECT t.id,
*           TRIM(BOTH ' ' FROM t.token) as token,
*           T_VERTEX(p_coord_string => TRIM(BOTH ' ' FROM t.token),
*                    p_id           => t.id,
*                    p_sdo_srid     => null)
*             .ST_AsText() as vertex
*      FROM table(tools.tokenizer('1.1 -2.1 3.47, 10 0 2,10 5 3,10 10 4,5 10 5,5 5 6',',')) t
*    ORDER BY t.id;
*
*    ID TOKEN         VERTEX
*    -- ------------- ----------------------------------------------------------
*     1 1.1 -2.1 3.47 T_Vertex(X=1.1,Y=-2.1,Z=3.47,W=0.0,ID=1,GT=3001,SRID=NULL)
*     2 10 0 2        T_Vertex(X=10.0,Y=0.0,Z=2.0,W=0.0,ID=2,GT=3001,SRID=NULL)
*     3 10 5 3        T_Vertex(X=10.0,Y=5.0,Z=3.0,W=0.0,ID=3,GT=3001,SRID=NULL)
*     4 10 10 4       T_Vertex(X=10.0,Y=10.0,Z=4.0,W=0.0,ID=4,GT=3001,SRID=NULL)
*     5 5 10 5        T_Vertex(X=5.0,Y=10.0,Z=5.0,W=0.0,ID=5,GT=3001,SRID=NULL)
*     6 5 5 6         T_Vertex(X=5.0,Y=5.0,Z=6.0,W=0.0,ID=6,GT=3001,SRID=NULL)
*
*     6 rows selected
*
*    SELECT t.id,
*             TRIM(BOTH ' ' FROM t.token) as token,
*             T_VERTEX(TRIM(BOTH ' ' FROM t.token),
*                      t.id,
*                      null)
*               .ST_AsText() as vertex
*        FROM table(tools.tokenizer(
*                     '1.1 -2.1 3.47 1.0,10 0 2 2.1,10 5 3 3,10 10 4 4.1,5 10 5 5.1,5 5 6 6.1',',')) t
*      ORDER BY t.id;
*
*            ID TOKEN             VERTEX
*    ---------- ----------------- ------------------------------------------------------------
*             1 1.1 -2.1 3.47 1.0 T_Vertex(X=1.1,Y=-2.1,Z=3.47,W=1.0,ID=1,GT=4401,SRID=NULL)
*             2 10 0 2 2.1        T_Vertex(X=10.0,Y=0.0,Z=2.0,W=2.1,ID=2,GT=4401,SRID=NULL)
*             3 10 5 3 3          T_Vertex(X=10.0,Y=5.0,Z=3.0,W=3.0,ID=3,GT=4401,SRID=NULL)
*             4 10 10 4 4.1       T_Vertex(X=10.0,Y=10.0,Z=4.0,W=4.1,ID=4,GT=4401,SRID=NULL)
*             5 5 10 5 5.1        T_Vertex(X=5.0,Y=10.0,Z=5.0,W=5.1,ID=5,GT=4401,SRID=NULL)
*             6 5 5 6 6.1         T_Vertex(X=5.0,Y=5.0,Z=6.0,W=6.1,ID=6,GT=4401,SRID=NULL)
*
*     6 rows selected
*/
Constructor Function T_Vertex( SELF           IN OUT NOCOPY T_Vertex,
p_coord_string in varchar2,
p_id           in integer default 1,
p_sdo_srid     in integer default null)
Return Self as result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_id        in integer,
p_sdo_gtype in integer default 2001,
p_sdo_srid  in integer default NULL)
Return Self as result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_x         In number,
p_y         In number)
Return Self As Result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_x         In number,
p_y         In number,
p_id        In integer,
p_sdo_gtype in integer,
p_sdo_srid  in integer)
Return Self As Result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_x         In number,
p_y         In number,
p_z         In number,
p_id        In integer,
p_sdo_gtype in integer,
p_sdo_srid  in integer)
Return Self As Result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_x         In number,
p_y         In number,
p_z         In number,
p_w         In number,
p_id        In integer,
p_sdo_gtype in integer,
p_sdo_srid  in integer)
Return Self As Result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_vertex    In mdsys.vertex_type,
p_sdo_gtype in integer default 2001,
p_sdo_srid  in integer default null)
Return Self As Result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_vertex    In mdsys.vertex_type,
p_id        In integer,
p_sdo_gtype in integer default 2001,
p_sdo_srid  in integer default null)
Return Self As Result,

Constructor Function T_Vertex( SELF        IN OUT NOCOPY T_Vertex,
p_point     in mdsys.sdo_point_type,
p_sdo_gtype in integer default 2001,
p_sdo_srid  in integer default null)
Return Self as result,
```

24.3. T_VERTEX/INSPECTORS(T_VERTEX) [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    A collection of T_VERTEX variable inspectors.
```

DESCRIPTION

```    ST_X, ST_Y, ST_Z, ST_W return the relevant (z,y,z,w) underlying ordinate property values.
ST_ID returns the value given to the ID property.
ST_SRID returns the value given to the sdo_srid property.
ST_Sdo_Gtype returns the value given to the sdo_gtype property (see also ST_Dims()).
```

SOURCE

```  Member Function ST_X          Return Number  Deterministic,
Member Function ST_Y          Return Number  Deterministic,
Member Function ST_Z          Return Number  Deterministic,
Member Function ST_W          Return Number  Deterministic,
Member Function ST_M          Return Number  Deterministic,
Member Function ST_ID         Return integer Deterministic,
Member Function ST_SRID       Return integer Deterministic,
Member Function ST_SDO_GTYPE  Return integer Deterministic,
Member Function ST_IsDeleted  Return integer Deterministic,
Member Function ST_IsMeasured Return integer Deterministic,
```

24.4. T_VERTEX/OrderBy [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    OrderBy -- Implements ordering function that can be used to sort a collection of T_Vertex objects.
```

SYNOPSIS

```    Order Member Function OrderBy(p_vertex in &&INSTALL_SCHEMA..T_Vertex)
Return Number deterministic
```

DESCRIPTION

```    This order by function allows a collection of T_Vertex objects to be sorted.
For example in the ORDER BY clause of a SELECT statement. Comparison uses all ordinates: X, Y, Z and W.
```

PARAMETERS

```    p_vertex (T_VERTEX) - Order pair
```

RESULT

```    order value (NUMBER) - -1 less than; 0 equal; 1 greater than
```

EXAMPLE

```    With vertices as (
select t_vertex(p_x=>dbms_random.value(0,level),
p_y=>dbms_random.value(0,level),
p_id=>1,
p_sdo_gtype=>2001,
p_sdo_srid=>null) as vertex
from dual
connect by level < 10
)
select a.vertex.st_astext(2) as vertex
from vertices a
order by a.vertex;

VERTEX
-------------------------------------------------------------
T_Vertex(X=.29,Y=1.61,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=.32,Y=1.39,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=.64,Y=.06,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=1.76,Y=2.76,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=2.06,Y=5.36,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=2.56,Y=8.99,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=3.08,Y=.63,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=4.17,Y=.57,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)
T_Vertex(X=6.55,Y=1.18,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)

9 rows selected
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.5. T_VERTEX/ST_AsCoordString [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_AsCoordString -- Returns text Description of Vertex
```

SYNOPSIS

```    Member Function ST_AsCoordString(p_separator    in varchar2 Default ' ',
p_format_model in varchar2 default 'TM9')
Return Varchar2 Deterministic,
```

DESCRIPTION

```    Returns textual description of the vertex's ordinates only.
Useful for working with WKT.
If rounding of ordinates is required first use ST_Round.
```

PARAMETERS

```    p_separator    (varchar2) -- Separator between ordinates.
p_format_model (varchar2) -- Oracle Number Format Model (see documentation)
default 'TM9')
```

RESULT

```    Coordinate String (varchar2)
```

EXAMPLE

```    select T_Vertex(
sdo_geometry('POINT(0 0)',NULL)
)
.ST_AsText() as pVertex,
T_Vertex(
sdo_geometry('POINT(147.5 -42.5)',4283)
)
.ST_AsText() as gVertex
from dual;

PVERTEX                                                   GVERTEX
--------------------------------------------------------- -----------------------------------------------------------------
T_Vertex(X=0,Y=0,Z=NULL,W=NULL,ID=NULL,GT=2001,SRID=NULL) T_Vertex(X=147.5,Y=-42.5,Z=NULL,W=NULL,ID=NULL,GT=2001,SRID=4283)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.6. T_VERTEX/ST_AsText [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_AsText -- Returns text Description of Vertex
```

SYNOPSIS

```    Member Function ST_AsText(p_format_model in varchar2 default 'TM9')
Return Varchar2 Deterministic,
```

DESCRIPTION

```    Returns textual description of vertex.
If rounding of ordinates is required, first use ST_Round.
```

PARAMETERS

```    p_format_model (varchar2) -- Oracle Number Format Model (see documentation)
default 'TM9') -- was 'TM9'
```

RESULT

```    Vertex Representation (varchar2)
```

EXAMPLE

```    select T_Vertex(
sdo_geometry('POINT(0 0)',NULL)
)
.ST_AsText() as pVertex,
T_Vertex(
sdo_geometry('POINT(147.5 -42.5)',4283)
)
.ST_AsText() as gVertex
from dual;

PVERTEX                                                   GVERTEX
--------------------------------------------------------- -----------------------------------------------------------------
T_Vertex(X=0,Y=0,Z=NULL,W=NULL,ID=NULL,GT=2001,SRID=NULL) T_Vertex(X=147.5,Y=-42.5,Z=NULL,W=NULL,ID=NULL,GT=2001,SRID=4283)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.7. T_VERTEX/ST_Bearing [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Bearing -- Returns bearing from SELF to supplied T_Vertex.
```

SYNOPSIS

```    Member Function ST_Bearing(p_vertex    in &&INSTALL_SCHEMA..T_Vertex,
p_projected in integer default 1,
p_normalize in integer default 1 )
Return Number Deterministic
```

DESCRIPTION

```    This function computes a bearing from the current object point (SELF) to the supplied T_Vertex.
Result is in degrees.
Use static function TOOLS.ST_Degrees to return as a whole circle bearing.
Geodetic calculations are used if p_projected = 0, otherwise planar calculations are used.
If p_normlize is true (1), the resulting bearing is normalised to a value between 0.360.
```

PARAMETERS

```    p_vertex (T_VERTEX)   -- A Vertex to which a bearing is calculated.
p_projected (integer) -- Usually called from T_GEOMETRY with SELF.projected.
If either 1 for Projected/Planar and 0 for Geographic/Geodetic.
If NULL, TOOLS.ST_GetSridType is called.
p_normalize (integer) -- If 1 computed bearing is normalized to a value between 0..360 degrees.
```

RESULT

```    Bearing (Number) -- Bearing in Degrees.
```

EXAMPLE

```    -- Simple bearing for projected data
select round(
T_Vertex(
sdo_geometry('POINT(0 0)',NULL)
)
.ST_Bearing(
T_Vertex(
sdo_geometry('POINT(10 10)',NULL)
),
p_projected=>1,
p_normalize=>1
),8) as bearing
from dual;

BEARING
-------
45

-- Simple geodetic bearing (2D)
select  COGO.DD2DMS(
T_Vertex(
sdo_geometry('POINT(147.5 -42.5)',4283)
)
.ST_Bearing(
T_Vertex(
sdo_geometry('POINT(147.6 -42.5)',4283)
),
p_projected=>0,
p_normalize=>1
)
) as bearing
from dual;

BEARING
-------------
90°02'01.606"
```

```    ST_Degrees.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.8. T_VERTEX/ST_Dims [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Dims -- Returns number of ordinate dimensions
```

SYNOPSIS

```    Member Function ST_Dims
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (2XXX etc) and extracts coordinate dimensions.
If SDO_GTYPE is null, examines ordinates eg XY not null, Z null -> 2.
```

RESULT

```    BOOLEAN (INTEGER) -- 2 if data 2D; 3 if 3D; 4 if 4D
```

EXAMPLE

```    select t_vertex().ST_Dims() as eDims,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_z  => 0.0,
p_sdo_gtype => 3001,
p_sdo_srid  => NULL
)
.ST_Dims() as dims
from dual;

EDIMS DIMS
----- ----
2    3
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.9. T_VERTEX/ST_Distance [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Distance -- Returns distance from current vertex (SELF) to supplied T_Vertex.
```

SYNOPSIS

```    Member Function ST_Distance(p_vertex    in &&INSTALL_SCHEMA..T_Vertex,
p_tolerance in number   default 0.05,
p_unit      in varchar2 default NULL)
Return Number Deterministic
```

DESCRIPTION

```    This function computes a distance from the current object point (SELF) to the supplied T_Vertex.
Result is in the distance units of the SDO_SRID, or in p_units where supplied.
```

PARAMETERS

```    p_vertex  (T_VERTEX) - A Vertex to which a bearing is calculated.
p_tolerance (NUMBER) - sdo_tolerance for use with sdo_geom.sdo_distance.
p_unit    (VARCHAR2) - Oracle Unit of Measure eg unit=M.
```

RESULT

```    distance (Number) -- Distance in SRID unit of measure or in supplied units (p_unit)
```

EXAMPLE

```    -- Planar in Meters
select Round(
T_Vertex(
sdo_geometry('POINT(0 0)',NULL)
)
.ST_Distance(
p_vertex   => T_Vertex(
sdo_geometry('POINT(10 10)',NULL)
),
p_tolerance=> 0.05
),
3
) as distance
from dual;

DISTANCE
----------
14.142

-- Geodetic In Kilometers
select Round(
T_Vertex(
sdo_geometry('POINT(147.5 -42.5)',4283)
)
.ST_Distance(
p_Vertex   => T_Vertex(
sdo_geometry('POINT(147.6 -42.5)',4283)
),
p_tolerance=> 0.05,
p_unit     => 'unit=KM'
),
4
) as distance
from dual;

DISTANCE
----------
8.2199
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.10. T_VERTEX/ST_Equals [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Equals -- Compares current object (SELF) with supplied vertex.
```

SYNOPSIS

```    Member Function ST_Equals(p_vertex    in &&INSTALL_SCHEMA..T_Vertex,
p_dPrecision in number default 3)
Return Integer deterministic
```

DESCRIPTION

```    This function compares current object vertex (SELF) to supplied vertex (p_vertex).
If all ordinates (to supplied precision) are equal, returns True (1) else False (0).
SDO_GTYPE, SDO_SRID and ID are not compared.
```

PARAMETERS

```    p_vertex    (T_VERTEX) - Vertex that is to be compared to current object (SELF).
p_dPrecision (INTEGER) - Decimal digits of precision for all ordinates.
```

RESULT

```    BOOLEAN (INTEGER) - 1 is True (Equal); 0 is False.
```

EXAMPLE

```    select t.IntValue as precision,
T_Vertex(
p_x        => 12847447.54578,
p_y        => 4374842.3425,
p_z        => 3.2746,
p_id       => 1,
p_sdo_gtype=> 3001,
p_sdo_srid => NULL
)
.ST_Equals(
T_Vertex(
p_x        => 12847447.546,
p_y        => 4374842.34,
p_z        => 3.2746,
p_id       => 1,
p_sdo_gtype=> 3001,
p_sdo_srid => NULL
),
t.IntValue
) as vEquals
from table(TOOLS.generate_series(1,3,1)) t;

PRECISION VEQUALS
--------- -------
1       1
2       1
3       0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.11. T_VERTEX/ST_FromBearingAndDistance [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_FromBearingAndDistance -- Returns new T_Vertex given bearing and distance.
```

SYNOPSIS

```    Member Function ST_FromBearingAndDistance(p_bearing   in number,
p_distance  in number,
p_projected in integer default 1)
Return T_Vertex Deterministic
```

DESCRIPTION

```    This function computes a new T_VERTEX computed from current object point (SELF)
the supplied bearing and distance.
Geodetic calculations are used if p_projected = 0, otherwise planar calculations are used.
```

PARAMETERS

```    p_bearing    (NUMBER) -- A whole circle bearing in radians.
p_distance   (NUMBER) -- Distance expressed in Oracle Unit of Measure eg METER.
p_projected (integer) -- Usually called from T_GEOMETRY with SELF.projected.
If either 1 for Projected/Planar and 0 for Geographic/Geodetic.
If NULL, TOOLS.ST_GetSridType is called.
```

RESULT

```    vertexx (T_VERTEX) -- New vertex computed using bearing and distance from current object.
```

EXAMPLE

```    -- Planar in Meters
select T_Vertex(
sdo_geometry('POINT(0 0)',NULL)
)
.ST_FromBearingAndDistance(
p_bearing   => 45.0,
p_distance  => 14.142,
p_projected => 1
)
.ST_Round(3)
.ST_AsText() as vertex
from dual;

VERTEX
--------------------------------------------------------
T_Vertex(X=10,Y=10,Z=NULL,W=NULL,ID=1,GT=2001,SRID=NULL)

-- Geodetic with distance in meters
select T_Vertex(
sdo_geometry('POINT(147.5 -42.5)',4283)
)
.ST_FromBearingAndDistance (
p_bearing   => COGO.DMS2DD('90°02''01.606"'),
p_distance  => 8219.9,
p_projected => 0
)
.ST_Round(6)
.ST_AsText() as vertex
from dual;

VERTEX
-----------------------------------------------------------------
T_Vertex(X=147.6,Y=-42.5,Z=NULL,W=NULL,ID=NULL,GT=2001,SRID=4283)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.12. T_VERTEX/ST_HasM [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_HasM -- Tests vertex to see if coordinates include a measure.
```

SYNOPSIS

```    Member Function ST_HasM
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc) to see if sdo_gtype has measure ordinate eg 3302 not 3002.
If SDO_GTYPE is null, examines coordinates to see if W ordinate is not null.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 is measure ordinate exists, 0 otherwise.
```

EXAMPLE

```    select t_vertex().ST_hasM() as eM,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
)
.ST_hasM() as hasM2,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_z  => 0.0,
p_sdo_gtype => 3301,
p_sdo_srid  => NULL
)
.ST_hasM() as hasM3
from dual;

EM HASM2 HASM3
-- ----- -----
0     0     1
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.13. T_VERTEX/ST_hasZ [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_hasZ -- Tests vertex to see if coordinates include a Z ordinate.
```

SYNOPSIS

```    Member Function ST_hasZ
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc). If D position is 2 then vertex does not have a Z ordinate.
If D position is 3 and measure ordinate position (L) is 0 then vertex has Z ordinate.
If D position is 3 and measure ordinate position (L) is not equal to 0 then vertex does not have a Z ordinate.
If D position is 4 and measure ordinate position (L) is equal to 0 or equal to D (4) then vertex has a Z ordinate.
If D position is 4 and measure ordinate position (L) is equal to 3 then vertex does not have a Z ordinate.
If SDO_GTYPE is null, examines Z and W ordinates of the vertex's coordinates to determine if vertex has Z ordinate.
```

RESULT

```    BOOLEAN (INTEGER) -- 1 is has Z ordinate, 0 otherwise.
```

EXAMPLE

```    select t_vertex().ST_hasZ() as eZ,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
)
.ST_Dims() as dims2,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_z  => 0.0,
p_sdo_gtype => 3001,
p_sdo_srid  => NULL
)
.ST_Dims() as dims3
from dual;

EZ      DIMS2      DIMS3
---------- ---------- ----------
0          2          3
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.14. T_VERTEX/ST_isEmpty [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_isEmpty -- Checks if Vertex data exists or not.
```

SYNOPSIS

```    Member Function ST_isEmpty
Return Integer Deterministic,
```

DESCRIPTION

```    If vertex object data are not null returns 1(True) else 0 (False).
cf "POINT EMPTY" WKT
```

RESULT

```    BOOLEAN (INTEGER) -- 1 if vertex has not values; 0 if has values
```

EXAMPLE

```    select t_vertex().ST_isEmpty() as isEmpty,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
)
.ST_isEmpty() as vIsEmpty
from dual;

ISEMPTY VISEMPTY
------- --------
1        0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.15. T_VERTEX/ST_Lrs_Dim [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Lrs_Dim -- Tests vertex to see if coordinates include a measure ordinate and returns measure ordinate's position.
```

SYNOPSIS

```    Member Function ST_Lrs_Dim
Return Integer Deterministic,
```

DESCRIPTION

```    Examines SDO_GTYPE (DLNN etc) measure ordinate position (L) and returns it.
If SDO_GTYPE is null, examines coordinates to see if W ordinate is not null.
```

RESULT

```    BOOLEAN (INTEGER) -- L from DLNN.
```

EXAMPLE

```    select t_vertex().ST_LRS_Dim() as eLrsDim,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
)
.ST_LRS_Dim() as lrsDim2,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_z  => 0.0,
p_sdo_gtype => 3301,
p_sdo_srid  => NULL
)
.ST_LRS_Dim() as lrsDim3
from dual;

ELRSDIM LRSDIM2 LRSDIM3
------- ------- -------
0       0       3
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.16. T_VERTEX/ST_LRS_Set_Measure [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_LRS_Set_Measure -- Sets measure attribute, adjusts sdo_gtype.
```

SYNOPSIS

```    Member Function ST_LRS_Set_Measure(p_measure in number)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    This function sets the W or Z ordinate the the supplied measure value
depending on the dimensionality of the vertex and its LRS dimension (see ST_LRS_Dim()).
Can change dimensionality of underlying T_Vertex object for example if already 3D,
with Z, but unmeasured: result will be vertex with 4401 sdo_gtype.
```

PARAMETERS

```    p_measure (number) - New Measure value.
```

RESULT

```    vertex (T_VERTEX)
```

EXAMPLE

```    -- ST_LRS_Set_Measure
select t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
)
.ST_LRS_Set_Measure(2.1)
.ST_AsText() as new3301Vertex,
t_vertex(
p_id => 0,
p_x  => 0.0,
p_y  => 0.0,
p_z  => 0.0,
p_sdo_gtype => 3001,
p_sdo_srid  => NULL
)
.ST_LRS_Set_Measure(1.2)
.ST_AsText() as new4401Vertex
from dual;

NEW3301VERTEX                                         NEW4401VERTEX
----------------------------------------------------- --------------------------------------------------
T_Vertex(X=0,Y=0,Z=2.1,W=NULL,ID=0,GT=3301,SRID=NULL) T_Vertex(X=0,Y=0,Z=0,W=1.2,ID=0,GT=4401,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.17. T_VERTEX/ST_Round [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Round -- Rounds X,Y,Z and m(w) ordinates to passed in precision.
```

SYNOPSIS

```    Member Function ST_Round(p_dec_places_x in integer default 8,
p_dec_places_y in integer default NULL,
p_dec_places_z in integer default 3,
p_dec_places_m in integer default 3)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    Applies relevant decimal digits of precision value to ordinate.
For example:
SELF.x := ROUND(SELF.x,p_dec_places_x);
```

PARAMETERS

```    p_dec_places_x (integer) - value applied to x Ordinate.
p_dec_places_y (integer) - value applied to y Ordinate.
p_dec_places_z (integer) - value applied to z Ordinate.
p_dec_places_m (integer) - value applied to m Ordinate.
```

RESULT

```    vertex (T_VERTEX)
```

EXAMPLE

```    -- Geodetic
select T_Vertex(
p_x        => 147.5489578,
p_y        => -42.53625,
p_id       => 1,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
)
.ST_Round(6,6)
.ST_AsText() as vertex
from dual;

VERTEX
-----------------------------------------------------------------------
T_Vertex(X=147.548958,Y=-42.53625,Z=NULL,W=NULL,ID=1,GT=2001,SRID=4283)

-- Planar
select T_Vertex(
p_x        => 12847447.54578,
p_y        => 4374842.3425,
p_z        => 3.2746,
p_id       => 1,
p_sdo_gtype=> 3001,
p_sdo_srid => NULL
)
.ST_Round(3,3,2)
.ST_AsText() as vertex
from dual;

VERTEX
---------------------------------------------------------------------------
T_Vertex(X=12847447.546,Y=4374842.343,Z=3.27,W=NULL,ID=1,GT=3001,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.18. T_VERTEX/ST_SdoGeometry [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_SdoGeometry -- Returns Vertex as a suitably encoded MDSYS.SDO_GEOMETRY object.
```

SYNOPSIS

```    Member Function ST_SdoGeometry
Return MDSYS.SDO_GEOMETRY Deterministic,
```

DESCRIPTION

```    The encoding of the returned SDO_GEOMETRY object depends on the dimension of the vertex
supplied using p_dims or SELF.ST_Dims() if p_dims is null.
This can be best seen in the source code from T_Vertex Type Body at the end of this documentation.
```

PARAMETERS

```    p_dims in integer default null - A dimension value that will override SELF.ST_Dims() eg return 2D from a 3D vertex.
```

RESULT

```    point (MDSYS.SDO_GEOMETRY) -- Type of Point geometry depends on what the vertex represents.
```

EXAMPLE

```    select T_Vertex(
p_x        => 147.5489578,
p_y        => -42.53625,
p_id       => 1,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
)
.ST_Round(6,6)
.ST_SdoGeometry() as geom
from dual;

GEOM
---------------------------------------------------------------------------
SDO_GEOMETRY(2001,4283,SDO_POINT_TYPE(147.548958,-42.53625,NULL),NULL,NULL)

select T_Vertex(
p_x        => 12847447.54578,
p_y        => 4374842.3425,
p_z        => 3.2746,
p_id       => 1,
p_sdo_gtype=> 3001,
p_sdo_srid => NULL
)
.ST_Round(3,3,2)
.ST_SdoGeometry() as geom
from dual;

GEOM
-------------------------------------------------------------------------------
SDO_GEOMETRY(3001,NULL,SDO_POINT_TYPE(12847447.546,4374842.343,3.27),NULL,NULL)

select T_Vertex(
p_x        => 12847447.54578,
p_y        => 4374842.3425,
p_z        => 3.2746,
p_w        => 0.002,
p_id       => 1,
p_sdo_gtype=> 4401,
p_sdo_srid => NULL
)
.ST_Round(3,3,2)
.ST_SdoGeometry() as geom
from dual;

GEOM
---------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(4401,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(12847447.546,4374842.343,3.27,0.002))
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

SOURCE

```  --   v_dims integer := NVL(p_dims,SELF.ST_Dims());
-- Begin
--   If ( SELF.sdo_gtype is null ) Then
--      Return null;
--   ElsIf ( SELF.sdo_gtype = 2001 or v_dims = 2) Then
--      Return mdsys.sdo_geometry(SELF.sdo_gtype,SELF.sdo_SRID,mdsys.sdo_point_type(self.x,self.y,NULL),null,null);
--   ElsIf ( v_dims = 3 ) Then
--      -- 3001, 3301, 4001, 4301 and 4401 all stop with Z. GetVertices places M in 4401 in Z spot not W
--      Return mdsys.sdo_geometry(SELF.sdo_gtype,SELF.sdo_SRID,mdsys.sdo_point_type(self.x,self.y,self.z),null,null);
--   ElsIf ( v_dims = 4 ) Then
--      If ( SELF.ST_Dims() = 3 ) Then
--         Return mdsys.sdo_geometry(SELF.sdo_gtype,SELF.sdo_SRID,mdsys.sdo_point_type(self.x,self.y,self.z),null,null);
--      Else
--         Return mdsys.sdo_geometry(SELF.sdo_gtype,SELF.sdo_SRID,NULL,mdsys.sdo_elem_info_array(1,1,1),mdsys.sdo_ordinate_array(self.x,self.y,self.z,self.w));
--      End If;
--   End If;
```

24.19. T_VERTEX/ST_SdoPointType [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_SdoPointType -- Returns vertex X,Y and Z ordinates as a MDSYS.SDO_POINT_TYPE object.
```

SYNOPSIS

```    Member Function ST_SdoPointType
Return MDSYS.SDO_POINT_TYPE Deterministic,
```

DESCRIPTION

```    Constructs a MDSYS.SDO_POINT_TYPE object from the X, Y and Z ordinate variables of the type and returns it.
If Vertex is 2D Z value will be NULL; if vertex dimension is > 3 only the X Y and Z ordinates are returned.
```

RESULT

```    vertex (MDSYS.SDO_POINT_TYPE) -- eg MDSYS.SDO_POINT_TYPE(SELF.ST_X,SELF.ST_Y,SELF.ST_Z);
```

EXAMPLE

```    -- ST_ToVertexType
select t_vertex(
p_id        => 0,
p_x         => 1.0,
p_y         => 2.0,
p_z         => 3.0,
p_w         => 4.0,
p_sdo_gtype => 4401,
p_sdo_srid  => NULL
).ST_SdoPointType()  as sdo_point_type
from dual;

SDO_POINT_TYPE
---------------------------
MDSYS.SDO_POINT_TYPE(1,2,3)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.20. T_VERTEX/ST_Self [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_Self -- Handy method for use with TABLE(T_Vertices) to return element as T_Vertex object.
```

SYNOPSIS

```    Member Function ST_Self
Return T_Vertex Deterministic,
```

DESCRIPTION

```    When extracting vertices from a geometry into T_Vertex objects via a TABLE function call to T_GEOMETRY.T_Vertices()
it is handy to have a method which allows access to the resulting T_VERTEX row as a single object.
In a sense this method allows access similar to t.COLUMN_VALUE for atmoic datatype access from TABLE functions.
```

RESULT

```    vertex (T_VERTEX) -- A single T_Vertex object.
```

EXAMPLE

```    set serveroutput on
BEGIN
FOR rec IN (select v.id, v.ST_Self() as vertex
from table(t_geometry(
SDO_GEOMETRY(2002,28355,NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(252282.861,5526962.496,252282.861,5526882.82, 252315.91,5526905.639, 252287.189,5526942.228)) )
.ST_Vertices()) v
)
LOOP
dbms_output.put_line(rec.id || ' => ' || rec.vertex.ST_AsText());
END LOOP;
END;
/
anonymous block completed
1 => T_Vertex(X=252282.9,Y=5526962.5,Z=NULL,W=NULL,ID=1,GT=2001,SRID=28355)
2 => T_Vertex(X=252282.9,Y=5526882.8,Z=NULL,W=NULL,ID=2,GT=2001,SRID=28355)
3 => T_Vertex(X=252315.9,Y=5526905.6,Z=NULL,W=NULL,ID=3,GT=2001,SRID=28355)
4 => T_Vertex(X=252287.2,Y=5526942.2,Z=NULL,W=NULL,ID=4,GT=2001,SRID=28355)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - September 2018 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.21. T_VERTEX/ST_SetCoordinate [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_SetCoordinate -- Is a procedure that sets a vertex's X,Y,Z and W(M) ordinates to passed in values
```

SYNOPSIS

```    Member Procedure ST_SetCoordinate(
SELF  IN OUT NOCOPY T_Vertex,
p_x in number default 8,
p_y in number default NULL,
p_z in number default 3,
p_w in number default 3)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    Assigns supplied values to t_vertex's x,y,z,w ordinates.
```

EXAMPLE

```      SELF.x := ROUND(SELF.x,p_dec_places_x);
```

PARAMETERS

```    p_x (number) - value assigned to x Ordinate.
p_y (number) - value assigned to y Ordinate.
p_z (number) - value assigned to z Ordinate.
p_w (number) - value assigned to w Ordinate.
```

EXAMPLE

```    set serveroutput on size unlimited
declare
v_vertex &&INSTALL_SCHEMA..t_vertex;
begin
v_vertex := &&INSTALL_SCHEMA..T_Vertex(
p_x        => 147.5489578,
p_y        => -42.53625,
p_id       => 1,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
);
v_vertex.ST_SetCoordinate(p_x => 148, p_y => -43);
dbms_output.put_line(v_vertex.ST_AsEWKT());
END;
/

SRID=4283;POINT (148 -43)
PL/SQL procedure successfully completed.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.22. T_VERTEX/ST_SubtendedAngle [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_SubtendedAngle -- Returns angle subtended by p_start_vertex/SELF/p_end_vertex
```

SYNOPSIS

```    Member Function ST_SubtendedAngle(p_start_vertex in &&INSTALL_SCHEMA..T_Vertex,
p_end_vertex   in &&INSTALL_SCHEMA..T_Vertex)
Return Number deterministic
```

DESCRIPTION

```    This function computes the angle subtended by the three points:
p_start_vertex ---> SELF ---> p_end_vertex
```

PARAMETERS

```    p_start_vertex (T_VERTEX) -- Vertex that defines first point in angle.
p_end_vertex   (T_VERTEX) -- Vertex that defines last  point in angle.
p_projected     (integer) -- Usually called from T_GEOMETRY with SELF.projected.
If either 1 for Projected/Planar and 0 for Geographic/Geodetic.
If NULL, TOOLS.ST_GetSridType is called.
```

RESULT

```    angle (NUMBER) - Subtended angle in radians.
```

EXAMPLE

```    -- Planar in Meters
select Round(
COGO.ST_Degrees(
T_Vertex(
p_id => 1,
p_x  => 0,
p_y  => 0,
p_sdo_gtype=> 2001,
p_sdo_srid => NULL
)
.ST_SubtendedAngle(
T_Vertex(
p_id => 2,
p_x  => 10,
p_y  => 0,
p_sdo_gtype=> 2001,
p_sdo_srid => NULL
),
T_Vertex(
p_id => 3,
p_x  => 10,
p_y  => 10,
p_sdo_gtype=> 2001,
p_sdo_srid => NULL
)
)
),8) as sAngle
from dual;

SANGLE
------
45

-- Geodetic
select COGO.DD2DMS(
COGO.ST_Degrees(
T_Vertex(
p_id => 1,
p_x  => 147.5,
p_y  => -42.5,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
)
.ST_SubtendedAngle(
T_Vertex(
p_id => 2,
p_x  => 147.3,
p_y  => -41.5,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
),
T_Vertex(
p_id => 3,
p_x  => 147.8,
p_y  => -41.1,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
)
)
)
) as sAngle
from dual;

SANGLE
--------------
336°35'43.118"
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.23. T_VERTEX/ST_To2D [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_To2D -- Removes and Z or measured attributes, adjusts sdo_gtype.
```

SYNOPSIS

```    Member Function ST_To2D
Return T_Vertex Deterministic,
```

DESCRIPTION

```    Changes dimensionality of underlying T_Vertex object.
If Vertex is 2D the vertex is returned unchanged.
If the Vertex is 3D or 4D, any Z or W (measure) will be removed; sdo_gtype is set to 2001.
```

RESULT

```    vertex (T_VERTEX)
```

EXAMPLE

```    -- ST_To2D
select t_vertex(
p_id => 0,
p_x  => 1.0,
p_y  => 2.0,
p_z  => 3.0,
p_w  => 4.0,
p_sdo_gtype => 4401,
p_sdo_srid  => NULL
)
.ST_To2D()
.ST_AsText() as Vertex2D
from dual;

VERTEX2D
------------------------------------------------------
T_Vertex(X=1,Y=2,Z=NULL,W=NULL,ID=0,GT=2001,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.24. T_VERTEX/ST_To3D [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_To3D -- Adds Z attribute, adjusts sdo_gtype.
```

SYNOPSIS

```    Member Function ST_To3D(p_keep_measure in integer,
p_default_z    in number)
Return T_Vertex Deterministic,
```

DESCRIPTION

```    Changes dimensionality of underlying T_Vertex object.
If Vertex is 3D the vertex is returned unchanged unless the vertex is additionally measured
and p_keep_measure = 1. In that case, the Z ordinate will be set to the W (measure) value
and the W (measure) value set to NULL.
If Vertex is 2D the vertex is changed to 3D and the Z ordinate set to p_default_z.
If the Vertex is 4D, any W (measure) is removed unless p_keep_measure is set to 1;
If p_keep_measure is 1, the W value is copied to the Z ordinate and the W ordinate set to null.
The sdo_gtype of the returned vertex is always 3001.
```

PARAMETERS

```    p_keep_measure (integer) - If vertex has a measure value, this parameter instructs the function to keep it.
p_default_z    (number)  - If a Z value has to be created (eg in case of 2D vertex being converted to 3D),
this parameter holds the new value for that ordinate.
```

RESULT

```    vertex (T_VERTEX)
```

EXAMPLE

```    -- ST_To3D
With Data as (
select t_vertex(
p_id        => 0,
p_x         => 1.0,
p_y         => 2.0,
p_sdo_gtype => 2001,
p_sdo_srid  => NULL
)  as Vertex2D
from dual
)
select a.vertex2D
.ST_To3D(p_keep_measure => 0,
p_default_z    => 3.0)
.ST_LRS_Set_Measure(4.0)
.ST_AsText() as vertex3
from data a;

VERTEX3
------------------------------------------------
T_Vertex(X=1,Y=2,Z=3,W=4,ID=0,GT=4401,SRID=NULL)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.25. T_VERTEX/ST_VertexType [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_VertexType -- Returns vertex ordinates as a MDSYS.VERTEX_TYPE object.
```

SYNOPSIS

```    Member Function ST_VertexType
Return MDSYS.VERTEX_TYPE Deterministic,
```

DESCRIPTION

```    Constructs a MDSYS.VERTEX_TYPE object from the ordinate variables of the type and returns it.
```

RESULT

```    vertex (MDSYS.VERTEX_TYPE) -- eg MDSYS.VERTEX_TYPE(x=>SELF.ST_X,y=>SELF.ST_Y,z=>SELF.ST_Z,w=>SELF.ST_W,id=>SELF.ST_Id);
```

EXAMPLE

```    -- ST_ToVertexType
select t_vertex(
p_id        => 0,
p_x         => 1.0,
p_y         => 2.0,
p_z         => 3.0,
p_w         => 4.0,
p_sdo_gtype => 4401,
p_sdo_srid  => NULL
).ST_VertexType()  as VertexType
from dual;

VERTEXTYPE
---------------------------------------------------------------
MDSYS.VERTEX_TYPE(1,2,3,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0)
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

24.26. T_VERTEX/ST_WithinTolerance [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

```    ST_WithinTolerance -- Discovers whether supplied vertex is within tolerance of current object vertex (SELF).
```

SYNOPSIS

```    Member Function ST_WithinTolerance(p_vertex    in &&INSTALL_SCHEMA..T_Vertex,
p_tolerance in number default 0.005)
Return Integer deterministic
```

DESCRIPTION

```    This function calculates distance from current object vertex (SELF) to supplied vertex (p_vertex)
If distance <= supplied tolerance the function returns 1 (true) otherwise 0 (false).
p_start_vertex ---> SELF ---> p_end_vertex
```

PARAMETERS

```    p_vertex  (T_VERTEX) - Vertex that is to be compared to current object (SELF).
p_tolerance (NUMBER) - sdo_tolerance for use with sdo_geom.sdo_distance.
```

RESULT

```    BOOLEAN (INTEGER) - 1 is True; 0 is False.
```

EXAMPLE

```    -- Geodetic
set serveroutput on size unlimited
With Data as (
select T_Vertex(
p_x        => 147.5,
p_y        => -42.5,
p_id       => 1,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
) as vertex_1,
T_Vertex(
p_x        => 147.5,
p_y        => -42.5000003,
p_id       => 2,
p_sdo_gtype=> 2001,
p_sdo_srid => 4283
) as vertex_2
from dual
)
select a.vertex_1
.ST_Distance(
p_vertex    => new T_Vertex(a.vertex_2),
p_tolerance => 0.005,
p_unit      => 'unit=M'
) as Distance,
case when t.InTValue = 0 then 0.5 else 0.005 end as tolerance,
a.vertex_1
.ST_WithinTolerance(
p_vertex    => new T_Vertex(a.vertex_2),
p_tolerance => case when t.InTValue = 0 then 0.5 else 0.005 end,
p_projected => 0
) as withinTolerance
from data a,
table(TOOLS.generate_series(0,1,1)) t;

DISTANCE  TOLERANCE WITHINTOLERANCE
---------- ---------- ---------------
.0333585156         .5               1
.0333585156       .005               0
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - Jan 2013 - Original coding.
```

```    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
```

25. OBJECT TYPE/T_VERTEXLIST [ Types ]

[ Top ] [ Types ]

NAME

```    T_VERTEXLIST -- Object type representing a collection of T_VERTICES
```

DESCRIPTION

```    An object type that represents an array/collection of T_VERTICES.
Includes Methods on that type.
```

NOTES

```    This also implements JTS's OffsetSegmentString.java.
A dynamic list of the vertices in a constructed offset curve.
Automatically removes adjacent vertices which are closer than a given tolerance.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Martin Davis  - 2016 - Java coding.
Simon Greener - Jul 2019 - extended T_Vertices to include methods derived from OffsetSegmentString.java
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_VERTEXLIST ] [ Methods ]

NAME

```    addOrdinates -- Allows an sdo_ordinate_array to be directly added to the underlying list.
```

SYNOPSIS

```    Member Procedure addOrdinates(
SELF        IN OUT NOCOPY T_VERTEXLIST,
p_dim       in integer,
p_lrs_dim   in integer,
p_ordinates in mdsys.sdo_ordinate_array ),
```

DESCRIPTION

```    This procedure allows for an sdo_ordinate_array to be directly added to the underlying list.
XYZM ordinates are all supported.
All vertices created adopt the SRID of the VertexList's first vertex.
Coordinate dimensionality and lrs dim should be same as underling VertexList.
```

ARGUMENTS

```    p_dim                  (integer) -- The coordinate dimension used to interpret the numbers in the sdo_ordinate_array.
p_lrs_dim              (integer) -- The dimension for the LRS ordiante.
p_ordinates (sdo_ordinate_array) -- The sdo_ordinate_array to be added to the vertex list.
```

EXAMPLE

```    -- Add sdo_ordinate_array to existing vertex list.
set serveroutput on size unlimited
declare
v_vList    t_vertexlist;
v_vertices &&INSTALL_SCHEMA..T_Vertices;
v_tgeom    t_geometry;
begin
v_vList    := T_VERTEXLIST(p_segment => &&INSTALL_SCHEMA..T_SEGMENT(p_line=>sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,1))));
dbms_output.put_line('Before v_vList.count=' || v_vList.vertexList.count);
p_dim     => 2,
p_lrs_dim => 0,
p_ordinates => sdo_ordinate_array(1,1,2,2,3,3)
);
dbms_output.put_line('After v_VList.count=' || v_vList.vertexList.count);
end;
/
show errors

Before v_vList.count=2
After v_VList.count=5

PL/SQL procedure successfully completed.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - August 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

[ Top ] [ T_VERTEXLIST ] [ Methods ]

NAME

```    addVertices -- Enables a collection of vertices to be added to the underlying list.
```

SYNOPSIS

```    Member Procedure addVertices(SELF       IN OUT NOCOPY &&INSTALL_SCHEMA..T_VERTEXLIST,
p_vertices in &&INSTALL_SCHEMA..T_Vertices,
isForward  in ineger default 1)
```

DESCRIPTION

```    This procedure allows for a collection of T_VERTEX objects to be added to the underlying list.
XYZM ordinates are all supported.
isForward is 1, the two vertex lists are merged with no tests are carried out to see if first vertex in list to be added is same as end vertex in underlying list.
However, when isForward is 2 the lists are merged with a test for duplicate coordinates.
If isForward is 2, p_vertices is reversed before appending with a duplicate test carried out.
```

ARGUMENTS

```    p_vertices (&&INSTALL_SCHEMA..T_Vertices) -- Collection of t_vertex object to add.
isForward           (boolean) -- Flag indicating whether vertices should be added in reverse order.
```

EXAMPLE

```    -- Add vertices of two linestrings with no test for duplicates
set serveroutput on size unlimited
declare
v_vList    t_vertexlist;
v_vertices &&INSTALL_SCHEMA..T_Vertices;
v_tgeom    t_geometry;
begin
v_vList    := T_VERTEXLIST(p_segment => &&INSTALL_SCHEMA..T_SEGMENT(p_line=>sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,1))));
dbms_output.put_line('Before v_vList.count=' || v_vList.vertexList.count);
v_tgeom    := t_geometry(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,1,2,2,3,3)));
select v.ST_Self() as vertex
bulk collect into v_vertices
from table(v_tgeom.ST_Vertices()) v;
p_isForward => 1);
dbms_output.put_line('After v_VList.count=' || v_vList.vertexList.count);
end;
/
show errors

Before v_vList.count=2
After v_VList.count=5

PL/SQL procedure successfully completed.

-- Now add vertices of two linestrings testing for duplicates
set serveroutput on size unlimited
declare
v_vList    t_vertexlist;
v_vertices &&INSTALL_SCHEMA..T_Vertices;
v_tgeom    t_geometry;
begin
v_vList    := T_VERTEXLIST(p_segment => &&INSTALL_SCHEMA..T_SEGMENT(p_line=>sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,1,1))));
dbms_output.put_line('Before v_vList.count=' || v_vList.vertexList.count);
v_tgeom    := t_geometry(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,1,2,2,3,3)));
select v.ST_Self() as vertex
bulk collect into v_vertices
from table(v_tgeom.ST_Vertices()) v;
p_isForward => 2);
dbms_output.put_line('After v_VList.count=' || v_vList.vertexList.count);
end;
/
show errors

Before v_vList.count=2
After v_VList.count=4

PL/SQL procedure successfully completed.
```

AUTHOR

```    Simon Greener
```

HISTORY

```    Simon Greener - July 2019 - Original coding.
```

```    (c) 2005-2019 by TheSpatialDBAdvisor/Simon Greener
```

25.3. T_VERTEXLIST/ATTRIBUTES(T_VERTEXLIST) [ Variables ]

[ Top ] [ T_VERTEXLIST ] [ Variables ]

ATTRIBUTES

```    seglist is a table of t_segment
minimimVertexDistance is min distance between two vertices. If less then any vertex is not added.
```

SOURCE

```  vertexList            &&INSTALL_SCHEMA..T_VERTICES,
minimimVertexDistance Number,
dPrecision            integer,
```

25.4. T_VERTEXLIST/CONSTRUCTORS(T_VERTEXE) [ Methods ]

[ Top ] [ T_VERTEXLIST ] [ Methods ]

NAME

```    A collection of T_VERTEXLIST Constructors.
```

SOURCE

```  -- Useful as an "Empty" constructor.
Constructor Function T_VERTEXLIST(SELF IN OUT NOCOPY T_VERTEXLIST)
Return Self As Result,

Constructor Function T_VERTEXLIST(SELF     IN OUT NOCOPY T_VERTEXLIST,
p_vertex in &&INSTALL_SCHEMA..T_VERTEX)
Return Self As Result,

Constructor Function T_VERTEXLIST(SELF        IN OUT NOCOPY T_VERTEXLIST,
p_segment   in &&INSTALL_SCHEMA..T_SEGMENT)
Return Self As Result,

Constructor Function T_VERTEXLIST(SELF        IN OUT NOCOPY T_VERTEXLIST,
p_line      in mdsys.sdo_geometry)
Return Self As Result,
```