ApsGis.dll

Geodetic.Longitude.LonInDmsToDeg Method

Converts a longitude in DMS (degrees, minutes, seconds) to decimal degrees.

public static bool LonInDmsToDeg(
   int degrees,
   int minutes,
   double seconds,
   LongitudeDirection lonDirection,
   out double lonInDeg,
   out string errorMessage
);

Parameters

degrees
the degrees part of the longitude in DMS
minutes
the minutes part of the longitude in DMS
seconds
the seconds part of the longitude in DMS
lonDirection
the direction part of the longitude in DMS
lonInDeg
the result longitude in decimal 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. The valid degree part is an integer number in the range from 0 (inclusive) to 180 (inclusive). The valid minutes part is an integer number in the range from 0 (inclusive) to 60 (exclusive). The valid seconds part is a real number in the range from 0 (inclusive) to 60 (exclusive).

Example

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

 string errorMessage = String.Empty;
 
 LongitudeDirection lonDirection = LongitudeDirection.Western;
 int degreesPart = 34;
 int minutesPart = 45;
 double secondsPart = 56.789;
 double lonInDeg = Double.NaN;

 if (Geodetic.Longitude.LonInDmsToDeg(degrees, minutes, seconds, lonDirection, out lonInDeg, out errorMessage))
 {
     Console.WriteLine("Longitude in degrees: " + lonInDeg.ToString());
 }
 else
 {
     Console.WriteLine(errorMessage);
 }
 

See Also

Longitude Class | ApsGis Namespace