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