TABLE OF CONTENTS

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

1.1. 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
    -------------- ----------------- ----------------
    1350'0"       SE                SouthEast
    18749'33.913" N                 North
    900'0"        E                 East
    11230'0"      ESE               East-SouthEast
    1800'0"       S                 South
    3150'0"       NW                NorthWest
    6730'0"       ENE               East-NorthEast
    33730'0"      NNW               North-NorthWest
    2700'0"       W                 West
    15730'0"      SSE               South-SouthEast
    20230'0"      SSW               South-SouthWest
    29230'0"      WNW               West-NorthWest
    2250'0"       SW                SouthWest
    24730'0"      WSW               West-SouthWest
    2230'0"       NNE               North-NorthEast
    450'0"        NE                NorthEast

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - August 2018 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

1.2. 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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

1.3. 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('1551''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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

1.4. 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.

COPYRIGHT

    (c) 2012-2017 by TheSpatialDBAdvisor/Simon Greener
  LICENSE
      Creative Commons Attribution-Share Alike 2.5 Australia License.
      http://creativecommons.org/licenses/by-sa/2.5/au/

1.5. COGO/QuadrantBearing [ Functions ]

[ Top ] [ COGO ] [ Functions ]

NAME

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

SYNOPSIS

    Function QuadrantBearing(p_bearing in number,
                             p_Degree  in NChar default '')

INPUTS

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

RESULT

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

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;

    QUADRANTBEARING
    ---------------
          N15.852^E
    
    select COGO.DD2DMS(t.IntValue)          as bearing,
           COGO.QuadrantBearing(t.IntValue) as QuadrantBearing
      from table(tools.generate_series(0,315,45)) t
     order by t.IntValue asc;
    
    BEARING    QUADRANTBEARING
    ---------- ---------------
    00'0"     N
    450'0"    N45E
    900'0"    E
    1350'0"   S45E
    1800'0"   S
    2250'0"   S45W
    2700'0"   W
    3150'0"   N45W 
    
     8 rows selected 

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - August 2018 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

1.6. 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)
      Return Number deterministic

INPUTS

    p_radians (NUMBER) - Angle in radians (clockwise from north)

DESCRIPTION

    This function converts supplied radians value to whole circle bearing clockwise from 0 as North.

EXAMPLE

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

       DEGREES
    ----------
       45.2345

RESULT

    degrees (NUMBER) - 0 to 360 degrees

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2012-2013 by TheSpatialDBAdvisor/Simon Greener

1.7. COGO/ST_Radians [ Functions ]

