UNPKG

@signalk/course-provider

Version:
156 lines 7.25 kB
export = Dms; /** * Functions for parsing and representing degrees / minutes / seconds. */ declare class Dms { static set separator(char: string); /** * Separator character to be used to separate degrees, minutes, seconds, and cardinal directions. * * Default separator is U+202F ‘narrow no-break space’. * * To change this (e.g. to empty string or full space), set Dms.separator prior to invoking * formatting. * * @example * import LatLon, { Dms } from '/js/geodesy/latlon-spherical.js'; * const p = new LatLon(51.2, 0.33).toString('dms'); // 51° 12′ 00″ N, 000° 19′ 48″ E * Dms.separator = ''; // no separator * const pʹ = new LatLon(51.2, 0.33).toString('dms'); // 51°12′00″N, 000°19′48″E */ static get separator(): string; /** * 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. Examples -3.62, * '3 37 12W', '3°37′12″W'. * * Thousands/decimal separators must be comma/dot; use Dms.fromLocale to convert locale-specific * thousands/decimal separators. * * @param {string|number} dms - Degrees or deg/min/sec in variety of formats. * @returns {number} Degrees as decimal number. * * @example * const lat = Dms.parse('51° 28′ 40.37″ N'); * const lon = Dms.parse('000° 00′ 05.29″ W'); * const p1 = new LatLon(lat, lon); // 51.4779°N, 000.0015°W */ static parse(dms: string | number): number; /** * 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. * - degrees are zero-padded to 3 digits; for degrees latitude, use .slice(1) to remove leading * zero. * * @private * @param {number} deg - Degrees to be formatted as specified. * @param {string} [format=d] - Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. * @param {number} [dp=4|2|0] - Number of decimal places to use – default 4 for d, 2 for dm, 0 for dms. * @returns {string} Degrees formatted as deg/min/secs according to specified format. */ private static toDms; /** * Converts numeric degrees to deg/min/sec latitude (2-digit degrees, suffixed with N/S). * * @param {number} deg - Degrees to be formatted as specified. * @param {string} [format=d] - Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. * @param {number} [dp=4|2|0] - Number of decimal places to use – default 4 for d, 2 for dm, 0 for dms. * @returns {string} Degrees formatted as deg/min/secs according to specified format. * * @example * const lat = Dms.toLat(-3.62, 'dms'); // 3°37′12″S */ static toLat(deg: number, format?: string, dp?: number): string; /** * Convert numeric degrees to deg/min/sec longitude (3-digit degrees, suffixed with E/W). * * @param {number} deg - Degrees to be formatted as specified. * @param {string} [format=d] - Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. * @param {number} [dp=4|2|0] - Number of decimal places to use – default 4 for d, 2 for dm, 0 for dms. * @returns {string} Degrees formatted as deg/min/secs according to specified format. * * @example * const lon = Dms.toLon(-3.62, 'dms'); // 3°37′12″W */ static toLon(deg: number, format?: string, dp?: number): string; /** * Converts numeric degrees to deg/min/sec as a bearing (0°..360°). * * @param {number} deg - Degrees to be formatted as specified. * @param {string} [format=d] - Return value as 'd', 'dm', 'dms' for deg, deg+min, deg+min+sec. * @param {number} [dp=4|2|0] - Number of decimal places to use – default 4 for d, 2 for dm, 0 for dms. * @returns {string} Degrees formatted as deg/min/secs according to specified format. * * @example * const lon = Dms.toBrng(-3.62, 'dms'); // 356°22′48″ */ static toBrng(deg: number, format?: string, dp?: number): string; /** * Converts DMS string from locale thousands/decimal separators to JavaScript comma/dot separators * for subsequent parsing. * * Both thousands and decimal separators must be followed by a numeric character, to facilitate * parsing of single lat/long string (in which whitespace must be left after the comma separator). * * @param {string} str - Degrees/minutes/seconds formatted with locale separators. * @returns {string} Degrees/minutes/seconds formatted with standard Javascript separators. * * @example * const lat = Dms.fromLocale('51°28′40,12″N'); // '51°28′40.12″N' in France * const p = new LatLon(Dms.fromLocale('51°28′40,37″N, 000°00′05,29″W'); // '51.4779°N, 000.0015°W' in France */ static fromLocale(str: string): string; /** * Converts DMS string from JavaScript comma/dot thousands/decimal separators to locale separators. * * Can also be used to format standard numbers such as distances. * * @param {string} str - Degrees/minutes/seconds formatted with standard Javascript separators. * @returns {string} Degrees/minutes/seconds formatted with locale separators. * * @example * const Dms.toLocale('123,456.789'); // '123.456,789' in France * const Dms.toLocale('51°28′40.12″N, 000°00′05.31″W'); // '51°28′40,12″N, 000°00′05,31″W' in France */ static toLocale(str: string): string; /** * Returns compass point (to given precision) for supplied bearing. * * @param {number} bearing - Bearing in degrees from north. * @param {number} [precision=3] - Precision (1:cardinal / 2:intercardinal / 3:secondary-intercardinal). * @returns {string} Compass point for supplied bearing. * * @example * const point = Dms.compassPoint(24); // point = 'NNE' * const point = Dms.compassPoint(24, 1); // point = 'N' */ static compassPoint(bearing: number, precision?: number): string; /** * Constrain degrees to range -90..+90 (for latitude); e.g. -91 => -89, 91 => 89. * * @private * @param {number} degrees * @returns degrees within range -90..+90. */ private static wrap90; /** * Constrain degrees to range -180..+180 (for longitude); e.g. -181 => 179, 181 => -179. * * @private * @param {number} degrees * @returns degrees within range -180..+180. */ private static wrap180; /** * Constrain degrees to range 0..360 (for bearings); e.g. -1 => 359, 361 => 1. * * @private * @param {number} degrees * @returns degrees within range 0..360. */ private static wrap360; } //# sourceMappingURL=dms.d.ts.map