signalk-polar-performance-plugin 0.0.21 → 0.0.22

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/package.json +1 -1
  2. package/plugin/index.js +21 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-polar-performance-plugin",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "A plugin that calculates performance information based on a (CSV) polar diagram.",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {
package/plugin/index.js CHANGED
@@ -37,6 +37,10 @@ module.exports = function (app) {
37
37
  type: 'boolean',
38
38
  title: 'Enable calculation of Optimum Wind Angle (difference between TWA and beat/run angle (depends on beat/run angle)'
39
39
  },
40
+ VMG: {
41
+ type: 'boolean',
42
+ title: 'Enable calculation of VMG, polarVMG and polar VMG ratio'
43
+ },
40
44
  useSOG: {
41
45
  type: 'boolean',
42
46
  title: 'Use speed over ground (SOG) as boat speed.'
@@ -47,7 +51,7 @@ module.exports = function (app) {
47
51
  },
48
52
  csvTable: {
49
53
  type: "string",
50
- title: "Enter csv with polar in http://jieter.github.io/orc-data/site/ style."
54
+ title: "Copy/paste the csv content of the polar in http://jieter.github.io/orc-data/site/ style."
51
55
  }
52
56
  }
53
57
  }
@@ -206,6 +210,11 @@ module.exports = function (app) {
206
210
  if (typeof perfObj.polarSpeed != 'undefined') {
207
211
  values.push({path: 'performance.polarSpeed', value: roundDec(perfObj.polarSpeed)})
208
212
  values.push({path: 'performance.polarSpeedRatio', value: roundDec(perfObj.polarSpeedRatio)})
213
+ if (options.VMG == true) {
214
+ values.push({path: 'performance.velocityMadeGood', value: roundDec(perfObj.velocityMadeGood)})
215
+ values.push({path: 'performance.polarVelocityMadeGood', value: roundDec(perfObj.polarVelocityMadeGood)})
216
+ values.push({path: 'performance.polarVelocityMadeGoodRatio', value: roundDec(perfObj.polarVelocityMadeGoodRatio)})
217
+ }
209
218
  }
210
219
  if (typeof perfObj.maxSpeed != 'undefined') {
211
220
  values.push({path: 'performance.maxSpeed', value: roundDec(perfObj.maxSpeed)})
@@ -369,11 +378,21 @@ module.exports = function (app) {
369
378
  }
370
379
  // Calculate polar performance ratio
371
380
  if (typeof performance.polarSpeed != 'undefined') {
372
- performance.polarSpeedRatio = (1 / performance.polarSpeed) * BSP
381
+ performance.polarSpeedRatio = BSP / performance.polarSpeed
382
+ if (options.VMG == true) {
383
+ performance.velocityMadeGood = Math.abs(BSP * Math.cos(TWA))
384
+ performance.polarVelocityMadeGood = Math.abs(performance.polarSpeed * Math.cos(TWA))
385
+ performance.polarVelocityMadeGoodRatio = performance.velocityMadeGood / performance.polarVelocityMadeGood
386
+ }
373
387
  } else {
374
388
  // No value would create stale values
375
389
  performance.polarSpeed = 0
376
390
  performance.polarSpeedRatio = 0
391
+ if (options.VMG == true) {
392
+ performance.velocityMadeGood = 0
393
+ performance.polarVelocityMadeGood = 0
394
+ performance.polarRatioVelocityMadeGood = 0
395
+ }
377
396
  }
378
397
  return performance
379
398
  }