@jbroll/nmea-simple
Version:
NMEA 0183 sentence parser and encoder
77 lines (76 loc) • 3.4 kB
TypeScript
export declare function toHexString(v: number): string;
export declare function padLeft(value: string | number, length: number, paddingCharacter: string): string;
/**
* Checks that the given NMEA sentence has a valid checksum.
*/
export declare function validNmeaChecksum(nmeaSentence: string): boolean;
/**
* Generate a checksum for an NMEA sentence without the trailing "*xx".
*/
export declare function computeNmeaChecksum(sentenceWithoutChecksum: string): number;
/**
* Generate the correct trailing "*xx" footer for an NMEA sentence.
*/
export declare function createNmeaChecksumFooter(sentenceWithoutChecksum: string): string;
/**
* Append the correct trailing "*xx" footer for an NMEA string and return the result.
*/
export declare function appendChecksumFooter(sentenceWithoutChecksum: string): string;
export declare function encodeFixed(value: number | undefined, decimalPlaces: number): string;
/**
* Encodes the latitude in the standard NMEA format "ddmm.mmmmmm".
*
* @param latitude Latitude in decimal degrees.
*/
export declare function encodeLatitude(latitude?: number): string;
/**
* Encodes the longitude in the standard NMEA format "dddmm.mmmmmm".
*
* @param longitude Longitude in decimal degrees.
*/
export declare function encodeLongitude(longitude?: number): string;
export declare function encodeAltitude(alt: number): string;
export declare function encodeAltitudeNoUnits(alt: number): string;
export declare function encodeGeoidalSeperation(geoidalSep: number): string;
export declare function encodeGeoidalSeperationNoUnits(geoidalSep: number): string;
export declare function encodeDegrees(degrees?: number): string;
export declare function encodeDate(date?: Date): string;
export declare function encodeTime(date?: Date): string;
export declare function encodeValue(value?: any): string;
/**
* Parse the given string to a float, returning 0 for an empty string.
*/
export declare function parseFloatSafe(str: string): number;
/**
* Parse the given string to a integer, returning 0 for an empty string.
*/
export declare function parseIntSafe(i: string): number;
/**
* Parse the given string to a float if possible, returning 0 for an undefined
* value and a string the the given string cannot be parsed.
*/
export declare function parseNumberOrString(str?: string): number | string;
/**
* Parses coordinate given as "dddmm.mm", "ddmm.mm", "dmm.mm" or "mm.mm"
*/
export declare function parseDmCoordinate(coordinate: string): number;
/**
* Parses latitude given as "ddmm.mm", "dmm.mm" or "mm.mm" (assuming zero
* degrees) along with a given hemisphere of "N" or "S" into decimal degrees,
* where north is positive and south is negative.
*/
export declare function parseLatitude(lat: string, hemi: string): number;
/**
* Parses latitude given as "dddmm.mm", "ddmm.mm", "dmm.mm" or "mm.mm" (assuming
* zero degrees) along with a given hemisphere of "E" or "W" into decimal
* degrees, where east is positive and west is negative.
*/
export declare function parseLongitude(lon: string, hemi: string): number;
/**
* Parses a UTC time and optionally a date and returns a Date
* object.
* @param {String} time Time the format "hhmmss" or "hhmmss.ss"
* @param {String=} date Optional date in format the ddmmyyyy or ddmmyy
* @returns {Date}
*/
export declare function parseTime(time: string, date?: string, rmcCompatible?: boolean): Date;