UNPKG

extended-nmea

Version:

A TypeScript library for parsing NMEA0183-like sentences with support for custom and proprietary sentences.

61 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GSA = exports.GsaFix = exports.GsaMode = void 0; const TalkerSentence_1 = require("../../types/sentences/TalkerSentence"); var GsaMode; (function (GsaMode) { GsaMode["Manual"] = "M"; GsaMode["Automatic"] = "A"; })(GsaMode = exports.GsaMode || (exports.GsaMode = {})); var GsaFix; (function (GsaFix) { GsaFix[GsaFix["NoFix"] = 1] = "NoFix"; GsaFix[GsaFix["Fix2D"] = 2] = "Fix2D"; GsaFix[GsaFix["Fix3D"] = 3] = "Fix3D"; })(GsaFix = exports.GsaFix || (exports.GsaFix = {})); class GSA extends TalkerSentence_1.TalkerSentence { constructor(data) { super(data); } get mode() { return this.dataFields[0]; } get fix() { return parseInt(this.dataFields[1]); } get ids() { return this.dataFields.slice(2, 13).filter(x => x.length > 0).map(x => parseInt(x)); } get positionalDop() { return parseFloat(this.dataFields[14]); } get horizontalDop() { return parseFloat(this.dataFields[15]); } get verticalDop() { return parseFloat(this.dataFields[16]); } get systemId() { if (this.dataFields.length === 17) { return null; } return this.dataFields[17]; } get valid() { const dataFieldsLength = this.dataFields.length; // NMEA 4.10 added systemId field return super.valid && (dataFieldsLength === 17 || dataFieldsLength === 18); } get invalidReason() { if (!super.valid) { return super.invalidReason; } if (this.dataFields.length !== 18 && this.dataFields.length !== 17) { return `Expected 17 or 18 fields, got ${this.dataFields.length}`; } return null; } } exports.GSA = GSA; GSA.ID = "GSA"; //# sourceMappingURL=GSA.js.map