GEOM

The GEOM package contains a generic collection of algorithms that work on SDO_GEOMETRY objects.

This package needs many TYPES to exist and also depends on other packages such as GF, CONSTANTS etc.

If you are interested in this package it is best to download the complete collection of packages and have a good look at the code.

 DEFINE defaultSchema = '&1'
  
 CREATE OR REPLACE PACKAGE Geom
 AUTHID CURRENT_USER
 IS
  
   /** Common types 
   */
   TYPE t_integers    IS TABLE OF INTEGER;
  
   TYPE t_VertexSet   IS TABLE OF &&defaultSchema..t_Vertex;
  
   TYPE t_VectorSet   IS TABLE OF &&defaultSchema..t_Vector;
  
   TYPE T_GeometrySet IS TABLE OF &&defaultSchema..T_Geometry;
  
   /* For Function GetNumRings() */
   c_rings_all        Constant Pls_Integer   := 0;
   c_rings_outer      Constant Pls_Integer   := 1;
   c_rings_inner      Constant Pls_Integer   := 2;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Convert_Unit
   * @precis     : Function to convert a value from one unit of measure to another.
   * @version    : 1.0
   * @usage      : Function Convert_Unit ( p_from_unit IN varchar2,
   *                                       p_value     IN Number
   *                                       p_to_unit   IN VarChar2 )
   *                 Return Number Deterministic;
   *               eg dLinks := &&defaultSchema..geom.convert_unit('CHAIN',1,'LINK');
   * @param      : p_from_unit  : Number : The unit of measure describing p_value. Must exist in mdsys.sdo_dist_units
   * @param      : p_value      : Number : The actual distance expressed in SRID's units to be converted
   * @return     : p_to_unit    : Number : The unit of measure to convert p_value to. Must exist in mdsys.sdo_dist_units
   * @note       : Supplied p_from_unit must exist in mdsys.sdo_dist_units
   * @note       : Supplied p_to_unit should exist in mdsys.sdo_dist_units
   * @history    : Simon Greener - Feb 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *                http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function Convert_Unit( p_from_unit in varchar2,
                          p_value     in number,
                          p_to_unit   in varchar2 )
            return number deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Convert_Distance
   * @precis     : Function to convert a distance in a SRID's unit of measure to another unit of measure.
   * @version    : 1.0
   * @usage      : Function Convert_Distance ( p_srid  IN number,
   *                                           p_value IN Number
   *                                           p_unit  IN VarChar2 )
   *                 Return Number Deterministic;
   *               eg distanceInFeet := &&defaultSchema..geom.Convert_Distance(8311,1,'Feet');
   * @param      : p_srid  : Number : A valid srid (ie exists in mdsys.cs_srs)
   * @param      : p_value : Number : The actual distance expressed in SRID's units to be converted
   * @return     : p_unit  : Number : The unit of measure to convert p_value to. Must exist in mdsys.sdo_dist_units
   * @note       : Supplied p_srid must exist in mdsys.cs_srs
   * @note       : Supplied p_units should exist in mdsys.sdo_dist_units
   * @history    : Simon Greener - Feb 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function Convert_Distance( p_srid  in number,
                              p_value in number,
                              p_unit  in varchar2 := 'Meter' )
            Return Number Deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Generate_Series
   * @precis     : Function that generates a series of numbers mimicking PostGIS's function with
   *               the same name
   * @version    : 1.0
   * @usage      : Function generate_series(p_start pls_integer,
   *                                        p_end   pls_integer,
   *                                        p_step  pls_integer )
   *                 Return &&defaultSchema..geom.t_integers Pipelined;
   *               eg SELECT s.* FROM TABLE(generate_series(1,1000,10)) s;
   * @param      : p_start : Integer : Starting value
   * @param      : p_end   : Integer : Ending value.
   * @return     : p_step  : Integer : The step value of the increment between start and end
   * @history    : Simon Greener - June 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function Generate_Series(p_start pls_integer,
                            p_end   pls_integer,
                            p_step  pls_integer )
        Return &&defaultSchema..geom.t_integers Pipelined;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Generate_DimInfo
   * @precis     : Function that generates a 2D/3D diminfo structure with default tolerances of
   *               Constants.c_MinVal/Constants.c_MaxVal
   * @version    : 1.0
   * @usage      : Function Generate_DimInfo(p_dims        in number,
   *                                         p_X_tolerance in number,
   *                                         p_Y_tolerance in number := NULL,
   *                                         p_Z_tolerance in number := NULL)
   *                 Return mdsys.sdo_dim_array deterministic;
   *               eg SELECT s.* FROM TABLE(generate_series(1,1000,10)) s;
   * @param      : p_dims        : Integer : Number of dimensions from 2 to 3 (will return NULL otherwise)
   * @param      : p_X_tolerance : Number : X ordinate tolerance
   * @return     : p_Y_tolerance : Number : Y ordinate tolerance
   * @return     : p_Z_tolerance : Number : Z ordinate tolerance
   * @history    : Simon Greener - June 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function Generate_DimInfo(p_dims        in number,
                             p_X_tolerance in number,
                             p_Y_tolerance in number := NULL,
                             p_Z_tolerance in number := NULL)
     Return mdsys.sdo_dim_array deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_MBR
   * @precis     : Function which computes minimum bounding rectangle of geometries.
   * @version    : 1.0
   * @description: This function directly operates on the vertices of geometries and does not use sdo_geom.mbr
   * @usage      : Function SDO_MBR ( p_geometry IN MDSYS.SDO_GEOMETRY )
   *                 Return MDSYS.SDO_GEOMETRY Deterministic;
   *               eg fixedShape := &&defaultSchema..geom.SDO_MBR(shape);
   * @param      : p_geometry   : MDSYS.SDO_GEOMETRY : A valid sdo_geometry.
   * @return     : MBR          : MDSYS.SDO_GEOMETRY : MBR as an optimized rectangle.
   * @history    : Simon Greener - Oct 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_MBR( p_geometry IN MDSYS.SDO_GEOMETRY )
            Return MDSYS.SDO_GEOMETRY Deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_LENGTH
   * @precis     : Function which computes length of linestrings or boundaries of polygons.
   * @version    : 1.0
   * @description: This function is a SQL based function that uses sdo_distance which is a Locator function.
   * @usage      : Function SDO_Length ( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                                     p_dimarray IN MDSYS.SDO_DIM_ARRAY
   *                                     p_units    IN VarChar2 )
   *                 Return Number Deterministic;
   *               eg fixedShape := &&defaultSchema..geom.length(shape,diminfo);
   * @param      : p_geometry   : MDSYS.SDO_GEOMETRY  : A valid sdo_geometry.
   * @param      : p_tolerance  : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @param      : p_unit       : varchar2            : Unit of measure for geometries with SRIDs
   * @return     : length       : Number : Length of linestring or boundary of a polygon in required unit of measure
   * @note       : Supplied p_unit should exist in mdsys.SDO_UNITS_OF_MEASURE
   * @history    : Simon Greener - Oct 2007 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_Length(p_geometry  in mdsys.sdo_geometry,
                       p_tolerance in number   default 0.05,
                       p_unit      in varchar2 default 'Meter' )
     Return number deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_LENGTH
   * @precis     : Overload of SDO_Length Function
   * @version    : 1.0
   * @usage      : Function SDO_Length ( p_geometry  IN MDSYS.SDO_GEOMETRY,
   *                                 p_tolerance IN Number
   *                                 p_units     IN VarChar2 )
   *                 Return Number Deterministic;
   *               eg fixedShape := &&defaultSchema..geom.length(shape,0.05);
   * @param      : p_geometry   : MDSYS.SDO_GEOMETRY : A valid sdo_geometry.
   * @param      : p_dimarray   : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @param      : p_unit       : varchar2            : Unit of measure for geometries with SRIDs
   * @return     : length       : NUMBER : Length of linestring or boundary of a polygon in required unit of measure
   * @note       : Supplied p_unit should exist in mdsys.SDO_UNITS_OF_MEASURE
   * @history    : Simon Greener - Oct 2007 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function sdo_length(p_geometry in mdsys.sdo_geometry,
                       p_diminfo  in mdsys.sdo_dim_array,
                       p_unit     in varchar2 default 'Meter' )
     Return number deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_AREA
   * @precis     : Function which computes area of a polygon.
   * @version    : 1.0
   * @description: These are wrapper functions over SDO_3GL.LENGTH_AREA procedures that are
   *               not mentioned in Oracle's licensing as being functions limited to Spatial (EE)
   * @usage      : Function SDO_Area ( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                                   p_dimarray IN MDSYS.SDO_DIM_ARRAY
   *                                   p_units    IN VarChar2 )
   *                 Return Number Deterministic;
   *               eg fixedShape := &&defaultSchema..geom.area(shape,diminfo);
   * @param      : p_geometry   : MDSYS.SDO_GEOMETRY : A valid sdo_geometry.
   * @param      : p_dimarray   : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @return     : area         : Number : Area of a polygon in required unit of measure
   * @note       : Supplied v_units should exist in mdsys.SDO_UNITS_OF_MEASURE
   * @history    : Simon Greener - Oct 2007 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_Area( p_geometry in mdsys.sdo_geometry,
                      p_diminfo  in mdsys.sdo_dim_array,
                      p_units    in varchar2 := 'Square Meter' )
     Return number deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_Area
   * @precis     : Overload of main SDO_Area Function
   * @version    : 1.0
   * @usage      : Function SDO_Area ( p_geometry  IN MDSYS.SDO_GEOMETRY,
   *                                   p_tolerance IN Number
   *                                   p_units     IN VarChar2 )
   *                 Return Number Deterministic;
   *               eg fixedShape := &&defaultSchema..geom.Area(shape,0.05);
   * @param      : p_geometry   : MDSYS.SDO_GEOMETRY : A valid sdo_geometry.
   * @param      : p_tolerance  : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @return     : area         : Number : Area of a polygon in required unit of measure
   * @note       : Supplied p_units should exist in mdsys.SDO_UNITS_OF_MEASURE
   * @history    : Simon Greener - Oct 2007 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_Area( p_geometry   in mdsys.sdo_geometry,
                      p_tolerance  in number,
                      p_units      in varchar2 := 'Square Meter' )
     Return Number Deterministic;
  
   /**
   * @function   : ADD_ELEMENT
   * @precis     : A procedure that allows a user to add a new element to a supplied
   *               element info array.
   * @version    : 1.0
   * @history    : Simon Greener - Jul 2001 - Original coding.
   * @todo       : Integrate into GF
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   procedure ADD_Element (
     p_sdo_elem_info  in out nocopy mdsys.sdo_elem_info_array,
     p_offset         in number,
     p_etype          in number,
     p_interpretation in number );
  
   /** Additional Wrapper function
   */
   Procedure ADD_Element( p_SDO_Elem_Info  in out nocopy mdsys.sdo_elem_info_array,
                          p_Elem_Info      in &&defaultSchema..ElemInfoType );
  
  
   /** ----------------------------------------------------------------------------------------
   * @function   : isCompoundElement
   * @precis     : A function that tests whether an sdo_geometry element contains circular arcs
   * @version    : 1.0
   * @history    : Simon Greener - Aug 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/  
   */
   Function isCompoundElement(p_elem_type in number)
     return boolean deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : isCompound
   * @precis     : A function that tests whether an sdo_geometry contains circular arcs
   * @version    : 1.0
   * @history    : Simon Greener - Dec 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function isCompound(p_elem_info in mdsys.sdo_elem_info_array)
     return integer deterministic;
  
   /** Wrapper 
   */
   Function hasCircularArcs(p_elem_info in mdsys.sdo_elem_info_array)
     return boolean deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : isRetangle
   * @precis     : A function that tests whether an sdo_geometry contains rectangles
   * @version    : 1.0
   * @history    : Simon Greener - Jun 2011 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/  
   */
   Function isRectangle(p_elem_info in mdsys.sdo_elem_info_array)
     return integer deterministic;
  
   Function hasRectangles(p_elem_info in mdsys.sdo_elem_info_array)
     return boolean deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Rectangle2Polygon
   * @precis     : A function that converts a single ringed geometry with a rectangle to its 5 vertex 
   *               Polygon equivalent.
   * @version    : 1.0
   * @history    : Simon Greener - Jun 2011 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/  
   */
   Function Rectangle2Polygon(p_geometry in mdsys.sdo_geometry)
     return mdsys.sdo_geometry deterministic;
  
   Function Polygon2Rectangle( p_geometry  in mdsys.sdo_geometry,
                               p_tolerance in number default 0.005 ) 
     Return mdsys.sdo_geometry Deterministic; 
  
   /** ----------------------------------------------------------------------------------------
   * @function   : isMeasured
   * @precis     : A function that tests whether an sdo_geometry contains LRS measures
   * @version    : 1.0
   * @history    : Simon Greener - Dec 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function isMeasured( p_gtype in number )
     return boolean deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : IsOrientedPoint
   * @precis     : A function that tests whether an sdo_geometry is an oriented (multi-)point
   * @version    : 1.0
   * @history    : Simon Greener - May 2010 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function IsOrientedPoint( P_Elem_Info In Mdsys.Sdo_Elem_Info_Array)
     Return Boolean Deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : ADD_COORDINATE
   * @precis     : A procedure that allows a user to add a new coordinate to a supplied ordinate info array.
   * @version    : 1.0
   * @history    : Simon Greener - Jul 2001 - Original coding.
   * @todo       : Integrate into GF
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   procedure ADD_Coordinate(
     p_ordinates  in out nocopy mdsys.sdo_ordinate_array,
     p_dim        in number,
     p_x_coord    in number,
     p_y_coord    in number,
     p_z_coord    in number,
     p_m_coord    in number,
     p_measured   in boolean := false);
  
   /**
   * Overloads of main ADD_COORDINATE procedure
   */
   PROCEDURE ADD_Coordinate( p_ordinates  in out nocopy mdsys.sdo_ordinate_array,
                             p_dim        in number,
                             p_coord      in &&defaultSchema..ST_Point,
                             p_measured   in boolean := false);
  
   PROCEDURE ADD_Coordinate( p_ordinates  in out nocopy mdsys.sdo_ordinate_array,
                             p_dim        in number,
                             p_coord      in &&defaultSchema..T_Vertex,
                             p_measured   in boolean := false);
  
   PROCEDURE ADD_Coordinate( p_ordinates  in out nocopy mdsys.sdo_ordinate_array,
                             p_dim        in number,
                             p_coord      in mdsys.vertex_type,
                             p_measured   in boolean := false);
  
   PROCEDURE ADD_Coordinate( p_ordinates  in out nocopy mdsys.sdo_ordinate_array,
                             p_dim        in number,
                             p_coord      in &&defaultSchema..vertex_type,
                             p_measured   in boolean := false);
  
   PROCEDURE ADD_Coordinate( p_ordinates  in out nocopy mdsys.sdo_ordinate_array,
                             p_dim        in number,
                             p_coord      in mdsys.sdo_point_type,
                             p_measured   in boolean := false);
  
   /** ----------------------------------------------------------------------------------------
   * @function   : TOTALCOORDS
   * @precis     : Returns number of 2D/3D/4D coordinates (as against ordinates) in a shape.
   * @version    : 1.0
   * @usage      : Function totalCoords ( p_geometry IN MDSYS.SDO_GEOMETRY ) RETURN number DETERMINISTIC;
   *               eg tCoords := geom.totalCoords(shape);
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A shape.
   * @return     : totalCoords : Number : The vector.
   * @history    : Simon Greener - Jan 2002 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function TotalCoords    (
     p_geometry in MDSYS.SDO_Geometry )
     return number deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : GetNumElem
   * @precis     : Returns total number of elements in a geometry.
   * @version    : 1.0
   * @usage      : Function GetNumElem ( p_geometry IN MDSYS.SDO_GEOMETRY )
   *                 Return number Deterministic;
   * @example    : SELECT GetNumElem(a.geom)
   *                 FROM ProjCompound2D a
   *                WHERE a.geom is not null;
   * @param      : p_geometry       : MDSYS.SDO_GEOMETRY : A shape.
   * @return     : NumberOfElements : ElemInfoSetType : Set of Elements of type ElemInfoSet.
   * @history    : Simon Greener - Jan 2006 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function GetNumElem(
     p_geometry in mdsys.sdo_geometry )
     return number deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : GetElemInfo
   * @precis     : Returns Element Info as a set of Elements.
   * @version    : 1.0
   * @usage      : Function GetElemInfo ( p_geometry IN MDSYS.SDO_GEOMETRY )
   *                 Return ElemInfoSetType Deterministic;
   * @example    : SELECT DISTINCT
   *                      ei.etype,
   *                      ei.interpretation
   *                 FROM ProjCompound2D a,
   *                      TABLE( &&defaultSchema..geom.GetElemInfo( a.geom ) ) ei
   *                WHERE a.geom is not null;
   * @param      : p_geometry : MDSYS.SDO_GEOMETRY : A shape.
   * @return     : elements   : ElemInfoSetType : Set of Elements of type ElemInfoSet.
   * @note       : Function is pipelined
   * @history    : Simon Greener - Jan 2006 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function GetElemInfo(
     p_geometry in mdsys.sdo_geometry)
     Return &&defaultSchema..ElemInfoSetType pipelined;
  
   Function GetElemInfoAt(
     p_geometry in mdsys.sdo_geometry,
     p_element  in pls_integer)
     Return &&defaultSchema..ElemInfoType deterministic;
  
   Function GetETypeAt(
     p_geometry  in mdsys.sdo_geometry,
     p_element   in pls_integer)
     Return pls_integer deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : GetNumRings
   * @precis     : Returns Number of Rings in a polygon/mutlipolygon.
   * @version    : 1.0
   * @usage      : Function GetNumRings ( p_geometry  IN MDSYS.SDO_GEOMETRY,
   *                                      p_ring_type IN INTEGER )
   *                 Return Number Deterministic;
   * @example    : SELECT GetNumRings( SDO_GEOMETRY(2007,  -- two-dimensional multi-part polygon with hole
   *                                                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)
   *                                               )
   *                                   )
   *                      as RingCount
   *                 FROM DUAL;
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A shape.
   * @param      : p_ring_type : integer : All, inner or outer rings
   * @return     : numberRings : Number : Number of outer and inner rings.
   * @history    : Simon Greener - Dec 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
  Function GetNumRings(p_geometry  in mdsys.sdo_geometry,
                       p_ring_type in integer /* 0 = ALL; 1 = OUTER; 2 = INNER */ )
    Return Number Deterministic;
  
   /* Overloads */
   Function GetNumRings( p_geometry in mdsys.sdo_geometry )
     Return Number Deterministic;
  
   Function GetNumOuterRings( p_geometry in mdsys.sdo_geometry )
     Return Number Deterministic;
  
   Function GetNumInnerRings( p_geometry in mdsys.sdo_geometry )
     Return Number Deterministic;
  
   /**
   * @function   : Convert_Geometry
   * @precis     : A function that converts any special elements - circulararcs, rectangles, \
   *               circles - in a geometry to vertex to vertex linestrings
   * @version    : 1.0
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A geographic shape.
   * @param      : p_arc2chord : number : The arc2chord distance used in converting circular arcs and circles. 
   *                                      Expressed in dataset units eg decimal degrees if 8311. See Convert_Distance 
   *                                      for method of converting distance in meters to dataset units.
   * @history    : Simon Greener - Feb 2008 - Original coding
   */
   Function Convert_Geometry(
      p_geometry  In mdsys.SDO_Geometry,
      p_arc2chord In Number := 0.1 )
      Return mdsys.SDO_GEOMETRY Deterministic;
  
   /***
   * @function   : GetVector
   * @precis     : Places a geometry's coordinates into a pipelined vector data structure using ST_Point (ie > 2D).
   * @version    : 2.0
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A geographic shape.
   * @history    : Simon Greener - Jan 2007 - ST_Point support, integrated into this package.
   */
   Function GetVector( p_geometry in mdsys.sdo_geometry )
     Return &&defaultSchema..GEOM.t_VectorSet pipelined ;
  
   /***
   * @function   : GetVector
   * @precis     : Places a geometry's coordinates into a pipelined vector data structure using ST_Point (ie > 2D).
   * @version    : 2.0
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A geographic shape.
   * @param      : p_arc2chord : number : The arc2chord distance used in converting circular arcs and circles. 
   *                                      Expressed in dataset units eg decimal degrees if 8311. See Convert_Distance 
   *                                      for method of converting distance in meters to dataset units.
   * @history    : Simon Greener - Jan 2007 - ST_Point support, integrated into this package.
   * @history    : Simon Greener - Apr 2008 - Rebuilt to be a wrapper over GetVector.
   */
   function GetVector( p_geometry  in mdsys.sdo_geometry,
                       p_arc2chord in number )
     Return &&defaultSchema..GEOM.t_VectorSet pipelined;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : GetVector2DArray
   * @precis     : Places a geometry's coordinates into a vector data structure.
   * @version    : 2.0
   * @description: Loads the coordinates of a linestring, polygon geometry into a
   *               simple vector data structure for easy manipulation by other functions
   * @usage      : Function GetVector2DArray ( p_geometry IN MDSYS.SDO_GEOMETRY, p_arc2chord in number := 0.1 )
   *                 Return Vector2DSetType DETERMINISTIC
   *               eg aVector := geom.GetVector2DArray(shape);
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A shape.
   * @param      : p_dimarray  : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @param      : p_arc2chord : number : The arc2chord distance used in converting circular arcs and circles. 
   *                                      Expressed in dataset units eg decimal degrees if 8311. See Convert_Distance 
   *                                      for method of converting distance in meters to dataset units.
   * @return     : geomVector  : Vector2DSetType : The vector.
   * @requires   : Global data types coordRec, vectorRec and Vector2DSetType
   * @requires   : GEOM package's GetVector() and Converte_Geometry() functions.
   * @history    : Simon Greener - Jun 2002 - Original coding.
   * @history    : Simon Greener - Jan 2006 - Point support, integrated into this package.
   * @history    : Simon Greener - Apr 2008 - Rebuilt to be a wrapper over GetVector.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function GetVector2DArray ( p_geometry  in mdsys.sdo_geometry,
                               p_arc2chord in number := 0.1 )
     Return &&defaultSchema..Vector2DSetType deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : GetVector2D
   * @precis     : Places a geometry's coordinates into a pipelined vector data structure.
   * @version    : 2.0
   * @description: Loads the coordinates of a linestring, polygon geometry into a
   *               pipelined vector data structure for easy manipulation by other functions
   * @usage      : Function GetVector2D( p_geometry IN MDSYS.SDO_GEOMETRY, p_arc2chord in number := 0.1 )
   *                 Return Vector2DSetType PIPELINED
   *               eg select *
   *                    from myshapetable a,
   *                         table(geom.GetPipeVector2D(a.shape));
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A geographic shape.
   * @param      : p_dimarray  : MDSYS.SDO_DIM_ARRAY : The dimarray describing the geographic shape.
   * @param      : p_arc2chord : number : The arc2chord distance used in converting circular arcs and circles.
   *                                      Expressed in dataset units eg decimal degrees if 8311. See Convert_Distance 
   *                                      for method of converting distance in meters to dataset units.
   * @return     : geomVector  : Vector2DSetType : The vector pipelined.
   * @requires   : Global data types coordRec, vectorRec and Vector2DSetType
   * @requires   : GF package.
   * @history    : Simon Greener - July 2006 - Original coding from GetVector2D
   * @history    : Simon Greener - Apr 2008 - Rebuilt to be a wrapper over GetVector.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function GetVector2D( p_geometry  in mdsys.sdo_geometry,
                         p_arc2chord in number := 0.1 )
     Return &&defaultSchema..Vector2DSetType pipelined;
  
   /***
   * @function   : GetArcs
   * @precis     : Like GetVector but this one only extracts 3 point arcs and circles from geometries.
   * @version    : 2.0
   * @history    : Simon Greener - Jan 2007 - Original coding.
   */
   Function GetArcs( p_geometry in mdsys.sdo_geometry )
     return &&defaultSchema..ArcSetType pipelined;
  
   /***
   * @function   : GetPointSet
   * @precis     : Places a geometry's coordinates into a pipelined  data structure using ST_Point (ie > 2D).
   * @version    : 1.0
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A geographic shape.
   * @param      : p_stroke    : number : If false (default), points in the geometry are returned as they are, 
   *                otherwise they are stroked.
   * @param      : p_arc2chord : number : The arc2chord distance used in converting circular arcs and circles. 
   *                                      Expressed in dataset units eg decimal degrees if 8311. See Convert_Distance 
   *                                      for method of converting distance in meters to dataset units.
   * @history    : Simon Greener - Jan 2007 - ST_Point support, integrated into this package.
   * @history    : Simon Greener - Jan 2008 - Added support for the conversion of rectangles, circular arcs and circles.
   */
   Function GetPointSet( p_geometry  In mdsys.Sdo_Geometry,
                         p_stroke    in number := 0,
                         p_arc2chord in number := 0.1)
            Return &&defaultSchema..ST_PointSet Pipelined;
  
   /**
   * OGC isSimple() function
   */
   function isSimple (
     p_geometry in mdsys.sdo_geometry,
     p_dimarray in MDSYS.SDO_Dim_Array )
     return integer deterministic;
  
   /**
   * Overload of main isSimple function
   */
   function isSimple (
     p_geometry  in mdsys.sdo_geometry,
     p_tolerance in number )
     return integer deterministic;
  
   /* ----------------------------------------------------------------------------------------
   * @function   : MOVE
   * @precis     : Function which updates all coordinates in a shape by applying x/y shift.
   * @version    : 2.0
   * @description: In order to be able to apply the King Island move to the shapes stored
   *               in an Oracle Spatial shape, a function is needed that iterates though
   *               all the coordinates of a shape and applys a deltaX and deltaY to them.
   *               If p_envelope is provided, only those coordinate that fall within it are moved:
   *               otherwise all are moved.
   * @usage      : Function move ( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                               p_deltaX IN number,
   *                               p_deltaY IN number,
   *                               p_envelope IN MDSYS.SDO_GEOMETRY ) RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
   *               eg fixedShape := &&defaultSchema..geom.tolerance(shape,diminfo);
   * @param      : p_geometry    : MDSYS.SDO_GEOMETRY : The shape to move.
   * @param      : p_deltaX      : number : Shift to be applied to the X coordinate.
   * @param      : p_deltaY      : number : Shift to be applied to the Y coordinate.
   * @param      : p_deltaZ      : number : Shift to be applied to the Z coordinate.
   * @param      : p_mbr         : MBR object : minimum bounding rectangle/envelope in which p_geometry's 
   *                coordinates have to be within to be able to be moved.
   * @param      : p_filter_geom : MDSYS.SDO_GEOMETRY : A shape defining a sub-area in which p_geometry's 
   *                coordinates have to be within for move.
   * @param      : p_filter_mask : varchar : A mask for use with SDO_GEOM.RELATE()
   * @param      : p_tolerance   : Number   : Tolerance used when processing vertices with SDO_GEOM.RELATE
   * @requires   : &&defaultSchema..GF package.
   * @return     : newShape      : MDSYS.SDO_GEOMETRY : Shape whose coordinates are 'moved'.
   * @history    : Simon Greener - Mar 2003 - Original coding.
   * @history    : Simon Greener - Jul 2006 - Migrated to GF package and made 3D aware.
   * @history    : Simon Greener - Sep 2007 - Removed need for SDO_GEOM.RELATE via use of MBR type.
   * @history    : Simon Greener - Jun 2008 - Removed modification of ordinates to precision of 
   *                diminfo/tolerance as duplicates Tolerance() function.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   FUNCTION Move( p_geometry    IN MDSYS.SDO_GEOMETRY,
                  p_tolerance   IN NUMBER,
                  p_deltaX      IN NUMBER,
                  p_deltaY      IN NUMBER,
                  p_deltaZ      IN NUMBER             := NULL,
                  p_mbr         IN &&defaultSchema..MBR        := NULL,
                  p_filter_geom IN MDSYS.SDO_GEOMETRY := NULL,
                  p_filter_mask IN VARCHAR2           := 'INSIDE'
                 )
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   /* Wrapper functions using OGC Syntax */
   FUNCTION ST_Translate( p_geometry  IN MDSYS.SDO_GEOMETRY,
                          p_tolerance IN NUMBER,
                          p_deltaX    IN NUMBER,
                          p_deltaY    IN NUMBER,
                          p_deltaZ    IN NUMBER := NULL,
                          p_mbr       IN &&defaultSchema..MBR := NULL
                        )
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   FUNCTION ST_Translate( p_geometry    IN MDSYS.SDO_GEOMETRY,
                          p_tolerance   IN NUMBER,
                          p_deltaX      IN NUMBER,
                          p_deltaY      IN NUMBER,
                          p_deltaZ      IN NUMBER,
                          p_filter_geom IN MDSYS.SDO_GEOMETRY,
                          p_filter_mask IN VARCHAR2 := 'INSIDE'
                        )
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   /* ----------------------------------------------------------------------------------------
   * @function   : SCALE
   * @precis     : Function which updates all coordinates in a shape by applying an x/y/z factor.
   * @version    : 1.0
   * @description: As against, move, which adds a supplied delta to existing coords, Scale multiplies
   *               existing coordinates by the supplied factors. Rounding is applied to the result using
   *               the supplied tolerances.
   * @usage      : Function Scale( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                               p_diminfo  IN MDSYS.SDO_DIM_ARRAY,
   *                               p_deltaX   IN number,
   *                               p_deltaY   IN number,
   *                               p_deltaY   IN number,
   *                             )
   *                 Return MDSYS.SDO_GEOMETRY DETERMINISTIC;
   *               eg fixedShape := &&defaultSchema..geom.tolerance(shape,diminfo);
   * @param      : p_geometry    : MDSYS.SDO_GEOMETRY : The shape to move.
   * @param      : p_diminfo     : SDO_DIM_ARRAY : Tolerance used to round x/y/z values after scaling
   * @param      : p_XFactor     : number : Factor to be applied to the X coordinate.
   * @param      : p_YFactor     : number : Factor to be applied to the Y coordinate.
   * @param      : p_ZFactor     : number : Factor to be applied to the Z coordinate.
   * @requires   : &&defaultSchema..GEOM.isMeasure and &&defaultSchema..GEOM.ADD_Coordinate
   * @return     : newShape      : MDSYS.SDO_GEOMETRY : Shape whose coordinates have been scaled.
   * @history    : Simon Greener - Jan 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   FUNCTION Scale( p_geometry    IN MDSYS.SDO_GEOMETRY,
                   p_diminfo     IN MDSYS.SDO_DIM_ARRAY,
                   p_XFactor     IN NUMBER,
                   p_YFactor     IN NUMBER,
                   p_ZFactor     IN NUMBER  := NULL
                 )
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   /* Wrapper functions */
   FUNCTION Scale( p_geometry    IN MDSYS.SDO_GEOMETRY,
                   p_tolerance   IN NUMBER,
                   p_XFactor     IN NUMBER,
                   p_YFactor     IN NUMBER,
                   p_ZFactor     IN NUMBER  := NULL
                 )
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   /* ----------------------------------------------------------------------------------------
   * @function   : Rotate
   * @precis     : Function which rotates a shape.
   * @version    : 1.0
   * @description: Simply rotates a shape around supplied axis point (or centre of MBR) by a
   *               specified rotation in whole circle degrees.
   * @usage      : Function Rotate ( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                                 p_dimarray IN MDSYS.SDO_DIM_ARRAY,
   *                                 p_X IN number,
   *                                 p_Y IN number,
   *                                 p_rotation IN number)
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : The shape to rotate.
   * @param      : p_dimarray  : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @param      : p_X         : number : Rotation point X
   * @param      : p_Y         : number : Rotation point Y
   * @param      : p_rotation  : number : Rotation between 0..360 degrees
   * @requires   : &&defaultSchema..GEOMETRY package.
   * @return     : newShape    : MDSYS.SDO_GEOMETRY : Shape whose coordinates are 'moved'.
   * @note       : Cartesian arithmetic only
   * @history    : Simon Greener, SpatialDB Advisor - Sept 2005 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   *               Any bugs or improvements to be supplied back to Simon Greener
   */
   Function Rotate (
     p_geometry in MDSYS.SDO_Geometry,
     p_dimarray in MDSYS.SDO_Dim_Array,
     p_X        in number,
     p_Y        in number,
     p_rotation in number := 0)
     return MDSYS.SDO_Geometry deterministic;
  
   /**
   * Overloads of main Rotate function
   */
   Function Rotate( p_geometry  IN MDSYS.SDO_GEOMETRY,
                    p_tolerance IN number,
                    p_rotation  IN number := 0)  -- 0 to 360 degrees
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   Function Rotate( p_geometry  IN MDSYS.SDO_GEOMETRY,
                    p_tolerance IN number,
                    p_X         IN number,
                    p_Y         IN number,
                    p_rotation  IN number := 0)  -- 0 to 360 degrees
     Return MDSYS.SDO_GEOMETRY Deterministic;
  
   Function Rotate( p_geometry IN MDSYS.SDO_GEOMETRY,
                    p_dimarray IN MDSYS.SDO_DIM_ARRAY,
                    p_rotatePt IN MDSYS.SDO_Point_Type,
                    p_rotation IN number := 0)  -- 0 to 360 degrees
     Return MDSYS.SDO_Geometry Deterministic;
  
   /* ----------------------------------------------------------------------------------------
   * @function   : Affine
   * @precis     : Applies a 3d affine transformation to the geometry to do things like 
   *                translate, rotate, scale in one step.
   * @version    : 1.0
   * @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
   * @usage      : Function Affine ( p_geom IN MDSYS.SDO_GEOMETRY,
   * @param      : p_geom  : MDSYS.SDO_GEOMETRY : The shape to rotate.
   * @param      : a, b, c, d, e, f, g, h, i, xoff, yoff, zoff :
   *               Represent the transformation matrix
   *                 / a  b  c  xoff \
   *                 | d  e  f  yoff |
   *                 | g  h  i  zoff |
   *                 \ 0  0  0     1 /
   *               and 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
   * @requires   : &&defaultSchema..GEOM.ADD_Coordinate Procedure
   *               SDO_UTIL.GetVertices Funciton
   *               SYS.UTL_NLA Package
   *               SYS.UTL_NLA_ARRAY_DBL Type
   *               SYS.utl_nla_array_int Type
   * @return     : newGeom  : MDSYS.SDO_GEOMETRY : Transformed input geometry.
   * @note       : Cartesian arithmetic only
   * @history    : Simon Greener, SpatialDB Advisor - Feb 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/. 
   *               Any bugs or improvements to be supplied back to Simon Greener
   */
   Function Affine(p_geom in mdsys.sdo_geometry,
                   p_a number,
                   p_b number,
                   p_c number,
                   p_d number,
                   p_e number,
                   p_f number,
                   p_g number,
                   p_h number,
                   p_i number,
                   p_xoff number,
                   p_yoff number,
                   p_zoff number)
     return mdsys.sdo_geometry deterministic;
  
   /* ----------------------------------------------------------------------------------------
   * @function   : Densify
   * @precis     : Implements a basic geometry densification algorithm.
   * @version    : 1.0
   * @description: This function uses a binary-chop recursive algorithm to add vertices to
   *               an existing vertex-to-vertex described linestring or polygon sdo_geometry.
   *               New vertices are added in such a way as to ensure that no two vertices will
   *               ever fall with p_tolerance. Also, because of the binary-chop implementation
   *               there is no guarantee that the added vertices will be p_distance apart. The
   *               implementation prefers to balance the added vertices across a complete segment
   *               such that an even number are added. The final vertex separation will be
   *               BETWEEN p_distance AND p_distance * 2 .
   *
   *               The implementation honours 3D and 4D shapes and averages these dimension values
   *               for the new vertices.
   *
   *               The function does not support compound objects or objects with circles,
   *               optimised rectangles or described by arcs. An exception is raised if one of
   *               these is passed to the function.
   *
   *               Any point shape is simply returned as it is.
   *
   * @usage      : Function Densify ( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                                  p_tolerance IN number,
   *                                  p_distance  IN number )
   *                                ) RETURN MDSYS.SDO_GEOMETRY
   *               eg new_detailed_geom := geom.Densify(geometry,1,10);
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A vector geometry described by vertex-to-vertex (Elem Interp 1).
   * @param      : p_tolerance : number : The sdo_tolerance for the geometry (see diminfo)
   * @param      : p_distance  : number : The desired optimal distance between added vertices. Must be > p_tolerance.
   * @return     : Geometry    : MDSYS.SDO_GEOMETRY : Densified geometry.
   * @requires   : &&defaultSchema..GF package.
   * @history    : Simon Greener - June 2006 - Original coding.
   * @history    : Simon Greener - July 2006 - Migrated to GF package.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function Densify( p_geometry  in MDSYS.SDO_Geometry,
                     p_tolerance in number,
                     p_distance  in number )
            return MDSYS.SDO_Geometry deterministic;
  
    /*
    --  @function To_2D
    --  @precis   Converts a geometry to a 2D geometry
    --  @version  2.0
    --  @usage    v_2D_geom := geom.To_2D(MDSYS.SDO_Geometry(3001,....)
    --  @history  Albert Godfrind, July 2006, Original Coding
    --  @history  Bryan Hall,      July 2006, Modified to handle points
    --  @history  Simon Greener,   July 2006, Integrated into geom with GF.
    --  @history  Simon Greener,   Aug  2009, Removed GF; Modified Byan Hall's version to handle compound elements.
    */
    Function To_2D( p_geom IN MDSYS.SDO_Geometry )
      Return MDSYS.SDO_Geometry deterministic;
  
    /*
    --  @function To_3D
    --  @precis   Converts a 2D or 4D geometry to a 3D geometry
    --  @version  1.0
    --  @usage    v_3D_geom := geom.To_3D(MDSYS.SDO_Geometry(2001,....),50)
    --  @history  Simon Greener,   May 2007 Original coding
    --  @history  Simon Greener,   Aug 2009 Added support for interpolating Z values
    */
   Function To_3D( p_geom      IN MDSYS.SDO_Geometry,
                   p_start_z   IN NUMBER := NULL,
                   p_end_z     IN NUMBER := NULL,
                   p_tolerance IN NUMBER := 0.05)
      Return MDSYS.SDO_Geometry deterministic;
  
    /*
    --  @function DownTo_3D
    --  @precis   Converts a 4D geometry to a 3D geometry
    --  @version  1.0
    --  @usage    v_3D_geom := geom.DownTo_3D(MDSYS.SDO_Geometry(4001,....),50)
    --  @history  Simon Greener,   May 2010 Original coding
    */
   Function DownTo_3D( p_geom  IN MDSYS.SDO_Geometry,
                       p_z_ord IN INTEGER )
     Return MDSYS.SDO_GEOMETRY deterministic;
  
    /** @Function : FIX_3D_Z
    **  @Precis   : Checks the Z ordinate in the SDO_GEOMETRY and if NULL changes to p_default_z value
    **  @Note     : Needed as MapServer appears to not handle 3003/3007 polygons with NULL Z 
   *                values in the sdo_ordinate_array
    **  @History  : Simon Greener  -  JUNE 4th 2007  - Original Coding
    **/
    Function Fix_3D_Z( p_3D_geom   IN MDSYS.SDO_Geometry,
                       p_default_z IN NUMBER := -9999 )
             Return MDSYS.SDO_Geometry Deterministic;
  
   /* ----------------------------------------------------------------------------------------
   * @function   : ExtractLine
   * @precis     : Function which extracts any lines in a COMPOUND 2004 object.
   * @version    : 1.0
   * @description: Result of an intersect can result in a COMPOUND shape with points, linestrings
   *               and polygons as the result.  This function iterates over all the parts of
   *               a multi-part (SDO_GTYPE  2004) shape, extracts only the linestring elements
   *               and returns them in a new shape.
   * @==usage      : Function ExtractLine ( p_geometry IN MDSYS.SDO_GEOMETRY )
   *                        RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
   *               eg v_geometry := &&defaultSchema..geom.ExtractLine(p_geometry);
   * @param      : p_geometry : MDSYS.SDO_GEOMETRY : A shape.
   * @return     : newShape   : MDSYS.SDO_GEOMETRY : Shape with only linestring elements.
   * @requires   : Oracle 10g esp SDO_UTIL.CONCAT_LINES
   * @history    : Simon Greener - Feb 2006 - Original coding
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function ExtractLine(
     p_geometry in MDSYS.SDO_Geometry )
     return MDSYS.SDO_Geometry deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : ExtractPoint
   * @precis     : Function which extracts any points in a COMPOUND 2004 object.
   * @version    : 1.0
   * @description: Result of an intersect can result in a COMPOUND shape with points, linestrings
   *               and polygons as the result.  This function iterates over all the parts of
   *               a multi-part (SDO_GTYPE  2004) shape, extracts only the point elements
   *               and returns them in a new shape.
   * @==usage      : Function ExtractPoint ( p_geometry IN MDSYS.SDO_GEOMETRY )
   *                        RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
   *               eg v_geometry := &&defaultSchema..geom.ExtractPoint(p_geometry);
   * @param      : p_geometry : MDSYS.SDO_GEOMETRY : A shape.
   * @return     : newShape   : MDSYS.SDO_GEOMETRY : Shape with only point elements.
   * @requires   : Oracle 10g esp SYS.SDO_UTIL.APPEND
   * @history    : Simon Greener - Feb 2006 - Original coding
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function ExtractPoint (
     p_geometry in MDSYS.SDO_Geometry )
     return MDSYS.SDO_Geometry deterministic;
  
   /** Function just to change a single point coded in sdo_ordinates to sdo_point representation
   * @param p_geometry  A sdo_geometry object.
   */
   Function ToSdoPoint ( p_geometry in MDSYS.SDO_Geometry )
     return MDSYS.SDO_Geometry Deterministic;
  
   /** Function which extracts a polygon from a COMPOUND 2004 object using 10g features.
   * @param p_geometry  A sdo_geometry object.
   */
   function ExtractPolygon (
     p_geometry in MDSYS.SDO_Geometry )
     return MDSYS.SDO_Geometry deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : ExtractPolygon9i
   * @precis     : Function which extracts any polygons in a COMPOUND 2004 object.
   * @version    : 1.0
   * @description: Result of an intersect can result in a COMPOUND shape with linestrings
   *               as well as polygons as the result.  This function iterates over all the parts of
   *               a multi-part (SDO_GTYPE  2004) shape, extracts the polygon elements
   *               and returns them in a new shape.
   * @==usage      : Function ExtractPolygon9i ( p_geometry IN MDSYS.SDO_GEOMETRY,
   *                                           p_dimarray IN MDSYS.SDO_DIM_ARRAY )
   *                        RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
   *               eg p_geometry := &&defaultSchema..geom.ExtractPolygon(p_geometry);
   * @param      : p_geometry : MDSYS.SDO_GEOMETRY  : A shape.
   * @param      : p_dimarray : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @requires   : &&defaultSchema..GEOMETRY package.
   * @return     : newShape : MDSYS.SDO_GEOMETRY : Shape with only polygon elements.
   * @history    : Simon Greener - Mar 2004 - Original coding.
   * @history    : Simon Greener - Oct 2005 - Changed to ExtractPolygon9i
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function ExtractPolygon9i(
     p_geometry in MDSYS.SDO_Geometry,
     p_dimarray in MDSYS.SDO_Dim_Array )
     return MDSYS.SDO_Geometry deterministic;
  
   /** ExtractGeometry
   * Overload of main ExtractFunctions (except ExtractPolyon9i)
   * @param  p_geometryType Type of geometry object (POINT, LINE, POLYGON) to extract.
   * @param  p_geometry     An Sdo_geometry object.
   */
   function ExtractGeometry(
     p_geometryType in varchar2,
     p_geometry     in MDSYS.SDO_Geometry )
     return MDSYS.SDO_Geometry deterministic;
  
   /**
   * ExtractElements returns each element identified in sdo_elem_info as a separate sdo_geometry
   * @param p_geometry    The main geometry object
   * @param p_subElements If set to 1 (true) subelements of a compound element will be extracted.
   */
   function ExtractElements(
     p_geometry    in MDSYS.SDO_Geometry,
     p_subElements in number )
     return &&defaultSchema..GeometrySetType deterministic;
  
   /**
   * ExtractElementsPiped returns each element identified in sdo_elem_info as a separate sdo_geometry but via a pipeline
   * @param p_geometry    The main geometry object
   * @param p_subElements If set to 1 (true) subelements of a compound element will be extracted.
   */
   function ExtractElementsPiped(
     p_geometry    in MDSYS.SDO_Geometry,
     p_subElements in number )
     return &&defaultSchema..GeometrySetType pipelined;
  
   /** ***************************************************************
   *  ExplodeGeometry
   *  ***************************************************************
   *  Created:     17/12/2004
   *  Author:      Simon Greener
   *  Description: Breaks a geometry into its fundamenal elements which
   *               includes the breaking down of compound LineStrings or
   *               Polygons down into their individual subElements: returns
   *               children of compound elements as themselves; and all other
   *               elements as themselves.
   *  Note:        This function is for 8i and 9iR1. For 9iR2 and above use ExtractElements
   *               with p_subElements = 1 to get an equivalent output.
   */
   Function ExplodeGeometry(
     p_geometry in MDSYS.SDO_Geometry )
     Return &&defaultSchema..GeometrySetType pipelined;
  
   /**
   * ST_Dump       Extracts valid, individual geometries, from a geometry's elements and sub-elements
   *  Created:     10/12/2008
   *  Author:      Simon Greener
   *  Description: Mimicks PostGIS ST_Dump function.
   *               Is a wrapper over ExtractElementsPiped
   */
   Function ST_Dump( p_geometry in MDSYS.SDO_GEOMETRY)
     Return &&defaultSchema..GeometrySetType pipelined;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Split
   * @precis     : A procedure that splits a line geometry at a known point
   * @version    : 1.0
   * @description: This procedure will split a linestring or multi-linestring sdo_geometry object
   *               at a supplied (known) point. 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 approproximates the nearest point on the linestring to the supplied point
   *               and splits it there: the algorithm is ratio based and will not be accurate for geodetic data.
   * @usage      : procedure Split( p_line      in mdsys.sdo_geometry, 
   *                                p_point     in mdsys.sdo_geometry,
   *                                p_tolerance in number,
   *                                p_out_line1 out mdsys.sdo_geometry,
   *                                p_out_line2 out mdsys.sdo_geometry )
   * @param      : p_line      : MDSYS.SDO_GEOMETRY : A linestring(2002) or multi-linestring (2006) 
   *                sdo_geometry object describing the line to be split.
   * @param      : p_point     : MDSYS.SDO_GEOMETRY : A point(2001) sdo_geometry object describing the 
   *                point for splitting the linestring.
   * @param      : p_tolerance : NUMBER : Tolerance value used in mdsys.sdo_geom.sdo_distance function.
   * @return     : p_out_line1 : MDSYS.SDO_GEOMETRY : First part of split linestring
   * @return     : p_out_line2 : MDSYS.SDO_GEOMETRY : Second part of split linestring
   * @history    : Simon Greener - Jan 2008 - Original coding.
   * @history    : Simon Greener - Dec 2009 - Fixed SRID handling bug for Geodetic data.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Procedure Split( p_line      in mdsys.sdo_geometry,
                    p_point     in mdsys.sdo_geometry,
                    p_tolerance in number,
                    p_out_line1 out nocopy mdsys.sdo_geometry,
                    p_out_line2 out nocopy mdsys.sdo_geometry );
  
   /**
   * Overload of the Split procedure
   */
   Function Split( p_line      in mdsys.sdo_geometry,
                   p_point     in mdsys.sdo_geometry,
                   p_tolerance in number )
     Return &&defaultSchema..GeometrySetType pipelined;
  
   /** AsEWKT
   * @function   : AsEWKT
   * @precis     : Function that returns a fully described WKT which includes SRID, 3D and 4D
   *               data with all inner elements including the WKT descriptor.
   *               As "Extended" WKT based on AutoDesk's FDO AGFText
   * @version    : 1.0
   * @history    : Simon Greener - Apr 2007 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function AsEWKT(
     p_geometry In mdsys.sdo_geometry )
            Return CLOB deterministic;
  
   /** AsEWKT
   * @param p_GeomSet  A set of sdo_geometry objects.
   */
   Function AsEWKT(
     p_GeomSet In &&defaultSchema..GeometrySetType )
            Return CLOB deterministic;
  
   /** RemoveDuplicateCoordinates
   * Sequential vertices with same coordinate values are replaced by a single vertex.
   * @param p_geometry  An sdo_geometry objects.
   * @param p_diminfo   An user_sdo_geom_metadata.diminfo object from which the sdo_tolerance values are extracted.
   */
   Function removeDuplicateCoordinates (
     p_geometry   in MDSYS.SDO_Geometry,
     p_diminfo in MDSYS.SDO_Dim_Array)
     return MDSYS.SDO_Geometry deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : TOLERANCE
   * @precis     : Function which updates all coordinates in a shape to precision of the
   *               tolerances referenced in the diminfo structure.
   * @version    : 1.0
   * @description: Nothing in the Oracle Spatial library ensures that a shape loaded into
   *               a column in a table has its ordinates set to the precision specified in
   *               the table's SDO_GEOM_METADATA DIMARRAY.
   *               This function ensures that all the ordinates of a shape are specified to the
   *               precision documented in its dimarray.
   * @usage      : Function tolerance ( p_geometry IN MDSYS.SDO_GEOMETRY, p_dimarray IN MDSYS.SDO_DIM_ARRAY ) 
   *                 Return MDSYS.SDO_GEOMETRY DETERMINISTIC;
   *               eg fixedShape := &&defaultSchema..geom.tolerance(shape,diminfo);
   * @param      : p_geometry  : MDSYS.SDO_GEOMETRY : A shape.
   * @param      : p_dimarray  : MDSYS.SDO_DIM_ARRAY : The dimarray describing the shape.
   * @requires   : &&defaultSchema..GF package.
   * @return     : newShape    : MDSYS.SDO_GEOMETRY : Shape whose coordinates are 'truncated'.
   * @history    : Simon Greener - Feb 2002 - Original coding.
   * @history    : Simon Greener - Jul 2006 - Migrated to GF package and made 3D aware.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function Tolerance (
     p_geometry in MDSYS.SDO_Geometry,
     p_dimarray in MDSYS.SDO_Dim_Array )
     return MDSYS.SDO_Geometry deterministic;
  
   /** Overloads of above */
   Function Tolerance (
     p_geometry in MDSYS.SDO_Geometry,
     p_tolerance in Number )
     return MDSYS.SDO_Geometry deterministic;
  
   Function Tolerance( p_geometry  IN MDSYS.SDO_GEOMETRY,
                       p_X_tolerance IN NUMBER,
                       p_Y_tolerance IN NUMBER,
                       p_Z_tolerance IN NUMBER := NULL)
     RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
  
   Function Roundordinates( P_Geometry        In Mdsys.Sdo_Geometry,
                            P_X_Round_Factor  In Number,
                            P_Y_Round_Factor  In Number := Null,
                            P_Z_Round_Factor  In Number := Null,
                            p_m_round_factor  In Number := null)
     Return Mdsys.Sdo_Geometry Deterministic;
  
   /** ToleranceUpdate
   *   Version of Tolerance that processes a whole table.
   *   @param p_tableName The table containing sdo_geometry objects.
   */
   procedure ToleranceUpdate(
     p_tableName in varchar2 );
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Parallel
   * @precis     : Function that moves the supplied linestring left/right a fixed amount. 
   *               Bends in the linestring, when moved, can remain vertex-connected or be converted to curves.
   * @version    : 1.0
   * @usage      : FUNCTION Parallel(p_geometry   in mdsys.sdo_geometry,
   *                                 p_distance   in number,
   *                                 p_tolerance  in number,
   *                                 p_curved     in number := 0)
   *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
   *               eg select Parallel(mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(1,1,1,10)),10,0.05) from dual;
   * @param      : p_geometry  : mdsys.sdo_geometry : Original linestring/multilinestring
   * @param      : p_distance  : Number : Distance to move parallel -vs = left; +ve = right
   * @param      : p_tolerance : Number : Standard Oracle diminfo tolerance.
   * @param      : p_curved    : Integer (but really boolean) : Boolean flag indicating whether to stroke 
   *                                                            bends in line (1=stroke;0=leave alone)
   * @return     : mdsys.sdo_geometry : input geometry moved parallel by p_distance units
   * @history    : Simon Greener - Devember 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au
   */
   FUNCTION Parallel(p_geometry   in mdsys.sdo_geometry,
                     p_distance   in number,
                     p_tolerance  in number,
                     p_curved     in number := 0)
     RETURN mdsys.sdo_geometry DETERMINISTIC;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SquareBuffer
   * @precis     : Function that creates a buffer with mitred rather than round ends.
   * @version    : 1.0
   * @usage      : FUNCTION SquareBuffer(p_geometry   in mdsys.sdo_geometry,
   *                                     p_distance   in number,
   *                                     p_tolerance  in number,
   *                                     p_curved     in number := 0)
   *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
   *               eg select SquareBuffer(mdsys.sdo_geometry(2002,null,null,
   *                                            sdo_elem_info_array(1,2,1),
   *                                            sdo_ordinate_array(1,1,1,10)),
   *                                      10,0.05) from dual;
   * @param      : p_geometry  : mdsys.sdo_geometry : Original linestring/multilinestring
   * @param      : p_distance  : Number : Buffer Distance
   * @param      : p_tolerance : Number : Standard Oracle diminfo tolerance.
   * @param      : p_curved    : Integer (but really boolean) : Boolean flag indicating whether 
   *               to stroke bends in line (1=stroke;0=leave alone)
   * @return     : mdsys.sdo_geometry : square buffer created over input geometry 
   * @history    : Simon Greener - June 2011 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SquareBuffer(p_geometry   in mdsys.sdo_geometry,
                         p_distance   in number,
                         p_tolerance  in number,
                         p_curved     in number := 0 )
     RETURN mdsys.sdo_geometry deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Filter_Rings
   * @precis     : Function that allows a user to remove inner rings from a polygon/multipolygon 
   *               based on an area value.
   * @version    : 1.0
   * @usage      : FUNCTION Filter_Rings(p_geometry   in mdsys.sdo_geometry,
   *                                     p_tolerance in number,
   *                                     p_area      in number,
   *                                     p_ring      in number := 0)
   *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
   *               eg select Filter_Rings(mdsys.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),
   *                                      10,
   *                                      0.05)
   *                    from dual;
   * @param      : p_geometry  : mdsys.sdo_geometry : Original polygon/multipolygon
   * @param      : p_area      : number : Area in square srid units below which an inner ring is removed.
   * @param      : p_tolerance : number : Standard Oracle diminfo tolerance.
   * @Param      : p_ring      : number : The number of the internal ring to be removed
   * @return     : mdsys.sdo_geometry : input geometry with any qualifying inner rings removed
   * @history    : Simon Greener - December 2008 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   FUNCTION Filter_Rings(p_geometry  in mdsys.sdo_geometry,
                         p_tolerance in number,
                         p_area      in number,
                         p_ring      in number := 0)
     RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_AddPoint
   * @precis     : Adds a point to a MultiPoint, LineString or MultiLineString geometry before 
   *                point <p_position> (1-based index: Set to -1/NULL for appending.
   * @version    : 1.0
   * @usage      : FUNCTION SDO_AddPoint(p_geometry   in mdsys.sdo_geometry,
   *                                     p_point      in mdsys.vertex_type,
   *                                     p_position   in number )
   *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
   * @param      : p_geometry  : mdsys.sdo_geometry : Original geometry
   * @param      : p_point     : number : Actual point coordinates to be inserted
   * @param      : p_position  : number : Position before which point is inserted. If NULL 
   *                or -1 the point is appended to whole geometry.
   * @return     : mdsys.sdo_geometry : input geometry with new point added.
   * @history    : Simon Greener - February 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_AddPoint(p_geometry   IN MDSYS.SDO_Geometry,
                         p_point      IN MDSYS.Vertex_Type,
                         p_position   IN Number )
     Return MDSYS.SDO_Geometry Deterministic;
  
   Function SDO_AddPoint(p_geometry   IN MDSYS.SDO_Geometry,
                         p_point      IN &&defaultSchema..Vertex_Type,
                         p_position   IN Number )
     Return MDSYS.SDO_Geometry Deterministic;
  
   -- Removes point (p_position) from a linestring. Offset is 1-based.
   Function SDO_RemovePoint(p_geometry  IN MDSYS.SDO_Geometry,
                            p_position  IN Number)
     Return MDSYS.SDO_Geometry Deterministic;
  
   -- OGC Style wrapper
   Function ST_RemovePoint(p_geometry  IN MDSYS.ST_Geometry,
                           p_position  IN Number)
     RETURN MDSYS.ST_Geometry DETERMINISTIC;
  
  /** ----------------------------------------------------------------------------------------
   * @function   : SDO_SetPoint
   * @precis     : Replace point (p_position) of linestring with given point (1-based index) 
   * @version    : 1. 0
   * @usage      : FUNCTION SDO_SetPoint(p_geometry   in mdsys.sdo_geometry,
   *                                     p_point      in mdsys.vertex_type,
   *                                     p_position   in number )
   *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
   * @param      : p_geometry  : mdsys.sdo_geometry : Original geometry object
   * @param      : p_point     : mdsys.vertex_update : Actual point coordinates updating existing point
   * @param      : p_position  : Number : Position of point to be updated. If NULL the last point is 
   *                   updated otherwise, if a single sdo_point, that point is updated.
   * @return     : mdsys.sdo_geometry : input geometry with changed point.
   * @history    : Simon Greener - February 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_SetPoint(p_geometry   IN MDSYS.SDO_Geometry,
                         p_point      IN MDSYS.Vertex_Type,
                         p_position   IN Number )
     Return MDSYS.SDO_Geometry Deterministic;
   Function SDO_SetPoint(p_geometry   IN MDSYS.SDO_Geometry,
                         p_point      IN &&defaultSchema..Vertex_Type,
                         p_position   IN Number )
     Return MDSYS.SDO_Geometry Deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : SDO_VertexUpdate
   * @precis     : Replace all points of geometry with new point where they match (including Z and M)
   * @version    : 1.0
   * @usage      : FUNCTION SDO_VertexUpdate(p_geometry in mdsys.sdo_geometry,
   *                                         p_old_point in mdsys.vertex_type,
   *                                         p_new_point in mdsys.vertex_type )
   *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
   * @param      : p_geometry  : mdsys.sdo_geometry : Original geometry object
   * @param      : p_old_point : mdsys.vertex_type : Actual point coordinates of an existing point
   * @param      : p_new_point : mdsys.vertex_type : Actual point coordinates of replacement point
   * @return     : mdsys.sdo_geometry : input geometry with changed point.
   * @history    : Simon Greener - February 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SDO_VertexUpdate(p_geometry  IN MDSYS.SDO_Geometry,
                             p_old_point IN MDSYS.Vertex_Type,
                             p_new_point IN MDSYS.Vertex_Type)
     Return MDSYS.SDO_Geometry Deterministic;
   Function SDO_VertexUpdate(p_geometry  IN MDSYS.SDO_Geometry,
                             p_old_point IN &&defaultSchema..Vertex_Type,
                             p_new_point IN &&defaultSchema..Vertex_Type)
     Return MDSYS.SDO_Geometry Deterministic;
  
   /** ----------------------------------------------------------------------------------------
   * @function   : Fix_Ordinates
   * @precis     : Allows calculations expressed as formula to change the ordinates of an SDO_Geometry
   * @version    : 1.0
   * @usage      : FUNCTION Fix_Ordinates(p_geometry   in mdsys.sdo_geometry,
   *                                      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;
   * @description: The formula may reference the ordinates of the geometry via the columns X, Y, Z and W
   *               (the Vertex_Type 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.
   * @param      : p_geometry  : mdsys.sdo_geometry : Original geometry object
   * @param      : p_x_formula : varchar2 : Mathematical formula to be applied to X ordinate
   * @param      : p_y_formula : varchar2 : Mathematical formula to be applied to Y ordinate
   * @param      : p_z_formula : varchar2 : Mathematical formula to be applied to Z ordinate
   * @param      : p_w_formula : varchar2 : Mathematical formula to be applied to W/M ordinate
   * @return     : mdsys.sdo_geometry : input geometry with modified ordiantes
   * @history    : Simon Greener - February 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function fix_ordinates(p_geometry in mdsys.sdo_geometry,
                          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;
  
   Function Append(p_geom_1 in mdsys.sdo_geometry, 
 	                 p_geom_2 in mdsys.sdo_geometry )
     Return mdsys.sdo_geometry deterministic;
 
   Function Concat_Lines(p_geom_1 in mdsys.sdo_geometry,
 	                       p_geom_2 in mdsys.sdo_geometry )
     Return mdsys.sdo_geometry deterministic;
 
  /** ----------------------------------------------------------------------------------------
   * @function    : Extend
   * @precis      : Shortens or increases length of single linestring by desired amount.
   * @description : To extend a linestring provide a positive number. The linestring
   *                will be extended by taking the bearing of the first/last vector in the linestring
   *                and extending it by the desired amount. Providing START for the p_end parameter
   *                will cause the linestring to be ended at its beginning only; END ensures the
   *                extension occurs from the end of the linestring; BOTH ensures extension occurs at
   *                both ends. Providing a negative extension value will cause the linestring to shrink
   *                from either START, END or BOTH ends. If vertices are met when shrink the linestring
   *                within the distance to be shrunk the vertices will be removed.
   * @version     : 1.0
   * @usage      : FUNCTION get_point( p_geom      in mdsys.sdo_geometry,
   *                                   p_extension in number,
   *                                   p_tolerance in number,
   *                                   p_end       in varchar2 default 'START' )
   *                 RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
   * @param      : p_geom      : MDSY.SDO_GEOMETRY : Geometry
   * @param      : p_extension : number   : The value to extend or shrink (-ve) the linesting
   * @param      : p_tolerance : number   : Standard Oracle diminfo tolerance.
   * @param      : p_end       : VARCHAR2 : START, END or BOTH
   * @history    : Simon Greener - July 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. 
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   function extend( p_geom      in mdsys.sdo_geometry,
                    p_extension in number,
                    p_tolerance in number,
                    p_end       in varchar2 default 'START' )
     return mdsys.sdo_geometry deterministic;
  
  /** ----------------------------------------------------------------------------------------
   * @function    : SwapOrdinates
   * @precis      : Allows for swapping ordinate pairs in a geometry.
   * @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.
   * @version     : 1.0
   * @usage       : Function SwapOrdinates( p_geom in mdsys.sdo_geometry,
   *                                        p_pair in varchar default 'XY' )
   *                  RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
   * @param      : p_geom : MDSYS.SDO_GEOMETRY : Geometry
   * @param      : p_pair : varchar2  : The ordinate pair to swap = XY, XZ, XM, YZ, YM or ZM
   * @return     : mdsys.sdo_geometry : changed geometry
   * @history    : Simon Greener - Aug 2009 - Original coding.
   * @copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
   *               http://creativecommons.org/licenses/by-sa/2.5/au/
   */
   Function SwapOrdinates( p_geom in mdsys.sdo_geometry,
                           p_pair in varchar2 default 'XY' /* Can be XY, XZ, XM, YZ, YM, ZM */ )
     return mdsys.sdo_geometry deterministic;
  
   /*********************************************************************************
   * @function    : Tokenizer
   * @precis      : Splits any string into its tokens.
   * @description : Supplied a string and a list of separators this function
   *                returns resultant tokens as a pipelined collection.
   * @example     : SELECT t.column_value
   *                  FROM TABLE(tokenizer('The rain in spain, stays mainly on the plain.!',' ,.!') ) t;
   * @param       : p_string. The string to be Tokenized.
   * @param       : p_separators. The characters that are used to split the string.
   * @requires    : t_TokenSet type to be declared.
   * @history     : Pawel Barut, http://pbarut.blogspot.com/2007/03/yet-another-tokenizer-in-oracle.html
   * @history     : Simon Greener - July 2006 - Original coding (extended SQL sourced from a blog on the internet)
   */
   Function Tokenizer(p_string     In VarChar2,
                      p_separators In VarChar2 DEFAULT ' ') 
     Return &&defaultSchema..T_TokenSet Pipelined;
  
   /*********************************************************************************
   * @function    : TokenAggregator
   * @precis      : A string aggregator.
   * @description : Takes a set of strings an aggregates/appends them using supplied separator
   * @example     : SELECT TokenAggregator(CAST(COLLECT(to_char(l.lineid)) AS t_TokenSet)) AS lineids
   *                  FROM test_lines_large_set l;
   * @param       : p_tokenSet  : The strings to be aggregated.
   * @param       : p_separator : The character that is placed between each token string.
   * @requires    : t_TokenSet type to be declared.
   * @history     : Simon Greener - June 2011 - Original coding 
   */
   Function TokenAggregator(p_tokenSet  IN  &&defaultSchema..t_TokenSet,
                            p_delimiter IN  VarChar2 DEFAULT ',') 
     Return VarChar2 Deterministic;
  
   /*********************************************************************************
   * @function    : ConcatLines
   * @precis      : A geometry linestring aggregator.
   * @description : Takes a set of linestrings and aggregates them into a single geoemtry
   * @example     : SELECT concatLines(CAST(COLLECT(a.geom) AS t_geometrySet)) AS lines
   *                  FROM test_lines_large_set l;
   * @param       : p_lines  : t_geometrySet : The lines to be aggregated.
   * @requires    : t_GeometrySet type to be declared.
   * @history     : Simon Greener - June 2011 - Original coding 
   */
   Function concatLines(p_lines IN &&defaultSchema..GEOM.t_geometrySet) 
     Return mdsys.sdo_geometry deterministic;
  
 End Geom;