diff options
author | geduxas <gediminas.vileikis@gmail.com> | 2023-09-20 09:31:36 +0000 |
---|---|---|
committer | geduxas <gediminas.vileikis@gmail.com> | 2023-09-20 09:31:36 +0000 |
commit | 3e2c5833ac8dbabb02569544359a61baaa489a76 (patch) | |
tree | e89bc803363f235fb707d29a3e1de5da2c03f55c /modern/src/common/util/converter.js | |
parent | 925c51d94f25021cb4fbf77cee7b0cb7f611692b (diff) | |
download | trackermap-web-3e2c5833ac8dbabb02569544359a61baaa489a76.tar.gz trackermap-web-3e2c5833ac8dbabb02569544359a61baaa489a76.tar.bz2 trackermap-web-3e2c5833ac8dbabb02569544359a61baaa489a76.zip |
OBDSpeed expected as km/h not knots.
Diffstat (limited to 'modern/src/common/util/converter.js')
-rw-r--r-- | modern/src/common/util/converter.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modern/src/common/util/converter.js b/modern/src/common/util/converter.js index cb21566b..6890763b 100644 --- a/modern/src/common/util/converter.js +++ b/modern/src/common/util/converter.js @@ -10,6 +10,18 @@ const speedConverter = (unit) => { } }; +const speedConverterKph = (unit) => { + switch (unit) { + case 'kmh': + return 1; + case 'mph': + return 0.62137; + case 'kn': + default: + return 0.539957; + } +}; + export const speedUnitString = (unit, t) => { switch (unit) { case 'kmh': @@ -24,6 +36,8 @@ export const speedUnitString = (unit, t) => { export const speedFromKnots = (value, unit) => value * speedConverter(unit); +export const speedFromKph = (value, unit) => value * speedConverterKph(unit); + export const speedToKnots = (value, unit) => value / speedConverter(unit); const distanceConverter = (unit) => { |