UNPKG

@jbroll/nmea-simple

Version:

NMEA 0183 sentence parser and encoder

36 lines (35 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("should"); var index_1 = require("../index"); describe("GNS", function () { it("parser", function () { var packet = index_1.parseNmeaSentence("$GNGNS,144127.0,4306.925564,N,08930.865195,W,AN,07,1.2,320.2,-37.0,,*52"); var todayString = new Date().toISOString().substring(0, 10); packet.should.have.property("sentenceId", "GNS"); packet.should.have.property("sentenceName", "GNSS fix data"); packet.should.have.property("talkerId", "GN"); packet.should.have.property("time", new Date(todayString + "T14:41:27.000Z")); // Corresponds to time 144127.0 today packet.should.have.property("latitude", 43.115426066666664); packet.should.have.property("longitude", -89.51441991666667); packet.should.have.property("modeIndicator", "AN"); packet.should.have.property("satellitesInView", 7); packet.should.have.property("horizontalDilution", 1.2); packet.should.have.property("altitudeMeters", 320.2); packet.should.have.property("geoidalSeperation", -37); }); it("encoder", function () { var sentence = index_1.encodeNmeaPacket({ sentenceId: "GNS", time: new Date("2020-01-17T14:41:27.000Z"), latitude: 43.115426066666664, longitude: -89.51441991666667, modeIndicator: "AN", satellitesInView: 7, horizontalDilution: 1.2, altitudeMeters: 320.2, geoidalSeperation: -37 }, "GN"); sentence.should.equal("$GNGNS,144127,4306.925564,N,08930.865195,W,AN,7,1.2,320.2,-37.0,,*7C"); }); });