Methods
(static) compassPoint(bearing, precisionopt) → {string}
Returns compass point (to given precision) for supplied bearing.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bearing |
number | Bearing in degrees from north. | ||
precision |
number |
<optional> |
3 | Precision (1:cardinal / 2:intercardinal / 3:secondary-intercardinal). |
Returns:
Compass point for supplied bearing.
- Type
- string
Example
var point = Dms.compassPoint(24); // point = 'NNE'
var point = Dms.compassPoint(24, 1); // point = 'N'
(static) parseDMS(dmsStr) → {number}
Parses string representing degrees/minutes/seconds into numeric degrees.
This is very flexible on formats, allowing signed decimal degrees, or deg-min-sec optionally
suffixed by compass direction (NSEW). A variety of separators are accepted (eg 3° 37′ 09″W).
Seconds and minutes may be omitted.
Parameters:
Name | Type | Description |
---|---|---|
dmsStr |
string | number | Degrees or deg/min/sec in variety of formats. |
Returns:
Degrees as decimal number.
- Type
- number
Example
var lat = Dms.parseDMS('51° 28′ 40.12″ N');
var lon = Dms.parseDMS('000° 00′ 05.31″ W');
var p1 = new LatLon(lat, lon); // 51.4778°N, 000.0015°W
(static) toBrng(deg, formatopt, dpopt) → {string}
Converts numeric degrees to deg/min/sec as a bearing (0°..360°)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
deg |
number | Degrees to be formatted as specified. | ||
format |
string |
<optional> |
dms | Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. |
dp |
number |
<optional> |
0|2|4 | Number of decimal places to use – default 0 for dms, 2 for dm, 4 for d. |
Returns:
Degrees formatted as deg/min/secs according to specified format.
- Type
- string
(private, static) toDMS(deg, formatopt, dpopt) → {string}
Converts decimal degrees to deg/min/sec format
- degree, prime, double-prime symbols are added, but sign is discarded, though no compass
direction is added.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
deg |
number | Degrees to be formatted as specified. | ||
format |
string |
<optional> |
dms | Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. |
dp |
number |
<optional> |
0|2|4 | Number of decimal places to use – default 0 for dms, 2 for dm, 4 for d. |
Returns:
Degrees formatted as deg/min/secs according to specified format.
- Type
- string
(static) toLat(deg, formatopt, dpopt) → {string}
Converts numeric degrees to deg/min/sec latitude (2-digit degrees, suffixed with N/S).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
deg |
number | Degrees to be formatted as specified. | ||
format |
string |
<optional> |
dms | Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. |
dp |
number |
<optional> |
0|2|4 | Number of decimal places to use – default 0 for dms, 2 for dm, 4 for d. |
Returns:
Degrees formatted as deg/min/secs according to specified format.
- Type
- string
(static) toLon(deg, formatopt, dpopt) → {string}
Convert numeric degrees to deg/min/sec longitude (3-digit degrees, suffixed with E/W)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
deg |
number | Degrees to be formatted as specified. | ||
format |
string |
<optional> |
dms | Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. |
dp |
number |
<optional> |
0|2|4 | Number of decimal places to use – default 0 for dms, 2 for dm, 4 for d. |
Returns:
Degrees formatted as deg/min/secs according to specified format.
- Type
- string