ApsGis.dll

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

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

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

Parameters

semiMajorAxisAInM
a semi major axis A (in meters) of the user defined reference ellipsoid
inverseFlattening
an inverse flattening of the user defined reference ellipsoid
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 distance (in meters), 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:

 double semiMajorAxisA = 6378137;
 double inverseFlattening = 298.257223563;

 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(semiMajorAxisA, inverseFlattening, 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