Top 5 Recent Articles
ARTICLES CATEGORIES
- Algorithms (22)
- All (399)
- Biography (1)
- Blog (44)
- Business Requirements (1)
- Commentary (1)
- Conversion (2)
- Customers (2)
- Data Models (1)
- Education (2)
- GeoRaptor (13)
- GPS (1)
- Image Processing (2)
- Import Export (8)
- Licensing (2)
- LiDAR (1)
- Linear Referencing (4)
- Manifold GIS (3)
- Mapping (1)
- MySQL Spatial (7)
- Networking and Routing (including Optimization) (5)
- Open Source (18)
- Oracle Spatial and Locator (194)
- Partitioning (1)
- PostGIS (36)
- Projections (1)
- Published Articles (1)
- qGIS (1)
- Recommendations (1)
- Services (1)
- Software Change Log (1)
- Source Code (37)
- Space Curves (9)
- Spatial Database Functions (109)
- Spatial DB comparison (1)
- Spatial XML Processing (11)
- SQL Server Spatial (92)
- Standards (3)
- Stored Procedure (17)
- Tessellation or Gridding (10)
- Tools (2)
- Topological Relationships (1)
- Training (2)
- Triangulation (2)
COGO
The CoOrdinate GeOmetry package contains a bunch of functions related to handling curves, circles, bearings and distances.
DEFINE defaultSchema = '&1'
create or replace
PACKAGE "COGO"
AUTHID CURRENT_USER
As
/** Declare Public constants
* @constant cPI The value of PI: Is in Constants package
* @constant cMAX Maximum number storable in NUMBER
*/
c_ELLIPSOID_ID CONSTANT VARCHAR2(100) := 'ELLIPSOID_ID';
c_ELLIPSOID_NAME CONSTANT VARCHAR2(100) := 'ELLIPSOID_NAME';
c_SRID CONSTANT VARCHAR2(100) := 'SRID';
/** Inspector function to return constant values in SQL SElect statements
*/
FUNCTION ELLIPSOID_ID
RETURN VARCHAR2;
FUNCTION ELLIPSOID_NAME
RETURN VARCHAR2;
FUNCTION SRID
RETURN VARCHAR2;
/** Allows controlling program to set Degree Symbol for use in DD2DMS
* @param p_Symbol A single character added as suffix to degrees value in DD2DMS
*/
Procedure SetDegreeSymbol( p_Symbol In NVarChar2 );
/** Allows controlling program to set Minutes Symbol for use in DD2DMS
* @param p_Symbol A single character added as suffix to minutes value in DD2DMS
*/
Procedure SetMinuteSymbol( p_Symbol In NVarChar2 );
/** Allows controlling program to set Seconds Symbol for use in DD2DMS
* @param p_Symbol A single character added as suffix to seconds value in DD2DMS
*/
Procedure SetSecondSymbol( p_Symbol In NVarChar2 );
/* ----------------------------------------------------------------------------------------
* @function : PointFromBearingAndDistance
* @precis : Returns point shape from starting E,N and bearing and distance.
* @version : 1.0
* @usage : FUNCTION PointFromBearindAndDistance (
* dStartE in number,
* dStartN in number,
* dBearing in number,
* dDistance in number )
* RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.PointFromBearingAndDistance(300000,5245000,225,45.56);
* @param : dStartE : Reference point's easting
* @paramtype : dStartE : NUMBER
* @param : dStartN : Reference point's northing
* @paramtype : dStartN : NUMBER
* @param : dBearing : Whole circle bearing from start point to new point
* @paramtype : dBearing : NUMBER
* @param : dDistance : Distance from N,E to new point
* @paramtype : dDistance : NUMBER
* @return : EndPoint : The new point from the start.
* @rtnType : EndPoint : MDSYS.SDO_GEOMETRY
* @note : Does not throw exceptions for dBearing not between 0 - 360
* @note : Assumes dBearing is a whole-cirle bearing.
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
FUNCTION PointFromBearingAndDistance ( dStartE in number,
dStartN in number,
dBearing in number,
dDistance in number )
RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
/* ----------------------------------------------------------------------------------------
* @function : RelativeLine
* @precis : Returns simple 2 vertex line whose first vertex is defined as a bearing and
* distance from a known point and whose second vertex is via a bearing and
* distance from the first point.
* @version : 1.0
* @usage : FUNCTION RelativeLine (
* dStartE in number,
* dStartN in number,
* dBearingStart in number,
* dDistanceStart in number,
* dBearingEnd in number,
* dDistanceEnd in number )
* RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.RelativeLine(300000,5245000,225,45.56,45,100);
* @param : dStartE : Reference point's easting
* @paramtype : dStartE : NUMBER
* @param : dStartN : Reference point's northing
* @paramtype : dStartN : NUMBER
* @param : dBearingStart : Whole circle bearing from start point to first vertex
* @paramtype : dBearingStart : NUMBER
* @param : dDistanceStart : Distance from start point to first vertex
* @paramtype : dDistanceStart : NUMBER
* @param : dBearingEnd : Whole circle bearing from first to the second vertex.
* @paramtype : dBearingEnd : NUMBER
* @param : dDistanceEnd : Distance from first vertex to the second vertex.
* @paramtype : dDistanceEnd : NUMBER
* @return : Linestring : The actual line as a linestring.
* @rtnType : Linestring : MDSYS.SDO_GEOMETRY
* @note : Does not throw exceptions for bearings not between 0 - 360
* @note : Assumes Bearings are whole-cirle bearing.
* @note : Assumes planar projection eg UTM.
* @uses : GIS.COGO.POINTFROMBEARINGANDDISTANCE()
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function RelativeLine( dStartX In Number,
dStartY In Number,
dBearingStart In Number,
dDistanceStart In Number,
dBearingEnd In Number,
dDistanceEnd In Number)
Return MDSYS.SDO_GEOMETRY Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : CreateCircle
* @precis : Returns 2003 Circle sdo_geometry from Centre XY and Radius
* @version : 1.0
* @usage : FUNCTION CreateCircle ( dCentreX in number,
* dCentreY in number,
* dRadius in number )
* RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.CreateCircle(300000,52450000,100);
* @param : dCentreX : X Ordinate of centre of Circle
* @paramtype : dCentreX : NUMBER
* @param : dCentreY : Y Ordinate of centre of Circle
* @paramtype : dCentreY : NUMBER
* @param : dRadius : Radius of Circle
* @paramtype : dRadius : NUMBER
* @return : CircleShape : Circle as 2003 object with interpretation 4
* @rtnType : CircleShape : MDSYS.SDO_GEOMETRY
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Mar 2005 - Original coding.
*/
Function CreateCircle(dCentreX in Number,
dCentreY in Number,
dRadius in Number)
Return MDSYS.SDO_GEOMETRY Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : FindCircle
* @precis : Finds Circle's centre X and Y and Radius from three points
* @version : 1.1
* @usage : procedure FindCircle
* (
* p_X1 in number, p_Y1 in number,
* p_X2 in number, p_Y2 in number,
* p_X3 in number, p_Y3 in number,
* p_CX out number,
* p_CY out number,
* p_Radius out number
* );
* eg &&defaultSchema..cogo.FindCircle(299900,5245000,
* 300000,5245100,
* 300100,5245000,
* centreX,centreY,Radius);
* @param : p_X1 : X ordinate of first point on circle
* @paramtype : p_X1 : NUMBER
* @param : p_Y1 : Y ordinate of first point on circle
* @paramtype : p_Y1 : NUMBER
* @param : p_X2 : X ordinate of second point on circle
* @paramtype : p_X2 : NUMBER
* @param : p_Y2 : Y ordinate of second point on circle
* @paramtype : p_Y2 : NUMBER
* @param : p_X3 : X ordinate of third point on circle
* @paramtype : p_X3 : NUMBER
* @param : p_Y3 : Y ordinate of third point on circle
* @paramtype : p_Y3 : NUMBER
* @return : p_CX : X ordinate of centre of circle
* @rtnType : p_CX : NUMBER
* @return : p_CY : Y ordinate of centre of circle
* @rtnType : p_CY : NUMBER
* @return : p_Radius : Radius of circle
* @rtnType : p_Radius : NUMBER
* @note : Throw exception if three points don't define circle.
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
procedure FindCircle ( p_X1 in number, p_Y1 in number,
p_X2 in number, p_Y2 in number,
p_X3 in number, p_Y3 in number,
p_CX out number,
p_CY out number,
p_Radius out number);
/* ----------------------------------------------------------------------------------------
* @function : FindCircle
* @precis : Finds Circle's centre X and Y and Radius from three points returning True
* if circle could be computed, False otherwise.
* @note : See procedure FindCircle documentation for data types etc of parameters.
* @note : Does not throw an exception.
* @history : Simon Greener - Jul 2006 - Original coding.
*/
function FindCircle( p_X1 in number, p_Y1 in number,
p_X2 in number, p_Y2 in number,
p_X3 in number, p_Y3 in number,
p_CX in out nocopy number,
p_CY in out nocopy number,
p_Radius in out nocopy number)
Return Boolean Deterministic;
procedure FindCircle ( pot_Pt1 in &&defaultSchema..VERTEX_TYPE,
pot_Pt2 in &&defaultSchema..VERTEX_TYPE,
pot_Pt3 in &&defaultSchema..VERTEX_TYPE,
pot_Centre out nocopy &&defaultSchema..VERTEX_TYPE,
p_Radius out nocopy number);
Function FindCircle ( pot_Pt1 in &&defaultSchema..VERTEX_TYPE,
pot_Pt2 in &&defaultSchema..VERTEX_TYPE,
pot_Pt3 in &&defaultSchema..VERTEX_TYPE,
pot_Centre out nocopy &&defaultSchema..VERTEX_TYPE,
p_Radius out nocopy number)
Return Boolean Deterministic;
/**
* @function : Circle2Polygon
* @precis : Returns 2003 Polygon shape from Circle Centre XY and Radius
* @version : 1.0
* @usage : FUNCTION Circle2Polygon ( dCentreX in number,
* dCentreY in number,
* dRadius in number,
* iSegments in INTEGER )
* RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.Circle2Polygon(300000,52450000,100,360);
* @param : dCentreX : X Ordinate of centre of Circle
* @paramtype : dCentreX : NUMBER
* @param : dCentreY : Y Ordinate of centre of Circle
* @paramtype : dCentreY : NUMBER
* @param : dRadius : Radius of Circle
* @paramtype : dRadius : NUMBER
* @param : iSegments : Number of arc (chord) segments in circle (+ve clockwise, -ve anti-clockwise)
* @paramtype : iSegments : INTEGER
* @return : PolyShape : Circle as 2003 polyon
* @rtnType : PolyShape : MDSYS.SDO_GEOMETRY
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function Circle2Polygon( dCentreX in number,
dCentreY in number,
dRadius in number,
iSegments in integer)
Return MDSYS.SDO_GEOMETRY DETERMINISTIC;
/** ----------------------------------------------------------------------------------------
* @function : CircularArc2Line
* @precis : Returns Polyline shape from Circular Arc with Start XY, End XY and Centre XY and Radius
* @version : 1.0
* @usage : FUNCTION CircularArc2Line( dStart in &&defaultSchema..ST_Point,
* dMid in &&defaultSchema..ST_Point,
* dEnd in &&defaultSchema..ST_Point,
* p_Arc2Chord in number := 0.1 )
* RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.CircularArc2Line(ST_Point(10,14), ST_Point(6,10), ST_Point(14,10), 0.5);
* @param : dStart : Start point for the Circular Arc
* @paramtype : dStart : &&defaultSchema..ST_Point
* @param : dMid : Middle point for the Circular Arc
* @paramtype : dMid : &&defaultSchema..ST_Point
* @param : dEnd : Coordinate of the end point for the Circular Arc
* @paramtype : dEnd : &&defaultSchema..ST_Point
* @param : p_Arc2Chord : Arc to chord separation distance for calculating vertices
* @paramtype : p_Arc2Chord : NUMBER
* @return : PolyShape : Circular Arc as polyline
* @rtnType : PolyShape : MDSYS.SDO_GEOMETRY
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
* @history : Simon Greener - Jan 2008 - Made function more standalone by incorporating code from GF package.
* Made attempt to fix rotation issues (still work in progress).
* @history : Simon Greener - Feb 2008 - Support for Z and measures added.
*/
Function CircularArc2Line(dStart in &&defaultSchema..ST_Point,
dMid in &&defaultSchema..ST_Point,
dEnd in &&defaultSchema..ST_Point,
p_Arc2Chord in number := 0.1 )
Return MDSYS.SDO_GEOMETRY DETERMINISTIC;
/** Alternate Bindings
*/
Function CircularArc2Line(dStart in &&defaultSchema..Vertex_Type,
dMid in &&defaultSchema..Vertex_Type,
dEnd in &&defaultSchema..Vertex_Type,
p_Arc2Chord in number := 0.1 )
Return MDSYS.SDO_GEOMETRY DETERMINISTIC;
/**
* @usage : FUNCTION CircularArc2Line( dStartX in number,
* dStartY in number,
* dMidX in number,
* dMidY in number,
* dEndX in number,
* dEndY in number,
* p_Arc2Chord in number := 0.1 )
* RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.CircularArc2Line(10,14, 6,10, 14,10, 0.5);
* @param : dStartX : X Ordinate of the start point for the Circular Arc
* @paramtype : dStartX : NUMBER
* @param : dStartY : Y Ordinate of the start point for the Circular Arc
* @paramtype : dStartY : NUMBER
* @param : dMidX : X Ordinate of the middle point for the Circular Arc
* @paramtype : dMidX : NUMBER
* @param : dMidY : Y Ordinate of the middle point for the Circular Arc
* @paramtype : dMidY : NUMBER
* @param : dEndX : X Ordinate of the end point for the Circular Arc
* @paramtype : dEndX : NUMBER
* @param : dEndY : Y Ordinate of the end point for the Circular Arc
* @paramtype : dEndY : NUMBER
*/
Function CircularArc2Line(dStartX in number,
dStartY in number,
dMidX in number,
dMidY in number,
dEndX in number,
dEndY in number,
p_Arc2Chord in number := 0.1 )
Return MDSYS.SDO_GEOMETRY DETERMINISTIC;
/* ----------------------------------------------------------------------------------------
* @function : ComputeChordLength
* @precis : Returns the length of the chord for an angle given the radius
* @version : 1.0
* @usage : FUNCTION ComputeChordLength( dRadius in number,
* dAngle in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.chordlength := &&defaultSchema..cogo.ComputeChordLength(100, 110);
* @param : dRadius : Radius of Circle
* @paramtype : dRadius : NUMBER
* @param : dAngle : Angle inside
* @paramtype : dAngle : NUMBER
* @return : ChordLength : the length of the chord in metres
* @rtnType : ChordLength : NUMBER
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function ComputeChordLength( dRadius in number,
dAngle in number)
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : ComputeArcLength
* @precis : Returns the length of the Arc for an angle given the radius
* @version : 1.0
* @usage : FUNCTION ComputeArcLength( dRadius in number,
* dAngle in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.arclength := &&defaultSchema..cogo.ComputeArcLength(100, 110);
* @param : dRadius : Radius of Circle
* @paramtype : dRadius : NUMBER
* @param : dAngle : Angle inside
* @paramtype : dAngle : NUMBER
* @return : ArcLength : the length of the chord in metres
* @rtnType : ArcLength : NUMBER
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function ComputeArcLength( dRadius in number,
dAngle in number)
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : ArcToChordSeparation
* @precis : Returns the distance between the midpoint of the Arc and the Chord for an angle given the radius
* @version : 1.0
* @usage : FUNCTION ArcToChordSeparation( dRadius in number,
* dAngle in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.sepearation := &&defaultSchema..cogo.ArcToChordSeparation(100, 110);
* @param : dRadius : NUMBER : Radius of Circle
* @param : dAngle : NUMBER : Angle inside
* @return : ArcToChordSeparation : NUMBER : the distance between the midpoint of the Arc and the Chord in metres
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function ArcToChordSeparation( dRadius in number,
dAngle in number )
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : OptimalCircleSegments
* @precis : Returns the optimal integer number of circle segments for an arc-to-chord
* separation given the radius
* @version : 1.0
* @usage : FUNCTION OptimalCircleSegments( dRadius in number,
* dArcToChordSeparation in number)
* RETURN INTEGER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.OptimalCircleSegments(100, 0.003);
* @param : dRadius : NUMBER : Radius of Circle
* @param : dArcToChordSeparation : NUMBER : Distance between the midpoint of the Arc and the Chord in metres
* @return : OptimalCircleSegments : INTEGER : the optimal number of segments
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function OptimalCircleSegments( dRadius in number,
dArcToChordSeparation in number)
Return Integer Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : ArcTan2
* @precis : Returns the angle in Radians with tangent opp/hyp. The returned value is between PI and -PI
* @version : 1.0
* @usage : FUNCTION ArcTan2( dOpp in number,
* dAdj in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.ArcTan2(14 ,15);
* @param : dOpp : NUMBER : Length of the vector perpendicular to two vectors (cross product)
* @param : dAdj : NUMBER : Length of the calculated from the dot product of two vectors
* @return : ArcTan2 : NUMBER : the angle in Radians with tangent opp/hyp
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Steve Harwin - Feb 2005 - Original coding.
*/
Function ArcTan2( dOpp in number,
dAdj in number)
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : CrossProductLength
* @precis : Return the cross product AB x BC, where a is Start, B is Centre and C is End.
* The cross product is a vector perpendicular to AB and BC having length |AB| * |BC| * Sin(theta)
* and with direction given by the right-hand rule.
* For two vectors in the X-Y plane, the result is a vector with X and Y components 0 so the Z
* component gives the vector's length and direction.
* @version : 1.0
* @usage : FUNCTION CrossProductLength( dStartX in number,
* dStartY in number,
* dCentreX in number,
* dCentreY in number,
* dEndX in number,
* dEndY in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.CrossProductLength(299900, 5200000, 300000, 5200000, 300000, 5200100);
* @param : dStartX : NUMBER : X Ordinate of the start point for the first vector
* @param : dStartY : NUMBER : Y Ordinate of the start point for the first vector
* @param : dCentreX : NUMBER : X Ordinate of the end point for the first vector and the start point for the second vector
* @param : dCentreY : NUMBER : Y Ordinate of the end point for the first vector and the start point for the second vector
* @param : dEndX : NUMBER : X Ordinate of the end point for the second vector
* @param : dEndY : NUMBER : Y Ordinate of the end point for the second vector
* @return : CrossProductLength : NUMBER : the length of the vector perpendicular to the first and second vector
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Steve Harwin - Feb 2005 - Original coding.
*/
Function CrossProductLength(dStartX in number,
dStartY in number,
dCentreX in number,
dCentreY in number,
dEndX in number,
dEndY in number)
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : DotProduct
* @precis : Return the dot product AB . BC, where a is Start, B is Centre and C is End..
* Note that AB . BC = |AB| * |BC| * Cos(theta).
* @version : 1.0
* @usage : FUNCTION DotProduct( dStartX in number,
* dStartY in number,
* dCentreX in number,
* dCentreY in number,
* dEndX in number,
* dEndY in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.DotProduct(299900, 5200000, 300000, 5200000, 300000, 5200100);
* @param : dStartX : NUMBER : X Ordinate of the start point for the first vector
* @param : dStartY : NUMBER : Y Ordinate of the start point for the first vector
* @param : dCentreX : NUMBER : X Ordinate of the end point for the first vector and the start point for the second vector
* @param : dCentreY : NUMBER : Y Ordinate of the end point for the first vector and the start point for the second vector
* @param : dEndX : NUMBER : X Ordinate of the end point for the second vector
* @param : dEndY : NUMBER : Y Ordinate of the end point for the second vector
* @return : DotProduct : NUMBER : the dot product AB . BC
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Steve Harwin - Feb 2005 - Original coding.
*/
Function DotProduct(dStartX in number,
dStartY in number,
dCentreX in number,
dCentreY in number,
dEndX in number,
dEndY in number)
Return Number Deterministic;
Function isGeographic( p_SRID in number )
Return Boolean Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : AngleBetween3Points
* @precis : Return the angle in Radians. Returns a value between PI and -PI.
* @version : 1.0
* @usage : FUNCTION AngleBetween3Points( dStartX in number,
* dStartY in number,
* dCentreX in number,
* dCentreY in number,
* dEndX in number,
* dEndY in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.AngleBetween3Points(299900, 5200000, 300000, 5200000, 300000, 5200100);
* @param : dStartX : NUMBER : X Ordinate of the start point for the first vector
* @param : dStartY : NUMBER : Y Ordinate of the start point for the first vector
* @param : dCentreX : NUMBER : X Ordinate of the end point for the first vector and the start point for the second vector
* @param : dCentreY : NUMBER : Y Ordinate of the end point for the first vector and the start point for the second vector
* @param : dEndX : NUMBER : X Ordinate of the end point for the second vector
* @param : dEndY : NUMBER : Y Ordinate of the end point for the second vector
* @return : AngleBetween3Points : NUMBER : the angle in Radians between PI and -PI
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Steve Harwin - Feb 2005 - Original coding.
*/
Function AngleBetween3Points( dStartX in number,
dStartY in number,
dCentreX in number,
dCentreY in number,
dEndX in number,
dEndY in number)
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : Bearing
* @precis : Returns a value between 0 and 2*PI representing the bearing
* North = 0, East = PI/2, South = PI, West = 3*PI/4
* To convert to degrees multiply by (180/PI).
* @version : 1.0
* @usage : FUNCTION Bearing( dE1 in number,
* dN1 in number,
* dE2 in number,
* dN2 in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.Bearing(299900, 5200000, 300000, 5200100);
* @param : dE1 : NUMBER : X Ordinate of the start point for the vector
* @param : dN1 : NUMBER : Y Ordinate of the start point for the vector
* @param : dE2 : NUMBER : X Ordinate of the end point for the vector
* @param : dN2 : NUMBER : Y Ordinate of the end point for the vector
* @return : Bearing : NUMBER : the angle in radians between 0 and 2*PI representing the bearing
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function Bearing( dE1 in number,
dN1 in number,
dE2 in number,
dN2 in number)
Return Number Deterministic;
/** Alternate binding: 1
*/
Function Bearing( startCoord in mdsys.sdo_point_type,
endCoord in mdsys.sdo_point_type)
Return Number Deterministic;
/** Alternate binding: 2
*/
Function Bearing( p_startCoord in mdsys.sdo_point_type,
p_endCoord in mdsys.sdo_point_type,
p_planar_srid in number,
p_geographic_srid in number := 8311
)
Return Number Deterministic;
/* Alternate binding for SQL/MM
*/
Function ST_Azimuth( p_startCoord in &&defaultSchema..ST_Point,
p_endCoord in &&defaultSchema..ST_Point)
Return Number Deterministic;
Function GreatCircleBearing ( p_lon1 in number,
p_lat1 in number,
p_lon2 in number,
p_lat2 in number)
Return number deterministic;
/* ----------------------------------------------------------------------------------------
* @function : Distance
* @precis : Returns the distance between (dE1,dN1) and (dE2,dN2).
* @version : 1.0
* @usage : FUNCTION Distance( dE1 in number,
* dN1 in number,
* dE2 in number,
* dN2 in number)
* RETURN NUMBER DETERMINISTIC;
* eg :new.shape := &&defaultSchema..cogo.Distance(299900, 5200000, 300000, 5200100);
* @param : dE1 : NUMBER : X Ordinate of the start point for the vector
* @param : dN1 : NUMBER : Y Ordinate of the start point for the vector
* @param : dE2 : NUMBER : X Ordinate of the end point for the vector
* @param : dN2 : NUMBER : Y Ordinate of the end point for the vector
* @return : Distance : NUMBER : the length in metres of the vector between (dE1,dN1) and (dE2,dN2)
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Feb 2005 - Original coding.
*/
Function Distance( dE1 in number,
dN1 in number,
dE2 in number,
dN2 in number)
Return Number Deterministic;
/** @note : Overload of Distance()
*/
Function Distance( p_startCoord in mdsys.sdo_point_type,
p_endCoord in mdsys.sdo_point_type)
Return Number Deterministic;
Function Distance( p_frst_vertex IN &&defaultSchema..ST_Point,
p_last_vertex IN &&defaultSchema..ST_Point,
p_srid IN number,
p_tolerance IN number)
Return Number Deterministic;
/** @note : Projects any geographic data to planar projection before calling Distance.
*/
Function Distance( p_startCoord in mdsys.sdo_point_type,
p_endCoord in mdsys.sdo_point_type,
p_geographic_srid in number := 8311,
p_tolerance in number := 0.05 )
Return Number Deterministic;
/** @note : A version that does not require use of sdo_geom.sdo_distance()
*/
function GreatCircleDistance( p_lon1 in number,
p_lat1 in number,
p_lon2 in number,
p_lat2 in number,
p_equatorial_radius in number default null,
p_flattening in number default null)
Return number deterministic;
/** @note : Overload of GreatCircleDistance.
*/
function GreatCircleDistance( p_lon1 in number,
p_lat1 in number,
p_lon2 in number,
p_lat2 in number,
p_ref_type in varchar2,
p_ref_id in number,
p_ellipsoid_name in varchar2 default null)
Return number deterministic;
Function DD2DMS( dDecDeg in number)
Return varchar2 Deterministic;
Function DMS2DD( dDeg in number,
dMin in number,
dSec in number)
Return Number Deterministic;
Function DD2DMS( dDecDeg in Number,
pDegree in NVarChar2,
pMinute in NVarChar2,
pSecond in NVarChar2 )
Return varchar2 Deterministic;
Function DMS2DD(strDegMinSec in varchar2)
Return Number deterministic;
Function Latitude( p_deg in pls_integer,
p_min in pls_integer,
p_sec in pls_integer,
p_sgn in pls_integer)
Return number Deterministic;
Function Longitude( p_deg in pls_integer,
p_min in pls_integer,
p_sec in pls_integer,
p_sgn in pls_integer)
Return Number Deterministic;
/* ----------------------------------------------------------------------------------------
* @function : FindLineIntersection
* @precis : Find the point where two vectors intersect.
* @version : 1.0
* @usage : PROCEDURE FindLineIntersection(x11 in number, y11 in number,
* x12 in Single, y12 in Single,
* x21 in Single, y21 in Single,
* x22 in Single, y22 in Single,
* inter_x OUT Single, inter_y OUT Single,
* inter_x1 OUT Single, inter_y1 OUT Single,
* inter_x2 OUT Single, inter_y2 OUT Single );
* @param : x11 : NUMBER : X Ordinate of the start point for the first vector
* @param : y11 : NUMBER : Y Ordinate of the start point for the first vector
* @param : x12 : NUMBER : X Ordinate of the end point for the first vector
* @param : y12 : NUMBER : Y Ordinate of the end point for the first vector
* @param : x21 : NUMBER : X Ordinate of the start point for the second vector
* @param : y21 : NUMBER : Y Ordinate of the start point for the second vector
* @param : x22 : NUMBER : X Ordinate of the end point for the second vector
* @param : y22 : NUMBER : Y Ordinate of the end point for the second vector
* @description: (inter_x, inter_y) is the point where the lines
* defined by the segments intersect.
* (inter_x1, inter_y1) is the point on segment 1 that
* is closest to segment 2.
* (inter_x2, inter_y2) is the point on segment 2 that
* is closest to segment 1.
* If the lines are parallel, all returned coordinates are 1E+38.
* -------
* Method:
* Treat the lines as parametric where line 1 is:
* X = x11 + dx1 * t1
* Y = y11 + dy1 * t1
* and line 2 is:
* X = x21 + dx2 * t2
* Y = y21 + dy2 * t2
* Setting these equal gives:
* x11 + dx1 * t1 = x21 + dx2 * t2
* y11 + dy1 * t1 = y21 + dy2 * t2
* Rearranging:
* x11 - x21 + dx1 * t1 = dx2 * t2
* y11 - y21 + dy1 * t1 = dy2 * t2
* (x11 - x21 + dx1 * t1) * dy2 = dx2 * t2 * dy2
* (y11 - y21 + dy1 * t1) * (-dx2) = dy2 * t2 * (-dx2)
* Adding the equations gives:
* (x11 - x21) * dy2 + ( dx1 * dy2) * t1 +
* (y21 - y11) * dx2 + (-dy1 * dx2) * t1 = 0
* Solving for t1 gives:
* t1 * (dy1 * dx2 - dx1 * dy2) =
* (x11 - x21) * dy2 + (y21 - y11) * dx2
* t1 = ((x11 - x21) * dy2 + (y21 - y11) * dx2) /
* (dy1 * dx2 - dx1 * dy2)
* Now solve for t2.
* ----------
* @Note : If 0 <= t1 <= 1, then the point lies on segment 1.
* : If 0 <= t2 <= 1, then the point lies on segment 1.
* : If dy1 * dx2 - dx1 * dy2 = 0 then the lines are parallel.
* : If the point of intersection is not on both
* : segments, then this is almost certainly not the
* : point where the two segments are closest.
* @note : Does not throw exceptions
* @note : Assumes planar projection eg UTM.
* @history : Simon Greener - Mar 2006 - Original coding.
*/
Procedure FindLineIntersection(
x11 in number, y11 in number,
x12 in number, y12 in number,
x21 in number, y21 in number,
x22 in number, y22 in number,
inter_x out nocopy number, inter_y out nocopy number,
inter_x1 out nocopy number, inter_y1 out nocopy number,
inter_x2 out nocopy number, inter_y2 out nocopy number );
/*
* degrees - returns radians converted to degrees
*/
Function degrees(p_radians in number)
return number deterministic;
/*
* radians - returns radians converted from degrees
*/
Function radians(p_degrees in number)
Return number deterministic;
END COGO;
Documentation
- GeoRaptor Documentation
- MySQL Spatial General Functions
- Oracle LRS Objects
- Oracle Spatial Exporter (Java + pl/SQL)
- Oracle Spatial Object Functions
- Oracle Spatial Object Functions (Multi Page)
- PostGIS pl/pgSQL Functions
- SC4O Oracle Java Topology Suite (Java + pl/SQL)
- SQL Server Spatial General TSQL Functions
- SQL Server Spatial LRS TSQL Functions