@sswroom/sswr 1.6.3 → 1.6.5
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.
- package/Changelog +20 -0
- package/cert.d.ts +55 -53
- package/cert.js +733 -134
- package/certutil.d.ts +11 -11
- package/certutil.js +11 -6
- package/data.d.ts +29 -1
- package/data.js +152 -24
- package/geometry.d.ts +11 -3
- package/geometry.js +110 -17
- package/hash.js +7 -2
- package/kml.d.ts +1 -1
- package/kml.js +46 -4
- package/leaflet.d.ts +2 -2
- package/leaflet.js +48 -4
- package/map.js +11 -0
- package/math.d.ts +1 -1
- package/math.js +361 -29
- package/media.d.ts +1 -1
- package/media.js +20 -9
- package/package.json +1 -1
- package/parser.js +30 -9
- package/text.d.ts +1 -1
- package/text.js +2 -2
- package/unit.js +746 -663
- package/web.d.ts +3 -0
- package/web.js +138 -15
package/unit.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as math from "./math.js";
|
|
2
2
|
|
|
3
|
-
export class UnitInfo
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export class UnitInfo {
|
|
4
|
+
/**
|
|
5
|
+
* @param {number} unit
|
|
6
|
+
* @param {string} symbol
|
|
7
|
+
* @param {string} name
|
|
8
|
+
* @param {number} ratio
|
|
9
|
+
* @param {number | undefined} [scale]
|
|
10
|
+
*/
|
|
11
|
+
constructor(unit, symbol, name, ratio, scale) {
|
|
7
12
|
this.unit = unit;
|
|
8
13
|
this.symbol = symbol;
|
|
9
14
|
this.name = name;
|
|
@@ -12,45 +17,49 @@ export class UnitInfo
|
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
export class Acceleration
|
|
16
|
-
{
|
|
20
|
+
export class Acceleration {
|
|
17
21
|
static Unit = {
|
|
18
22
|
METER_PER_SECOND_SQUARED: 1,
|
|
19
23
|
STANDARD_GRAVITY: 2
|
|
20
24
|
};
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @param {number} u
|
|
28
|
+
*/
|
|
29
|
+
static getUnitInfo(u) {
|
|
30
|
+
switch (u) {
|
|
31
|
+
case Acceleration.Unit.METER_PER_SECOND_SQUARED:
|
|
32
|
+
return new UnitInfo(u, "m/s^2", "Meter Per Second Squared", 1);
|
|
33
|
+
case Acceleration.Unit.STANDARD_GRAVITY:
|
|
34
|
+
return new UnitInfo(u, "g", "Gravity", 9.80665);
|
|
30
35
|
}
|
|
31
36
|
return null;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @param {number} u
|
|
41
|
+
*/
|
|
42
|
+
static getUnitRatio(u) {
|
|
43
|
+
switch (u) {
|
|
44
|
+
case Acceleration.Unit.METER_PER_SECOND_SQUARED:
|
|
45
|
+
return 1.0;
|
|
46
|
+
case Acceleration.Unit.STANDARD_GRAVITY:
|
|
47
|
+
return 9.80665;
|
|
42
48
|
}
|
|
43
49
|
return 1.0;
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {number} fromUnit
|
|
54
|
+
* @param {number} toUnit
|
|
55
|
+
* @param {number} fromValue
|
|
56
|
+
*/
|
|
57
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
48
58
|
return fromValue * Acceleration.getUnitRatio(fromUnit) / Acceleration.getUnitRatio(toUnit);
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
export class Angle
|
|
53
|
-
{
|
|
62
|
+
export class Angle {
|
|
54
63
|
static Unit = {
|
|
55
64
|
RADIAN: 1,
|
|
56
65
|
GRADIAN: 2,
|
|
@@ -62,94 +71,104 @@ export class Angle
|
|
|
62
71
|
MICROARCSECOND: 8
|
|
63
72
|
};
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @param {number} u
|
|
76
|
+
*/
|
|
77
|
+
static getUnitInfo(u) {
|
|
78
|
+
switch (u) {
|
|
79
|
+
case Angle.Unit.RADIAN:
|
|
80
|
+
return new UnitInfo(u, "rad", "Radian", 1);
|
|
81
|
+
case Angle.Unit.GRADIAN:
|
|
82
|
+
return new UnitInfo(u, "grad", "Gradian", Math.PI / 200.0);
|
|
83
|
+
case Angle.Unit.TURN:
|
|
84
|
+
return new UnitInfo(u, "", "Turns", Math.PI * 2.0);
|
|
85
|
+
case Angle.Unit.DEGREE:
|
|
86
|
+
return new UnitInfo(u, "°", "Degree", Math.PI / 180.0);
|
|
87
|
+
case Angle.Unit.ARCMINUTE:
|
|
88
|
+
return new UnitInfo(u, "′", "Arcminute", Math.PI / 10800.0);
|
|
89
|
+
case Angle.Unit.ARCSECOND:
|
|
90
|
+
return new UnitInfo(u, "″", "Arcsecond", Math.PI / 648000.0);
|
|
91
|
+
case Angle.Unit.MILLIARCSECOND:
|
|
92
|
+
return new UnitInfo(u, "mas", "Milliarcsecond", Math.PI / 648000000.0);
|
|
93
|
+
case Angle.Unit.MICROARCSECOND:
|
|
94
|
+
return new UnitInfo(u, "μas", "Microarcsecond", Math.PI / 648000000000.0);
|
|
85
95
|
}
|
|
86
96
|
return null;
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
/**
|
|
100
|
+
* @param {number} u
|
|
101
|
+
*/
|
|
102
|
+
static getUnitRatio(u) {
|
|
103
|
+
switch (u) {
|
|
104
|
+
case Angle.Unit.RADIAN:
|
|
105
|
+
return 1;
|
|
106
|
+
case Angle.Unit.GRADIAN:
|
|
107
|
+
return Math.PI / 200.0;
|
|
108
|
+
case Angle.Unit.TURN:
|
|
109
|
+
return Math.PI * 2.0;
|
|
110
|
+
case Angle.Unit.DEGREE:
|
|
111
|
+
return Math.PI / 180.0;
|
|
112
|
+
case Angle.Unit.ARCMINUTE:
|
|
113
|
+
return Math.PI / 10800.0;
|
|
114
|
+
case Angle.Unit.ARCSECOND:
|
|
115
|
+
return Math.PI / 648000.0;
|
|
116
|
+
case Angle.Unit.MILLIARCSECOND:
|
|
117
|
+
return Math.PI / 648000000.0;
|
|
118
|
+
case Angle.Unit.MICROARCSECOND:
|
|
119
|
+
return Math.PI / 648000000000.0;
|
|
109
120
|
}
|
|
110
121
|
return 1;
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
/**
|
|
125
|
+
* @param {number} fromUnit
|
|
126
|
+
* @param {number} toUnit
|
|
127
|
+
* @param {number} fromValue
|
|
128
|
+
*/
|
|
129
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
115
130
|
return fromValue * Angle.getUnitRatio(fromUnit) / Angle.getUnitRatio(toUnit);
|
|
116
131
|
}
|
|
117
132
|
}
|
|
118
133
|
|
|
119
|
-
export class ApparentPower
|
|
120
|
-
{
|
|
134
|
+
export class ApparentPower {
|
|
121
135
|
static Unit = {
|
|
122
136
|
VOLT_AMPERE: 1
|
|
123
137
|
};
|
|
124
138
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
/**
|
|
140
|
+
* @param {number} u
|
|
141
|
+
*/
|
|
142
|
+
static getUnitInfo(u) {
|
|
143
|
+
switch (u) {
|
|
144
|
+
case ApparentPower.Unit.VOLT_AMPERE:
|
|
145
|
+
return new UnitInfo(u, "VA", "Volt-Ampere", 1);
|
|
131
146
|
}
|
|
132
147
|
return null;
|
|
133
148
|
}
|
|
134
149
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
/**
|
|
151
|
+
* @param {number} u
|
|
152
|
+
*/
|
|
153
|
+
static getUnitRatio(u) {
|
|
154
|
+
switch (u) {
|
|
155
|
+
case ApparentPower.Unit.VOLT_AMPERE:
|
|
156
|
+
return 1;
|
|
141
157
|
}
|
|
142
158
|
return 1;
|
|
143
159
|
}
|
|
144
160
|
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
/**
|
|
162
|
+
* @param {number} fromUnit
|
|
163
|
+
* @param {number} toUnit
|
|
164
|
+
* @param {number} fromValue
|
|
165
|
+
*/
|
|
166
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
147
167
|
return fromValue * ApparentPower.getUnitRatio(fromUnit) / ApparentPower.getUnitRatio(toUnit);
|
|
148
168
|
}
|
|
149
169
|
}
|
|
150
170
|
|
|
151
|
-
export class Count
|
|
152
|
-
{
|
|
171
|
+
export class Count {
|
|
153
172
|
static Unit = {
|
|
154
173
|
UNIT: 1,
|
|
155
174
|
K_UNIT: 2,
|
|
@@ -162,174 +181,161 @@ export class Count
|
|
|
162
181
|
TI_UNIT: 9
|
|
163
182
|
};
|
|
164
183
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
/**
|
|
185
|
+
* @param {number} u
|
|
186
|
+
*/
|
|
187
|
+
static getUnitInfo(u) {
|
|
188
|
+
switch (u) {
|
|
189
|
+
case Count.Unit.UNIT:
|
|
190
|
+
return new UnitInfo(u, "", "Unit", 1.0);
|
|
191
|
+
case Count.Unit.K_UNIT:
|
|
192
|
+
return new UnitInfo(u, "K", "Kilo", 1000.0);
|
|
193
|
+
case Count.Unit.KI_UNIT:
|
|
194
|
+
return new UnitInfo(u, "Ki", "Binary Kilo", 1024.0);
|
|
195
|
+
case Count.Unit.M_UNIT:
|
|
196
|
+
return new UnitInfo(u, "M", "Mega", 1000000.0);
|
|
197
|
+
case Count.Unit.MI_UNIT:
|
|
198
|
+
return new UnitInfo(u, "Mi", "Binary Mega", 1048576.0);
|
|
199
|
+
case Count.Unit.G_UNIT:
|
|
200
|
+
return new UnitInfo(u, "G", "Giga", 1000000000.0);
|
|
201
|
+
case Count.Unit.GI_UNIT:
|
|
202
|
+
return new UnitInfo(u, "Gi", "Binary Giga", 1073741824.0);
|
|
203
|
+
case Count.Unit.T_UNIT:
|
|
204
|
+
return new UnitInfo(u, "T", "Tera", 1000000000000.0);
|
|
205
|
+
case Count.Unit.TI_UNIT:
|
|
206
|
+
return new UnitInfo(u, "Ti", "Binary Tera", 1099511627776.0);
|
|
187
207
|
}
|
|
188
208
|
return null;
|
|
189
209
|
}
|
|
190
210
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
/**
|
|
212
|
+
* @param {number} u
|
|
213
|
+
*/
|
|
214
|
+
static getUnitRatio(u) {
|
|
215
|
+
switch (u) {
|
|
216
|
+
case Count.Unit.UNIT:
|
|
217
|
+
return 1.0;
|
|
218
|
+
case Count.Unit.K_UNIT:
|
|
219
|
+
return 1000.0;
|
|
220
|
+
case Count.Unit.KI_UNIT:
|
|
221
|
+
return 1024.0;
|
|
222
|
+
case Count.Unit.M_UNIT:
|
|
223
|
+
return 1000000.0;
|
|
224
|
+
case Count.Unit.MI_UNIT:
|
|
225
|
+
return 1048576.0;
|
|
226
|
+
case Count.Unit.G_UNIT:
|
|
227
|
+
return 1000000000.0;
|
|
228
|
+
case Count.Unit.GI_UNIT:
|
|
229
|
+
return 1073741824.0;
|
|
230
|
+
case Count.Unit.T_UNIT:
|
|
231
|
+
return 1000000000000.0;
|
|
232
|
+
case Count.Unit.TI_UNIT:
|
|
233
|
+
return 1099511627776.0;
|
|
213
234
|
}
|
|
214
235
|
return 1;
|
|
215
236
|
}
|
|
216
237
|
|
|
217
|
-
|
|
218
|
-
|
|
238
|
+
/**
|
|
239
|
+
* @param {number} fromUnit
|
|
240
|
+
* @param {number} toUnit
|
|
241
|
+
* @param {number} fromValue
|
|
242
|
+
*/
|
|
243
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
219
244
|
return fromValue * ApparentPower.getUnitRatio(fromUnit) / ApparentPower.getUnitRatio(toUnit);
|
|
220
245
|
}
|
|
221
246
|
|
|
222
|
-
|
|
223
|
-
|
|
247
|
+
/**
|
|
248
|
+
* @param {number} val
|
|
249
|
+
* @param {number | null} nDecimal
|
|
250
|
+
*/
|
|
251
|
+
static wellFormat(val, nDecimal) {
|
|
224
252
|
if (nDecimal == null || nDecimal < 1)
|
|
225
253
|
nDecimal = 2;
|
|
226
254
|
let lval = Math.log10(val);
|
|
227
|
-
if (lval < 0)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
{
|
|
231
|
-
return math.roundToStr(val * 100, nDecimal)+"c";
|
|
255
|
+
if (lval < 0) {
|
|
256
|
+
if (lval >= -2) {
|
|
257
|
+
return math.roundToStr(val * 100, nDecimal) + "c";
|
|
232
258
|
}
|
|
233
|
-
else if (lval >= -3)
|
|
234
|
-
|
|
235
|
-
return math.roundToStr(val * 1000, nDecimal)+"m";
|
|
259
|
+
else if (lval >= -3) {
|
|
260
|
+
return math.roundToStr(val * 1000, nDecimal) + "m";
|
|
236
261
|
}
|
|
237
|
-
else if (lval >= -6)
|
|
238
|
-
|
|
239
|
-
return math.roundToStr(val * 1000000, nDecimal)+"u";
|
|
262
|
+
else if (lval >= -6) {
|
|
263
|
+
return math.roundToStr(val * 1000000, nDecimal) + "u";
|
|
240
264
|
}
|
|
241
|
-
else if (lval >= -9)
|
|
242
|
-
|
|
243
|
-
return math.roundToStr(val * 1.0e9, nDecimal)+"n";
|
|
265
|
+
else if (lval >= -9) {
|
|
266
|
+
return math.roundToStr(val * 1.0e9, nDecimal) + "n";
|
|
244
267
|
}
|
|
245
|
-
else if (lval >= -12)
|
|
246
|
-
|
|
247
|
-
return math.roundToStr(val * 1.0e12, nDecimal)+"p";
|
|
268
|
+
else if (lval >= -12) {
|
|
269
|
+
return math.roundToStr(val * 1.0e12, nDecimal) + "p";
|
|
248
270
|
}
|
|
249
|
-
else if (lval >= -15)
|
|
250
|
-
|
|
251
|
-
return math.roundToStr(val * 1.0e15, nDecimal)+"f";
|
|
271
|
+
else if (lval >= -15) {
|
|
272
|
+
return math.roundToStr(val * 1.0e15, nDecimal) + "f";
|
|
252
273
|
}
|
|
253
|
-
else if (lval >= -18)
|
|
254
|
-
|
|
255
|
-
return math.roundToStr(val * 1.0e18, nDecimal)+"a";
|
|
274
|
+
else if (lval >= -18) {
|
|
275
|
+
return math.roundToStr(val * 1.0e18, nDecimal) + "a";
|
|
256
276
|
}
|
|
257
|
-
else if (lval >= -21)
|
|
258
|
-
|
|
259
|
-
return math.roundToStr(val * 1.0e21, nDecimal)+"z";
|
|
277
|
+
else if (lval >= -21) {
|
|
278
|
+
return math.roundToStr(val * 1.0e21, nDecimal) + "z";
|
|
260
279
|
}
|
|
261
|
-
else
|
|
262
|
-
|
|
263
|
-
return math.roundToStr(val * 1.0e24, nDecimal)+"y";
|
|
280
|
+
else {
|
|
281
|
+
return math.roundToStr(val * 1.0e24, nDecimal) + "y";
|
|
264
282
|
}
|
|
265
283
|
}
|
|
266
|
-
else if (lval < 3)
|
|
267
|
-
{
|
|
284
|
+
else if (lval < 3) {
|
|
268
285
|
return math.roundToStr(val, nDecimal);
|
|
269
286
|
}
|
|
270
|
-
else if (lval < 6)
|
|
271
|
-
|
|
272
|
-
return math.roundToStr(val / 1.0e3, nDecimal)+"k";
|
|
287
|
+
else if (lval < 6) {
|
|
288
|
+
return math.roundToStr(val / 1.0e3, nDecimal) + "k";
|
|
273
289
|
}
|
|
274
|
-
else if (lval < 9)
|
|
275
|
-
|
|
276
|
-
return math.roundToStr(val / 1.0e6, nDecimal)+"M";
|
|
290
|
+
else if (lval < 9) {
|
|
291
|
+
return math.roundToStr(val / 1.0e6, nDecimal) + "M";
|
|
277
292
|
}
|
|
278
|
-
else if (val < 12)
|
|
279
|
-
|
|
280
|
-
return math.roundToStr(val / 1.0e9, nDecimal)+"G";
|
|
293
|
+
else if (val < 12) {
|
|
294
|
+
return math.roundToStr(val / 1.0e9, nDecimal) + "G";
|
|
281
295
|
}
|
|
282
|
-
else if (val < 15)
|
|
283
|
-
|
|
284
|
-
return math.roundToStr(val / 1.0e12, nDecimal)+"T";
|
|
296
|
+
else if (val < 15) {
|
|
297
|
+
return math.roundToStr(val / 1.0e12, nDecimal) + "T";
|
|
285
298
|
}
|
|
286
|
-
else if (val < 18)
|
|
287
|
-
|
|
288
|
-
return math.roundToStr(val / 1.0e15, nDecimal)+"P";
|
|
299
|
+
else if (val < 18) {
|
|
300
|
+
return math.roundToStr(val / 1.0e15, nDecimal) + "P";
|
|
289
301
|
}
|
|
290
|
-
else if (val < 21)
|
|
291
|
-
|
|
292
|
-
return math.roundToStr(val / 1.0e18, nDecimal)+"E";
|
|
302
|
+
else if (val < 21) {
|
|
303
|
+
return math.roundToStr(val / 1.0e18, nDecimal) + "E";
|
|
293
304
|
}
|
|
294
|
-
else if (val < 24)
|
|
295
|
-
|
|
296
|
-
return math.roundToStr(val / 1.0e21, nDecimal)+"Z";
|
|
305
|
+
else if (val < 24) {
|
|
306
|
+
return math.roundToStr(val / 1.0e21, nDecimal) + "Z";
|
|
297
307
|
}
|
|
298
|
-
else
|
|
299
|
-
|
|
300
|
-
return math.roundToStr(val / 1.0e24, nDecimal)+"Y";
|
|
308
|
+
else {
|
|
309
|
+
return math.roundToStr(val / 1.0e24, nDecimal) + "Y";
|
|
301
310
|
}
|
|
302
311
|
}
|
|
303
312
|
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
/**
|
|
314
|
+
* @param {number} val
|
|
315
|
+
* @param {number | null} nDecimal
|
|
316
|
+
*/
|
|
317
|
+
static wellFormatBin(val, nDecimal) {
|
|
306
318
|
if (nDecimal == null || nDecimal < 1)
|
|
307
319
|
nDecimal = 2;
|
|
308
|
-
if (val < 1024)
|
|
309
|
-
{
|
|
320
|
+
if (val < 1024) {
|
|
310
321
|
return math.roundToStr(val, nDecimal);
|
|
311
322
|
}
|
|
312
|
-
else if (val < 1048576)
|
|
313
|
-
|
|
314
|
-
return math.roundToStr(val / 1024, nDecimal)+"Ki";
|
|
323
|
+
else if (val < 1048576) {
|
|
324
|
+
return math.roundToStr(val / 1024, nDecimal) + "Ki";
|
|
315
325
|
}
|
|
316
|
-
else if (val < 1073741824)
|
|
317
|
-
|
|
318
|
-
return math.roundToStr(val / 1048576, nDecimal)+"Mi";
|
|
326
|
+
else if (val < 1073741824) {
|
|
327
|
+
return math.roundToStr(val / 1048576, nDecimal) + "Mi";
|
|
319
328
|
}
|
|
320
|
-
else if (val < 1099511627776)
|
|
321
|
-
|
|
322
|
-
return math.roundToStr(val / 1073741824, nDecimal)+"Gi";
|
|
329
|
+
else if (val < 1099511627776) {
|
|
330
|
+
return math.roundToStr(val / 1073741824, nDecimal) + "Gi";
|
|
323
331
|
}
|
|
324
|
-
else
|
|
325
|
-
|
|
326
|
-
return math.roundToStr(val / 1099511627776, nDecimal)+"Ti";
|
|
332
|
+
else {
|
|
333
|
+
return math.roundToStr(val / 1099511627776, nDecimal) + "Ti";
|
|
327
334
|
}
|
|
328
335
|
}
|
|
329
336
|
}
|
|
330
337
|
|
|
331
|
-
export class Distance
|
|
332
|
-
{
|
|
338
|
+
export class Distance {
|
|
333
339
|
static Unit = {
|
|
334
340
|
METER: 0,
|
|
335
341
|
CENTIMETER: 1,
|
|
@@ -355,202 +361,217 @@ export class Distance
|
|
|
355
361
|
PIXEL: 21,
|
|
356
362
|
TWIP: 22
|
|
357
363
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* @param {number} u
|
|
367
|
+
*/
|
|
368
|
+
static getUnitInfo(u) {
|
|
369
|
+
switch (u) {
|
|
370
|
+
case Distance.Unit.METER:
|
|
371
|
+
return new UnitInfo(u, "m", "Meter", 1.0);
|
|
372
|
+
case Distance.Unit.CENTIMETER:
|
|
373
|
+
return new UnitInfo(u, "cm", "Centimeter", 0.01);
|
|
374
|
+
case Distance.Unit.MILLIMETER:
|
|
375
|
+
return new UnitInfo(u, "mm", "Millimeter", 0.001);
|
|
376
|
+
case Distance.Unit.MICROMETER:
|
|
377
|
+
return new UnitInfo(u, "μm", "Micrometer", 0.000001);
|
|
378
|
+
case Distance.Unit.NANOMETER:
|
|
379
|
+
return new UnitInfo(u, "nm", "Nanometer", 0.000000001);
|
|
380
|
+
case Distance.Unit.PICOMETER:
|
|
381
|
+
return new UnitInfo(u, "pm", "Picometer", 0.000000000001);
|
|
382
|
+
case Distance.Unit.KILOMETER:
|
|
383
|
+
return new UnitInfo(u, "km", "Kilometer", 1000.0);
|
|
384
|
+
case Distance.Unit.INCH:
|
|
385
|
+
return new UnitInfo(u, "\"", "Inch", 0.0254);
|
|
386
|
+
case Distance.Unit.FOOT:
|
|
387
|
+
return new UnitInfo(u, "ft", "Foot", 0.0254 * 12.0);
|
|
388
|
+
case Distance.Unit.YARD:
|
|
389
|
+
return new UnitInfo(u, "yd", "Yard", 0.0254 * 36.0);
|
|
390
|
+
case Distance.Unit.MILE:
|
|
391
|
+
return new UnitInfo(u, "mile", "Mile", 0.0254 * 12.0 * 5280);
|
|
392
|
+
case Distance.Unit.NAUTICAL_MILE:
|
|
393
|
+
return new UnitInfo(u, "NM", "Nautical Mile", 1852.0);
|
|
394
|
+
case Distance.Unit.AU:
|
|
395
|
+
return new UnitInfo(u, "AU", "Astronomical unit", 149597870700.0);
|
|
396
|
+
case Distance.Unit.LIGHTSECOND:
|
|
397
|
+
return new UnitInfo(u, "ls", "Light-second", 299792458.0);
|
|
398
|
+
case Distance.Unit.LIGHTMINUTE:
|
|
399
|
+
return new UnitInfo(u, "lm", "Light-minute", 17987547480.0);
|
|
400
|
+
case Distance.Unit.LIGHTHOUR:
|
|
401
|
+
return new UnitInfo(u, "lh", "Light-hour", 299792458.0 * 3600.0);
|
|
402
|
+
case Distance.Unit.LIGHTDAY:
|
|
403
|
+
return new UnitInfo(u, "ld", "Light-day", 299792458.0 * 86400.0);
|
|
404
|
+
case Distance.Unit.LIGHTWEEK:
|
|
405
|
+
return new UnitInfo(u, "lw", "Light-week", 299792458.0 * 604800.0);
|
|
406
|
+
case Distance.Unit.LIGHTYEAR:
|
|
407
|
+
return new UnitInfo(u, "ly", "Light-year", 299792458.0 * 31557600.0);
|
|
408
|
+
case Distance.Unit.EMU:
|
|
409
|
+
return new UnitInfo(u, "emu", "English Metric Unit", 1 / 36000000.0);
|
|
410
|
+
case Distance.Unit.POINT:
|
|
411
|
+
return new UnitInfo(u, "pt", "Point", 0.0254 / 72.0);
|
|
412
|
+
case Distance.Unit.PIXEL:
|
|
413
|
+
return new UnitInfo(u, "px", "Pixel", 0.0254 / 96.0);
|
|
414
|
+
case Distance.Unit.TWIP:
|
|
415
|
+
return new UnitInfo(u, "twip", "Twentieth of an inch point", 0.0254 / 1440.0);
|
|
409
416
|
}
|
|
410
417
|
return null;
|
|
411
418
|
}
|
|
412
419
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
420
|
+
/**
|
|
421
|
+
* @param {number} u
|
|
422
|
+
*/
|
|
423
|
+
static getUnitRatio(u) {
|
|
424
|
+
switch (u) {
|
|
425
|
+
case Distance.Unit.METER:
|
|
426
|
+
return 1.0;
|
|
427
|
+
case Distance.Unit.CENTIMETER:
|
|
428
|
+
return 0.01;
|
|
429
|
+
case Distance.Unit.MILLIMETER:
|
|
430
|
+
return 0.001;
|
|
431
|
+
case Distance.Unit.MICROMETER:
|
|
432
|
+
return 0.000001;
|
|
433
|
+
case Distance.Unit.NANOMETER:
|
|
434
|
+
return 0.000000001;
|
|
435
|
+
case Distance.Unit.PICOMETER:
|
|
436
|
+
return 0.000000000001;
|
|
437
|
+
case Distance.Unit.KILOMETER:
|
|
438
|
+
return 1000.0;
|
|
439
|
+
case Distance.Unit.INCH:
|
|
440
|
+
return 0.0254;
|
|
441
|
+
case Distance.Unit.FOOT:
|
|
442
|
+
return 0.0254 * 12.0;
|
|
443
|
+
case Distance.Unit.YARD:
|
|
444
|
+
return 0.0254 * 36.0;
|
|
445
|
+
case Distance.Unit.MILE:
|
|
446
|
+
return 0.0254 * 12.0 * 5280;
|
|
447
|
+
case Distance.Unit.NAUTICAL_MILE:
|
|
448
|
+
return 1852.0;
|
|
449
|
+
case Distance.Unit.AU:
|
|
450
|
+
return 149597870700.0;
|
|
451
|
+
case Distance.Unit.LIGHTSECOND:
|
|
452
|
+
return 299792458.0;
|
|
453
|
+
case Distance.Unit.LIGHTMINUTE:
|
|
454
|
+
return 17987547480.0;
|
|
455
|
+
case Distance.Unit.LIGHTHOUR:
|
|
456
|
+
return 299792458.0 * 3600.0;
|
|
457
|
+
case Distance.Unit.LIGHTDAY:
|
|
458
|
+
return 299792458.0 * 86400.0;
|
|
459
|
+
case Distance.Unit.LIGHTWEEK:
|
|
460
|
+
return 299792458.0 * 604800.0;
|
|
461
|
+
case Distance.Unit.LIGHTYEAR:
|
|
462
|
+
return 299792458.0 * 31557600.0;
|
|
463
|
+
case Distance.Unit.EMU:
|
|
464
|
+
return 1 / 36000000.0;
|
|
465
|
+
case Distance.Unit.POINT:
|
|
466
|
+
return 0.0254 / 72.0;
|
|
467
|
+
case Distance.Unit.PIXEL:
|
|
468
|
+
return 0.0254 / 96.0;
|
|
469
|
+
case Distance.Unit.TWIP:
|
|
470
|
+
return 0.0254 / 1440.0;
|
|
463
471
|
}
|
|
464
472
|
return 1;
|
|
465
473
|
}
|
|
466
474
|
|
|
467
|
-
|
|
468
|
-
|
|
475
|
+
/**
|
|
476
|
+
* @param {number} fromUnit
|
|
477
|
+
* @param {number} toUnit
|
|
478
|
+
* @param {number} fromValue
|
|
479
|
+
*/
|
|
480
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
469
481
|
return fromValue * Distance.getUnitRatio(fromUnit) / Distance.getUnitRatio(toUnit);
|
|
470
482
|
}
|
|
471
483
|
}
|
|
472
484
|
|
|
473
|
-
export class ElectricCurrent
|
|
474
|
-
{
|
|
485
|
+
export class ElectricCurrent {
|
|
475
486
|
static Unit = {
|
|
476
487
|
AMPERE: 1,
|
|
477
488
|
MILLIAMPERE: 2,
|
|
478
489
|
MICROAMPERE: 3
|
|
479
490
|
};
|
|
480
491
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
492
|
+
/**
|
|
493
|
+
* @param {number} u
|
|
494
|
+
*/
|
|
495
|
+
static getUnitInfo(u) {
|
|
496
|
+
switch (u) {
|
|
497
|
+
case ElectricCurrent.Unit.AMPERE:
|
|
498
|
+
return new UnitInfo(u, "A", "Ampere", 1);
|
|
499
|
+
case ElectricCurrent.Unit.MILLIAMPERE:
|
|
500
|
+
return new UnitInfo(u, "mA", "Milliampere", 0.001);
|
|
501
|
+
case ElectricCurrent.Unit.MICROAMPERE:
|
|
502
|
+
return new UnitInfo(u, "μA", "Microampere", 0.000001);
|
|
491
503
|
}
|
|
492
504
|
return null;
|
|
493
505
|
}
|
|
494
506
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
507
|
+
/**
|
|
508
|
+
* @param {number} u
|
|
509
|
+
*/
|
|
510
|
+
static getUnitRatio(u) {
|
|
511
|
+
switch (u) {
|
|
512
|
+
case ElectricCurrent.Unit.AMPERE:
|
|
513
|
+
return 1;
|
|
514
|
+
case ElectricCurrent.Unit.MILLIAMPERE:
|
|
515
|
+
return 0.001;
|
|
516
|
+
case ElectricCurrent.Unit.MICROAMPERE:
|
|
517
|
+
return 0.000001;
|
|
505
518
|
}
|
|
506
519
|
return 1;
|
|
507
520
|
}
|
|
508
521
|
|
|
509
|
-
|
|
510
|
-
|
|
522
|
+
/**
|
|
523
|
+
* @param {number} fromUnit
|
|
524
|
+
* @param {number} toUnit
|
|
525
|
+
* @param {number} fromValue
|
|
526
|
+
*/
|
|
527
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
511
528
|
return fromValue * ElectricCurrent.getUnitRatio(fromUnit) / ElectricCurrent.getUnitRatio(toUnit);
|
|
512
529
|
}
|
|
513
530
|
}
|
|
514
531
|
|
|
515
|
-
export class ElectricPotential
|
|
516
|
-
{
|
|
532
|
+
export class ElectricPotential {
|
|
517
533
|
static Unit = {
|
|
518
534
|
VOLT: 1,
|
|
519
535
|
MILLIVOLT: 2
|
|
520
536
|
};
|
|
521
537
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
538
|
+
/**
|
|
539
|
+
* @param {number} u
|
|
540
|
+
*/
|
|
541
|
+
static getUnitInfo(u) {
|
|
542
|
+
switch (u) {
|
|
543
|
+
case ElectricPotential.Unit.VOLT:
|
|
544
|
+
return new UnitInfo(u, "V", "Volt", 1);
|
|
545
|
+
case ElectricPotential.Unit.MILLIVOLT:
|
|
546
|
+
return new UnitInfo(u, "mV", "Millivolt", 0.001);
|
|
530
547
|
}
|
|
531
548
|
return null;
|
|
532
549
|
}
|
|
533
550
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
551
|
+
/**
|
|
552
|
+
* @param {number} u
|
|
553
|
+
*/
|
|
554
|
+
static getUnitRatio(u) {
|
|
555
|
+
switch (u) {
|
|
556
|
+
case ElectricPotential.Unit.VOLT:
|
|
557
|
+
return 1;
|
|
558
|
+
case ElectricPotential.Unit.MILLIVOLT:
|
|
559
|
+
return 0.001;
|
|
542
560
|
}
|
|
543
561
|
return 1;
|
|
544
562
|
}
|
|
545
563
|
|
|
546
|
-
|
|
547
|
-
|
|
564
|
+
/**
|
|
565
|
+
* @param {number} fromUnit
|
|
566
|
+
* @param {number} toUnit
|
|
567
|
+
* @param {number} fromValue
|
|
568
|
+
*/
|
|
569
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
548
570
|
return fromValue * ElectricPotential.getUnitRatio(fromUnit) / ElectricPotential.getUnitRatio(toUnit);
|
|
549
571
|
}
|
|
550
572
|
}
|
|
551
573
|
|
|
552
|
-
export class Energy
|
|
553
|
-
{
|
|
574
|
+
export class Energy {
|
|
554
575
|
static Unit = {
|
|
555
576
|
JOULE: 1,
|
|
556
577
|
WATTHOUR: 2,
|
|
@@ -559,119 +580,134 @@ export class Energy
|
|
|
559
580
|
KILOCALORIE: 5
|
|
560
581
|
};
|
|
561
582
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
583
|
+
/**
|
|
584
|
+
* @param {number} u
|
|
585
|
+
*/
|
|
586
|
+
static getUnitInfo(u) {
|
|
587
|
+
switch (u) {
|
|
588
|
+
case Energy.Unit.JOULE:
|
|
589
|
+
return new UnitInfo(u, "J", "Joule", 1);
|
|
590
|
+
case Energy.Unit.WATTHOUR:
|
|
591
|
+
return new UnitInfo(u, "Wh", "Watt-hour", 3600.0);
|
|
592
|
+
case Energy.Unit.KILOWATTHOUR:
|
|
593
|
+
return new UnitInfo(u, "kWh", "Kilowatt-hour", 3600000.0);
|
|
594
|
+
case Energy.Unit.CALORIE:
|
|
595
|
+
return new UnitInfo(u, "cal", "Gram calorie", 4.184);
|
|
596
|
+
case Energy.Unit.KILOCALORIE:
|
|
597
|
+
return new UnitInfo(u, "kcal", "Kilocalorie", 4184);
|
|
576
598
|
}
|
|
577
599
|
return null;
|
|
578
600
|
}
|
|
579
601
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
602
|
+
/**
|
|
603
|
+
* @param {number} u
|
|
604
|
+
*/
|
|
605
|
+
static getUnitRatio(u) {
|
|
606
|
+
switch (u) {
|
|
607
|
+
case Energy.Unit.JOULE:
|
|
608
|
+
return 1;
|
|
609
|
+
case Energy.Unit.WATTHOUR:
|
|
610
|
+
return 3600.0;
|
|
611
|
+
case Energy.Unit.KILOWATTHOUR:
|
|
612
|
+
return 3600000.0;
|
|
613
|
+
case Energy.Unit.CALORIE:
|
|
614
|
+
return 4.184;
|
|
615
|
+
case Energy.Unit.KILOCALORIE:
|
|
616
|
+
return 4184;
|
|
594
617
|
}
|
|
595
618
|
return 1;
|
|
596
619
|
}
|
|
597
620
|
|
|
598
|
-
|
|
599
|
-
|
|
621
|
+
/**
|
|
622
|
+
* @param {number} fromUnit
|
|
623
|
+
* @param {number} toUnit
|
|
624
|
+
* @param {number} fromValue
|
|
625
|
+
*/
|
|
626
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
600
627
|
return fromValue * Energy.getUnitRatio(fromUnit) / Energy.getUnitRatio(toUnit);
|
|
601
628
|
}
|
|
602
629
|
}
|
|
603
630
|
|
|
604
|
-
export class Force
|
|
605
|
-
{
|
|
631
|
+
export class Force {
|
|
606
632
|
static Unit = {
|
|
607
633
|
NEWTON: 1
|
|
608
634
|
};
|
|
609
635
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
636
|
+
/**
|
|
637
|
+
* @param {number} u
|
|
638
|
+
*/
|
|
639
|
+
static getUnitInfo(u) {
|
|
640
|
+
switch (u) {
|
|
641
|
+
case Force.Unit.NEWTON:
|
|
642
|
+
return new UnitInfo(u, "N", "Newton", 1);
|
|
616
643
|
}
|
|
617
644
|
return null;
|
|
618
645
|
}
|
|
619
646
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
647
|
+
/**
|
|
648
|
+
* @param {number} u
|
|
649
|
+
*/
|
|
650
|
+
static getUnitRatio(u) {
|
|
651
|
+
switch (u) {
|
|
652
|
+
case Force.Unit.NEWTON:
|
|
653
|
+
return 1;
|
|
626
654
|
}
|
|
627
655
|
return 1;
|
|
628
656
|
}
|
|
629
657
|
|
|
630
|
-
|
|
631
|
-
|
|
658
|
+
/**
|
|
659
|
+
* @param {number} fromUnit
|
|
660
|
+
* @param {number} toUnit
|
|
661
|
+
* @param {number} fromValue
|
|
662
|
+
*/
|
|
663
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
632
664
|
return fromValue * Force.getUnitRatio(fromUnit) / Force.getUnitRatio(toUnit);
|
|
633
665
|
}
|
|
634
666
|
}
|
|
635
667
|
|
|
636
|
-
export class Frequency
|
|
637
|
-
{
|
|
668
|
+
export class Frequency {
|
|
638
669
|
static Unit = {
|
|
639
670
|
HERTZ: 1,
|
|
640
671
|
KILOHERTZ: 2
|
|
641
672
|
};
|
|
642
673
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
674
|
+
/**
|
|
675
|
+
* @param {number} u
|
|
676
|
+
*/
|
|
677
|
+
static getUnitInfo(u) {
|
|
678
|
+
switch (u) {
|
|
679
|
+
case Frequency.Unit.HERTZ:
|
|
680
|
+
return new UnitInfo(u, "Hz", "Hertz", 1);
|
|
681
|
+
case Frequency.Unit.KILOHERTZ:
|
|
682
|
+
return new UnitInfo(u, "kHz", "Kilohertz", 1000);
|
|
651
683
|
}
|
|
652
684
|
return null;
|
|
653
685
|
}
|
|
654
686
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
687
|
+
/**
|
|
688
|
+
* @param {number} u
|
|
689
|
+
*/
|
|
690
|
+
static getUnitRatio(u) {
|
|
691
|
+
switch (u) {
|
|
692
|
+
case Frequency.Unit.HERTZ:
|
|
693
|
+
return 1;
|
|
694
|
+
case Frequency.Unit.KILOHERTZ:
|
|
695
|
+
return 1000;
|
|
663
696
|
}
|
|
664
697
|
return 1;
|
|
665
698
|
}
|
|
666
699
|
|
|
667
|
-
|
|
668
|
-
|
|
700
|
+
/**
|
|
701
|
+
* @param {number} fromUnit
|
|
702
|
+
* @param {number} toUnit
|
|
703
|
+
* @param {number} fromValue
|
|
704
|
+
*/
|
|
705
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
669
706
|
return fromValue * Frequency.getUnitRatio(fromUnit) / Frequency.getUnitRatio(toUnit);
|
|
670
707
|
}
|
|
671
708
|
}
|
|
672
709
|
|
|
673
|
-
export class MagneticField
|
|
674
|
-
{
|
|
710
|
+
export class MagneticField {
|
|
675
711
|
static Unit = {
|
|
676
712
|
TESLA: 1,
|
|
677
713
|
GAUSS: 2,
|
|
@@ -679,46 +715,51 @@ export class MagneticField
|
|
|
679
715
|
MILLITESLA: 4
|
|
680
716
|
};
|
|
681
717
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
718
|
+
/**
|
|
719
|
+
* @param {number} u
|
|
720
|
+
*/
|
|
721
|
+
static getUnitInfo(u) {
|
|
722
|
+
switch (u) {
|
|
723
|
+
case MagneticField.Unit.TESLA:
|
|
724
|
+
return new UnitInfo(u, "T", "Tesla", 1);
|
|
725
|
+
case MagneticField.Unit.GAUSS:
|
|
726
|
+
return new UnitInfo(u, "G", "Gauss", 0.0001);
|
|
727
|
+
case MagneticField.Unit.MICROTESLA:
|
|
728
|
+
return new UnitInfo(u, "uT", "Micro Tesla", 0.000001);
|
|
729
|
+
case MagneticField.Unit.MILLITESLA:
|
|
730
|
+
return new UnitInfo(u, "mT", "Milli Tesla", 0.001);
|
|
694
731
|
}
|
|
695
732
|
return null;
|
|
696
733
|
}
|
|
697
734
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
735
|
+
/**
|
|
736
|
+
* @param {number} u
|
|
737
|
+
*/
|
|
738
|
+
static getUnitRatio(u) {
|
|
739
|
+
switch (u) {
|
|
740
|
+
case MagneticField.Unit.TESLA:
|
|
741
|
+
return 1;
|
|
742
|
+
case MagneticField.Unit.GAUSS:
|
|
743
|
+
return 0.0001;
|
|
744
|
+
case MagneticField.Unit.MICROTESLA:
|
|
745
|
+
return 0.000001;
|
|
746
|
+
case MagneticField.Unit.MILLITESLA:
|
|
747
|
+
return 0.001;
|
|
710
748
|
}
|
|
711
749
|
return 1;
|
|
712
750
|
}
|
|
713
751
|
|
|
714
|
-
|
|
715
|
-
|
|
752
|
+
/**
|
|
753
|
+
* @param {number} fromUnit
|
|
754
|
+
* @param {number} toUnit
|
|
755
|
+
* @param {number} fromValue
|
|
756
|
+
*/
|
|
757
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
716
758
|
return fromValue * MagneticField.getUnitRatio(fromUnit) / MagneticField.getUnitRatio(toUnit);
|
|
717
759
|
}
|
|
718
760
|
}
|
|
719
761
|
|
|
720
|
-
export class Mass
|
|
721
|
-
{
|
|
762
|
+
export class Mass {
|
|
722
763
|
static Unit = {
|
|
723
764
|
KILOGRAM: 1,
|
|
724
765
|
GRAM: 2,
|
|
@@ -727,92 +768,102 @@ export class Mass
|
|
|
727
768
|
OZ: 5
|
|
728
769
|
};
|
|
729
770
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
771
|
+
/**
|
|
772
|
+
* @param {number} u
|
|
773
|
+
*/
|
|
774
|
+
static getUnitInfo(u) {
|
|
775
|
+
switch (u) {
|
|
776
|
+
case Mass.Unit.KILOGRAM:
|
|
777
|
+
return new UnitInfo(u, "kg", "Kilogram", 1.0);
|
|
778
|
+
case Mass.Unit.GRAM:
|
|
779
|
+
return new UnitInfo(u, "g", "Gram", 0.001);
|
|
780
|
+
case Mass.Unit.TONNE:
|
|
781
|
+
return new UnitInfo(u, "t", "Tonne", 1000.0);
|
|
782
|
+
case Mass.Unit.POUND:
|
|
783
|
+
return new UnitInfo(u, "lb", "Pounds", 0.45359237);
|
|
784
|
+
case Mass.Unit.OZ:
|
|
785
|
+
return new UnitInfo(u, "oz", "Ounce", 0.45359237 / 16);
|
|
744
786
|
}
|
|
745
787
|
return null;
|
|
746
788
|
}
|
|
747
789
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
790
|
+
/**
|
|
791
|
+
* @param {number} u
|
|
792
|
+
*/
|
|
793
|
+
static getUnitRatio(u) {
|
|
794
|
+
switch (u) {
|
|
795
|
+
case Mass.Unit.KILOGRAM:
|
|
796
|
+
return 1.0;
|
|
797
|
+
case Mass.Unit.GRAM:
|
|
798
|
+
return 0.001;
|
|
799
|
+
case Mass.Unit.TONNE:
|
|
800
|
+
return 1000.0;
|
|
801
|
+
case Mass.Unit.POUND:
|
|
802
|
+
return 0.45359237;
|
|
803
|
+
case Mass.Unit.OZ:
|
|
804
|
+
return 0.45359237 / 16;
|
|
762
805
|
}
|
|
763
806
|
return 1;
|
|
764
807
|
}
|
|
765
808
|
|
|
766
|
-
|
|
767
|
-
|
|
809
|
+
/**
|
|
810
|
+
* @param {number} fromUnit
|
|
811
|
+
* @param {number} toUnit
|
|
812
|
+
* @param {number} fromValue
|
|
813
|
+
*/
|
|
814
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
768
815
|
return fromValue * Mass.getUnitRatio(fromUnit) / Mass.getUnitRatio(toUnit);
|
|
769
816
|
}
|
|
770
817
|
}
|
|
771
818
|
|
|
772
|
-
export class Power
|
|
773
|
-
{
|
|
819
|
+
export class Power {
|
|
774
820
|
static Unit = {
|
|
775
821
|
WATT: 1,
|
|
776
822
|
MILLIWATT: 2,
|
|
777
823
|
KILOWATT: 3
|
|
778
824
|
};
|
|
779
825
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
826
|
+
/**
|
|
827
|
+
* @param {number} u
|
|
828
|
+
*/
|
|
829
|
+
static getUnitInfo(u) {
|
|
830
|
+
switch (u) {
|
|
831
|
+
case Power.Unit.WATT:
|
|
832
|
+
return new UnitInfo(u, "W", "Watt", 1.0);
|
|
833
|
+
case Power.Unit.MILLIWATT:
|
|
834
|
+
return new UnitInfo(u, "mW", "Milliwatt", 0.001);
|
|
835
|
+
case Power.Unit.KILOWATT:
|
|
836
|
+
return new UnitInfo(u, "kW", "Kilowatt", 1000.0);
|
|
790
837
|
}
|
|
791
838
|
return null;
|
|
792
839
|
}
|
|
793
840
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
841
|
+
/**
|
|
842
|
+
* @param {number} u
|
|
843
|
+
*/
|
|
844
|
+
static getUnitRatio(u) {
|
|
845
|
+
switch (u) {
|
|
846
|
+
case Power.Unit.WATT:
|
|
847
|
+
return 1.0;
|
|
848
|
+
case Power.Unit.MILLIWATT:
|
|
849
|
+
return 0.001;
|
|
850
|
+
case Power.Unit.KILOWATT:
|
|
851
|
+
return 1000.0;
|
|
804
852
|
}
|
|
805
853
|
return 1;
|
|
806
854
|
}
|
|
807
855
|
|
|
808
|
-
|
|
809
|
-
|
|
856
|
+
/**
|
|
857
|
+
* @param {number} fromUnit
|
|
858
|
+
* @param {number} toUnit
|
|
859
|
+
* @param {number} fromValue
|
|
860
|
+
*/
|
|
861
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
810
862
|
return fromValue * Power.getUnitRatio(fromUnit) / Power.getUnitRatio(toUnit);
|
|
811
863
|
}
|
|
812
864
|
}
|
|
813
865
|
|
|
814
|
-
export class Pressure
|
|
815
|
-
{
|
|
866
|
+
export class Pressure {
|
|
816
867
|
static Unit = {
|
|
817
868
|
PASCAL: 1,
|
|
818
869
|
BAR: 2,
|
|
@@ -823,159 +874,179 @@ export class Pressure
|
|
|
823
874
|
HPASCAL: 7
|
|
824
875
|
};
|
|
825
876
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
877
|
+
/**
|
|
878
|
+
* @param {number} u
|
|
879
|
+
*/
|
|
880
|
+
static getUnitInfo(u) {
|
|
881
|
+
switch (u) {
|
|
882
|
+
case Pressure.Unit.PASCAL:
|
|
883
|
+
return new UnitInfo(u, "Pa", "Pascal", 1.0);
|
|
884
|
+
case Pressure.Unit.BAR:
|
|
885
|
+
return new UnitInfo(u, "bar", "Bar", 100000.0);
|
|
886
|
+
case Pressure.Unit.ATM:
|
|
887
|
+
return new UnitInfo(u, "atm", "Standard atmosphere", 101325.0);
|
|
888
|
+
case Pressure.Unit.TORR:
|
|
889
|
+
return new UnitInfo(u, "Torr", "Torr", 101325.0 / 760.0);
|
|
890
|
+
case Pressure.Unit.PSI:
|
|
891
|
+
return new UnitInfo(u, "psi", "Pounds per square inch", 4.4482216152605 / 0.0254 / 0.0254);
|
|
892
|
+
case Pressure.Unit.KPASCAL:
|
|
893
|
+
return new UnitInfo(u, "kPa", "Kilo Pascal", 1000.0);
|
|
894
|
+
case Pressure.Unit.HPASCAL:
|
|
895
|
+
return new UnitInfo(u, "hPa", "Hecto Pascal", 100.0);
|
|
844
896
|
}
|
|
845
897
|
return null;
|
|
846
898
|
}
|
|
847
899
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
900
|
+
/**
|
|
901
|
+
* @param {number} u
|
|
902
|
+
*/
|
|
903
|
+
static getUnitRatio(u) {
|
|
904
|
+
switch (u) {
|
|
905
|
+
case Pressure.Unit.PASCAL:
|
|
906
|
+
return 1.0;
|
|
907
|
+
case Pressure.Unit.BAR:
|
|
908
|
+
return 100000.0;
|
|
909
|
+
case Pressure.Unit.ATM:
|
|
910
|
+
return 101325.0;
|
|
911
|
+
case Pressure.Unit.TORR:
|
|
912
|
+
return 101325.0 / 760.0;
|
|
913
|
+
case Pressure.Unit.PSI:
|
|
914
|
+
return 4.4482216152605 / 0.0254 / 0.0254;
|
|
915
|
+
case Pressure.Unit.KPASCAL:
|
|
916
|
+
return 1000.0;
|
|
917
|
+
case Pressure.Unit.HPASCAL:
|
|
918
|
+
return 100.0;
|
|
866
919
|
}
|
|
867
920
|
return 1;
|
|
868
921
|
}
|
|
869
922
|
|
|
870
|
-
|
|
871
|
-
|
|
923
|
+
/**
|
|
924
|
+
* @param {number} fromUnit
|
|
925
|
+
* @param {number} toUnit
|
|
926
|
+
* @param {number} fromValue
|
|
927
|
+
*/
|
|
928
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
872
929
|
return fromValue * Pressure.getUnitRatio(fromUnit) / Pressure.getUnitRatio(toUnit);
|
|
873
930
|
}
|
|
874
931
|
}
|
|
875
932
|
|
|
876
|
-
export class Ratio
|
|
877
|
-
{
|
|
933
|
+
export class Ratio {
|
|
878
934
|
static Unit = {
|
|
879
935
|
RATIO: 1,
|
|
880
936
|
PERCENT: 2
|
|
881
937
|
};
|
|
882
938
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
939
|
+
/**
|
|
940
|
+
* @param {number} u
|
|
941
|
+
*/
|
|
942
|
+
static getUnitInfo(u) {
|
|
943
|
+
switch (u) {
|
|
944
|
+
case Ratio.Unit.RATIO:
|
|
945
|
+
return new UnitInfo(u, "", "Ratio", 1.0);
|
|
946
|
+
case Ratio.Unit.PERCENT:
|
|
947
|
+
return new UnitInfo(u, "%", "Percent", 0.01);
|
|
891
948
|
}
|
|
892
949
|
return null;
|
|
893
950
|
}
|
|
894
951
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
952
|
+
/**
|
|
953
|
+
* @param {number} u
|
|
954
|
+
*/
|
|
955
|
+
static getUnitRatio(u) {
|
|
956
|
+
switch (u) {
|
|
957
|
+
case Ratio.Unit.RATIO:
|
|
958
|
+
return 1.0;
|
|
959
|
+
case Ratio.Unit.PERCENT:
|
|
960
|
+
return 0.01;
|
|
903
961
|
}
|
|
904
962
|
return 1;
|
|
905
963
|
}
|
|
906
964
|
|
|
907
|
-
|
|
908
|
-
|
|
965
|
+
/**
|
|
966
|
+
* @param {number} fromUnit
|
|
967
|
+
* @param {number} toUnit
|
|
968
|
+
* @param {number} fromValue
|
|
969
|
+
*/
|
|
970
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
909
971
|
return fromValue * Ratio.getUnitRatio(fromUnit) / Ratio.getUnitRatio(toUnit);
|
|
910
972
|
}
|
|
911
973
|
}
|
|
912
974
|
|
|
913
|
-
export class ReactiveEnergy
|
|
914
|
-
{
|
|
975
|
+
export class ReactiveEnergy {
|
|
915
976
|
static Unit = {
|
|
916
977
|
KVARH: 1
|
|
917
978
|
};
|
|
918
979
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
980
|
+
/**
|
|
981
|
+
* @param {number} u
|
|
982
|
+
*/
|
|
983
|
+
static getUnitInfo(u) {
|
|
984
|
+
switch (u) {
|
|
985
|
+
case ReactiveEnergy.Unit.KVARH:
|
|
986
|
+
return new UnitInfo(u, "kvarh", "Kilovolt-amperer hour", 1.0);
|
|
925
987
|
}
|
|
926
988
|
return null;
|
|
927
989
|
}
|
|
928
990
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
991
|
+
/**
|
|
992
|
+
* @param {number} u
|
|
993
|
+
*/
|
|
994
|
+
static getUnitRatio(u) {
|
|
995
|
+
switch (u) {
|
|
996
|
+
case ReactiveEnergy.Unit.KVARH:
|
|
997
|
+
return 1.0;
|
|
935
998
|
}
|
|
936
999
|
return 1;
|
|
937
1000
|
}
|
|
938
1001
|
|
|
939
|
-
|
|
940
|
-
|
|
1002
|
+
/**
|
|
1003
|
+
* @param {number} fromUnit
|
|
1004
|
+
* @param {number} toUnit
|
|
1005
|
+
* @param {number} fromValue
|
|
1006
|
+
*/
|
|
1007
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
941
1008
|
return fromValue * ReactiveEnergy.getUnitRatio(fromUnit) / ReactiveEnergy.getUnitRatio(toUnit);
|
|
942
1009
|
}
|
|
943
1010
|
}
|
|
944
1011
|
|
|
945
|
-
export class ReactivePower
|
|
946
|
-
{
|
|
1012
|
+
export class ReactivePower {
|
|
947
1013
|
static Unit = {
|
|
948
1014
|
VAR: 1
|
|
949
1015
|
};
|
|
950
1016
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1017
|
+
/**
|
|
1018
|
+
* @param {number} u
|
|
1019
|
+
*/
|
|
1020
|
+
static getUnitInfo(u) {
|
|
1021
|
+
switch (u) {
|
|
1022
|
+
case ReactivePower.Unit.VAR:
|
|
1023
|
+
return new UnitInfo(u, "", "Ratio", 1.0);
|
|
957
1024
|
}
|
|
958
1025
|
return null;
|
|
959
1026
|
}
|
|
960
1027
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1028
|
+
/**
|
|
1029
|
+
* @param {number} u
|
|
1030
|
+
*/
|
|
1031
|
+
static getUnitRatio(u) {
|
|
1032
|
+
switch (u) {
|
|
1033
|
+
case ReactivePower.Unit.VAR:
|
|
1034
|
+
return 1.0;
|
|
967
1035
|
}
|
|
968
1036
|
return 1;
|
|
969
1037
|
}
|
|
970
1038
|
|
|
971
|
-
|
|
972
|
-
|
|
1039
|
+
/**
|
|
1040
|
+
* @param {number} fromUnit
|
|
1041
|
+
* @param {number} toUnit
|
|
1042
|
+
* @param {number} fromValue
|
|
1043
|
+
*/
|
|
1044
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
973
1045
|
return fromValue * ReactivePower.getUnitRatio(fromUnit) / ReactivePower.getUnitRatio(toUnit);
|
|
974
1046
|
}
|
|
975
1047
|
}
|
|
976
1048
|
|
|
977
|
-
export class Speed
|
|
978
|
-
{
|
|
1049
|
+
export class Speed {
|
|
979
1050
|
static Unit = {
|
|
980
1051
|
METER_PER_SECOND: 1,
|
|
981
1052
|
KM_PER_HOUR: 2,
|
|
@@ -983,102 +1054,114 @@ export class Speed
|
|
|
983
1054
|
KNOT: 4
|
|
984
1055
|
};
|
|
985
1056
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1057
|
+
/**
|
|
1058
|
+
* @param {number} u
|
|
1059
|
+
*/
|
|
1060
|
+
static getUnitInfo(u) {
|
|
1061
|
+
switch (u) {
|
|
1062
|
+
case Speed.Unit.METER_PER_SECOND:
|
|
1063
|
+
return new UnitInfo(u, "m/s", "Meter per second", 1.0);
|
|
1064
|
+
case Speed.Unit.KM_PER_HOUR:
|
|
1065
|
+
return new UnitInfo(u, "km/h", "Kilometer per hour", 1000 / 3600.0);
|
|
1066
|
+
case Speed.Unit.MILE_PER_HOUR:
|
|
1067
|
+
return new UnitInfo(u, "mph", "Mile per hour", Distance.getUnitRatio(Distance.Unit.MILE) / 3600.0);
|
|
1068
|
+
case Speed.Unit.KNOT:
|
|
1069
|
+
return new UnitInfo(u, "knot", "Knot", Distance.getUnitRatio(Distance.Unit.NAUTICAL_MILE) / 3600.0);
|
|
998
1070
|
}
|
|
999
1071
|
return null;
|
|
1000
1072
|
}
|
|
1001
1073
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1074
|
+
/**
|
|
1075
|
+
* @param {number} u
|
|
1076
|
+
*/
|
|
1077
|
+
static getUnitRatio(u) {
|
|
1078
|
+
switch (u) {
|
|
1079
|
+
case Speed.Unit.METER_PER_SECOND:
|
|
1080
|
+
return 1.0;
|
|
1081
|
+
case Speed.Unit.KM_PER_HOUR:
|
|
1082
|
+
return 1000 / 3600.0;
|
|
1083
|
+
case Speed.Unit.MILE_PER_HOUR:
|
|
1084
|
+
return Distance.getUnitRatio(Distance.Unit.MILE) / 3600.0;
|
|
1085
|
+
case Speed.Unit.KNOT:
|
|
1086
|
+
return Distance.getUnitRatio(Distance.Unit.NAUTICAL_MILE) / 3600.0;
|
|
1014
1087
|
}
|
|
1015
1088
|
return 1;
|
|
1016
1089
|
}
|
|
1017
1090
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1091
|
+
/**
|
|
1092
|
+
* @param {number} fromUnit
|
|
1093
|
+
* @param {number} toUnit
|
|
1094
|
+
* @param {number} fromValue
|
|
1095
|
+
*/
|
|
1096
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
1020
1097
|
return fromValue * Speed.getUnitRatio(fromUnit) / Speed.getUnitRatio(toUnit);
|
|
1021
1098
|
}
|
|
1022
1099
|
}
|
|
1023
1100
|
|
|
1024
|
-
export class Temperature
|
|
1025
|
-
{
|
|
1101
|
+
export class Temperature {
|
|
1026
1102
|
static Unit = {
|
|
1027
1103
|
CELSIUS: 1,
|
|
1028
1104
|
KELVIN: 2,
|
|
1029
1105
|
FAHRENHEIT: 3
|
|
1030
1106
|
};
|
|
1031
1107
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1108
|
+
/**
|
|
1109
|
+
* @param {number} u
|
|
1110
|
+
*/
|
|
1111
|
+
static getUnitInfo(u) {
|
|
1112
|
+
switch (u) {
|
|
1113
|
+
case Temperature.Unit.CELSIUS:
|
|
1114
|
+
return new UnitInfo(u, "℃", "Degree Celsius", 1.0, -273.15);
|
|
1115
|
+
case Temperature.Unit.KELVIN:
|
|
1116
|
+
return new UnitInfo(u, "K", "Kelvin", 1.0, 0.0);
|
|
1117
|
+
case Temperature.Unit.FAHRENHEIT:
|
|
1118
|
+
return new UnitInfo(u, "℉", "Degree Fahrenheit", 5 / 9, -459.67);
|
|
1042
1119
|
}
|
|
1043
1120
|
return null;
|
|
1044
1121
|
}
|
|
1045
1122
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1123
|
+
/**
|
|
1124
|
+
* @param {number} u
|
|
1125
|
+
*/
|
|
1126
|
+
static getUnitRatio(u) {
|
|
1127
|
+
switch (u) {
|
|
1128
|
+
case Temperature.Unit.CELSIUS:
|
|
1129
|
+
return 1.0;
|
|
1130
|
+
case Temperature.Unit.KELVIN:
|
|
1131
|
+
return 1.0;
|
|
1132
|
+
case Temperature.Unit.FAHRENHEIT:
|
|
1133
|
+
return 5 / 9;
|
|
1056
1134
|
}
|
|
1057
1135
|
return 1;
|
|
1058
1136
|
}
|
|
1059
1137
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1138
|
+
/**
|
|
1139
|
+
* @param {number} u
|
|
1140
|
+
*/
|
|
1141
|
+
static getUnitScale(u) {
|
|
1142
|
+
switch (u) {
|
|
1143
|
+
case Temperature.Unit.CELSIUS:
|
|
1144
|
+
return -273.15;
|
|
1145
|
+
case Temperature.Unit.KELVIN:
|
|
1146
|
+
return 0.0;
|
|
1147
|
+
case Temperature.Unit.FAHRENHEIT:
|
|
1148
|
+
return -459.67;
|
|
1070
1149
|
}
|
|
1071
1150
|
return null;
|
|
1072
1151
|
}
|
|
1073
1152
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1153
|
+
/**
|
|
1154
|
+
* @param {number} fromUnit
|
|
1155
|
+
* @param {number} toUnit
|
|
1156
|
+
* @param {number} fromValue
|
|
1157
|
+
*/
|
|
1158
|
+
static convert(fromUnit, toUnit, fromValue) {
|
|
1159
|
+
// @ts-ignore
|
|
1076
1160
|
return (fromValue * Temperature.getUnitRatio(fromUnit) - Temperature.getUnitScale(fromUnit)) / Temperature.getUnitRatio(toUnit) + Temperature.getUnitScale(toUnit);
|
|
1077
1161
|
}
|
|
1078
1162
|
}
|
|
1079
1163
|
|
|
1080
|
-
export function getList()
|
|
1081
|
-
{
|
|
1164
|
+
export function getList() {
|
|
1082
1165
|
return [
|
|
1083
1166
|
Acceleration,
|
|
1084
1167
|
Angle,
|