Comparing version 0.6.1 to 0.7.1
@@ -23,6 +23,6 @@ | ||
var Angles = require('angles'); | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
@@ -40,11 +40,11 @@ var lat1 = gps.state.lat; | ||
console.log("\033[2J\033[;H" + | ||
"You are at (" + lat1 + ", " + lon1 + "),\n" + | ||
"The closest confluence point (" + lat2 + ", " + lon2 + ") is in " + dist + " km.\n" + | ||
"You have to go " + head + "° " + rose); | ||
console.log("\033[2J\033[;H" + | ||
"You are at (" + lat1 + ", " + lon1 + "),\n" + | ||
"The closest confluence point (" + lat2 + ", " + lon2 + ") is in " + dist + " km.\n" + | ||
"You have to go " + head + "° " + rose); | ||
}); | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
}); |
@@ -24,16 +24,16 @@ | ||
app.get('/', function(req, res) { | ||
app.get('/', function (req, res) { | ||
res.sendFile(__dirname + '/dashboard.html'); | ||
}); | ||
var GPS = require('../../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
gps.state.bearing = 0; | ||
var prev = {lat: null, lon: null}; | ||
var prev = { lat: null, lon: null }; | ||
http.listen(3000, function() { | ||
http.listen(3000, function () { | ||
console.log('listening on *:3000'); | ||
gps.on('data', function() { | ||
gps.on('data', function () { | ||
if (prev.lat !== null && prev.lon !== null) { | ||
@@ -48,5 +48,5 @@ gps.state.bearing = GPS.Heading(prev.lat, prev.lon, gps.state.lat, gps.state.lon); | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
}); | ||
}); |
@@ -6,3 +6,3 @@ | ||
var byline = require('byline'); | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
@@ -13,3 +13,3 @@ | ||
// This filters all GGA packages from the dump | ||
gps.on('GGA', function(gga) { | ||
gps.on('GGA', function (gga) { | ||
@@ -20,5 +20,5 @@ console.log('Lat: ' + gga.lat); | ||
stream.on('data', function(data) { | ||
stream.on('data', function (data) { | ||
gps.update(data.toString()); | ||
}); |
@@ -23,11 +23,11 @@ | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
ws.write(data.raw + '\n'); | ||
}); | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
}); |
@@ -6,3 +6,3 @@ | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
@@ -13,3 +13,3 @@ process.stdin.resume(); | ||
function Process() { | ||
Transform.call(this, {objectMode: true}); | ||
Transform.call(this, { objectMode: true }); | ||
} | ||
@@ -19,3 +19,3 @@ | ||
_line: "", | ||
_transform: function(chunk, encoding, done) { | ||
_transform: function (chunk, encoding, done) { | ||
@@ -29,3 +29,3 @@ var data = this._line + chunk.toString(); | ||
lines.forEach(function(x) { | ||
lines.forEach(function (x) { | ||
@@ -40,3 +40,3 @@ var tmp = GPS.parse(x); | ||
}, | ||
_flush: function(done) { | ||
_flush: function (done) { | ||
@@ -61,3 +61,3 @@ if (this._line) { | ||
process.stdin | ||
.pipe(new Process) | ||
.pipe(process.stdout); | ||
.pipe(new Process) | ||
.pipe(process.stdout); |
@@ -28,3 +28,3 @@ | ||
var GPS = require('../../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
@@ -45,3 +45,3 @@ | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
@@ -70,7 +70,7 @@ if (data.lat && data.lon) { | ||
app.get('/', function(req, res) { | ||
app.get('/', function (req, res) { | ||
res.sendFile(__dirname + '/maps.html'); | ||
}); | ||
http.listen(3000, function() { | ||
http.listen(3000, function () { | ||
@@ -80,4 +80,4 @@ console.log('listening on *:3000'); | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
}); |
@@ -27,11 +27,11 @@ | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
}); |
@@ -22,6 +22,6 @@ | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
@@ -31,3 +31,3 @@ if (!data.time) | ||
exec('date -s "' + data.time.toString() + '"', function(error, stdout, stderr) { | ||
exec('date -s "' + data.time.toString() + '"', function (error, stdout, stderr) { | ||
if (error) throw error; | ||
@@ -40,3 +40,3 @@ // Clock should be set now, exit | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
@@ -43,0 +43,0 @@ }); |
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
@@ -8,3 +8,3 @@ | ||
gps.on('data', function(parsed) { | ||
gps.on('data', function (parsed) { | ||
@@ -11,0 +11,0 @@ console.log(parsed); |
@@ -21,11 +21,11 @@ | ||
var GPS = require('../gps.js'); | ||
var GPS = require('gps'); | ||
var gps = new GPS; | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
console.log(gps.state); | ||
}); | ||
parser.on('data', function(data) { | ||
parser.on('data', function (data) { | ||
gps.update(data); | ||
}); |
{ | ||
"name": "gps", | ||
"title": "gps.js", | ||
"version": "0.6.1", | ||
"homepage": "https://www.xarg.org/2016/07/using-gps-with-node-js-and-javascript/", | ||
"bugs": "https://github.com/infusion/GPS.js/issues", | ||
"title": "GPS.js", | ||
"version": "0.7.1", | ||
"homepage": "https://raw.org/article/using-gps-with-node-js-and-javascript/", | ||
"bugs": "https://github.com/rawify/GPS.js/issues", | ||
"description": "A GPS NMEA parser library", | ||
@@ -26,20 +26,39 @@ "keywords": [ | ||
], | ||
"author": "Robert Eisele <robert@xarg.org> (http://www.xarg.org/)", | ||
"main": "gps.js", | ||
"types": "gps.d.ts", | ||
"private": false, | ||
"main": "./dist/gps.js", | ||
"module": "./dist/gps.mjs", | ||
"types": "./gps.d.ts", | ||
"browser": "./dist/gps.min.js", | ||
"unpkg": "./dist/gps.min.js", | ||
"readmeFilename": "README.md", | ||
"directories": { | ||
"example": "examples", | ||
"test": "tests" | ||
"exports": { | ||
".": { | ||
"types": "./gps.d.ts", | ||
"require": "./dist/gps.js", | ||
"import": "./dist/gps.mjs" | ||
} | ||
}, | ||
"license": "MIT OR GPL-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/infusion/GPS.js.git" | ||
"url": "git@github.com:rawify/GPS.js.git" | ||
}, | ||
"funding": { | ||
"type": "github", | ||
"url": "https://github.com/sponsors/rawify" | ||
}, | ||
"author": { | ||
"name": "Robert Eisele", | ||
"email": "robert@raw.org", | ||
"url": "https://raw.org/" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"directories": { | ||
"example": "examples", | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"build": "crude-build GPS", | ||
"test": "mocha tests/*.js" | ||
@@ -50,10 +69,10 @@ }, | ||
"byline": "^5.0.0", | ||
"chai": "^4.3.4", | ||
"express": "^4.17.2", | ||
"mocha": "^9.1.4", | ||
"serialport": "^9.2.8", | ||
"socket.io": "^4.4.1", | ||
"crude-build": "^0.0.3", | ||
"express": "^4.21.0", | ||
"kalman": "0.0.2", | ||
"mocha": "^10.7.3", | ||
"serialport": "^12.0.0", | ||
"socket.io": "^4.8.0", | ||
"sylvester": "0.0.21" | ||
} | ||
} |
@@ -5,3 +5,2 @@ | ||
[![NPM Package](https://img.shields.io/npm/v/gps.svg?style=flat)](https://npmjs.org/package/gps "View this project on npm") | ||
[![Build Status](https://travis-ci.org/infusion/GPS.js.svg?branch=master)](https://travis-ci.org/infusion/GPS.js) | ||
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) | ||
@@ -12,5 +11,5 @@ | ||
Usage | ||
=== | ||
## Usage | ||
The interface of GPS.js is as simple as the following few lines. You need to add an event-listener for the completion of the task and invoke the update method with a sentence you want to process. There are much more examples in the examples folder. | ||
@@ -33,5 +32,5 @@ | ||
State | ||
=== | ||
## State | ||
The real advantage over other NMEA implementations is, that the GPS information is interpreted and normalized. The most high-level API is the state object, which changes with every new event. You can use this information with: | ||
@@ -45,4 +44,4 @@ | ||
Installation | ||
=== | ||
## Installation | ||
Installing GPS.js is as easy as cloning this repo or use the following command: | ||
@@ -54,5 +53,5 @@ | ||
Find the serial device | ||
=== | ||
## Find the serial device | ||
On Linux serial devices typically have names like `/dev/ttyS1`, on OSX `/dev/tty.usbmodem1411` after installing a USB to serial driver and on Windows, you're probably fine by using the highest COM device you can find in the device manager. Please note that if you have multiple USB ports on your computer and use them randomly, you have to lookup the path/device again. | ||
@@ -72,5 +71,5 @@ | ||
Examples | ||
=== | ||
## Examples | ||
GPS.js comes with some examples, like drawing the current latitude and longitude to Google Maps, displaying a persistent state and displaying the parsed raw data. In some cases you have to adjust the serial path to your own GPS receiver to make it work. | ||
@@ -151,5 +150,5 @@ | ||
Available Methods | ||
=== | ||
## Available Methods | ||
update(line) | ||
@@ -171,5 +170,5 @@ --- | ||
Implemented Protocols | ||
=== | ||
## Implemented Protocols | ||
GGA - Fix information | ||
@@ -298,4 +297,4 @@ --- | ||
GPS State | ||
=== | ||
## GPS State | ||
If the streaming API is not needed, but a solid state of the system, the `gps.state` object can be used. It has the following properties: | ||
@@ -315,9 +314,9 @@ | ||
Troubleshooting | ||
=== | ||
## Troubleshooting | ||
If you don't get valid position information after turning on the receiver, chances are high you simply have to wait as it takes some [time to first fix](https://en.wikipedia.org/wiki/Time_to_first_fix). | ||
Functions | ||
=== | ||
## Functions | ||
GPS.js comes with a few static functions, which helps working with geo-coordinates. | ||
@@ -347,8 +346,8 @@ | ||
Using GPS.js with the browser | ||
=== | ||
## Using GPS.js with the browser | ||
The use cases should be rare to parse NMEA directly inside the browser, but it works too. | ||
```html | ||
<script src="gps.js"></script> | ||
<script src="gps.min.js"></script> | ||
<script> | ||
@@ -360,13 +359,22 @@ var gps = new GPS; | ||
Testing | ||
=== | ||
If you plan to enhance the library, make sure you add test cases and all the previous tests are passing. You can test the library with | ||
## Building the library | ||
After cloning the Git repository run: | ||
``` | ||
npm test | ||
npm install | ||
npm run build | ||
``` | ||
Copyright and licensing | ||
=== | ||
Copyright (c) 2016, [Robert Eisele](https://www.xarg.org/) | ||
Dual licensed under the MIT or GPL Version 2 licenses. | ||
## Run a test | ||
Testing the source against the shipped test suite is as easy as | ||
``` | ||
npm run test | ||
``` | ||
## Copyright and licensing | ||
Copyright (c) 2025, [Robert Eisele](https://raw.org/) | ||
Licensed under the MIT license. |
var expect = require('chai').expect; | ||
var GPS = require('../gps.js'); | ||
const GPS = require('gps'); | ||
const assert = require('assert'); | ||
describe('GPS functions', function() { | ||
describe('GPS functions', function () { | ||
it('should measure distance', function() { | ||
it('should measure distance', function () { | ||
var result = GPS.Distance(45.527517, -122.718766, 45.373373, -121.693604); | ||
expect(result).to.deep.equal(81.80760861833895); | ||
assert.deepEqual(result, 81.80760861833895) | ||
}); | ||
it('should measure heading', function() { | ||
it('should measure heading', function () { | ||
var result = GPS.Heading(45.527517, -122.718766, 45.373373, -121.693604); | ||
expect(result).to.deep.equal(101.73177498132071); | ||
assert.deepEqual(result, 101.73177498132071) | ||
}); | ||
}); |
@@ -6,9 +6,9 @@ | ||
var today = new Date(); | ||
let today = new Date(); | ||
today = today.getUTCFullYear() + '-' + _(today.getUTCMonth() + 1) + '-' + _(today.getUTCDate()); | ||
var expect = require('chai').expect; | ||
var GPS = require('../gps.js'); | ||
var gps = new GPS; | ||
var tests = { | ||
const GPS = require('gps'); | ||
const assert = require('assert'); | ||
const gps = new GPS; | ||
const tests = { | ||
'foo': 'invalid', | ||
@@ -28,2 +28,3 @@ '$GPGSA,A,3,29,26,31,21,,,,,,,,,2.0,1.7,1.0*39': { | ||
'type': 'GSA', | ||
"system": "unknown", | ||
"systemId": null, | ||
@@ -107,2 +108,3 @@ 'valid': true, | ||
'signalId': null, | ||
"system": "GPS", | ||
'satellites': [ | ||
@@ -112,23 +114,31 @@ { | ||
'elevation': 17, | ||
"key": "GP16", | ||
'prn': 16, | ||
'snr': 46, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 307, | ||
'elevation': 61, | ||
"key": "GP20", | ||
'prn': 20, | ||
'snr': 51, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 283, | ||
'elevation': 36, | ||
"key": "GP23", | ||
'prn': 23, | ||
'snr': 47, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 34, | ||
'elevation': 6, | ||
"key": "GP25", | ||
'prn': 25, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
} | ||
@@ -166,2 +176,3 @@ ], | ||
"systemId": null, | ||
"system": "unknown", | ||
'raw': '$GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A', | ||
@@ -187,2 +198,3 @@ 'satellites': [ | ||
'signalId': null, | ||
"system": "GPS", | ||
'raw': '$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70', | ||
@@ -193,23 +205,31 @@ 'satellites': [ | ||
'elevation': 63, | ||
"key": "GP10", | ||
'prn': 10, | ||
'snr': 17, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 98, | ||
'elevation': 61, | ||
"key": "GP7", | ||
'prn': 7, | ||
'snr': 15, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 290, | ||
'elevation': 59, | ||
"key": "GP5", | ||
'prn': 5, | ||
'snr': 20, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 157, | ||
'elevation': 54, | ||
"key": "GP8", | ||
'prn': 8, | ||
'snr': 30, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
} | ||
@@ -263,2 +283,3 @@ ], | ||
], | ||
"system": "unknown", | ||
'type': 'GSA', | ||
@@ -278,25 +299,34 @@ 'valid': true, | ||
'elevation': 3, | ||
"key": "GP3", | ||
'prn': 3, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 270, | ||
'elevation': 15, | ||
"key": "GP4", | ||
'prn': 4, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 10, | ||
'elevation': 1, | ||
"key": "GP6", | ||
'prn': 6, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 292, | ||
'elevation': 6, | ||
"key": "GP13", | ||
'prn': 13, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
} | ||
], | ||
"system": "GPS", | ||
'type': 'GSV', | ||
@@ -315,26 +345,35 @@ 'valid': true | ||
'elevation': 25, | ||
"key": "GP14", | ||
'prn': 14, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 208, | ||
'elevation': 57, | ||
"key": "GP16", | ||
'prn': 16, | ||
'snr': 39, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 296, | ||
'elevation': 67, | ||
"key": "GP18", | ||
'prn': 18, | ||
'snr': 40, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 246, | ||
'elevation': 40, | ||
"key": "GP19", | ||
'prn': 19, | ||
'snr': 0, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
} | ||
], | ||
'type': 'GSV', | ||
"system": "GPS", | ||
'valid': false | ||
@@ -352,26 +391,35 @@ }, | ||
'elevation': 39, | ||
"key": "GP2", | ||
'prn': 2, | ||
'snr': 16, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 70, | ||
'elevation': 28, | ||
"key": "GP13", | ||
'prn': 13, | ||
'snr': 17, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 252, | ||
'elevation': 23, | ||
"key": "GP26", | ||
'prn': 26, | ||
'snr': null, | ||
'status': 'in view' | ||
'status': 'in view', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 186, | ||
'elevation': 14, | ||
"key": "GP4", | ||
'prn': 4, | ||
'snr': 15, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
} | ||
], | ||
'type': 'GSV', | ||
"system": "GPS", | ||
'valid': true | ||
@@ -389,20 +437,27 @@ }, | ||
'elevation': 9, | ||
"key": "GP29", | ||
'prn': 29, | ||
'snr': 24, | ||
'status': 'tracking' | ||
'status': 'tracking', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': 20, | ||
'elevation': 9, | ||
"key": "GP16", | ||
'prn': 16, | ||
'snr': null, | ||
'status': 'in view' | ||
'status': 'in view', | ||
"system": "GPS" | ||
}, { | ||
'azimuth': null, | ||
'elevation': null, | ||
"key": "GP36", | ||
'prn': 36, | ||
'snr': null, | ||
'status': 'in view' | ||
'status': 'in view', | ||
"system": "GPS" | ||
} | ||
], | ||
'type': 'GSV', | ||
"system": "GPS", | ||
'valid': true | ||
@@ -574,23 +629,31 @@ }, | ||
"elevation": 20, | ||
"key": "GP2", | ||
"prn": 2, | ||
"snr": 26, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "GPS" | ||
}, { | ||
"azimuth": 72, | ||
"elevation": 20, | ||
"key": "GP6", | ||
"prn": 6, | ||
"snr": 18, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "GPS" | ||
}, { | ||
"azimuth": 40, | ||
"elevation": 77, | ||
"key": "GP12", | ||
"prn": 12, | ||
"snr": 37, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "GPS" | ||
}, { | ||
"azimuth": 309, | ||
"elevation": 30, | ||
"key": "GP14", | ||
"prn": 14, | ||
"snr": 25, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "GPS" | ||
} | ||
@@ -600,2 +663,3 @@ ], | ||
"signalId": 1, | ||
"system": "GPS", | ||
"type": "GSV", | ||
@@ -612,5 +676,7 @@ "valid": true | ||
"elevation": 11, | ||
"key": "GA33", | ||
"prn": 33, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "Galileo" | ||
} | ||
@@ -620,2 +686,3 @@ ], | ||
"signalId": 7, | ||
"system": "Galileo", | ||
"type": "GSV", | ||
@@ -632,23 +699,31 @@ "valid": true | ||
"elevation": 22, | ||
"key": "GP2", | ||
"prn": 2, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "GPS" | ||
}, { | ||
"azimuth": 357, | ||
"elevation": 0, | ||
"key": "GP3", | ||
"prn": 3, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "GPS" | ||
}, { | ||
"azimuth": 68, | ||
"elevation": 21, | ||
"key": "GP6", | ||
"prn": 6, | ||
"snr": 18, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "GPS" | ||
}, { | ||
"azimuth": 46, | ||
"elevation": 73, | ||
"key": "GP12", | ||
"prn": 12, | ||
"snr": 32, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "GPS" | ||
} | ||
@@ -658,2 +733,3 @@ ], | ||
"signalId": 6, | ||
"system": "GPS", | ||
"type": "GSV", | ||
@@ -670,23 +746,31 @@ "valid": true | ||
"elevation": 49, | ||
"key": "GA2", | ||
"prn": 2, | ||
"snr": 30, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "Galileo" | ||
}, { | ||
"azimuth": 221, | ||
"elevation": 22, | ||
"key": "GA3", | ||
"prn": 3, | ||
"snr": 29, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "Galileo" | ||
}, { | ||
"azimuth": 328, | ||
"elevation": 12, | ||
"key": "GA7", | ||
"prn": 7, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "Galileo" | ||
}, { | ||
"azimuth": 278, | ||
"elevation": 32, | ||
"key": "GA8", | ||
"prn": 8, | ||
"snr": 35, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "Galileo" | ||
} | ||
@@ -697,2 +781,3 @@ ], | ||
"type": "GSV", | ||
"system": "Galileo", | ||
"valid": true | ||
@@ -708,26 +793,35 @@ }, | ||
"elevation": 31, | ||
"key": "GB13", | ||
"prn": 13, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BeiDou" | ||
}, { | ||
"azimuth": 255, | ||
"elevation": 12, | ||
"key": "GB21", | ||
"prn": 21, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BeiDou" | ||
}, { | ||
"azimuth": 293, | ||
"elevation": 18, | ||
"key": "GB26", | ||
"prn": 26, | ||
"snr": 27, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BeiDou" | ||
}, { | ||
"azimuth": 155, | ||
"elevation": 46, | ||
"key": "GB29", | ||
"prn": 29, | ||
"snr": 31, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BeiDou" | ||
} | ||
], | ||
"satsInView": 4, | ||
"system": "BeiDou", | ||
"signalId": 1, | ||
@@ -755,2 +849,3 @@ "type": "GSV", | ||
"mode": "automatic", | ||
"system": "GPS", | ||
"systemId": 1, | ||
@@ -886,2 +981,3 @@ "pdop": 1.55, | ||
"systemId": 1, | ||
"system": "GPS", | ||
"type": "GSA", | ||
@@ -969,25 +1065,34 @@ "valid": true, | ||
"elevation": null, | ||
"key": "BD1", | ||
"prn": 1, | ||
"snr": 37, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BD" | ||
}, { | ||
"azimuth": null, | ||
"elevation": null, | ||
"key": "BD2", | ||
"prn": 2, | ||
"snr": 38, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BD" | ||
}, { | ||
"azimuth": null, | ||
"elevation": null, | ||
"key": "BD3", | ||
"prn": 3, | ||
"snr": 39, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BD" | ||
}, { | ||
"azimuth": null, | ||
"elevation": null, | ||
"key": "BD5", | ||
"prn": 5, | ||
"snr": 37, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BD" | ||
}], | ||
"satsInView": 16, | ||
"system": "BD", | ||
"signalId": null, | ||
@@ -1004,20 +1109,27 @@ "type": "GSV", | ||
"elevation": 46, | ||
"key": "BD10", | ||
"prn": 10, | ||
"snr": 31, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BD" | ||
}, { | ||
"azimuth": 161, | ||
"elevation": 43, | ||
"key": "BD8", | ||
"prn": 8, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BD" | ||
}, { | ||
"azimuth": 217, | ||
"elevation": 40, | ||
"key": "BD9", | ||
"prn": 9, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BD" | ||
}], | ||
"satsInView": 3, | ||
"signalId": null, | ||
"system": "BD", | ||
"type": "GSV", | ||
@@ -1033,25 +1145,34 @@ "valid": true | ||
"elevation": 18, | ||
"key": "BD211", | ||
"prn": 211, | ||
"snr": 36, | ||
"status": "tracking" | ||
"status": "tracking", | ||
"system": "BD" | ||
}, { | ||
"azimuth": 113, | ||
"elevation": 7, | ||
"key": "BD205", | ||
"prn": 205, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BD" | ||
}, { | ||
"azimuth": 29, | ||
"elevation": 4, | ||
"key": "BD206", | ||
"prn": 206, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BD" | ||
}, { | ||
"azimuth": 46, | ||
"elevation": 30, | ||
"key": "BD209", | ||
"prn": 209, | ||
"snr": null, | ||
"status": "in view" | ||
"status": "in view", | ||
"system": "BD" | ||
}], | ||
"satsInView": 6, | ||
"system": "BD", | ||
"signalId": null, | ||
@@ -1081,3 +1202,3 @@ "type": "GSV", | ||
it('Should pass ' + i, function () { | ||
expect(collect[i]).to.deep.equal(tests[i]); | ||
assert.deepEqual(collect[i], tests[i]); | ||
}); | ||
@@ -1084,0 +1205,0 @@ })(i); |
var expect = require('chai').expect; | ||
var GPS = require('../gps.js'); | ||
var gps = new GPS; | ||
const GPS = require('gps'); | ||
const assert = require('assert'); | ||
const gps = new GPS; | ||
var res = [{ | ||
'lat': 48.539856666666665, | ||
'lon': 9.059166666666666, | ||
'speed': 4.22256, | ||
'status': 'active', | ||
'time': new Date('2016-01-26T23:49:19.000Z'), | ||
'track': 2.93, | ||
'raw': '$GPRMC,234919.000,A,4832.3914,N,00903.5500,E,2.28,2.93,260116,,*0D', | ||
'type': 'RMC', | ||
'faa': null, | ||
"navStatus": null, | ||
'valid': true, | ||
'variation': null | ||
}, { | ||
'speed': 4.22256, | ||
'track': 2.93, | ||
'trackMagnetic': null, | ||
'raw': '$GPVTG,2.93,T,,M,2.28,N,4.2,K*66', | ||
'type': 'VTG', | ||
'faa': null, | ||
'valid': true | ||
} | ||
const res = [{ | ||
'lat': 48.539856666666665, | ||
'lon': 9.059166666666666, | ||
'speed': 4.22256, | ||
'status': 'active', | ||
'time': new Date('2016-01-26T23:49:19.000Z'), | ||
'track': 2.93, | ||
'raw': '$GPRMC,234919.000,A,4832.3914,N,00903.5500,E,2.28,2.93,260116,,*0D', | ||
'type': 'RMC', | ||
'faa': null, | ||
"navStatus": null, | ||
'valid': true, | ||
'variation': null | ||
}, { | ||
'speed': 4.22256, | ||
'track': 2.93, | ||
'trackMagnetic': null, | ||
'raw': '$GPVTG,2.93,T,,M,2.28,N,4.2,K*66', | ||
'type': 'VTG', | ||
'faa': null, | ||
'valid': true | ||
} | ||
]; | ||
describe('partial updates', function() { | ||
describe('partial updates', function () { | ||
it('should work async with partial updates', function(done) { | ||
it('should work async with partial updates', function (done) { | ||
var K = 0; | ||
gps.on('data', function(data) { | ||
gps.on('data', function (data) { | ||
try { | ||
expect(data).to.deep.equal(res[K++]); | ||
assert.deepEqual(data, res[K++]); | ||
} catch (e) { | ||
@@ -41,0 +41,0 @@ done(e); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
435717
0
100
4115
369
4