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.0.8 to 0.0.9

gps.min.js

2

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

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

@@ -28,3 +28,3 @@

gps.on('data', function(raw, data) {
gps.on('data', function() {
io.emit('state', gps.state);

@@ -31,0 +31,0 @@ });

/**
* GPS.js v0.0.8 26/01/2016
* @license GPS.js v0.0.9 26/01/2016
*

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

var D2R = Math.PI / 180;
var collectSats = [];

@@ -37,3 +39,3 @@

if (data['type'] === 'GSA') {
state['sats_active'] = data['satellites'];
state['satsActive'] = data['satellites'];
state['fix'] = data['fix'];

@@ -55,3 +57,3 @@ state['hdop'] = data['hdop'];

if (data['msgNumber'] === data['msgsTotal']) {
state['sats_visible'] = collectSats;
state['satsVisible'] = collectSats;
collectSats = [];

@@ -568,11 +570,25 @@ }

GPS['Bearing'] = function(lat1, lon1, lat2, lon2) {
// Heading (N=0, E=90, S=189, W=270) from point 1 to point 2
GPS['Heading'] = function(lat1, lon1, lat2, lon2) {
var BearingRad = Math.atan2((Math.sin(lon2 - lon1) * Math.cos(lat2)),
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) *
Math.cos(lat2) * Math.cos(lon2 - lon1));
var dlon = (lon2 - lon1) * D2R;
var CalBearing = 180.0 * BearingRad / Math.PI;
lat1 = lat1 * D2R;
lat2 = lat2 * D2R;
return (CalBearing + 360) % 360;
var sdlon = Math.sin(dlon);
var cdlon = Math.cos(dlon);
var slat1 = Math.sin(lat1);
var clat1 = Math.cos(lat1);
var slat2 = Math.sin(lat2);
var clat2 = Math.cos(lat2);
var n = sdlon * clat2;
var d = clat1 * slat2 - slat1 * clat2 * cdlon;
var head = Math.atan2(n, d) * 180 / Math.PI;
return (head + 360) % 360;
};

@@ -583,3 +599,5 @@

// Haversine Formula
// R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159
// Because Earth is no exact sphere, rounding errors may be up to 0.5%.
// var RADIUS = 6371; // Earth radius average

@@ -589,10 +607,15 @@ // var RADIUS = 6378.137; // Earth radius at equator

var d2r = Math.PI / 180;
var hLat = (lat2 - lat1) * D2R * 0.5; // Half of lat difference
var hLon = (lon2 - lon1) * D2R * 0.5; // Half of lon difference
var hLat = (lat2 - lat1) * d2r * 0.5; // Half of lat difference
var hLon = (lon2 - lon1) * d2r * 0.5; // Half of lon difference
lat1 = lat1 * D2R;
lat2 = lat2 * D2R;
var tmp = Math.sin(hLat) * Math.sin(hLat) +
Math.cos(lat1 * d2r) * Math.cos(lat2 * d2r) * Math.sin(hLon) * Math.sin(hLon);
var shLat = Math.sin(hLat);
var shLon = Math.sin(hLon);
var clat1 = Math.cos(lat1);
var clat2 = Math.cos(lat2);
var tmp = shLat * shLat + clat1 * clat2 * shLon * shLon;
//return RADIUS * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));

@@ -599,0 +622,0 @@ return RADIUS * 2 * Math.asin(Math.sqrt(tmp));

{
"name": "gps",
"title": "gps.js",
"version": "0.0.8",
"version": "0.0.9",
"homepage": "https://github.com/infusion/GPS.js",

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

@@ -20,4 +20,3 @@

// Add an event listener on all protocols
gps.on('data', function(raw, parsed) {
gps.on('data', function(parsed) {
console.log(parsed);

@@ -39,3 +38,3 @@ });

```javascript
gps.on('data', function(raw, data) {
gps.on('data', function() {
console.log(gps.state);

@@ -89,3 +88,3 @@ });

After that you can open the browser and go to http://localhost:3000 The result should look like
After that you can open the browser and go to http://localhost:3000 The result should look like, which in principle is just a visualiziation of the state object `gps.state`

@@ -234,6 +233,6 @@ ![GPS TU Dresden](https://github.com/infusion/GPS.js/blob/master/res/dashboard.png?raw=true)

- alt: Altitude
- sats_active: Array of active satellites
- satsActive: Array of active satellites
- speed: Speed over ground in km/h
- track: Track in degrees
- sats_visible: Array of all visible satellites
- satsVisible: Array of all visible satellites

@@ -256,5 +255,5 @@ Adding new protocols is a matter of minutes. If you need a protocol which isn't implemented, I'm happy to see a pull request or a new ticket.

GPS.Bearing(latFrom, lonFrom, latTo, lonTo)
GPS.Heading(latFrom, lonFrom, latTo, lonTo)
---
Calculates the angle from one coordinate to another
Calculates the angle from one coordinate to another. Heading is represented as windrose coordinates (N=0, E=90, S=189, W=270).

@@ -266,3 +265,3 @@

```
```html
<script src="gps.js"></script>

@@ -269,0 +268,0 @@ <script>

@@ -15,7 +15,7 @@

it('should measure bearing', function() {
it('should measure heading', function() {
var result = GPS.Bearing(45.527517, -122.718766, 45.373373, -121.693604);
var result = GPS.Heading(45.527517, -122.718766, 45.373373, -121.693604);
expect(result).to.deep.equal(113.85710071762026);
expect(result).to.deep.equal(101.73177498132071);

@@ -22,0 +22,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