feat: 导入 NMEA-0183 GPS 协议解析库(node-nmea)
Some checks failed
Node.js CI / build (10.x) (push) Has been cancelled
Node.js CI / build (12.x) (push) Has been cancelled
Node.js CI / build (14.x) (push) Has been cancelled
Node.js CI / build (15.x) (push) Has been cancelled

NMEA-0183 语句解析器,含 21 个语句类型 codec 与配套单元测试。

- codecs/:APB/BWC/DBT/GGA/GLL/GRMT/GSA/GSV/HDG/HDM/HDT/MWV/RDID/
  RMB/RMC/ROT/RSA/TXT/VTG/VWR/ZDA
- test/:各 codec 对应的 mocha 用例
- .github/workflows/:node与 npm-publish 流水线

许可证:MIT(原作者 James Penn)
This commit is contained in:
hyzl
2026-10-19 09:54:44 +08:00
commit b0a1993169
50 changed files with 1951 additions and 0 deletions

44
test/GGAtest.js Normal file
View File

@@ -0,0 +1,44 @@
var should = require('should');
describe('GGA ', function () {
it('parses', function () {
var msg = require("../nmea.js").parse("$IIGGA,123519,4807.04,N,1131.00,E,1,8,0.9,545.9,M,46.9,M,,*52");
msg.should.have.property('type', 'fix');
msg.should.have.property('sentence', 'GGA');
msg.should.have.property('talker_id', 'II');
msg.should.have.property('timestamp', '123519');
msg.should.have.property('lat', '4807.04');
msg.should.have.property('latPole', 'N');
msg.should.have.property('lon', '1131.00');
msg.should.have.property('lonPole', 'E');
msg.should.have.property('fixType', 'fix');
msg.should.have.property('numSat', 8);
msg.should.have.property('horDilution', 0.9);
msg.should.have.property('alt', 545.9);
msg.should.have.property('altUnit', 'M');
msg.should.have.property('geoidalSep', 46.9);
msg.should.have.property('geoidalSepUnit', 'M');
});
});
describe('GGA', function () {
it('encodes ok', function () {
var nmeaMsg = require("../nmea.js").encode('II', {
type: 'fix',
timestamp: new Date(Date.UTC(2013, 1, 1, 12, 35, 19)),
lat: 4807.04,
latPole: 'N',
lon: 1131.00,
lonPole: 'E',
fixType: 'fix',
numSat: 8,
horDilution: 0.9,
alt: 545.9,
altUnit: 'M',
geoidalSep: 46.9,
geoidalSepUnit: 'M'
});
nmeaMsg.should.equal("$IIGGA,123519,4807.04,N,1131.00,E,1,8,0.9,545.9,M,46.9,M,,*52");
});
});