Convert sexagesimal degrees to binary double-precision degrees

Namespace: ASCOM.Utilities.Interfaces
Assembly: ASCOM.Utilities (in ASCOM.Utilities.dll) Version: 6.0.0.0 (6.1.1.2619)

Syntax

C#
double DMSToDegrees(
	string DMS
)
Visual Basic
Function DMSToDegrees ( _
	DMS As String _
) As Double
Visual C++
double DMSToDegrees(
	String^ DMS
)

Parameters

DMS
Type: System..::..String
The sexagesimal input string (degrees)

Return Value

The double-precision binary value (degrees) represented by the sexagesimal input

Remarks

The sexagesimal to real conversion methods such as this one are flexible enough to convert just about anything that resembles sexagesimal. Thee way they operate is to first separate the input string into numeric "tokens", strings consisting only of the numerals 0-9, plus and minus, and period. All other characters are considered delimiters. Once the input string is parsed into tokens they are converted to numerics.

If there are more than three numeric tokens, only the first three are considered, the remainder are ignored. Left to right positionally, the tokens are assumed to represent units (degrees or hours), minutes, and seconds. If only two tokens are present, they are assumed to be units and minutes, and if only one token is present, it is assumed to be units. Any token can have a fractionsl part. Of course it would not be normal (for example) for both the minutes and seconds parts to have fractional parts, but it would be legal. So 00:30.5:30 would convert to 1.0 unit.

Note that plain units, for example 23.128734523 are acceptable to the method.

See Also