aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/util/converter.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-05 16:43:42 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-05 16:43:42 -0700
commit8bde80a8cd1fb9b92f4867edbeeae48158f9036b (patch)
tree493edc77a38e4e39b438c4255a02cf843eedc821 /modern/src/common/util/converter.js
parentdad1892d4718f15c9ecdd301db140d66d52da6b3 (diff)
downloadtrackermap-web-8bde80a8cd1fb9b92f4867edbeeae48158f9036b.tar.gz
trackermap-web-8bde80a8cd1fb9b92f4867edbeeae48158f9036b.tar.bz2
trackermap-web-8bde80a8cd1fb9b92f4867edbeeae48158f9036b.zip
Configurable altitude units
Diffstat (limited to 'modern/src/common/util/converter.js')
-rw-r--r--modern/src/common/util/converter.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/modern/src/common/util/converter.js b/modern/src/common/util/converter.js
index 559e68aa..cb21566b 100644
--- a/modern/src/common/util/converter.js
+++ b/modern/src/common/util/converter.js
@@ -54,6 +54,30 @@ export const distanceFromMeters = (value, unit) => value * distanceConverter(uni
export const distanceToMeters = (value, unit) => value / distanceConverter(unit);
+const altitudeConverter = (unit) => {
+ switch (unit) {
+ case 'ft':
+ return 3.28084;
+ case 'm':
+ default:
+ return 1;
+ }
+};
+
+export const altitudeUnitString = (unit, t) => {
+ switch (unit) {
+ case 'ft':
+ return t('sharedFeet');
+ case 'm':
+ default:
+ return t('sharedMeters');
+ }
+};
+
+export const altitudeFromMeters = (value, unit) => value * altitudeConverter(unit);
+
+export const altitudeToMeters = (value, unit) => value / altitudeConverter(unit);
+
const volumeConverter = (unit) => {
switch (unit) {
case 'impGal':