ApsGis.dll

Geodetic.Longitude.LonInDegToDms Method

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

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

Parameters

lonInDeg
a longitude in decimal degrees
preferredLonDirection
a prefered longitude direction
degrees
the degrees part of the result longitude in DMS, passed by reference (out)
minutes
the minutes part of the result longitude in DMS, passed by reference (out)
seconds
the seconds part of the result longitude in DMS, passed by reference (out)
lonDirection
the direction part of the result longitude in DMS, 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 longitude is a real number in the range from -180 (inclusive) to 180 (inclusive).

Example

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

 string errorMessage = String.Empty;
 
 double lonInDeg = 38.889139;
 LongitudeDirection preferredLonDirection = LongitudeDirection.Northern;
 int degreesPart;
 int minutesPart;
 double secondsPart = Double.NaN;
 LongitudeDirection lonDirection = LongitudeDirection.NotDefined;

 if (Geodetic.Longitude.LonInDegToDms(lonInDeg, preferredLonDirection, out degrees, out minutes, out seconds, out lonDirection, out errorMessage))
 {
     Console.WriteLine("Degrees part, DMS: " + degrees.ToString());
     Console.WriteLine("Minutes part, DMS: " + minutes.ToString());
     Console.WriteLine("Seconds part, DMS: " + seconds.ToString());
 }
 else
 {
     Console.WriteLine(errorMessage);
 }
 

See Also

Longitude Class | ApsGis Namespace