Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gps

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gps - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

2

bower.json
{
"name": "gps",
"main": "gps.js",
"version": "0.5.1",
"version": "0.5.2",
"homepage": "https://github.com/infusion/GPS.js",

@@ -6,0 +6,0 @@ "description": "A GPS NMEA parser library",

@@ -6,2 +6,5 @@

var Sylvester = require('sylvester');
var Kalman = require('kalman').KF;
// var file = '/dev/cu.usbserial';

@@ -29,4 +32,37 @@ // var file = '/dev/ttyUSB0';

gps.on('GGA', function(data) {
io.emit('position', data);
// Simple Kalman Filter set up
var A = Sylvester.Matrix.I(2);
var B = Sylvester.Matrix.Zero(2, 2);
var H = Sylvester.Matrix.I(2);
var C = Sylvester.Matrix.I(2);
var Q = Sylvester.Matrix.I(2).multiply(1e-11);
var R = Sylvester.Matrix.I(2).multiply(0.00001);
// Measure
var u = $V([0, 0]);
var filter = new Kalman($V([0, 0]), $M([[1, 0], [0, 1]]));
gps.on('data', function(data) {
if (data.lat && data.lon) {
filter.update({
A: A,
B: B,
C: C,
H: H,
R: R,
Q: Q,
u: u,
y: $V([data.lat, data.lon])
});
gps.state.position = {
cov: filter.P.elements,
pos: filter.x.elements
};
}
io.emit('position', gps.state);
});

@@ -33,0 +69,0 @@

/**
* @license GPS.js v0.5.1 26/01/2016
* @license GPS.js v0.5.2 26/01/2016
*

@@ -15,7 +15,2 @@ * Copyright (c) 2016, Robert Eisele (robert@xarg.org)

var MIN_LON = -Math.PI;
var MAX_LON = Math.PI;
var MIN_LAT = -Math.PI / 2;
var MAX_LAT = Math.PI / 2;
var collectSats = [];

@@ -26,3 +21,3 @@

// TODO: can we really use RMC time here or is it the time of fix?
if (data['type'] === 'RMC' || data['type'] === 'GGA' || data['type'] === 'GLL') {
if (data['type'] === 'RMC' || data['type'] === 'GGA' || data['type'] === 'GLL' || data['type'] === 'GNS') {
state['time'] = data['time'];

@@ -198,7 +193,7 @@ state['lat'] = data['lat'];

case 4:
return 'rtk'; // valid RTK fix
return 'rtk'; // valid (real time kinematic) RTK fix
case 5:
return 'rtk-float'; // valid RTK float
return 'rtk-float'; // valid (real time kinematic) RTK float
case 6:
return 'estimated';
return 'estimated'; // dead reckoning
case 7:

@@ -244,2 +239,4 @@ return 'manual';

switch (faa) {
case '':
return null;
case 'A':

@@ -250,3 +247,3 @@ return 'autonomous';

case 'E':
return 'estimated';
return 'estimated'; // dead reckoning
case 'M':

@@ -260,2 +257,6 @@ return 'manual input';

return 'precise';
case 'R':
return 'rtk'; // valid (real time kinematic) RTK fix
case 'F':
return 'rtk-float'; // valid (real time kinematic) RTK float
}

@@ -327,3 +328,3 @@ throw new Error('INVALID FAA MODE: ' + faa);

$--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh
1) Time (UTC)

@@ -365,3 +366,3 @@ 2) Latitude

if (gsa.length !== 19) {
if (gsa.length !== 19 && gsa.length !== 20) {
throw new Error('Invalid GSA length: ' + str);

@@ -373,4 +374,4 @@ }

eg2. $GPGSA,A,3,19,28,14,18,27,22,31,39,,,,,1.7,1.0,1.3*35
1 = Mode:

@@ -387,2 +388,3 @@ M=Manual, forced to operate in 2D or 3D

17 = VDOP
(18) = systemID NMEA 4.10
18 = Checksum

@@ -405,3 +407,4 @@ */

'hdop': parseNumber(gsa[16]),
'vdop': parseNumber(gsa[17])
'vdop': parseNumber(gsa[17]),
'systemId': gsa.length > 19 ? parseNumber(gsa[18]) : null
};

@@ -412,3 +415,3 @@ },

if (rmc.length !== 13 && rmc.length !== 14) {
if (rmc.length !== 13 && rmc.length !== 14 && rmc.length !== 15) {
throw new Error('Invalid RMC length: ' + str);

@@ -419,3 +422,3 @@ }

$GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a*hh
RMC = Recommended Minimum Specific GPS/TRANSIT Data

@@ -434,2 +437,3 @@ 1 = UTC of position fix

(12) = NMEA 2.3 introduced FAA mode indicator (A=Autonomous, D=Differential, E=Estimated, N=Data not valid)
(13) = NMEA 4.10 introduced nav status
12 = Checksum

@@ -446,3 +450,4 @@ */

'variation': parseRMCVariation(rmc[10], rmc[11]),
'faa': rmc.length === 14 ? parseFAA(rmc[12]) : null
'faa': rmc.length > 13 ? parseFAA(rmc[12]) : null,
'navStatus': rmc.length > 14 ? rmc[13] : null
};

@@ -463,3 +468,3 @@ },