[ 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;

       RADIANS
    ----------
       .789491

RESULT

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

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2012-2017 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.

COPYRIGHT

    (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/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.

COPYRIGHT

    (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 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 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 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 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 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 GET_MEASURE(point IN mdsys.sdo_geometry)
    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 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;

   FUNCTION TRANSLATE_MEASURE(geom_segment IN mdsys.sdo_geometry,
                              translate_m  IN NUMBER) 
     RETURN mdsys.sdo_geometry 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 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;

   /** 
    * 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;

  /**
   * 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 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 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 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;

   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 Geom_Segment_Length(geom_segment in mdsys.sdo_geometry,
                                unit         in varchar2 default null)
     RETURN NUMBER 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_X_dec_places in integer default null,
                              p_y_dec_places in integer default null,
                              p_Z_dec_places in integer default null,
                              p_w_dec_places in integer default null)
     RETURN mdsys.sdo_geometry Deterministic;

4. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

4.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.

COPYRIGHT

     (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener

4.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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

4.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,
      GEOCENTRIC   ==> GEOGRAPHIC,
      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.

COPYRIGHT

     (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener

4.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.

COPYRIGHT

    (c) 2012-2017 by TheSpatialDBAdvisor/Simon Greener

4.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 book.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.

COPYRIGHT

     (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener

4.6. TOOLS/Tokenizer [ Functions ]

[ Top ] [ TOOLS ] [ Functions ]

NAME

    Tokenizer - Splits any string into tokens and separators.

SYNOPSIS

    Function Tokenizer (
                  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.

COPYRIGHT

    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener

5. 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.

COPYRIGHT

    (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;

6. 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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

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

7. 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..

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

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

8. 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 for Book.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

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

9. 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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

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

10. OBJECT TYPE ARRAY/T_SEGMENTS [ Structures ]

[ Top ] [ Structures ]

NAME

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

DESCRIPTION

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

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_SEGMENTS 
           AS TABLE OF &&INSTALL_SCHEMA..T_SEGMENTObj

11. 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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

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

12. OBJECT TYPE ARRAY/T_VERTICES [ Structures ]

[ Top ] [ Structures ]

NAME

    T_ELEMINFOSET -- Array of of T_Vertex objects.

DESCRIPTION

    An array of T_VERTEX objects.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2005 - Original coding.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

SOURCE

CREATE OR REPLACE TYPE &&INSTALL_SCHEMA..T_Vertices 
           IS TABLE OF &&INSTALL_SCHEMA..T_Vertex;

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.

COPYRIGHT

    (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).
                                See also function COGO.DMS2DD.
    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.

COPYRIGHT

    (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..

COPYRIGHT

    (c) 2005-2018 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
    precision -- Number of Significant Decimal Digits of precision.
                 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,
  precision integer,
  projected integer,

15.2. T_GEOMETRY/CONSTRUCTORS(T_GEOMETRY) [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    A collection of T_GEOMETRY Constructors.

SOURCE

  Constructor Function T_GEOMETRY  (p_geom      in mdsys.sdo_geometry)
                Return Self As Result,

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

  Constructor Function T_GEOMETRY  (p_geom      in mdsys.sdo_geometry,
                                    p_tolerance in number,
                                    p_precision in integer)
                Return Self As Result,

  Constructor Function T_GEOMETRY  (p_geom      in mdsys.sdo_geometry,
                                    p_tolerance in number,
                                    p_precision in integer,
                                    p_projected in varchar2)
                Return Self As Result,

  Constructor Function 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  (p_SEGMENT    in &&INSTALL_SCHEMA..T_SEGMENT,
                                    p_srid      in integer,
                                    p_tolerance in number default 0.005,
                                    p_precision in integer default 2,
                                    p_projected in varchar2 default 'PLANAR')
                Return Self As Result,

15.3. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.4. T_GEOMETRY/ST_Add_SEGMENT [ Methods ]

[ 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.5. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.6. 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,
           0 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,
           0 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(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(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.7. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.8. 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.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.9. 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)
             Return CLOB Deterministic,

DESCRIPTION

    Returns textual description of T_GEOMETRY.
    Rounds ordinates via object precision variable.

ARGUMENTS

    p_linefeed (integer) - 1 if apply linefeed to coordinates

RESULT

    textual description (string)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.10. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.11. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.12. 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

    -- Oracle calls
    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 'MDSYS.SDO_GEOM.' || case when t.IntValue = 3 then 'SDO_CENTROID' else 'SDO_PointOnSurface' end as oraMethod,
           a.tGeom
            .ST_Centroid_A(p_method => t.IntValue)
            .ST_RoundOrdinates(a.tGeom.precision)
            .geom as centroid
      from data a,
           table(tools.generate_series(3,4,1)) t;
    
    ORAMETHOD                         CENTROID
    --------------------------------- ---------------------------------------------------------------------
    MDSYS.SDO_GEOM.SDO_CENTROID       SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2377.12,234.77,NULL),NULL,NULL)
    MDSYS.SDO_GEOM.SDO_PointOnSurface SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2300,-700,NULL),NULL,NULL)
    
    -- Average of Geometry Ordinate examples
    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 case when t.IntValue = 1 
                then 'Average X Of Geometry' 
                else 'Average Y Of Geometry' 
            end as Method,
           a.tGeom
            .ST_Centroid_A(p_method => case t.IntValue when 1 then 0 else 10 end)
            .ST_RoundOrdinates(a.tGeom.precision)
            .geom as centroid
      from data a,
           table(tools.generate_series(1,2,1)) t;
    
    METHOD                CENTROID
    --------------------- ----------------------------------------------------------------------
    Average X Of Geometry SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2322.86,-282.86,NULL),NULL,NULL)
    Average Y Of Geometry SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2396.43,314.29,NULL),NULL,NULL)
 
    -- Middle of Geometry MBR Ordinate ranges
    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 case when t.IntValue = 1 
                then 'Middle X Of Geometry MBR' 
                else 'Middle Y Of Geometry MBR' 
            end as Method,
           a.tGeom
            .ST_Centroid_A(p_method => case t.IntValue when 1 then 1 else 11 end)
            .ST_RoundOrdinates(a.tGeom.precision)
            .geom as centroid
      from data a,
           table(tools.generate_series(1,2,1)) t;
    
    METHOD                   CENTROID
    ------------------------ ----------------------------------------------------------------
    Middle X Of Geometry MBR SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2300,-300,NULL),NULL,NULL)
    Middle Y Of Geometry MBR SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2425,200,NULL),NULL,NULL) 

    -- User Supplied X or Y seed ordinate
    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 case when t.IntValue = 1 
                then 'User Supplied X Ordinate' 
                else 'User Supplied Y Ordinate' 
            end as Method,
           a.tGeom
            .ST_Centroid_A(p_method     => case t.IntValue when 1 then 2      else 12 end,
                           P_Seed_Value => case t.IntValue when 1 then 2035.4 else 284.6 end)
            .ST_RoundOrdinates(a.tGeom.precision)
            .geom as centroid
      from data a,
           table(tools.generate_series(1,2,1)) t;
    
    METHOD                   CENTROID
    ------------------------ ---------------------------------------------------------------------
    User Supplied X Ordinate SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2035.4,-323.54,NULL),NULL,NULL)
    User Supplied Y Ordinate SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(2403.85,284.6,NULL),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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.13. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.14. 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.precision.
    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_RoundOrdinates(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.15. 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_RoundOrdinates(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_RoundOrdinates(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_RoundOrdinates(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_RoundOrdinates(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.16. T_GEOMETRY/ST_Cogo2Polygon [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

   ST_Cogo2Polygon - Creates single polygone 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.precision.
    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_RoundOrdinates(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_RoundOrdinates(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_RoundOrdinates(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.17. T_GEOMETRY/ST_Compress [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

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

SYNOPSIS

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

DESCRIPTION

    Keeps starting point of underlying 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.

RESULT

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

TODO

    Investigate application of geometry envelope's lower left/right from coordinates before subtraction.

EXAMPLE

    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.05,1,1) as original
      from dual
    )
    Select f.compressed.ST_AsText() as compressed,
           f.compressed.ST_Decompress(f.delta_factor).ST_Equals(f.original) as before_after_equals
      From (Select a.original.ST_Compress(a.delta_factor) As compressed,
                   a.original,
                   a.delta_factor
             From data a
            ) f;

    COMPRESSED                                                                                                                                             BEFORE_AFTER_EQUALS
    ------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------
    LINESTRING (210124.235 6860562.134, -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)                   1

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - December 2015 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.18. 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.19. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.20. T_GEOMETRY/ST_Decompress [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

   ST_Decompress - Reverse Compress applied by ST_Compress if same p_factor_applied.

SYNOPSIS

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

DESCRIPTION

    Keeps starting point of underlying 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.

RESULT

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

TODO

    Investigate application of geometry envelope's lower left/right from coordinates before subtraction.

EXAMPLE

    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.05,1,1) as original
      from dual
    )
    Select f.compressed.ST_Decompress(f.delta_factor).ST_AsText() as decompressed,
           f.compressed.ST_Decompress(f.delta_factor).ST_Equals(f.original) as before_after_equals
      From (Select a.original.ST_Compress(a.delta_factor) As compressed,
                   a.original,
                   a.delta_factor
             From data a
            ) f;

    COMPRESSED                                                                                                                                                                      BEFORE_AFTER_EQUALS
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------
    LINESTRING (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)                   1

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - December 2015 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.21. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.22. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.23. 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
      from user_sdo_geom_metadata u;

    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))
    BASE_ADDRESSES           GEOM        SDO_GEOMETRY(2003,2872,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(5979545.39731847,2085905.79636266,6022316.7615783,6022316.7615783))
    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))
    ROAD_CLINES              GEOM        SDO_GEOMETRY(2003,2872,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(5979762.10717428,2085798.82445402,6024890.06350611,6024890.06350611))
    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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.24. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.25. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.26. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.27. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.28. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.29. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.30. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.31. T_GEOMETRY/ST_EndVertex [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_EndVertex -- Returns last vertex in underlying geometry.

SYNOPSIS

    Member Function ST_EndVertex
             Return mdsys.vertex_type Deterministic

RESULT

    Vertex (vertex_type) -- Vertex at end of geometry.

DESCRIPTION

    Returns last vertex describing underlying geometry.
    Actual end vertex ID is provided in returned vertex_type.

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() as end_vertex
      from data a;

    VERTEX
    -----------------------------------------------------------------
    VERTEX_TYPE(0,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,5)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.32. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.33. 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_tgeometry in &&INSTALL_SCHEMA..T_Geometry)
             Return Integer deterministic

ARGUMENTS

    p_tGeometry (T_GEOMETRY) - T_GEOMETRY that is to be compared to current object (SELF).

DESCRIPTION

    This function compares current t_geometry object (SELF) to supplied p_tgeometry object.
    Only compares SDO_GEOMETRY objects.

RESULT

    True or False (Integer) - 1 is True (Equal); 0 is False.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - July 2017 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.34. 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.
    With road_clines As (
    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_RoundOrdinates()
             .ST_Length('unit=U.S. Foot'),2) as new_length,
           rl.tgeom
             .ST_Extend(90,'START','unit=U.S. Foot')
             .ST_RoundOrdinates()
             .ST_AsText() as sGeom
      FROM road_clines rl;

    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.precision) as newLength,
           f.tGeom.ST_RoundOrdinates(f.tGeom.precision,1,1).ST_AsText() as geom
      from (select a.tgeom.ST_Length(p_round=>a.tGeom.precision) 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.precision) 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.precision) 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

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.35. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.36. 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.precision,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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.37. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.38. 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.precision,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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.39. 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,

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.

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.

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
      From data a;

    ORIGINALAREA FILTEREDAREA
    ------------ ------------
             395          400
     143.7507329          100
    GEOMETRY
    ------------------------------------------------------------------------------------------------------------------------------------
    mdsys.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))
    mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(10,10,11,10,11,11,10,11,10,10))
    mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(5,5,7,5,7,7,5,7,5,5))
    mdsys.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))
    mdsys.sdo_geometry(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(0,0,10,10))

RESULT

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

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.40. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.41. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.42. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.43. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.44. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.45. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.46. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.47. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.48. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.49. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.50. 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.precision number of decimal digits of precision.

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.

COPYRIGHT

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.51. 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.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.52. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.53. 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.
    This function does this by using the Oracle MDSYS.ST_GEOMETRY.ST_IsSimple method.

RESULT

    1/0 (integer) -- 1 if Simple, 0 if not.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2018 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.54. 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().
    See also SDO_GEOM.VALIDATE_GEOMETRY etc.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.55. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.56. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.57. 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
    -------- --------
    00'0"        3.5
    1800'0"      3.5
    900'0"       3.5
    00'0"        3.5
    431'12"     5.43
    2700'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
    -------- -------- ---
    00'0"      3.506 0.2
    1800'0"    3.614 1.1
    900'0"     3.614   2
    00'0"      3.64    3
    431'12"    5.608 4.4
    2700'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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.58. 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 snigle fofset at right angles to an imaginary line from first to last vertex, then apply offset to all vertices in the linestring. Is a "simple" versio 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.59. T_GEOMETRY/ST_LRS_Add_Measure [ Methods ]

[ 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_LRS_ADD_Measure(110.0)
             .ST_RoundOrdinates(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.60. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.61. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.62. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.63. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.64. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.65. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.66. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.67. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.68. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.69. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.70. T_GEOMETRY/ST_LRS_Is_Shape_Pt_Measure [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_LRS_Is_Shape_Pt_Measure -- Checks if M values increase in value over all of the linestring.

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 - JanJuly7 - Original Coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.71. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.72. 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.

SEE ALSO

    ST_Locate_Measure(p_measure in number, ...)

15.73. 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.

SEE ALSO

    ST_Locate_Measures(p_start_measure in number, ...)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original Coding.

15.74. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.75. 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.76. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.77. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.78. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.79. 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.80. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.81. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.82. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.83. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.84. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.85. 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.
    NOTE: 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.86. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.87. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.88. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.89. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.90. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.91. 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
    --------------------------------------------------------------------------------------------------------------
    BOOK.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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.92. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.93. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.94. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.95. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.96. T_GEOMETRY/ST_NumInteriorRing [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_NumInteriorRing -- Returns number of top level geometry elements in underlying 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.97. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.98. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.99. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.100. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.101. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.102. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.103. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.104. 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) -- Oridinal Point with structure changed.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener, Jul 2017 - New Method.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.105. 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_distance in number,
                                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_distance (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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.106. T_GEOMETRY/ST_ParallelSimple [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_ParallelSimple

DESCRIPTION

    Function under development to replace ST_Parallel do not use.

15.107. T_GEOMETRY/ST_ParallelSimpleZ [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_ParallelSimpleZ

DESCRIPTION

    Function under development to replace ST_Parallel do not use.

15.108. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.109. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.110. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.111. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.112. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.113. 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 "BOOKTEST.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_RoundOrdinates(2,1,1).ST_AsText() as tgeom,
           a.tgeom.ST_Length(p_round=>a.tGeom.precision) as gLength,
           a.tgeom.ST_Reduce(1.414,'START').ST_Length(p_round=>a.tGeom.precision) as newLength
      from data a union all
    select 1.414   as seLength,
           'END'   as Start_end,
           a.tgeom.ST_Reduce(1.414,'END').ST_RoundOrdinates(2,1,1).ST_AsText() as tgeom,
           a.tgeom.ST_Length(p_round=>a.tGeom.precision) as gLength,
           a.tgeom.ST_Reduce(1.414,'END').ST_Length(p_round=>a.tGeom.precision) as newLength
      from data a union all
    select 1.414  as seLength,
           'BOTH' as Start_end,
           a.tgeom.ST_Reduce(1.414,'BOTH').ST_RoundOrdinates(2,1,1).ST_AsText() as tgeom,
           a.tgeom.ST_Length(p_round=>a.tGeom.precision) as gLength,
           a.tgeom.ST_Reduce(1.414,'BOTH').ST_Length(p_round=>a.tGeom.precision) 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

COPYRIGHT

    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener

15.114. 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_RoundOrdinates(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.115. 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()

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

NOTES

    SDO_GEOM.RELATE() requires Enterprise Spatial licensing before 12c.
    The method checks for a version and returns NULL if not licensed.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2018 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.116. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.117. 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 "BOOKTEST.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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.118. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.119. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.120. 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_RoundOrdinates(a.geom.precision,a.geom.precision,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_RoundOrdinates(a.geom.precision,a.geom.precision,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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.121. 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_RoundOrdinates(a.geom.precision,a.geom.precision,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_RoundOrdinates(a.geom.precision,a.geom.precision,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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.122. 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_RoundOrdinates(a.geom.precision,a.geom.precision,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_RoundOrdinates(a.geom.precision,a.geom.precision,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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.123. 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_RoundOrdinates(a.geom.precision,a.geom.precision,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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.124. 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_RoundOrdinates(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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.125. T_GEOMETRY/ST_RoundOrdinates [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_RoundOrdinates -- Rounds X,Y,Z and w ordinates to passed in precision.

SYNOPSIS

    Member Function ST_RoundOrdinates(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_w 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_w (integer) - value applied to w Ordinate.

RESULT

    geometry (T_GEOMETRY)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.126. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.127. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.128. 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) -- Oridinal Point with structure changed.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener, Jan 2013 - Port to Object method.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.129. 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 "BOOK.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)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - December 2017 - Original PLSQL Coding for Oracle

15.130. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.131. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.132. T_GEOMETRY/ST_SetPrecision [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_SetPrecision -- Sets precision property value of object after construction.

SYNOPSIS

    Member Procedure ST_SetPrecision (p_precision in integer default 3),

DESCRIPTION

    The precision object property is normally set when the object is constructed.
    This member function allows the user to change the value dynamically.

ARGUMENTS

    p_precision : integer : Any valid integer value for the Oracle ROUND function.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jun 2017 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.133. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.134. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jul 2017 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.135. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jul 2017 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.136. T_GEOMETRY/ST_SetTolerance [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_SetTolerance -- Sets tolerance value of object after construction.

SYNOPSIS

    Member Procedure 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.137. 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

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.138. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.139. 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

SEE ALSO

    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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.140. 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.

SEE ALSO

    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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.141. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.142. 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.

SEE ALSO

    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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener
  DEPRECATED
    April 30th. Use ....

15.143. 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.144. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.145. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.146. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.147. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.148. T_GEOMETRY/ST_StartVertex [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_StartVertex -- Returns first vertex in underlying geometry.

SYNOPSIS

    Member Function ST_StartVertex
             Return mdsys.vertex_type Deterministic

RESULT

    Vertex (vertex_type) -- 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() as start_vertex
      from data a;

    VERTEX
    -----------------------------------------------------------------
    VERTEX_TYPE(0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.149. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.150. 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).
      POINT -- Centre point of each grid cell/Tile
      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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.151. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.152. 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.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.153. 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 suypplied start and end measures.
    If mdsys.sdo_geometry is 4D it is reduced to 3D with measures reset to supplied start and end values ie result is XYW.

RESULT

    SELF (TO_GEOMETRY) -- 3D mdsys.sdo_geometry line encoded with start and end measures.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.154. 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.

RESULT

    SELF (TO_GEOMETRY) -- 3D Underlying mdsys.sdo_geometry.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.155. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.156. 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_id    in integer,
                                          p_start_point in mdsys.sdo_point_type,
                                          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.

ARGUMENTS

    p_start_id           (integer) - A vertex that exists in the underlying geometry.
    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_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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.157. 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.precision 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.

COPYRIGHT

    (c) 2008-2018 by TheSpatialDBAdvisor/Simon Greener

15.158. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.159. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.160. 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 mdsys.vertex_type Deterministic

ARGUMENTS

    p_vertex (integer) -- Vertex number between 1 and ST_NumVertices().

RESULT

    Vertex (vertex_type) -- 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 vertex_type 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) as VertexN
      from data a;

    VERTEXN
    ----------------------------------------------------------------
    VERTEX_TYPE(5,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,15)

    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) as vertex
      from data a,
           table(tools.generate_series(1,a.tLine.ST_NumVertices(),1)) t;

    VERTEX
    -----------------------------------------------------------------
    VERTEX_TYPE(0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1)
    VERTEX_TYPE(20,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,2)
    VERTEX_TYPE(20,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,3)
    VERTEX_TYPE(10,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4)
    VERTEX_TYPE(0,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,5)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.161. 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(2)
      from GEOMETRIES a,
           Table(a.tPolygon.ST_Vertices()) t;

    T.ST_ASTEXT(2)
    -------------------------------------
    T_Vertex(0,0,NULL,NULL,1,2001,NULL)
    T_Vertex(20,0,NULL,NULL,2,2001,NULL)
    T_Vertex(20,20,NULL,NULL,3,2001,NULL)
    T_Vertex(0,20,NULL,NULL,4,2001,NULL)
    T_Vertex(0,0,NULL,NULL,5,2001,NULL)
    T_Vertex(10,10,NULL,NULL,6,2001,NULL)
    T_Vertex(10,11,NULL,NULL,7,2001,NULL)
    T_Vertex(11,11,NULL,NULL,8,2001,NULL)
    T_Vertex(11,10,NULL,NULL,9,2001,NULL)
    T_Vertex(10,10,NULL,NULL,10,2001,NULL)
    T_Vertex(5,5,NULL,NULL,11,2001,NULL)
    T_Vertex(5,7,NULL,NULL,12,2001,NULL)
    T_Vertex(7,7,NULL,NULL,13,2001,NULL)
    T_Vertex(7,5,NULL,NULL,14,2001,NULL)
    T_Vertex(5,5,NULL,NULL,15,2001,NULL)

     15 rows selected

RESULT

    vertices (T_VERTICES) -- Table of T_Vertex objects.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.162. 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

SEE ALSO

    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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.163. T_GEOMETRY/ST_WKB [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_WKB -- 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_WKB
             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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

15.164. T_GEOMETRY/ST_WKT [ Methods ]

[ Top ] [ T_GEOMETRY ] [ Methods ]

NAME

    ST_WKT -- 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_WKT
             Return Integer 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.

RESULT

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

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 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..

COPYRIGHT

    (c) 2005-2018 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)
    precision integer,            -- Precision value associated with geometry object (normally T_GEOMETRY.precision object)
    projected integer,            -- Projected value associated with geometry object (normally T_GEOMETRY.projected object)

SOURCE

   gid       number,
   geometry  mdsys.sdo_geometry,
   tolerance number,
   precision 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 for Book.

COPYRIGHT

    (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 for Book.

COPYRIGHT

    (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.

COPYRIGHT

    (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 (
                          p_geometry IN MDSYS.SDO_GEOMETRY
                        )
                 Return SELF As Result,

   Constructor Function T_MBR
                   Return SELF as Result,

   Constructor Function T_MBR(
                          p_geometry  IN MDSYS.SDO_GEOMETRY,
                          p_tolerance IN NUMBER 
                        )
                   Return SELF as Result,

   Constructor Function T_MBR(
                          p_geometry IN MDSYS.SDO_GEOMETRY,
                          p_dimarray IN MDSYS.SDO_DIM_ARRAY
                        )
                   Return SELF as Result,

   Constructor Function T_MBR(
                          p_Vertex  In &&INSTALL_SCHEMA..T_Vertex,
                          p_dExtent In Number
                        )
                   Return SELF as Result,

   Constructor Function 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

   Member Function X
            Return Number Deterministic,

   Member Function Y
            Return Number Deterministic,

   Member Function Width
            Return Number Deterministic,

   Member Function Height
            Return Number Deterministic,

   Member Function Area
            Return Number Deterministic,

   Member Function Centre
            Return &&INSTALL_SCHEMA..T_Vertex Deterministic,

   Member Function Center
            Return &&INSTALL_SCHEMA..T_Vertex Deterministic,

   Member Function AsDimArray
            Return MDSYS.SDO_DIM_ARRAY Deterministic,

   Member Function AsString
            Return VarChar2 Deterministic,

   Member Function AsCSV
            Return VarChar2 Deterministic,

   Member Function AsWKT
            Return VARCHAR2 Deterministic,

   Member Function AsSVG
            Return VarChar2 Deterministic,

   Member Function getCentreAsSVG
            Return VarChar2 Deterministic,

19.4. T_MBR/Modifiers(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

   Member Procedure SetEmpty,

   Member Procedure Expand(p_Vertex IN &&INSTALL_SCHEMA..T_Vertex),

   Member Procedure Expand(p_dX IN NUMBER,
                           p_dY IN NUMBER),

   Member Procedure Expand(p_other IN &&INSTALL_SCHEMA..T_MBR),

   Member Procedure Normalize(p_dRatio In Number),

   Member Procedure SetToPart(p_geometry in mdsys.sdo_geometry, 
                              p_which    in pls_integer /* 0 smallest, 1 largest */ ),

   Member Procedure SetSmallestPart(p_geometry IN MDSYS.SDO_GEOMETRY ),

   Member Procedure SetLargestPart( p_geometry IN MDSYS.SDO_GEOMETRY ),

   Member Procedure Intersection(p_other In &&INSTALL_SCHEMA..T_MBR ),

19.5. T_MBR/Sorting(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

   Member Function Equals(   p_other In &&INSTALL_SCHEMA..T_MBR )
            Return Boolean Deterministic,
   Order 
   Member Function Evaluate(p_other In &&INSTALL_SCHEMA..T_MBR)
            Return PLS_Integer

19.6. T_MBR/Testers(T_MBR) [ Variables ]

[ Top ] [ T_MBR ] [ Variables ]

SOURCE

   Member Function isEmpty
            Return Boolean Deterministic,

   Member Function Contains( p_other In &&INSTALL_SCHEMA..T_MBR )
            Return Boolean Deterministic,

   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,

   Member Function Compare(  p_other In &&INSTALL_SCHEMA..T_MBR )
            Return Number Deterministic,

   Member Function Overlap(  p_other in &&INSTALL_SCHEMA..T_MBR )
            Return Boolean Deterministic,

20. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.1. T_SEGMENT/ATTRIBUTES(T_SEGMENT) [ 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

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,

20.2. T_SEGMENT/CONSTRUCTORS(T_SEGMENT) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    A collection of T_SEGMENT Constructors.

SOURCE

  Constructor Function T_SEGMENT
                Return Self As Result,

  Constructor Function T_SEGMENT( p_segment in &&INSTALL_SCHEMA..T_SEGMENT)
                Return Self As Result,

  Constructor Function T_SEGMENT( p_line in mdsys.sdo_geometry)
                Return Self As Result,

  Constructor Function T_SEGMENT(p_sdo_gtype In Integer,
                                 p_sdo_srid  In Integer)
                Return Self As Result,

  Constructor Function 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)
                Return Self As Result,

  Constructor Function 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)
                Return Self As Result,

  Constructor Function 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)
                Return Self As Result,

  Constructor Function 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)
                Return Self As Result,

  Constructor Function 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)
                Return Self As Result,

  Constructor Function 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)
                Return Self As Result,

