@aguacerowx/javascript-sdk 0.0.9 → 0.0.11
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/package.json +48 -48
- package/src/AguaceroCore.js +879 -854
- package/src/coordinate_configs.js +374 -374
- package/src/default-colormaps.js +2972 -2912
- package/src/dictionaries.js +4286 -4267
- package/src/events.js +31 -31
- package/src/fill-layer-worker.js +26 -26
- package/src/getBundleId.js +21 -21
- package/src/index.js +16 -16
- package/src/map-styles.js +101 -101
- package/src/unitConversions.js +102 -102
- package/dist/AguaceroCore.js +0 -998
- package/dist/coordinate_configs.js +0 -380
- package/dist/default-colormaps.js +0 -1228
- package/dist/dictionaries.js +0 -4022
- package/dist/events.js +0 -37
- package/dist/fill-layer-worker.js +0 -29
- package/dist/getBundleId.js +0 -26
- package/dist/index.js +0 -46
- package/dist/map-styles.js +0 -300
- package/dist/unitConversions.js +0 -125
package/src/events.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
// aguacero-api/src/events.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A simple class for emitting and listening to events.
|
|
5
|
-
*/
|
|
6
|
-
export class EventEmitter {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.callbacks = {};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
on(event, cb) {
|
|
12
|
-
if (!this.callbacks[event]) this.callbacks[event] = [];
|
|
13
|
-
this.callbacks[event].push(cb);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// --- THIS IS THE MISSING PIECE ---
|
|
17
|
-
// Add this method to allow listeners to be removed.
|
|
18
|
-
off(event, cb) {
|
|
19
|
-
const cbs = this.callbacks[event];
|
|
20
|
-
if (cbs) {
|
|
21
|
-
// Create a new array that excludes the callback we want to remove
|
|
22
|
-
this.callbacks[event] = cbs.filter(callback => callback !== cb);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
emit(event, data) {
|
|
27
|
-
const cbs = this.callbacks[event];
|
|
28
|
-
if (cbs) {
|
|
29
|
-
cbs.forEach(cb => cb(data));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
// aguacero-api/src/events.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simple class for emitting and listening to events.
|
|
5
|
+
*/
|
|
6
|
+
export class EventEmitter {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.callbacks = {};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
on(event, cb) {
|
|
12
|
+
if (!this.callbacks[event]) this.callbacks[event] = [];
|
|
13
|
+
this.callbacks[event].push(cb);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// --- THIS IS THE MISSING PIECE ---
|
|
17
|
+
// Add this method to allow listeners to be removed.
|
|
18
|
+
off(event, cb) {
|
|
19
|
+
const cbs = this.callbacks[event];
|
|
20
|
+
if (cbs) {
|
|
21
|
+
// Create a new array that excludes the callback we want to remove
|
|
22
|
+
this.callbacks[event] = cbs.filter(callback => callback !== cb);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
emit(event, data) {
|
|
27
|
+
const cbs = this.callbacks[event];
|
|
28
|
+
if (cbs) {
|
|
29
|
+
cbs.forEach(cb => cb(data));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
32
|
}
|
package/src/fill-layer-worker.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// aguaceroAPI/src/fill-layer-worker.js
|
|
2
|
-
|
|
3
|
-
import { decompress } from 'fzstd';
|
|
4
|
-
|
|
5
|
-
// Listen for messages from the main thread
|
|
6
|
-
self.onmessage = async (e) => {
|
|
7
|
-
const { compressedData, encoding } = e.data;
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
// Perform the heavy decompression work
|
|
11
|
-
const decompressedData = decompress(compressedData);
|
|
12
|
-
|
|
13
|
-
// Send the successful result back to the main thread
|
|
14
|
-
self.postMessage({
|
|
15
|
-
success: true,
|
|
16
|
-
decompressedData,
|
|
17
|
-
encoding
|
|
18
|
-
}, [decompressedData.buffer]); // Transfer the buffer for performance
|
|
19
|
-
|
|
20
|
-
} catch (error) {
|
|
21
|
-
// If something goes wrong, send an error message back
|
|
22
|
-
self.postMessage({
|
|
23
|
-
success: false,
|
|
24
|
-
error: error.message
|
|
25
|
-
});
|
|
26
|
-
}
|
|
1
|
+
// aguaceroAPI/src/fill-layer-worker.js
|
|
2
|
+
|
|
3
|
+
import { decompress } from 'fzstd';
|
|
4
|
+
|
|
5
|
+
// Listen for messages from the main thread
|
|
6
|
+
self.onmessage = async (e) => {
|
|
7
|
+
const { compressedData, encoding } = e.data;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
// Perform the heavy decompression work
|
|
11
|
+
const decompressedData = decompress(compressedData);
|
|
12
|
+
|
|
13
|
+
// Send the successful result back to the main thread
|
|
14
|
+
self.postMessage({
|
|
15
|
+
success: true,
|
|
16
|
+
decompressedData,
|
|
17
|
+
encoding
|
|
18
|
+
}, [decompressedData.buffer]); // Transfer the buffer for performance
|
|
19
|
+
|
|
20
|
+
} catch (error) {
|
|
21
|
+
// If something goes wrong, send an error message back
|
|
22
|
+
self.postMessage({
|
|
23
|
+
success: false,
|
|
24
|
+
error: error.message
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
27
|
};
|
package/src/getBundleId.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// This module acts as a platform-agnostic proxy.
|
|
2
|
-
|
|
3
|
-
let getBundleIdImpl;
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
// This line will ONLY succeed in a React Native environment where the
|
|
7
|
-
// 'react-native-device-info' module is installed.
|
|
8
|
-
const DeviceInfo = require('react-native-device-info');
|
|
9
|
-
|
|
10
|
-
// If the above line doesn't throw an error, we set the implementation
|
|
11
|
-
// to the native version.
|
|
12
|
-
getBundleIdImpl = () => DeviceInfo.getBundleId();
|
|
13
|
-
|
|
14
|
-
} catch (e) {
|
|
15
|
-
// If require() fails, we know we are in a non-React Native environment
|
|
16
|
-
// (like the web). We set the implementation to a "dummy" function
|
|
17
|
-
// that does nothing and returns null.
|
|
18
|
-
getBundleIdImpl = () => null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Export the chosen implementation.
|
|
1
|
+
// This module acts as a platform-agnostic proxy.
|
|
2
|
+
|
|
3
|
+
let getBundleIdImpl;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
// This line will ONLY succeed in a React Native environment where the
|
|
7
|
+
// 'react-native-device-info' module is installed.
|
|
8
|
+
const DeviceInfo = require('react-native-device-info');
|
|
9
|
+
|
|
10
|
+
// If the above line doesn't throw an error, we set the implementation
|
|
11
|
+
// to the native version.
|
|
12
|
+
getBundleIdImpl = () => DeviceInfo.getBundleId();
|
|
13
|
+
|
|
14
|
+
} catch (e) {
|
|
15
|
+
// If require() fails, we know we are in a non-React Native environment
|
|
16
|
+
// (like the web). We set the implementation to a "dummy" function
|
|
17
|
+
// that does nothing and returns null.
|
|
18
|
+
getBundleIdImpl = () => null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Export the chosen implementation.
|
|
22
22
|
export const getBundleId = getBundleIdImpl;
|
package/src/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// In packages/javascript-sdk/src/index.js (The final, correct version)
|
|
2
|
-
|
|
3
|
-
// Import the specific things you want to make public from your package's internal files.
|
|
4
|
-
import { AguaceroCore } from './AguaceroCore.js';
|
|
5
|
-
import { EventEmitter } from './events.js';
|
|
6
|
-
import { THEME_CONFIGS } from './map-styles.js';
|
|
7
|
-
import { DICTIONARIES } from './dictionaries.js';
|
|
8
|
-
import { getUnitConversionFunction } from './unitConversions.js';
|
|
9
|
-
|
|
10
|
-
// Now, export them all so other packages can import them.
|
|
11
|
-
export {
|
|
12
|
-
AguaceroCore,
|
|
13
|
-
EventEmitter,
|
|
14
|
-
THEME_CONFIGS,
|
|
15
|
-
DICTIONARIES,
|
|
16
|
-
getUnitConversionFunction
|
|
1
|
+
// In packages/javascript-sdk/src/index.js (The final, correct version)
|
|
2
|
+
|
|
3
|
+
// Import the specific things you want to make public from your package's internal files.
|
|
4
|
+
import { AguaceroCore } from './AguaceroCore.js';
|
|
5
|
+
import { EventEmitter } from './events.js';
|
|
6
|
+
import { THEME_CONFIGS } from './map-styles.js';
|
|
7
|
+
import { DICTIONARIES } from './dictionaries.js';
|
|
8
|
+
import { getUnitConversionFunction } from './unitConversions.js';
|
|
9
|
+
|
|
10
|
+
// Now, export them all so other packages can import them.
|
|
11
|
+
export {
|
|
12
|
+
AguaceroCore,
|
|
13
|
+
EventEmitter,
|
|
14
|
+
THEME_CONFIGS,
|
|
15
|
+
DICTIONARIES,
|
|
16
|
+
getUnitConversionFunction
|
|
17
17
|
};
|
package/src/map-styles.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
export const defaultLightMapStyles = {
|
|
2
|
-
landOcean: {
|
|
3
|
-
landColor: '#f0f0f0',
|
|
4
|
-
oceanColor: '#a8d8ea',
|
|
5
|
-
waterDepth: {
|
|
6
|
-
visible: true,
|
|
7
|
-
color: '#97c7d9'
|
|
8
|
-
},
|
|
9
|
-
nationalPark: {
|
|
10
|
-
visible: true,
|
|
11
|
-
color: '#d4e6d4',
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
transportation: {
|
|
15
|
-
roads: { visible: true, color: '#d3d3d3', width: 0.7 },
|
|
16
|
-
airports: { visible: true, color: '#d3d3d3', width: 0.7 }
|
|
17
|
-
},
|
|
18
|
-
boundaries: {
|
|
19
|
-
countries: { visible: true, color: '#000000', width: 1.5, lineType: 'solid' },
|
|
20
|
-
states: { visible: true, color: '#000000', width: 1.5, lineType: 'solid' },
|
|
21
|
-
counties: { visible: true, color: '#515151', width: 1.2, lineType: 'solid' }
|
|
22
|
-
},
|
|
23
|
-
waterFeatures: {
|
|
24
|
-
waterways: { visible: true, color: '#a8d8ea', width: 0.7 }
|
|
25
|
-
},
|
|
26
|
-
labels: {
|
|
27
|
-
countries: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 14, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
28
|
-
states: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
29
|
-
cities: {
|
|
30
|
-
major: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
31
|
-
minor: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 }
|
|
32
|
-
},
|
|
33
|
-
airports: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
34
|
-
poi: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
35
|
-
continents: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 16, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1.5 },
|
|
36
|
-
waterLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#0077be', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
37
|
-
naturalLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#2E8B57', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
38
|
-
subdivisionLabels: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 }
|
|
39
|
-
},
|
|
40
|
-
terrain: {
|
|
41
|
-
visible: true,
|
|
42
|
-
intensity: 0.15,
|
|
43
|
-
shadowColor: '#b0b0b0',
|
|
44
|
-
highlightColor: '#ffffff',
|
|
45
|
-
accentColor: '#b0b0b0'
|
|
46
|
-
},
|
|
47
|
-
oceanOnTop: false,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const defaultDarkMapStyles = {
|
|
51
|
-
landOcean: {
|
|
52
|
-
landColor: '#242424',
|
|
53
|
-
oceanColor: '#252525',
|
|
54
|
-
waterDepth: {
|
|
55
|
-
visible: true,
|
|
56
|
-
color: '#000000'
|
|
57
|
-
},
|
|
58
|
-
nationalPark: {
|
|
59
|
-
visible: true,
|
|
60
|
-
color: '#202020',
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
transportation: {
|
|
64
|
-
roads: { visible: true, color: '#4f4f4f', width: 0.5 },
|
|
65
|
-
airports: { visible: true, color: '#4f4f4f', width: 0.6 }
|
|
66
|
-
},
|
|
67
|
-
boundaries: {
|
|
68
|
-
countries: { visible: true, color: '#ffffff', width: 1.5, lineType: 'solid' },
|
|
69
|
-
states: { visible: true, color: '#ffffff', width: 1.5, lineType: 'solid' },
|
|
70
|
-
counties: { visible: true, color: '#a2a2a2', width: 1.2, lineType: 'solid' }
|
|
71
|
-
},
|
|
72
|
-
waterFeatures: {
|
|
73
|
-
waterways: { visible: true, color: '#333333', width: 0.5 }
|
|
74
|
-
},
|
|
75
|
-
labels: {
|
|
76
|
-
countries: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 14, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
77
|
-
states: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
78
|
-
cities: {
|
|
79
|
-
major: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
80
|
-
minor: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 }
|
|
81
|
-
},
|
|
82
|
-
airports: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
83
|
-
poi: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
84
|
-
continents: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 16, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1.5 },
|
|
85
|
-
waterLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#a8d8ea', outlineColor: '#000000', outlineWidth: 1 },
|
|
86
|
-
naturalLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#90ee90', outlineColor: '#000000', outlineWidth: 1 },
|
|
87
|
-
subdivisionLabels: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 }
|
|
88
|
-
},
|
|
89
|
-
terrain: {
|
|
90
|
-
visible: true,
|
|
91
|
-
intensity: 0.2,
|
|
92
|
-
shadowColor: '#000000',
|
|
93
|
-
highlightColor: '#FFFFFF',
|
|
94
|
-
accentColor: '#000000'
|
|
95
|
-
},
|
|
96
|
-
oceanOnTop: false,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const THEME_CONFIGS = {
|
|
100
|
-
light: defaultLightMapStyles,
|
|
101
|
-
dark: defaultDarkMapStyles,
|
|
1
|
+
export const defaultLightMapStyles = {
|
|
2
|
+
landOcean: {
|
|
3
|
+
landColor: '#f0f0f0',
|
|
4
|
+
oceanColor: '#a8d8ea',
|
|
5
|
+
waterDepth: {
|
|
6
|
+
visible: true,
|
|
7
|
+
color: '#97c7d9'
|
|
8
|
+
},
|
|
9
|
+
nationalPark: {
|
|
10
|
+
visible: true,
|
|
11
|
+
color: '#d4e6d4',
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
transportation: {
|
|
15
|
+
roads: { visible: true, color: '#d3d3d3', width: 0.7 },
|
|
16
|
+
airports: { visible: true, color: '#d3d3d3', width: 0.7 }
|
|
17
|
+
},
|
|
18
|
+
boundaries: {
|
|
19
|
+
countries: { visible: true, color: '#000000', width: 1.5, lineType: 'solid' },
|
|
20
|
+
states: { visible: true, color: '#000000', width: 1.5, lineType: 'solid' },
|
|
21
|
+
counties: { visible: true, color: '#515151', width: 1.2, lineType: 'solid' }
|
|
22
|
+
},
|
|
23
|
+
waterFeatures: {
|
|
24
|
+
waterways: { visible: true, color: '#a8d8ea', width: 0.7 }
|
|
25
|
+
},
|
|
26
|
+
labels: {
|
|
27
|
+
countries: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 14, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
28
|
+
states: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
29
|
+
cities: {
|
|
30
|
+
major: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
31
|
+
minor: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 }
|
|
32
|
+
},
|
|
33
|
+
airports: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
34
|
+
poi: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
35
|
+
continents: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 16, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1.5 },
|
|
36
|
+
waterLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#0077be', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
37
|
+
naturalLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#2E8B57', outlineColor: '#ffffff', outlineWidth: 1 },
|
|
38
|
+
subdivisionLabels: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#000000', outlineColor: '#ffffff', outlineWidth: 1 }
|
|
39
|
+
},
|
|
40
|
+
terrain: {
|
|
41
|
+
visible: true,
|
|
42
|
+
intensity: 0.15,
|
|
43
|
+
shadowColor: '#b0b0b0',
|
|
44
|
+
highlightColor: '#ffffff',
|
|
45
|
+
accentColor: '#b0b0b0'
|
|
46
|
+
},
|
|
47
|
+
oceanOnTop: false,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const defaultDarkMapStyles = {
|
|
51
|
+
landOcean: {
|
|
52
|
+
landColor: '#242424',
|
|
53
|
+
oceanColor: '#252525',
|
|
54
|
+
waterDepth: {
|
|
55
|
+
visible: true,
|
|
56
|
+
color: '#000000'
|
|
57
|
+
},
|
|
58
|
+
nationalPark: {
|
|
59
|
+
visible: true,
|
|
60
|
+
color: '#202020',
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
transportation: {
|
|
64
|
+
roads: { visible: true, color: '#4f4f4f', width: 0.5 },
|
|
65
|
+
airports: { visible: true, color: '#4f4f4f', width: 0.6 }
|
|
66
|
+
},
|
|
67
|
+
boundaries: {
|
|
68
|
+
countries: { visible: true, color: '#ffffff', width: 1.5, lineType: 'solid' },
|
|
69
|
+
states: { visible: true, color: '#ffffff', width: 1.5, lineType: 'solid' },
|
|
70
|
+
counties: { visible: true, color: '#a2a2a2', width: 1.2, lineType: 'solid' }
|
|
71
|
+
},
|
|
72
|
+
waterFeatures: {
|
|
73
|
+
waterways: { visible: true, color: '#333333', width: 0.5 }
|
|
74
|
+
},
|
|
75
|
+
labels: {
|
|
76
|
+
countries: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 14, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
77
|
+
states: { visible: false, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
78
|
+
cities: {
|
|
79
|
+
major: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 12, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
80
|
+
minor: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 }
|
|
81
|
+
},
|
|
82
|
+
airports: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
83
|
+
poi: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 10, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 },
|
|
84
|
+
continents: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 16, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1.5 },
|
|
85
|
+
waterLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#a8d8ea', outlineColor: '#000000', outlineWidth: 1 },
|
|
86
|
+
naturalLabels: { visible: true, fontFamily: 'Open Sans Italic', fontSize: 10, color: '#90ee90', outlineColor: '#000000', outlineWidth: 1 },
|
|
87
|
+
subdivisionLabels: { visible: true, fontFamily: 'Open Sans Regular', fontSize: 11, color: '#ffffff', outlineColor: '#000000', outlineWidth: 1 }
|
|
88
|
+
},
|
|
89
|
+
terrain: {
|
|
90
|
+
visible: true,
|
|
91
|
+
intensity: 0.2,
|
|
92
|
+
shadowColor: '#000000',
|
|
93
|
+
highlightColor: '#FFFFFF',
|
|
94
|
+
accentColor: '#000000'
|
|
95
|
+
},
|
|
96
|
+
oceanOnTop: false,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const THEME_CONFIGS = {
|
|
100
|
+
light: defaultLightMapStyles,
|
|
101
|
+
dark: defaultDarkMapStyles,
|
|
102
102
|
};
|
package/src/unitConversions.js
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A utility module for converting between different physical units.
|
|
3
|
-
* Contains a comprehensive object of conversion functions and a helper
|
|
4
|
-
* to retrieve the correct function based on unit names.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// The main object containing all the raw conversion functions.
|
|
8
|
-
export const unitConversions = {
|
|
9
|
-
kelvin_to_celsius: (data) => data - 273.15,
|
|
10
|
-
kelvin_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
|
|
11
|
-
kelvin_to_c: (data) => data - 273.15,
|
|
12
|
-
kelvin_to_f: (data) => (data - 273.15) * 9/5 + 32,
|
|
13
|
-
k_to_celsius: (data) => data - 273.15,
|
|
14
|
-
k_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
|
|
15
|
-
k_to_c: (data) => data - 273.15,
|
|
16
|
-
k_to_f: (data) => (data - 273.15) * 9/5 + 32,
|
|
17
|
-
celsius_to_fahrenheit: (data) => (data * 9/5) + 32,
|
|
18
|
-
celsius_to_f: (data) => (data * 9/5) + 32,
|
|
19
|
-
c_to_fahrenheit: (data) => (data * 9/5) + 32,
|
|
20
|
-
c_to_f: (data) => (data * 9/5) + 32,
|
|
21
|
-
fahrenheit_to_celsius: (data) => (data - 32) * 5/9,
|
|
22
|
-
fahrenheit_to_c: (data) => (data - 32) * 5/9,
|
|
23
|
-
f_to_celsius: (data) => (data - 32) * 5/9,
|
|
24
|
-
f_to_c: (data) => (data - 32) * 5/9,
|
|
25
|
-
meters_to_feet: (data) => data * 3.28084,
|
|
26
|
-
meters_to_km: (data) => data / 1000,
|
|
27
|
-
m_to_feet: (data) => data * 3.28084,
|
|
28
|
-
m_to_ft: (data) => data * 3.28084,
|
|
29
|
-
m_to_km: (data) => data / 1000,
|
|
30
|
-
kts_to_mph: (data) => data * 1.15078,
|
|
31
|
-
mph_to_kts: (data) => data / 1.15078,
|
|
32
|
-
kts_to_ms: (data) => data / 1.94384449,
|
|
33
|
-
mph_to_ms: (data) => data / 2.23693629,
|
|
34
|
-
ms_to_mph: (data) => data * 2.23694,
|
|
35
|
-
ms_to_kts: (data) => data * 1.94384,
|
|
36
|
-
kts_to_kmh: (data) => data * 1.852,
|
|
37
|
-
mph_to_kmh: (data) => data * 1.60934,
|
|
38
|
-
ms_to_kmh: (data) => data * 3.6,
|
|
39
|
-
kmh_to_kts: (data) => data / 1.852,
|
|
40
|
-
kmh_to_mph: (data) => data / 1.60934,
|
|
41
|
-
kmh_to_ms: (data) => data / 3.6,
|
|
42
|
-
inches_to_mm: (data) => data * 25.4,
|
|
43
|
-
inches_to_cm: (data) => data * 2.54,
|
|
44
|
-
in_to_mm: (data) => data * 25.4,
|
|
45
|
-
in_to_cm: (data) => data * 2.54,
|
|
46
|
-
mm_to_in: (data) => data / 25.4,
|
|
47
|
-
mm_to_inches: (data) => data / 25.4,
|
|
48
|
-
cm_to_in: (data) => data / 2.54,
|
|
49
|
-
cm_to_inches: (data) => data / 2.54,
|
|
50
|
-
inhr_to_mmhr: (data) => data * 25.4,
|
|
51
|
-
inhr_to_cmhr: (data) => data * 2.54,
|
|
52
|
-
in_hr_to_mm_hr: (data) => data * 25.4,
|
|
53
|
-
in_hr_to_cm_hr: (data) => data * 2.54,
|
|
54
|
-
mmhr_to_inhr: (data) => data / 25.4,
|
|
55
|
-
cmhr_to_inhr: (data) => data / 2.54,
|
|
56
|
-
mm_hr_to_in_hr: (data) => data / 25.4,
|
|
57
|
-
cm_hr_to_in_hr: (data) => data / 2.54,
|
|
58
|
-
mmhr_to_cmhr: (data) => data / 10,
|
|
59
|
-
cmhr_to_mmhr: (data) => data * 10,
|
|
60
|
-
mm_hr_to_cm_hr: (data) => data / 10,
|
|
61
|
-
cm_hr_to_mm_hr: (data) => data * 10
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Finds and returns the correct conversion function based on "from" and "to" unit strings.
|
|
66
|
-
* It normalizes common unit abbreviations to a consistent key.
|
|
67
|
-
* @param {string} fromUnit - The starting unit (e.g., 'kelvin', '°C', 'kts').
|
|
68
|
-
* @param {string} toUnit - The target unit (e.g., 'fahrenheit', '°F', 'mph').
|
|
69
|
-
* @returns {function(number): number | null} The conversion function, or null if not found.
|
|
70
|
-
*/
|
|
71
|
-
export function getUnitConversionFunction(fromUnit, toUnit) {
|
|
72
|
-
// A map to standardize various unit string formats to a single key format.
|
|
73
|
-
const unitMap = {
|
|
74
|
-
'°c': 'c', '°f': 'f', '°k': 'k',
|
|
75
|
-
'celsius': 'c', 'fahrenheit': 'f', 'kelvin': 'k',
|
|
76
|
-
'c': 'c', 'f': 'f', 'k': 'k', '°F': 'f', '°C': 'c',
|
|
77
|
-
'kts': 'kts', 'm/s': 'ms', 'mph': 'mph', 'km/h': 'kmh',
|
|
78
|
-
'knots': 'kts',
|
|
79
|
-
'ft': 'ft', 'feet': 'ft',
|
|
80
|
-
'km': 'km',
|
|
81
|
-
'mm': 'mm',
|
|
82
|
-
'cm': 'cm',
|
|
83
|
-
'm': 'm', 'meters': 'm',
|
|
84
|
-
'in/hr': 'inhr', 'mm/hr': 'mmhr', 'cm/hr': 'cmhr',
|
|
85
|
-
'in': 'in', 'inches': 'in'
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// Cleans and standardizes the input unit string.
|
|
89
|
-
const normalizeUnit = (unit) => {
|
|
90
|
-
if (!unit) return '';
|
|
91
|
-
const lowerUnit = unit.toLowerCase().trim();
|
|
92
|
-
return unitMap[lowerUnit] || lowerUnit;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const fromNormalized = normalizeUnit(fromUnit);
|
|
96
|
-
const toNormalized = normalizeUnit(toUnit);
|
|
97
|
-
|
|
98
|
-
// Constructs the key to look up in the `unitConversions` object (e.g., 'k_to_f').
|
|
99
|
-
const conversionKey = `${fromNormalized}_to_${toNormalized}`;
|
|
100
|
-
|
|
101
|
-
// Return the function if it exists, otherwise return null.
|
|
102
|
-
return unitConversions[conversionKey] || null;
|
|
1
|
+
/**
|
|
2
|
+
* A utility module for converting between different physical units.
|
|
3
|
+
* Contains a comprehensive object of conversion functions and a helper
|
|
4
|
+
* to retrieve the correct function based on unit names.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// The main object containing all the raw conversion functions.
|
|
8
|
+
export const unitConversions = {
|
|
9
|
+
kelvin_to_celsius: (data) => data - 273.15,
|
|
10
|
+
kelvin_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
|
|
11
|
+
kelvin_to_c: (data) => data - 273.15,
|
|
12
|
+
kelvin_to_f: (data) => (data - 273.15) * 9/5 + 32,
|
|
13
|
+
k_to_celsius: (data) => data - 273.15,
|
|
14
|
+
k_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
|
|
15
|
+
k_to_c: (data) => data - 273.15,
|
|
16
|
+
k_to_f: (data) => (data - 273.15) * 9/5 + 32,
|
|
17
|
+
celsius_to_fahrenheit: (data) => (data * 9/5) + 32,
|
|
18
|
+
celsius_to_f: (data) => (data * 9/5) + 32,
|
|
19
|
+
c_to_fahrenheit: (data) => (data * 9/5) + 32,
|
|
20
|
+
c_to_f: (data) => (data * 9/5) + 32,
|
|
21
|
+
fahrenheit_to_celsius: (data) => (data - 32) * 5/9,
|
|
22
|
+
fahrenheit_to_c: (data) => (data - 32) * 5/9,
|
|
23
|
+
f_to_celsius: (data) => (data - 32) * 5/9,
|
|
24
|
+
f_to_c: (data) => (data - 32) * 5/9,
|
|
25
|
+
meters_to_feet: (data) => data * 3.28084,
|
|
26
|
+
meters_to_km: (data) => data / 1000,
|
|
27
|
+
m_to_feet: (data) => data * 3.28084,
|
|
28
|
+
m_to_ft: (data) => data * 3.28084,
|
|
29
|
+
m_to_km: (data) => data / 1000,
|
|
30
|
+
kts_to_mph: (data) => data * 1.15078,
|
|
31
|
+
mph_to_kts: (data) => data / 1.15078,
|
|
32
|
+
kts_to_ms: (data) => data / 1.94384449,
|
|
33
|
+
mph_to_ms: (data) => data / 2.23693629,
|
|
34
|
+
ms_to_mph: (data) => data * 2.23694,
|
|
35
|
+
ms_to_kts: (data) => data * 1.94384,
|
|
36
|
+
kts_to_kmh: (data) => data * 1.852,
|
|
37
|
+
mph_to_kmh: (data) => data * 1.60934,
|
|
38
|
+
ms_to_kmh: (data) => data * 3.6,
|
|
39
|
+
kmh_to_kts: (data) => data / 1.852,
|
|
40
|
+
kmh_to_mph: (data) => data / 1.60934,
|
|
41
|
+
kmh_to_ms: (data) => data / 3.6,
|
|
42
|
+
inches_to_mm: (data) => data * 25.4,
|
|
43
|
+
inches_to_cm: (data) => data * 2.54,
|
|
44
|
+
in_to_mm: (data) => data * 25.4,
|
|
45
|
+
in_to_cm: (data) => data * 2.54,
|
|
46
|
+
mm_to_in: (data) => data / 25.4,
|
|
47
|
+
mm_to_inches: (data) => data / 25.4,
|
|
48
|
+
cm_to_in: (data) => data / 2.54,
|
|
49
|
+
cm_to_inches: (data) => data / 2.54,
|
|
50
|
+
inhr_to_mmhr: (data) => data * 25.4,
|
|
51
|
+
inhr_to_cmhr: (data) => data * 2.54,
|
|
52
|
+
in_hr_to_mm_hr: (data) => data * 25.4,
|
|
53
|
+
in_hr_to_cm_hr: (data) => data * 2.54,
|
|
54
|
+
mmhr_to_inhr: (data) => data / 25.4,
|
|
55
|
+
cmhr_to_inhr: (data) => data / 2.54,
|
|
56
|
+
mm_hr_to_in_hr: (data) => data / 25.4,
|
|
57
|
+
cm_hr_to_in_hr: (data) => data / 2.54,
|
|
58
|
+
mmhr_to_cmhr: (data) => data / 10,
|
|
59
|
+
cmhr_to_mmhr: (data) => data * 10,
|
|
60
|
+
mm_hr_to_cm_hr: (data) => data / 10,
|
|
61
|
+
cm_hr_to_mm_hr: (data) => data * 10
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Finds and returns the correct conversion function based on "from" and "to" unit strings.
|
|
66
|
+
* It normalizes common unit abbreviations to a consistent key.
|
|
67
|
+
* @param {string} fromUnit - The starting unit (e.g., 'kelvin', '°C', 'kts').
|
|
68
|
+
* @param {string} toUnit - The target unit (e.g., 'fahrenheit', '°F', 'mph').
|
|
69
|
+
* @returns {function(number): number | null} The conversion function, or null if not found.
|
|
70
|
+
*/
|
|
71
|
+
export function getUnitConversionFunction(fromUnit, toUnit) {
|
|
72
|
+
// A map to standardize various unit string formats to a single key format.
|
|
73
|
+
const unitMap = {
|
|
74
|
+
'°c': 'c', '°f': 'f', '°k': 'k',
|
|
75
|
+
'celsius': 'c', 'fahrenheit': 'f', 'kelvin': 'k',
|
|
76
|
+
'c': 'c', 'f': 'f', 'k': 'k', '°F': 'f', '°C': 'c',
|
|
77
|
+
'kts': 'kts', 'm/s': 'ms', 'mph': 'mph', 'km/h': 'kmh',
|
|
78
|
+
'knots': 'kts',
|
|
79
|
+
'ft': 'ft', 'feet': 'ft',
|
|
80
|
+
'km': 'km',
|
|
81
|
+
'mm': 'mm',
|
|
82
|
+
'cm': 'cm',
|
|
83
|
+
'm': 'm', 'meters': 'm',
|
|
84
|
+
'in/hr': 'inhr', 'mm/hr': 'mmhr', 'cm/hr': 'cmhr',
|
|
85
|
+
'in': 'in', 'inches': 'in'
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Cleans and standardizes the input unit string.
|
|
89
|
+
const normalizeUnit = (unit) => {
|
|
90
|
+
if (!unit) return '';
|
|
91
|
+
const lowerUnit = unit.toLowerCase().trim();
|
|
92
|
+
return unitMap[lowerUnit] || lowerUnit;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const fromNormalized = normalizeUnit(fromUnit);
|
|
96
|
+
const toNormalized = normalizeUnit(toUnit);
|
|
97
|
+
|
|
98
|
+
// Constructs the key to look up in the `unitConversions` object (e.g., 'k_to_f').
|
|
99
|
+
const conversionKey = `${fromNormalized}_to_${toNormalized}`;
|
|
100
|
+
|
|
101
|
+
// Return the function if it exists, otherwise return null.
|
|
102
|
+
return unitConversions[conversionKey] || null;
|
|
103
103
|
}
|