ApsGis.dll

Geodetic.CalculateBearingInDeg(GeoEllipsoid, Double, Double, Double, Double, Double, String) Method

Calculates a bearing (in degrees) between two geodetic coordinates on the surface of a reference ellipsoid.

public static bool CalculateBearingInDeg(
   GeoEllipsoid ge,
   double latInDeg1,
   double lonInDeg1,
   double latInDeg2,
   double lonInDeg2,
   out double bearingInDeg,
   out string errorMessage
);

Parameters

ge
a predefined reference ellipsoid (GeoEllipsoid)
latInDeg1
the latitude (in decimal degrees) of the first geodetic coordinate
lonInDeg1
the longitude (in decimal degrees) of the first geodetic coordinate
latInDeg2
the latitude (in decimal degrees) of the second geodetic coordinate
lonInDeg2
the longitude (in decimal degrees) of the second geodetic coordinate
bearingInDeg
the calculated bearing (in degrees), passed by reference (out)
errorMessage
an error message, passed by reference (out), that contains detailed error / warning information

Return Value

true - the function has succeeded, false - it has failed

Remarks

The function verifies validity of its arguments.

Example

This sample shows how to call the Geodetic.CalculateBearingInDeg method from C# code:

 GeoEllipsoid ge = GeoEllipsoid.WE;

 string errorMessage = String.Empty;
 
 double latInDeg = 38.889139;
 double lonInDeg = -77.049;
 double latInDeg2 = 39.889139;
 double lonInDeg2 = -78.049;
 
 double bearingInDeg = Double.NaN;
 
 if (Geodetic.CalculateBearingInDeg(ge, latInDeg1, lonInDeg1, latInDeg2, lonInDeg2, out bearingInDeg, out errorMessage))
 {
     Console.WriteLine("Bearing, in degrees: " + bearingInDeg.ToString());
 }
 else
 {
     Console.WriteLine(errorMessage);
 }
 

See Also

Geodetic Class | ApsGis Namespace | Geodetic.CalculateBearingInDeg Overload List