@signalk/nmea0183-utilities
Version:
Various utilities for transforming NMEA0183 units into SI units for use in SK.
90 lines • 3.78 kB
TypeScript
/**
* NMEA 0183 utilities: checksum, unit conversion, coordinate parsing,
* timestamp assembly, and numeric parsing helpers.
*
* All transforms output SI units so downstream Signal K consumers do not
* need to carry unit metadata.
*/
export declare const RATIOS: {
readonly NM_IN_KM: 1.852;
readonly KM_IN_NM: 0.539956803;
readonly KNOTS_IN_MS: 0.514444;
readonly KNOTS_IN_MPH: 1.150779;
readonly KNOTS_IN_KPH: 1.852;
readonly MPH_IN_MS: 0.44704;
readonly MPH_IN_KPH: 1.609344;
readonly MPH_IN_KNOTS: 0.868976;
readonly KPH_IN_MS: 0.277778;
readonly KPH_IN_MPH: 0.621371;
readonly KPH_IN_KNOTS: 0.539957;
readonly MS_IN_KPH: 3.6;
readonly MS_IN_MPH: 2.236936;
readonly MS_IN_KNOTS: 1.943844;
readonly DEG_IN_RAD: 0.0174532925;
readonly RAD_IN_DEG: 57.2957795;
readonly CELSIUS_IN_KELVIN: 273.15;
readonly METER_IN_FEET: 3.2808;
readonly METER_IN_FATHOM: 0.5468;
};
export type UnitFormat = 'km' | 'nm' | 'm' | 'ft' | 'fa' | 'knots' | 'kph' | 'ms' | 'mph' | 'deg' | 'rad' | 'c' | 'k' | 'f';
export type Pole = 'N' | 'S' | 'E' | 'W';
export interface SignalKSource {
type: 'NMEA0183';
label: 'signalk-parser-nmea0183';
sentence: string;
}
export declare function valid(sentence: unknown, validateChecksum?: boolean): boolean;
export declare function appendChecksum(sentence: string): string;
export declare function source(sentence?: string): SignalKSource;
export declare function transform(value: number | string, inputFormat: UnitFormat, outputFormat: UnitFormat): number;
export declare function magneticVariation(degrees: number | string, pole: Pole): number;
export declare function timestamp(time?: string, date?: string): string;
export declare function coordinate(value: string, pole: Pole): number;
export declare function isValidPosition(latitude: unknown, longitude: unknown): boolean;
export declare function zero(n: number): string;
export declare function int(n: unknown): number;
export declare function float(n: unknown): number;
export declare function intOrNull(n: unknown): number | null;
export declare function floatOrNull(n: unknown): number | null;
export declare function transformOrNull(value: unknown, inputFormat: UnitFormat, outputFormat: UnitFormat): number | null;
export declare function magneticVariationOrNull(degrees: unknown, pole: unknown): number | null;
declare const _default: {
RATIOS: {
readonly NM_IN_KM: 1.852;
readonly KM_IN_NM: 0.539956803;
readonly KNOTS_IN_MS: 0.514444;
readonly KNOTS_IN_MPH: 1.150779;
readonly KNOTS_IN_KPH: 1.852;
readonly MPH_IN_MS: 0.44704;
readonly MPH_IN_KPH: 1.609344;
readonly MPH_IN_KNOTS: 0.868976;
readonly KPH_IN_MS: 0.277778;
readonly KPH_IN_MPH: 0.621371;
readonly KPH_IN_KNOTS: 0.539957;
readonly MS_IN_KPH: 3.6;
readonly MS_IN_MPH: 2.236936;
readonly MS_IN_KNOTS: 1.943844;
readonly DEG_IN_RAD: 0.0174532925;
readonly RAD_IN_DEG: 57.2957795;
readonly CELSIUS_IN_KELVIN: 273.15;
readonly METER_IN_FEET: 3.2808;
readonly METER_IN_FATHOM: 0.5468;
};
valid: typeof valid;
appendChecksum: typeof appendChecksum;
source: typeof source;
transform: typeof transform;
magneticVariation: typeof magneticVariation;
timestamp: typeof timestamp;
coordinate: typeof coordinate;
isValidPosition: typeof isValidPosition;
zero: typeof zero;
int: typeof int;
float: typeof float;
intOrNull: typeof intOrNull;
floatOrNull: typeof floatOrNull;
transformOrNull: typeof transformOrNull;
magneticVariationOrNull: typeof magneticVariationOrNull;
};
export default _default;
//# sourceMappingURL=index.d.ts.map