Serial port and GPS

Utils.coord2dec Method 

Converts the given coordinate string to decimal degrees.

[Visual Basic]
Public Shared Function coord2dec( _
   ByVal coord As String, _
   ByVal isNorthSouth As Boolean _
) As Double
[C#]
public static double coord2dec(
   string coord,
   bool isNorthSouth
);

Parameters

coord
the coordinate string
isNorthSouth
true vertical, false horizontal

Return Value

the resulting decimal degrees

Remarks

The coordinates may be given either as decimal degrees or as degrees, minutes, seconds, decimal part of seconds. Example: the left or right coordinate in decimal format 12.58243888889 corresponds to 12°34'56.78''E in degrees, minutes and seconds. The negative left or right coordinate -12.58243888889 means 12°34'56.78''E. Similar for top and bottom coordinates, where positive numbers mean North (N) and negative numbers South (S). Please consider using always dot for decimal points, rather than the locales dependend comma. Alternatively to to the character ° for degrees, ' for minutes and '' for seconds the small letters d, m and s may be used, thus you can get rid of encoding specific problems especially for the degrees, for which the character is differently encoded in different code pages. So the strings 12°34'56.78''E and 12d34m56.78sE mean exactly the same, the first one is more pretty, the later one more reliable.

Exceptions

Exception Type Condition
ArgumentException For not well formated input strings, also for commas instead of dots or for Weast/East for isNorthSouth true and vice versa.

See Also

Utils Class | serial Namespace