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

gps

Package Overview
Dependencies
Maintainers
2
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.4.9 to 0.5.0

2

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

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

@@ -91,2 +91,4 @@ export as namespace gps;

[key: string]: any;
processed: number;
errors: number;

@@ -93,0 +95,0 @@ time?: Date;

/**
* @license GPS.js v0.4.9 26/01/2016
* @license GPS.js v0.5.0 26/01/2016
*

@@ -302,3 +302,3 @@ * Copyright (c) 2016, Robert Eisele (robert@xarg.org)

this['events'] = {};
this['state'] = {};
this['state'] = {'errors': 0, 'processed': 0};
}

@@ -322,3 +322,3 @@

$--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)

@@ -367,4 +367,4 @@ 2) Latitude

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

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

$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

@@ -452,3 +452,3 @@ 1 = UTC of position fix

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

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

$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

@@ -525,3 +525,3 @@ 2 = Message number

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

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

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

@@ -640,3 +640,3 @@ 2. N or S (North or South)

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

@@ -757,4 +757,8 @@ 2. T: indicates heading relative to True North

if (parsed === false)
this['state']['processed']++;
if (parsed === false) {
this['state']['errors']++;
return false;
}

@@ -761,0 +765,0 @@ updateState(this['state'], parsed);

/*
GPS.js v0.4.9 26/01/2016
GPS.js v0.5.0 26/01/2016

@@ -10,10 +10,11 @@ Copyright (c) 2016, Robert Eisele (robert@xarg.org)

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={}}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||1!==a.length%4)throw Error("Invalid GSV length: "+b);for(var d=[],c=4;c<a.length-1;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}},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);if(!1===b)return!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);
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||1!==a.length%4)throw Error("Invalid GSV length: "+b);for(var d=[],c=4;c<a.length-1;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}},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);
{
"name": "gps",
"title": "gps.js",
"version": "0.4.9",
"version": "0.5.0",
"homepage": "https://github.com/infusion/GPS.js",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/infusion/GPS.js/issues",

@@ -528,3 +528,3 @@

"stationID": null,
"time": new Date('2019-01-20T02:39:20.476Z'),
"time": new Date(today + 'T02:39:20.476Z'),
"type": "GGA",

@@ -531,0 +531,0 @@ "valid": false // false because we manually changed fix to 0

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