20.3. 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

PARAMETERS

    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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.4. T_SEGMENT/ST_AsText [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_AsText -- Returns text Description of underlying segment

SYNOPSIS

    Member Function ST_AsText(p_X_dec_places in integer default 8,
                              p_Y_dec_places in integer default 8,
                              p_Z_dec_places in integer default 3,
                              p_M_dec_places in integer default 3)
             Return Varchar2 Deterministic,

DESCRIPTION

    Returns textual description of segment with optional rounding of X,Y,Z and w ordinates to passed in precision.

PARAMETERS

    p_X_dec_places (integer) - value applied to x Ordinate.
    p_Y_dec_places (integer) - value applied to y Ordinate.
    p_Z_dec_places (integer) - value applied to z Ordinate.
    p_M_Dec_places (integer) - value applied to w/m Ordinate.

RESULT

    String - T_SEGMENT in text format.
 TOBEDONE
    Reverse ST_FromText()

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.5. T_SEGMENT/ST_Bearing [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_Bearing -- Returns Bearing, in radians, from start to end

SYNOPSIS

    Member Function ST_Bearing()
             Return Number Deterministic

DESCRIPTION

    This function computes a bearing from the current object point's startCoord to its EndCoord.
    Result is in radians. Use static function ST_Degrees to return as a whole circle bearing.

RESULT

    bearing (Number) -- Bearing in Radians.

SEE ALSO

    ST_Degrees.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.6. T_SEGMENT/ST_Closest(p_point p_tolerance p_unit) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_Closest -- Finds nearest point on line where supplied vertex would fall (snap to).

SYNOPSIS

    Member Function ST_Closest(p_point     in &&INSTALL_SCHEMA..t_vertex,
             Return &&INSTALL_SCHEMA..T_Vertex Deterministic

DESCRIPTION

    Finds nearest point on line where supplied vertex would fall (snap to).
    Computations respect SRID and unit as uses SDO_GEOM.SDO_CLOSEST_POINTS.
    Alternate version of function can be used when SDO_GEOM version fails to compute point.
    This function handles fact that SDO_GEOM function does not support measured segments.

PARAMETERS

    p_point   (T_VERTEX) - Point expressed as a T_Vertex object.
    p_tolerance (NUMBER) - SDO_Tolerance for use with sdo_geom.sdo_distance.
    p_unit    (VARCHAR2) - Oracle Unit of Measure eg unit=M.

RESULT

    vertext (T_VERTEX) -- Nearest point on line supplied vertex is nearest to.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.7. T_SEGMENT/ST_Closest(p_vertex) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_Closest -- Finds nearest point on line where supplied vertex would fall (snap to).

SYNOPSIS

    Member Function ST_Closest(p_vertex in &&INSTALL_SCHEMA..t_vertex)
             Return &&INSTALL_SCHEMA..T_Vertex Deterministic

DESCRIPTION

    Finds nearest point on line where supplied vertex would fall (snap to).
    Computations are all planar with no respect for SRID. 
    See alternate version of function.

PARAMETERS

    p_vertex (T_VERTEX)   - Point expressed as a T_Vertex object.

TODO

    Add support for SRID units of measure (ie parameter p_unit).

RESULT

    vertext (T_VERTEX) -- Nearest point on line supplied vertex is nearest to.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.8. 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

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.9. T_SEGMENT/ST_Distance(p_geom p_tolerance p_precision p_unit) [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_Distance -- Returns Distance from segment to first vertex in sdo_geometry

SYNOPSIS

    Member Function ST_Distance(p_geom      in mdsys.sdo_geometry,
                                p_tolerance in number   DEFAULT 0.05,
                                p_precision In Integer  DEFAULT 2,
                                p_unit      in varchar2 DEFAULT NULL)
             Return Number Deterministic

PARAMETERS

    p_geom     (sdo_geometry) - A geometry from whose first vertex a bearing is calculated.
    p_tolerance      (NUMBER) - SDO_Tolerance for use with sdo_geom.sdo_distance.
    p_precision      (NUMBER) - Decimal digits of precision for a generic ordinate.
    p_unit         (VARCHAR2) - Oracle Unit of Measure eg unit=M.

DESCRIPTION

    This function computes a distance from the input sdo_geometry objects first point to the underlying T_SEGMENT.
    Result is in the distance units of the SDO_SRID, or in p_units where supplied.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.10. T_SEGMENT/ST_Distance(p_vertex p_tolerance p_precision 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_tolerance in Number   DEFAULT 0.05,
                                p_precision In Integer  DEFAULT 2,
                                p_unit      in varchar2 DEFAULT NULL)
             Return Number Deterministic

PARAMETERS

    p_geom      (T_VERTEX) - A single vertex from which a bearing to the segment is calculated.
    p_tolerance   (NUMBER) - SDO_Tolerance for use with sdo_geom.sdo_distance.
    p_precision   (NUMBER) - Decimal digits of precision for a generic ordinate.
    p_unit      (VARCHAR2) - Oracle Unit of Measure eg unit=M.

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.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.11. 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_precision in number  default 3,
             Return Integer deterministic

PARAMETERS

    p_segment   (T_SEGMENT) - Vertex that is to be compared to current object (SELF).
    p_precision (INTEGER) - Decimal digits of precision for all ordinates.
    p_coords    (Integer) - Boolean. If 1, only coordinates are compared; if 0, then all elements including segment_id etc are compared.

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

RESULT

    BOOLEAN (INTEGER) - 1 is True (Equal); 0 is False.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.12. 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

    select &&INSTALL_SCHEMA..T_Segment(
              sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,2),sdo_ordinate_array(0,0,5,5,10,0))
           ).ST_FindCircle()
            .ST_AsText() as circle_params
     from dual;
  
    CIRCLE_PARAMS
    -----------------------------------
    T_Vertex(5,0,5,NULL,NULL,2001,NULL)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.13. 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 is has Z ordinate, 0 otherwise.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.14. 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)

RESULT

    BOOLEAN (INTEGER) -- 1 if segment has no non null values; 0 if has values

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.15. T_SEGMENT/ST_isMeasured [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_isMeasured -- Tests segment to see if coordinates include a measure.

SYNOPSIS

    Member Function ST_isMeasure
             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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.16. 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.

RESULT

    BOOLEAN (INTEGER) -- 1 if two segments have opposite direction.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.17. T_SEGMENT/ST_Length [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_Length -- Returns Length of the segment 

SYNOPSIS

    Member Function ST_Length(p_tolerance in Number   DEFAULT 0.005,
                              p_unit      in varchar2 DEFAULT NULL)
             Return Number Deterministic

PARAMETERS

    p_tolerance   (NUMBER) - SDO_Tolerance for use with sdo_geom.sdo_distance.
    p_unit      (VARCHAR2) - Oracle Unit of Measure eg unit=M.

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.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.18. T_SEGMENT/ST_LRS_Compute_Measure [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_LRS_Compute_Measure -- Computes measure of point on segment.

SYNOPSIS

    Member Function ST_LRS_Compute_Measure(p_vertex    In &&INSTALL_SCHEMA..t_vertex,
                                           p_tolerance IN NUMBER   Default 0.005,
                                           p_unit      IN varchar2 Default null)
             Return Number Deterministic

PARAMETERS

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.

RESULT

    measure (Number) -- Measure value associated with point between start and end measure of segment.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.19. 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

    BOOLEAN (INTEGER) -- L from DLNN.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.20. 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
             Return Number Deterministic

PARAMETERS

DESCRIPTION

    This function computes length by subtracting end and start measure ordinates.

RESULT

    distance (Number) -- Difference between end and start measure ordinates (delta).

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.21. 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 Number 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.

RESULT

    segment (T_SEGMENT) -- New segment.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.22. 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_next_segment in number,
                                     p_offset       in number,
                                     p_tolerance    in number  Default 0.05,
                                     p_unit         In Integer Default NULL)
             Return &&INSTALL_SCHEMA..T_Vertex Deterministic

DESCRIPTION

    Supplied with a second segment (p_next_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.

PARAMETERS

    p_next_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_tolerance    (number) - SDO_Tolerance for use with sdo_geom.sdo_distance.
    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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.23. 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_tolerance in number  Default 0.05,
                                   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.

PARAMETERS

    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_tolerance (NUMBER) - SDO_Tolerance for use with sdo_geom.sdo_distance.
    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

    vertext (T_VERTEX)   - New point on line with optional perpendicular offset.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.24. T_SEGMENT/ST_Parallel [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_Parallel -- Moves segment parallel to imaginary line drawn from first to last vertex.

SYNOPSIS

    Member Function ST_Parallel(p_distance in number)
             Return &&INSTALL_SCHEMA..T_GEOMETRY deterministic

DESCRIPTION

    Function that extracts the first and last vertex of a segment, 
    computes a single offset at right angles to an imaginary line from first to last vertex, 
    then applies offset to segment.

PARAMETERS

    p_distance (NUMBER)   - Value +/- integer value.

TODO

    Add support for SRID units of measure (ie parameter p_unit).

RESULT

    New segment (T_SEGMENT) -- Input segment 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.
    Simon Greener - January 2014  - Port/Rewrite to T_SEGMENT object function member.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.25. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.26. T_SEGMENT/ST_RoundOrdinates [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_RoundOrdinates -- Rounds X,Y,Z and w ordinates of segment's coordinates to passed in precision.

SYNOPSIS

    Member Function ST_RoundOrdinates(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_w 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);

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_w (integer) - value applied to w Ordinate.

RESULT

    segment (T_SEGMENT)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.27. T_SEGMENT/ST_SdoGeometry [ Methods ]

[ Top ] [ T_SEGMENT ] [ Methods ]

NAME

    ST_SdoGeometry -- Returns segment as a suitably encoded MDSYS.SDO_GEOMETRY object.

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.

PARAMETERS

    p_dims in integer default null - A dimension value that will override SELF.ST_Dims() eg to return 2D from a 3D segment.

SYNOPSIS

    Member Function ST_SdoGeometry(p_dims in integer default null)
             Return MDSYS.sdo_geometry Deterministic,

RESULT

    linestring (MDSYS.SDO_GEOMETRY) -- Two (or three) point linestring. 

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.28. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.29. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

20.30. 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,
                            p_default_z    in number)
             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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

21. OBJECT TYPE/T_SEGMENTOBJ [ Types ]

[ Top ] [ Types ]

NAME

    T_SEGMENTOBJ Type

DESCRIPTION

    An object type that represents a single segment in a way that allows
    the receiver of a PIPELINED function of T_SEGMENTs to access the actual segment
    and not the segment's individual attributes.

NOTES

    No methods are defined on this object.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

21.1. T_SEGMENTOBJ/ATTRIBUTES(T_SEGMENTOBJ) [ Variables ]

[ Top ] [ T_SEGMENTOBJ ] [ Variables ]

ATTRIBUTES

    segment -- T_SEGMENT Object.

SOURCE

  segment &&INSTALL_SCHEMA..T_SEGMENT

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 for Book.

COPYRIGHT

    (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.

COPYRIGHT

    (c) 2012-2018 by TheSpatialDBAdvisor/Simon Greener

23.1. T_VECTOR3D/AddV [ Methods ]

[ 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.

COPYRIGHT

    (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.

COPYRIGHT

    (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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.4. T_VECTOR3D/AsText [ Methods ]

[ Top ] [ T_VECTOR3D ] [ Methods ]

NAME

    AsText -- Produces a textual representation of a T_VECTOR3D.

SYNOPSIS

    Member Function AsText(p_round IN integer DEFAULT 9)
             Return Varchar2 Deterministic,

PARAMETERS

    p_round (integer) - Ordinate rounding value.
  RETURNS
    Produces a textual representation of a T_VECTOR3D eg {x=0.0,y=1.0,z=2.1}

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - January 2011 - Original coding.

COPYRIGHT

    (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( p_SEGMENT in &&INSTALL_SCHEMA..T_SEGMENT)
                Return Self As Result,

  Constructor Function T_VECTOR3D( p_SEGMENT in &&INSTALL_SCHEMA..T_VECTOR3D)
                Return Self As Result,

  Constructor Function T_VECTOR3D( p_vertex in &&INSTALL_SCHEMA..T_Vertex)
                Return Self As Result,

  Constructor Function 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.

COPYRIGHT

    (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.

COPYRIGHT

    (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.

COPYRIGHT

    (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.

COPYRIGHT

    (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.

COPYRIGHT

    (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.

COPYRIGHT

    (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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.14. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.15. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.16. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.17. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.18. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.19. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.20. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.21. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.22. 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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

23.23. 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.

COPYRIGHT

    (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.

COPYRIGHT

    (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

SOURCE

  x         number,
  y         number,
  z         number,
  w         number,
  id        integer,
  sdo_gtype integer,
  sdo_srid  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
       Return Self As Result,

  Constructor Function T_Vertex( p_vertex In &&INSTALL_SCHEMA..T_vertex )
       Return Self As Result,

  Constructor Function T_Vertex( p_point in mdsys.sdo_geometry )
       Return Self As Result,

  Constructor Function T_Vertex( p_sdo_gtype in integer,
                                 p_sdo_srid  in integer)
       Return Self as result,

  Constructor Function 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( 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( 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( 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( 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( 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_ID        Return integer Deterministic,
  Member Function ST_SRID      Return integer Deterministic,
  Member Function ST_SDO_GTYPE 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

PARAMETERS

    p_vertex (T_VERTEX) - 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 uses all ordinates: X, Y, Z and W.

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(.33,.26,NULL,NULL,1,2001,NULL)
    T_Vertex(.85,.63,NULL,NULL,1,2001,NULL)
    T_Vertex(1.96,.16,NULL,NULL,1,2001,NULL)
    T_Vertex(2.02,3.45,NULL,NULL,1,2001,NULL)
    T_Vertex(2.39,1.16,NULL,NULL,1,2001,NULL)
    T_Vertex(2.64,2.15,NULL,NULL,1,2001,NULL)
    T_Vertex(4.5,4.47,NULL,NULL,1,2001,NULL)
    T_Vertex(4.9,3.72,NULL,NULL,1,2001,NULL)
    T_Vertex(6.78,2.54,NULL,NULL,1,2001,NULL)

     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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.5. T_VERTEX/ST_AsText [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

    ST_AsText -- Returns text Description of Vertex

SYNOPSIS

    Member Function ST_AsText(p_X_dec_places in integer default 8,
                              p_Y_dec_places in integer default 8,
                              p_Z_dec_places in integer default 3,
                              p_M_dec_places in integer default 3)
             Return Varchar2 Deterministic,

DESCRIPTION

    Returns textual description of vertex with optional rounding of X,Y,Z and w ordinates to passed in precision.

PARAMETERS

    p_X_dec_places (integer) - value applied to x Ordinate.
    p_Y_dec_places (integer) - value applied to y Ordinate.
    p_Z_dec_places (integer) - value applied to z Ordinate.
    p_M_Dec_places (integer) - value applied to w/m Ordinate.

RESULT

    vertex (T_VERTEX)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.6. 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)
             Return Number Deterministic

PARAMETERS

    p_vertex (T_VERTEX) - A Vertex to which a bearing is calculated.

DESCRIPTION

    This function computes a bearing from the current object point (SELF) to the supplied T_Vertex.
    Result is in radians. Use static function ST_Degrees to return as a whole circle bearing.

RESULT

    bearing (Number) -- Bearing in Radians.

SEE ALSO

    ST_Degrees.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.7. 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

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.8. 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

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.

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.

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.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.9. 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_precision in number default 3)
             Return Integer deterministic

PARAMETERS

    p_vertex (T_VERTEX) - Vertex that is to be compared to current object (SELF).
    p_round   (INTEGER) - Decimal digits of precision for all ordinates.

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.

RESULT

    BOOLEAN (INTEGER) - 1 is True (Equal); 0 is False.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.10. 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)
             Return &&INSTALL_SCHEMA..T_Vertex Deterministic

PARAMETERS

    p_bearing  (NUMBER) - A whole circle bearing in radians.
    p_distance (NUMBER) - Distance expressed in Oracle Unit of Measure eg METER.

DESCRIPTION

    This function computes a new T_VERTEX computed from current object point (SELF)
    the supplied bearing and distance.

RESULT

    vertexx (T_VERTEX) -- New vertex computed using bearing and distance from current object.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.11. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.12. T_VERTEX/ST_isMeasured [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

    ST_isMeasured -- Tests vertex to see if coordinates include a measure.

SYNOPSIS

    Member Function ST_isMeasure
             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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.13. T_VERTEX/ST_isNull [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

    ST_isNull -- Checks if Vertex data exists or not.

SYNOPSIS

    Member Function ST_isNull
             Return Integer Deterministic,

DESCRIPTION

    If vertex object data are not null returns 1(True) else 0 (False).

RESULT

    BOOLEAN (INTEGER) -- 1 if vertex has not values; 0 if has values

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.14. 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.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.15. 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
             Return &&INSTALL_SCHEMA..T_Vertex Deterministic,

PARAMETERS

    p_measure (number) - New Measure value.

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.

RESULT

    vertex (T_VERTEX) 

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.16. T_VERTEX/ST_RoundOrdinates [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

    ST_RoundOrdinates -- Rounds X,Y,Z and w ordinates to passed in precision.

SYNOPSIS

    Member Function ST_RoundOrdinates(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_w in integer default 3)
             Return &&INSTALL_SCHEMA..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_w (integer) - value applied to w Ordinate.

RESULT

    vertex (T_VERTEX)

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.17. T_VERTEX/ST_SdoGeometry [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

    ST_SdoGeometry -- Returns Vertex as a suitably encoded MDSYS.SDO_GEOMETRY object.

PARAMETERS

    p_dims in integer default null - A dimension value that will override SELF.ST_Dims() eg return 2D from a 3D vertex.

SYNOPSIS

    Member Function ST_SdoGeometry
             Return MDSYS.SDO_GEOMETRY Deterministic,

RESULT

    point (MDSYS.SDO_GEOMETRY) -- Type of Point geometry depends on what the vertex represents.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

DESCRIPTION

    The encoding of the returned SDO_GEOMETRY object depends on the dimension of the vertex.
    This can be best seen in the following piece of source code from the type body.

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.18. 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);

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.19. 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

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.

DESCRIPTION

    This function computes the angle subtended by the three points:
    p_start_vertex ---> SELF ---> p_end_vertex

RESULT

    angle (NUMBER) - Subtended angle in radians.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.20. 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 &&INSTALL_SCHEMA..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) 

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.21. T_VERTEX/ST_To3D [ Methods ]

[ Top ] [ T_VERTEX ] [ Methods ]

NAME

    ST_To3D -- Removes and Z or measured attributes, adjusts sdo_gtype.

SYNOPSIS

    Member Function ST_To3D
             Return &&INSTALL_SCHEMA..T_Vertex Deterministic,

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.

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.

RESULT

    vertex (T_VERTEX) 

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.22. 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);

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener

24.23. 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

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.

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

RESULT

    BOOLEAN (INTEGER) - 1 is True; 0 is False.

AUTHOR

    Simon Greener

HISTORY

    Simon Greener - Jan 2013 - Original coding.

COPYRIGHT

    (c) 2005-2018 by TheSpatialDBAdvisor/Simon Greener