------------------------------------------------------------------------------
1 = Track made good (degrees true)

@@ -505,3 +510,3 @@ 2 = Fixed text 'T' indicates that track made good is relative to true north

if (gsv.length < 9 || gsv.length % 4 % 3 === 0) {
if (gsv.length % 4 % 3 === 0) {
throw new Error('Invalid GSV length: ' + str);

@@ -512,3 +517,3 @@ }

$GPGSV,1,1,13,02,02,213,,03,-3,000,,11,00,121,,14,13,172,05*67
1 = Total number of messages of this type in this cycle

@@ -536,3 +541,3 @@ 2 = Message number

by linear map elevation from 0° to 90° into r to 0
centerX + cos(azimuth - 90) * (1 - elevation / 90) * radius

@@ -561,3 +566,3 @@ centerY + sin(azimuth - 90) * (1 - elevation / 90) * radius

if (gll.length !== 9) {
if (gll.length !== 9 && gll.length !== 8) {
throw new Error('Invalid GLL length: ' + str);

@@ -572,3 +577,3 @@ }

------------------------------------------------------------------------------
1. Latitude

@@ -588,3 +593,4 @@ 2. N or S (North or South)

'lat': parseCoord(gll[1], gll[2]),
'lon': parseCoord(gll[3], gll[4])
'lon': parseCoord(gll[3], gll[4]),
'faa': gll.length === 9 ? parseFAA(gll[7]) : null
};

@@ -654,3 +660,3 @@ },

------------------------------------------------------------------------------
1. Heading in degrees

@@ -665,2 +671,79 @@ 2. T: indicates heading relative to True North

};
},
'GRS': function(str, grs) {
if (grs.length !== 18) {
throw new Error('Invalid GRS length: ' + str);
}
var res = [];
for (var i = 3; i <= 14; i++) {
var tmp = parseNumber(grs[i]);
if (tmp !== null)
res.push(tmp);
}
return {
'time': parseTime(grs[1]),
'mode': parseNumber(grs[2]),
'res': res
};
},
'GBS': function(str, gbs) {
if (gbs.length !== 10 && gbs.length !== 12) {
throw new Error('Invalid GBS length: ' + str);
}
/*
0 1 2 3 4 5 6 7 8
| | | | | | | | |
$--GBS,hhmmss.ss,x.x,x.x,x.x,x.x,x.x,x.x,x.x*hh<CR><LF>
1. UTC time of the GGA or GNS fix associated with this sentence
2. Expected error in latitude (meters)
3. Expected error in longitude (meters)
4. Expected error in altitude (meters)
5. PRN (id) of most likely failed satellite
6. Probability of missed detection for most likely failed satellite
7. Estimate of bias in meters on most likely failed satellite
8. Standard deviation of bias estimate
--
9. systemID (NMEA 4.10)
10. signalID (NMEA 4.10)
*/
return {
'time': parseTime(gbs[1]),
'errLat': parseNumber(gbs[2]),
'errLon': parseNumber(gbs[3]),
'errAlt': parseNumber(gbs[4]),
'failedSat': parseNumber(gbs[5]),
'probFailedSat': parseNumber(gbs[6]),
'biasFailedSat': parseNumber(gbs[7]),
'stdFailedSat': parseNumber(gbs[8]),
'systemId': gbs.length === 12 ? parseNumber(gbs[9]) : null,
'signalId': gbs.length === 12 ? parseNumber(gbs[10]) : null
};
},
'GNS': function(str, gns) {
if (gns.length !== 14 && gns.length !== 15) {
throw new Error('Invalid GNS length: ' + str);
}
return {
'time': parseTime(gns[1]),
'lat': parseCoord(gns[2], gns[3]),
'lon': parseCoord(gns[4], gns[5]),
'mode': gns[6],
'satsUsed': parseNumber(gns[7]),
'hdop': parseNumber(gns[8]),
'alt': parseNumber(gns[9]),
'sep': parseNumber(gns[10]),
'diffAge': parseNumber(gns[11]),
'diffStation': parseNumber(gns[12]),
'navStatus': gns.length === 15 ? gns[13] : null // NMEA 4.10
};
}

@@ -667,0 +750,0 @@ };

