signalk-to-noforeignland 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +16 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -179,10 +179,15 @@ module.exports = function (app) {
179
179
  let timestamp = update.timestamp;
180
180
  for (value of update.values) {
181
181
 
182
- if (value.value.latitude === 0 && value.value.longitude === 0) {
183
- // Skip saving point with latitude and longitude both equal to 0
184
- return;
185
- }
182
+
183
+ if (
184
+ Math.abs(value.value.latitude) <= 0.01 &&
185
+ Math.abs(value.value.longitude) <= 0.01
186
+ ) {
187
+ // Coordinates are within ±0.1 of (0,0)
188
+ return;
189
+ }
190
+
186
191
  // app.debug(`value:`, value);
187
192
 
188
193
  if (!shouldDoLog) {
@@ -401,10 +406,13 @@ module.exports = function (app) {
401
406
  if (line) {
402
407
  try {
403
408
  const point = JSON.parse(line);
404
- if (isValidLatitude(point.lat) && isValidLongitude(point.lon)) {
405
- track.push([point.t,point.lat, point.lon])
406
- lastTimestamp = point.t
407
- }
409
+
410
+ const timestamp = new Date(point.t).getTime();
411
+ if (!isNaN(timestamp) && isValidLatitude(point.lat) && isValidLongitude(point.lon)) {
412
+ track.push([timestamp, point.lat, point.lon]);
413
+ lastTimestamp = timestamp;
414
+ }
415
+
408
416
  } catch (error) {
409
417
  app.debug('could not parse line from track file:', line);
410
418
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-to-noforeignland",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "SignalK track logger to noforeignland.com ",
5
5
  "main": "index.js",
6
6
  "keywords": [