diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-02-15 22:10:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-15 22:10:52 -0800 |
commit | 8560d1f0f4f6709cc964762dbe5d65f63d40190e (patch) | |
tree | bd812414d948efb3ba38c9065facd1cc131449cc /modern/src/common/converter.js | |
parent | 65af8bad51851ff7f15319d5ce14ff24697aaded (diff) | |
parent | 9d3bea9f3ecb2da4563a8cf7f444f478f88e9c38 (diff) | |
download | etbsa-traccar-web-8560d1f0f4f6709cc964762dbe5d65f63d40190e.tar.gz etbsa-traccar-web-8560d1f0f4f6709cc964762dbe5d65f63d40190e.tar.bz2 etbsa-traccar-web-8560d1f0f4f6709cc964762dbe5d65f63d40190e.zip |
Merge pull request #815 from mail2bishnoi/maintenance
Initial Maintenance Screen
Diffstat (limited to 'modern/src/common/converter.js')
-rw-r--r-- | modern/src/common/converter.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/modern/src/common/converter.js b/modern/src/common/converter.js index e48b076..9cdc623 100644 --- a/modern/src/common/converter.js +++ b/modern/src/common/converter.js @@ -1,13 +1,39 @@ -export const speedConverter = (value, unit) => { - let factor; +const speedConverter = unit => { switch (unit) { case 'kmh': - factor = 1.852; + return 1.852; case 'mph': - factor = 1.15078; + return 1.15078; case 'kn': default: - factor = 1; + return 1; } - return (value * factor).toFixed(2); }; + +const distanceConverter = unit => { + switch (unit) { + case 'mi': + return 0.000621371; + case 'nmi': + return 0.000539957; + case 'km': + default: + return 0.001; + } +} + +export const speedFromKnots = (value, unit) => { + return value * speedConverter(unit); +} + +export const speedToKnots = (value, unit) => { + return value / speedConverter(unit); +} + +export const distanceFromMeters = (value, unit) => { + return value * distanceConverter(unit); +} + +export const distanceToMeters = (value, unit) => { + return value / distanceConverter(unit); +} |