blob: 9cdc6239c76626c3f4e74074eb0a87c283fcd5da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
const speedConverter = unit => {
switch (unit) {
case 'kmh':
return 1.852;
case 'mph':
return 1.15078;
case 'kn':
default:
return 1;
}
};
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);
}
|