ApsGis.dll

TM.ParseLongitudeInDmsd Method

Parses longitude from the provided string, assuming that the DegreesMinutesSecondsDirection (DMS) format is in use.

public static bool ParseLongitudeInDmsd(
   string str,
   int precision,
   out double lonInDeg,
   out string errorMessage
);

Parameters

str
a string to be parsed
precision
a precision used in parsing
lonInDeg
the parsed 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 before running parsing. The valid precision is an integer number in the range from 0 (inclusive) to 15 (inclusive). The function recognizes the DegreesMinutesSecondsDirection (DMS) format, i.e. DDD MM SS.SSSS [E, W], for example: 77 2 56.4 W. The function verifies the validity of the parsed result also. The valid longitude (in degrees) is a real number in the range from -180.0 (inclusive) to 180.0 (inclusive).

Example

This sample shows how to call the TM.ParseLongitudeInDmsd method from C# code:

 string errorMessage = String.Empty;
 
 string str = "77 2 56.4 W";
 int precision = 10;
 double lonInDeg = Double.NaN;

 if (TM.ParseLongitudeInDmsd(str, precision, out lonInDeg, out errorMessage))
 {
     Console.WriteLine("LonInDeg: " + lonInDeg.ToString());
 }
 else
 {
     Console.WriteLine(errorMessage);
 }
 

See Also

TM Class | ApsGis Namespace