/*
GPS.js v0.5.1 26/01/2016
GPS.js v0.5.2 26/01/2016

@@ -7,14 +7,15 @@ Copyright (c) 2016, Robert Eisele (robert@xarg.org)

*/
(function(t){function l(b,a){if(""===b)return null;var d=new Date;if(a){var c=a.slice(4),g=a.slice(2,4)-1,e=a.slice(0,2);4===c.length?d.setUTCFullYear(Number(c),Number(g),Number(e)):d.setUTCFullYear(Number("20"+c),Number(g),Number(e))}d.setUTCHours(Number(b.slice(0,2)));d.setUTCMinutes(Number(b.slice(2,4)));d.setUTCSeconds(Number(b.slice(4,6)));c=b.slice(7);g=c.length;e=0;0!==g&&(e=parseFloat(c)*Math.pow(10,3-g));d.setUTCMilliseconds(Number(e));return d}function k(b,a){if(""===b)return null;var d=
1;switch(a){case "S":d=-1;case "N":var c=2;break;case "W":d=-1;case "E":c=3}return d*(parseFloat(b.slice(0,c))+parseFloat(b.slice(c))/60)}function e(b){return""===b?null:parseFloat(b)}function n(b){return""===b?null:1.852*parseFloat(b)}function u(b){if(""===b)return null;switch(parseInt(b,10)){case 0:return null;case 1:return"fix";case 2:return"dgps-fix";case 3:return"pps-fix";case 4:return"rtk";case 5:return"rtk-float";case 6:return"estimated";case 7:return"manual";case 8:return"simulated"}throw Error("INVALID GGA FIX: "+
b);}function p(b){switch(b){case "A":return"active";case "V":return"void";case "":return null}throw Error("INVALID RMC/GLL STATUS: "+b);}function q(b){switch(b){case "A":return"autonomous";case "D":return"differential";case "E":return"estimated";case "M":return"manual input";case "S":return"simulated";case "N":return"not valid";case "P":return"precise"}throw Error("INVALID FAA MODE: "+b);}function r(b,a){if("M"===a||""===a)return e(b);throw Error("Unknown unit: "+a);}function f(){if(!(this instanceof
f))return new f;this.events={};this.state={errors:0,processed:0}}var h=Math.PI/180,m=[];f.prototype.events=null;f.prototype.state=null;f.mod={GGA:function(b,a){if(16!==a.length)throw Error("Invalid GGA length: "+b);return{time:l(a[1]),lat:k(a[2],a[3]),lon:k(a[4],a[5]),alt:r(a[9],a[10]),quality:u(a[6]),satellites:e(a[7]),hdop:e(a[8]),geoidal:r(a[11],a[12]),age:e(a[13]),stationID:e(a[14])}},GSA:function(b,a){if(19!==a.length)throw Error("Invalid GSA length: "+b);for(var d=[],c=3;15>c;c++)""!==a[c]&&
d.push(parseInt(a[c],10));a:{c=a[1];switch(c){case "M":c="manual";break a;case "A":c="automatic";break a;case "":c=null;break a}throw Error("INVALID GSA MODE: "+c);}a:{var g=a[2];switch(g){case "1":case "":g=null;break a;case "2":g="2D";break a;case "3":g="3D";break a}throw Error("INVALID GSA FIX: "+g);}return{mode:c,fix:g,satellites:d,pdop:e(a[15]),hdop:e(a[16]),vdop:e(a[17])}},RMC:function(b,a){if(13!==a.length&&14!==a.length)throw Error("Invalid RMC length: "+b);var d=l(a[1],a[9]),c=p(a[2]),g=
a[10],f=a[11];return{time:d,status:c,lat:k(a[3],a[4]),lon:k(a[5],a[6]),speed:n(a[7]),track:e(a[8]),variation:""===g||""===f?null:parseFloat(g)*("W"===f?-1:1),faa:14===a.length?q(a[12]):null}},VTG:function(b,a){if(10!==a.length&&11!==a.length)throw Error("Invalid VTG length: "+b);if(""===a[2]&&""===a[8]&&""===a[6])return{track:null,trackMagetic:null,speed:null,faa:null};if("T"!==a[2])throw Error("Invalid VTG track mode: "+b);if("K"!==a[8]||"N"!==a[6])throw Error("Invalid VTG speed tag: "+b);return{track:e(a[1]),
trackMagnetic:""===a[3]?null:e(a[3]),speed:n(a[5]),faa:11===a.length?q(a[9]):null}},GSV:function(b,a){if(9>a.length||0===a.length%4%3)throw Error("Invalid GSV length: "+b);for(var d=[],c=4;c<a.length-3;c+=4){var g=e(a[c]),f=e(a[c+3]);d.push({prn:g,elevation:e(a[c+1]),azimuth:e(a[c+2]),snr:f,status:null!==g?null!==f?"tracking":"in view":null})}return{msgNumber:e(a[2]),msgsTotal:e(a[1]),satellites:d,signalId:2===a.length%4?e(a[a.length-2]):null}},GLL:function(b,a){if(9!==a.length)throw Error("Invalid GLL length: "+
b);return{time:l(a[5]),status:p(a[6]),lat:k(a[1],a[2]),lon:k(a[3],a[4])}},ZDA:function(b,a){return{time:l(a[1],a[2]+a[3]+a[4])}},GST:function(b,a){if(10!==a.length)throw Error("Invalid GST length: "+b);return{time:l(a[1]),rms:e(a[2]),ellipseMajor:e(a[3]),ellipseMinor:e(a[4]),ellipseOrientation:e(a[5]),latitudeError:e(a[6]),longitudeError:e(a[7]),heightError:e(a[8])}},HDT:function(b,a){if(4!==a.length)throw Error("Invalid HDT length: "+b);return{heading:parseFloat(a[1]),trueNorth:"T"===a[2]}}};f.Parse=
function(b){if("string"!==typeof b)return!1;var a=b.split(","),d=a.pop();if(2>a.length||"$"!==b.charAt(0)||-1===d.indexOf("*"))return!1;d=d.split("*");a.push(d[0]);a.push(d[1]);a[0]=a[0].slice(3);if(void 0!==f.mod[a[0]]){d=this.mod[a[0]](b,a);d.raw=b;for(var c=0,e=1;e<b.length;e++){var h=b.charCodeAt(e);if(42===h)break;c^=h}d.valid=c===parseInt(a[a.length-1],16);d.type=a[0];return d}return!1};f.Heading=function(b,a,d,c){a=(c-a)*h;b*=h;d*=h;c=Math.cos(d);return(180*Math.atan2(Math.sin(a)*c,Math.cos(b)*
Math.sin(d)-Math.sin(b)*c*Math.cos(a))/Math.PI+360)%360};f.Distance=function(b,a,d,c){var e=(d-b)*h*.5;a=(c-a)*h*.5;b*=h;d*=h;e=Math.sin(e);a=Math.sin(a);return 12745.6*Math.asin(Math.sqrt(e*e+Math.cos(b)*Math.cos(d)*a*a))};f.TotalDistance=function(b){if(2>b.length)return 0;for(var a=0,d=0;d<b.length-1;d++){var c=b[d],e=b[d+1];a+=f.Distance(c.lat,c.lon,e.lat,e.lon)}return a};f.prototype.update=function(b){b=f.Parse(b);this.state.processed++;if(!1===b)return this.state.errors++,!1;var a=this.state;
if("RMC"===b.type||"GGA"===b.type||"GLL"===b.type)a.time=b.time,a.lat=b.lat,a.lon=b.lon;"ZDA"===b.type&&(a.time=b.time);"GGA"===b.type&&(a.alt=b.alt);"RMC"===b.type&&(a.speed=b.speed,a.track=b.track);"GSA"===b.type&&(a.satsActive=b.satellites,a.fix=b.fix,a.hdop=b.hdop,a.pdop=b.pdop,a.vdop=b.vdop);if("GSV"===b.type){for(var d=b.satellites,c=0;c<d.length;c++)m.push(d[c]);b.msgNumber===b.msgsTotal&&(a.satsVisible=m,m=[])}this.emit("data",b);this.emit(b.type,b);return!0};f.prototype.partial="";f.prototype.updatePartial=
function(b){for(this.partial+=b;;){b=this.partial.indexOf("\r\n");if(-1===b)break;var a=this.partial.slice(0,b);"$"===a.charAt(0)&&this.update(a);this.partial=this.partial.slice(b+2)}};f.prototype.on=function(b,a){return void 0===this.events[b]?(this.events[b]=a,this):null};f.prototype.off=function(b){void 0!==this.events[b]&&(this.events[b]=void 0);return this};f.prototype.emit=function(b,a){void 0!==this.events[b]&&this.events[b].call(this,a)};"object"===typeof exports?(Object.defineProperty(exports,
"__esModule",{value:!0}),f["default"]=f,f.GPS=f,module.exports=f):t.GPS=f})(this);
(function(t){function f(b,a){if(""===b)return null;var g=new Date;if(a){var d=a.slice(4),c=a.slice(2,4)-1,e=a.slice(0,2);4===d.length?g.setUTCFullYear(Number(d),Number(c),Number(e)):g.setUTCFullYear(Number("20"+d),Number(c),Number(e))}g.setUTCHours(Number(b.slice(0,2)));g.setUTCMinutes(Number(b.slice(2,4)));g.setUTCSeconds(Number(b.slice(4,6)));d=b.slice(7);c=d.length;e=0;0!==c&&(e=parseFloat(d)*Math.pow(10,3-c));g.setUTCMilliseconds(Number(e));return g}function h(b,a){if(""===b)return null;var c=
1;switch(a){case "S":c=-1;case "N":var d=2;break;case "W":c=-1;case "E":d=3}return c*(parseFloat(b.slice(0,d))+parseFloat(b.slice(d))/60)}function c(b){return""===b?null:parseFloat(b)}function p(b){return""===b?null:1.852*parseFloat(b)}function u(b){if(""===b)return null;switch(parseInt(b,10)){case 0:return null;case 1:return"fix";case 2:return"dgps-fix";case 3:return"pps-fix";case 4:return"rtk";case 5:return"rtk-float";case 6:return"estimated";case 7:return"manual";case 8:return"simulated"}throw Error("INVALID GGA FIX: "+
b);}function q(b){switch(b){case "A":return"active";case "V":return"void";case "":return null}throw Error("INVALID RMC/GLL STATUS: "+b);}function l(b){switch(b){case "":return null;case "A":return"autonomous";case "D":return"differential";case "E":return"estimated";case "M":return"manual input";case "S":return"simulated";case "N":return"not valid";case "P":return"precise";case "R":return"rtk";case "F":return"rtk-float"}throw Error("INVALID FAA MODE: "+b);}function r(b,a){if("M"===a||""===a)return c(b);
throw Error("Unknown unit: "+a);}function e(){if(!(this instanceof e))return new e;this.events={};this.state={errors:0,processed:0}}var k=Math.PI/180,m=[];e.prototype.events=null;e.prototype.state=null;e.mod={GGA:function(b,a){if(16!==a.length)throw Error("Invalid GGA length: "+b);return{time:f(a[1]),lat:h(a[2],a[3]),lon:h(a[4],a[5]),alt:r(a[9],a[10]),quality:u(a[6]),satellites:c(a[7]),hdop:c(a[8]),geoidal:r(a[11],a[12]),age:c(a[13]),stationID:c(a[14])}},GSA:function(b,a){if(19!==a.length&&20!==a.length)throw Error("Invalid GSA length: "+
b);for(var g=[],d=3;15>d;d++)""!==a[d]&&g.push(parseInt(a[d],10));a:{d=a[1];switch(d){case "M":d="manual";break a;case "A":d="automatic";break a;case "":d=null;break a}throw Error("INVALID GSA MODE: "+d);}a:{var e=a[2];switch(e){case "1":case "":e=null;break a;case "2":e="2D";break a;case "3":e="3D";break a}throw Error("INVALID GSA FIX: "+e);}return{mode:d,fix:e,satellites:g,pdop:c(a[15]),hdop:c(a[16]),vdop:c(a[17]),systemId:19<a.length?c(a[18]):null}},RMC:function(b,a){if(13!==a.length&&14!==a.length&&
15!==a.length)throw Error("Invalid RMC length: "+b);var g=f(a[1],a[9]),d=q(a[2]),e=a[10],n=a[11];return{time:g,status:d,lat:h(a[3],a[4]),lon:h(a[5],a[6]),speed:p(a[7]),track:c(a[8]),variation:""===e||""===n?null:parseFloat(e)*("W"===n?-1:1),faa:13<a.length?l(a[12]):null,navStatus:14<a.length?a[13]:null}},VTG:function(b,a){if(10!==a.length&&11!==a.length)throw Error("Invalid VTG length: "+b);if(""===a[2]&&""===a[8]&&""===a[6])return{track:null,trackMagetic:null,speed:null,faa:null};if("T"!==a[2])throw Error("Invalid VTG track mode: "+
b);if("K"!==a[8]||"N"!==a[6])throw Error("Invalid VTG speed tag: "+b);return{track:c(a[1]),trackMagnetic:""===a[3]?null:c(a[3]),speed:p(a[5]),faa:11===a.length?l(a[9]):null}},GSV:function(b,a){if(0===a.length%4%3)throw Error("Invalid GSV length: "+b);for(var g=[],d=4;d<a.length-3;d+=4){var e=c(a[d]),f=c(a[d+3]);g.push({prn:e,elevation:c(a[d+1]),azimuth:c(a[d+2]),snr:f,status:null!==e?null!==f?"tracking":"in view":null})}return{msgNumber:c(a[2]),msgsTotal:c(a[1]),satellites:g,signalId:2===a.length%
4?c(a[a.length-2]):null}},GLL:function(b,a){if(9!==a.length&&8!==a.length)throw Error("Invalid GLL length: "+b);return{time:f(a[5]),status:q(a[6]),lat:h(a[1],a[2]),lon:h(a[3],a[4]),faa:9===a.length?l(a[7]):null}},ZDA:function(b,a){return{time:f(a[1],a[2]+a[3]+a[4])}},GST:function(b,a){if(10!==a.length)throw Error("Invalid GST length: "+b);return{time:f(a[1]),rms:c(a[2]),ellipseMajor:c(a[3]),ellipseMinor:c(a[4]),ellipseOrientation:c(a[5]),latitudeError:c(a[6]),longitudeError:c(a[7]),heightError:c(a[8])}},
HDT:function(b,a){if(4!==a.length)throw Error("Invalid HDT length: "+b);return{heading:parseFloat(a[1]),trueNorth:"T"===a[2]}},GRS:function(b,a){if(18!==a.length)throw Error("Invalid GRS length: "+b);for(var g=[],d=3;14>=d;d++){var e=c(a[d]);null!==e&&g.push(e)}return{time:f(a[1]),mode:c(a[2]),res:g}},GBS:function(b,a){if(10!==a.length&&12!==a.length)throw Error("Invalid GBS length: "+b);return{time:f(a[1]),errLat:c(a[2]),errLon:c(a[3]),errAlt:c(a[4]),failedSat:c(a[5]),probFailedSat:c(a[6]),biasFailedSat:c(a[7]),
stdFailedSat:c(a[8]),systemId:12===a.length?c(a[9]):null,signalId:12===a.length?c(a[10]):null}},GNS:function(b,a){if(14!==a.length&&15!==a.length)throw Error("Invalid GNS length: "+b);return{time:f(a[1]),lat:h(a[2],a[3]),lon:h(a[4],a[5]),mode:a[6],satsUsed:c(a[7]),hdop:c(a[8]),alt:c(a[9]),sep:c(a[10]),diffAge:c(a[11]),diffStation:c(a[12]),navStatus:15===a.length?a[13]:null}}};e.Parse=function(b){if("string"!==typeof b)return!1;var a=b.split(","),c=a.pop();if(2>a.length||"$"!==b.charAt(0)||-1===c.indexOf("*"))return!1;
c=c.split("*");a.push(c[0]);a.push(c[1]);a[0]=a[0].slice(3);if(void 0!==e.mod[a[0]]){c=this.mod[a[0]](b,a);c.raw=b;for(var d=0,f=1;f<b.length;f++){var h=b.charCodeAt(f);if(42===h)break;d^=h}c.valid=d===parseInt(a[a.length-1],16);c.type=a[0];return c}return!1};e.Heading=function(b,a,c,d){a=(d-a)*k;b*=k;c*=k;d=Math.cos(c);return(180*Math.atan2(Math.sin(a)*d,Math.cos(b)*Math.sin(c)-Math.sin(b)*d*Math.cos(a))/Math.PI+360)%360};e.Distance=function(b,a,c,d){var e=(c-b)*k*.5;a=(d-a)*k*.5;b*=k;c*=k;e=Math.sin(e);
a=Math.sin(a);return 12745.6*Math.asin(Math.sqrt(e*e+Math.cos(b)*Math.cos(c)*a*a))};e.TotalDistance=function(b){if(2>b.length)return 0;for(var a=0,c=0;c<b.length-1;c++){var d=b[c],f=b[c+1];a+=e.Distance(d.lat,d.lon,f.lat,f.lon)}return a};e.prototype.update=function(b){b=e.Parse(b);this.state.processed++;if(!1===b)return this.state.errors++,!1;var a=this.state;if("RMC"===b.type||"GGA"===b.type||"GLL"===b.type||"GNS"===b.type)a.time=b.time,a.lat=b.lat,a.lon=b.lon;"ZDA"===b.type&&(a.time=b.time);"GGA"===
b.type&&(a.alt=b.alt);"RMC"===b.type&&(a.speed=b.speed,a.track=b.track);"GSA"===b.type&&(a.satsActive=b.satellites,a.fix=b.fix,a.hdop=b.hdop,a.pdop=b.pdop,a.vdop=b.vdop);if("GSV"===b.type){for(var c=b.satellites,d=0;d<c.length;d++)m.push(c[d]);b.msgNumber===b.msgsTotal&&(a.satsVisible=m,m=[])}this.emit("data",b);this.emit(b.type,b);return!0};e.prototype.partial="";e.prototype.updatePartial=function(b){for(this.partial+=b;;){b=this.partial.indexOf("\r\n");if(-1===b)break;var a=this.partial.slice(0,
b);"$"===a.charAt(0)&&this.update(a);this.partial=this.partial.slice(b+2)}};e.prototype.on=function(b,a){return void 0===this.events[b]?(this.events[b]=a,this):null};e.prototype.off=function(b){void 0!==this.events[b]&&(this.events[b]=void 0);return this};e.prototype.emit=function(b,a){void 0!==this.events[b]&&this.events[b].call(this,a)};"object"===typeof exports?(Object.defineProperty(exports,"__esModule",{value:!0}),e["default"]=e,e.GPS=e,module.exports=e):t.GPS=e})(this);
{
"name": "gps",
"title": "gps.js",
"version": "0.5.1",
"homepage": "https://github.com/infusion/GPS.js",
"version": "0.5.2",
"homepage": "https://www.xarg.org/2016/07/using-gps-with-node-js-and-javascript/",
"bugs": "https://github.com/infusion/GPS.js/issues",

@@ -50,7 +50,9 @@ "description": "A GPS NMEA parser library",

"chai": "^4.1.0",
"express": "^4.15.3",
"express": "^4.16.4",
"mocha": "^5.2.0",
"serialport": "^7.1.1",
"socket.io": "^2.0.3"
"socket.io": "^2.0.3",
"kalman": "0.0.2",
"sylvester": "0.0.21"
}
}

