SpatialDB Advisor
Many years ago I wrote a Coordinate Geometry (COGO) package for Oracle Sdo_Geometry that contained a Bearing function that, given two points, would return the angle in radians from the horizontal of the vector defined by point A and B.
PostGIS has a similar function called ST_Azimuth.
Here are the relevant declarations of the Bearing function and overloaded ST_Azimuth interfaces.
CREATE OR REPLACE PACKAGE "COGO"
AUTHID CURRENT_USER
As
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 := CODESYS.cogo.Bearing(299900, 5200000, 300000, 5200100);
** param : dE1 : X Ordinate of the start point for the vector
** paramtype : dE1 : NUMBER
** param : dN1 : Y Ordinate of the start point for the vector
** paramtype : dN1 : NUMBER
** param : dE2 : X Ordinate of the end point for the vector
** paramtype : dE2 : NUMBER
** param : dN2 : Y Ordinate of the end point for the vector
** paramtype : dN2 : NUMBER
** return : Bearing : the angle in radians between 0 and 2*PI representing the bearing
** rtnType : Bearing : NUMBER
** 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;
Now, some examples of the use of these functions.
/* What happens when NULL points are provided */
SELECT COGO.Bearing(NULL,NULL)
FROM DUAL;
I hope this is useful to someone.


















<<Implementing a Translate/ST_Translate/Move function for Oracle Spatial >>Filtering Rings (Oracle Spatial)