@@ -27,2 +27,3 @@

'type': 'GSA',
"systemId": null,
'valid': true,

@@ -38,2 +39,3 @@ 'vdop': 1

'track': 2.93,
"navStatus": null,
'raw': '$GPRMC,234919.000,A,4832.3914,N,00903.5500,E,2.28,2.93,260116,,*0D',

@@ -94,2 +96,3 @@ 'type': 'RMC',

'type': 'RMC',
"navStatus": null,
'faa': null,

@@ -160,2 +163,3 @@ 'valid': true,

'pdop': 1.72,
"systemId": null,
'raw': '$GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A',

@@ -221,2 +225,3 @@ 'satellites': [

'type': 'RMC',
"navStatus": null,
'valid': true,

@@ -247,2 +252,3 @@ 'variation': -3.1

'raw': '$GPGSA,A,3,12,05,25,29,,,,,,,,,9.4,7.6,5.6*37',
"systemId": null,
'satellites': [

@@ -402,2 +408,3 @@ 12,

'type': 'RMC',
"navStatus": null,
'valid': true,

@@ -431,2 +438,3 @@ 'variation': null

'type': 'RMC',
"navStatus": null,
'valid': true,

@@ -442,3 +450,4 @@ 'variation': null

'type': 'GLL',
'valid': true
'valid': true,
"faa": "differential"
},

@@ -452,3 +461,4 @@ '$GPGLL,4916.45,N,12311.12,W,225444,A,*1D': {

'type': 'GLL',
'valid': true
'valid': true,
'faa': null
},

@@ -704,2 +714,180 @@ '$GPGGA,174815.40,4141.46474,N,00849.77225,W,1,08,1.24,11.8,M,50.5,M,,*76': {

"valid": true
},
"$GNRMC,191029.00,A,4843.01033,N,00227.78756,E,0.024,,010319,,,A,V*1C": {
"faa": "autonomous",
"lat": 48.716838833333334,
"lon": 2.463126,
"navStatus": "V",
"raw": "$GNRMC,191029.00,A,4843.01033,N,00227.78756,E,0.024,,010319,,,A,V*1C",
"speed": 0.044448,
"status": "active",
"time": new Date("2019-03-01T19:10:29.000Z"),
"track": null,
"type": "RMC",
"valid": true,
"variation": null
},
"$GNGSA,A,3,25,29,31,26,16,21,,,,,,,1.55,0.84,1.30,1*00": {
"fix": "3D",
"hdop": 0.84,
"mode": "automatic",
"systemId": 1,
"pdop": 1.55,
"raw": "$GNGSA,A,3,25,29,31,26,16,21,,,,,,,1.55,0.84,1.30,1*00",
"satellites": [
25,
29,
31,
26,
16,
21
],
"type": "GSA",
"valid": true,
"vdop": 1.3
},
'$GPRMC,085542.023,V,,,,,,,041211,,,N*45': {
"faa": "not valid",
"lat": null,
"lon": null,
"navStatus": null,
"raw": "$GPRMC,085542.023,V,,,,,,,041211,,,N*45",
"speed": null,
"status": "void",
"time": new Date('2011-12-04T08:55:42.023Z'),
"track": null,
"type": "RMC",
"valid": true,
"variation": null
},
'$GPGGA,100313.99,3344.459045,N,09639.616711,W,1,05,0.0,220.9,M,0.0,M,0.0,0000*66': {
"age": 0,
"alt": 220.9,
"geoidal": 0,
"hdop": 0,
"lat": 33.74098408333333,
"lon": -96.66027851666666,
"quality": "fix",
"raw": "$GPGGA,100313.99,3344.459045,N,09639.616711,W,1,05,0.0,220.9,M,0.0,M,0.0,0000*66",
"satellites": 5,
"stationID": 0,
"time": new Date(today + 'T10:03:13.990Z'),
"type": "GGA",
"valid": true
},
'$GNGRS,112423.00,1,-0.1,-0.4,5.6,-4.3,1.4,-0.2,,,,,,,1,1*51': {
"mode": 1,
"raw": "$GNGRS,112423.00,1,-0.1,-0.4,5.6,-4.3,1.4,-0.2,,,,,,,1,1*51",
"res": [
-0.1,
-0.4,
5.6,
-4.3,
1.4,
-0.2
],
"time": new Date(today + 'T11:24:23.000Z'),
"type": "GRS",
"valid": true
},
'$GNGRS,112423.00,1,0.0,0.0,0.0,-6.4,-1.2,,,,,,,,1,6*7F': {
"mode": 1,
"raw": "$GNGRS,112423.00,1,0.0,0.0,0.0,-6.4,-1.2,,,,,,,,1,6*7F",
"res": [
0,
0,
0,
-6.4,
-1.2
],
"time": new Date(today + 'T11:24:23.000Z'),
"type": "GRS",
"valid": true
},
'$GNGRS,112423.00,1,-2.5,0.8,0.2,7.2,6.2,,,,,,,,2,1*5B': {
"mode": 1,
"raw": "$GNGRS,112423.00,1,-2.5,0.8,0.2,7.2,6.2,,,,,,,,2,1*5B",
"res": [
-2.5,
0.8,
0.2,
7.2,
6.2
],
"time": new Date(today + 'T11:24:23.000Z'),
"type": "GRS",
"valid": true
},
'$GNGBS,112424.00,2.5,1.5,5.4,,,,,,*5D': {
"raw": "$GNGBS,112424.00,2.5,1.5,5.4,,,,,,*5D",
"type": "GBS",
"time": new Date(today + 'T11:24:24.000Z'),
"errLat": 2.5,
"errLon": 1.5,
"errAlt": 5.4,
"failedSat": null,
"probFailedSat": null,
"biasFailedSat": null,
"stdFailedSat": null,
"valid": true,
"systemId": null,
"signalId": null
},
'$GPGBS,015509.00,-0.031,-0.186,0.219,19,0.000,-0.354,6.972*4D': {
"raw": "$GPGBS,015509.00,-0.031,-0.186,0.219,19,0.000,-0.354,6.972*4D",
"type": "GBS",
"time": new Date(today + 'T01:55:09.000Z'),
"errLat": -0.031,
"errLon": -0.186,
"errAlt": 0.219,
"failedSat": 19,
"probFailedSat": 0,
"biasFailedSat": -0.354,
"stdFailedSat": 6.972,
"valid": true,
"systemId": null,
"signalId": null
},
'$GNGSA,A,3,24,12,19,15,,,,,,,,,5.27,3.57,3.87,1*05': {
"fix": "3D",
"hdop": 3.57,
"mode": "automatic",
"pdop": 5.27,
"raw": "$GNGSA,A,3,24,12,19,15,,,,,,,,,5.27,3.57,3.87,1*05",
"satellites": [
24,
12,
19,
15
],
"systemId": 1,
"type": "GSA",
"valid": true,
"vdop": 3.87
},
'$GNGNS,133216.00,4843.01093,N,00227.78866,E,ANNN,04,3.57,55.4,46.3,,,V*29': {
"raw": "$GNGNS,133216.00,4843.01093,N,00227.78866,E,ANNN,04,3.57,55.4,46.3,,,V*29",
"type": "GNS",
"time": new Date(today + 'T13:32:16.000Z'),
"valid": true,
"alt": 55.4,
"diffAge": null,
"diffStation": null,
"hdop": 3.57,
"lat": 48.71684883333333,
"lon": 2.463144333333333,
"mode": "ANNN",
"navStatus": "V",
"satsUsed": 4,
"sep": 46.3
},
'$GPGLL,5000.05254,N,04500.02356,E,090037.059,A*35': {
'faa': null,
"lat": 50.000875666666666,
"lon": 45.00039266666667,
"raw": "$GPGLL,5000.05254,N,04500.02356,E,090037.059,A*35",
"status": "active",
"type": "GLL",
"valid": true,
"time": new Date(today + 'T09:00:37.059Z'),
}

@@ -742,7 +930,5 @@ };

'$GPGSV,3,3,12,30,11,308,,16,,333,,12,,191,,07,-4,033,*62',
'$GPRMC,085542.023,V,,,,,,,041211,,,N*45',
'$GPGGA,085543.023,,,,,0,00,,,M,0.0,M,,0000*58',
'$IIBWC,160947,6008.160,N,02454.290,E,162.4,T,154.3,M,001.050,N,DEST*1C',
'$IIAPB,A,A,0.001,L,N,V,V,154.3,M,DEST,154.3,M,154.2,M*19'
$GPGGA,100313.99,3344.459045,N,09639.616711,W,1,05,0.0,220.9,M,0.0,M,0.0,0000*66
$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76

@@ -749,0 +935,0 @@ $GPGGA,181650.692,7204.589,N,01915.106,W,0,00,,,M,,M,,*59

@@ -16,2 +16,3 @@

'faa': null,
"navStatus": null,
'valid': true,

@@ -47,2 +48,3 @@ 'variation': null

done();
return;
}

@@ -49,0 +51,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc