@aguacerowx/javascript-sdk 0.0.28 → 0.0.29
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/dist/AguaceroCore.js +794 -207
- package/dist/default-colormaps.js +556 -437
- package/dist/dictionaries.js +2069 -2411
- package/dist/events.js +2 -2
- package/dist/getBundleId.js +9 -20
- package/dist/getBundleId.native.js +18 -0
- package/dist/gridDecodePipeline.js +37 -0
- package/dist/gridDecodeWorker.js +31 -0
- package/dist/index.js +172 -1
- package/dist/nexradTiltCoalesce.js +95 -0
- package/dist/nexradTilts.js +129 -0
- package/dist/nexrad_level3_catalog.js +56 -0
- package/dist/nexrad_support.js +269 -0
- package/dist/satellite_support.js +395 -0
- package/dist/unitConversions.js +10 -10
- package/package.json +99 -99
- package/src/coordinate_configs.js +374 -374
- package/src/default-colormaps.js +3369 -3369
- package/src/dictionaries.js +3857 -3857
- package/src/events.js +31 -31
- package/src/fill-layer-worker.js +26 -26
- package/src/getBundleId.js +8 -8
- package/src/getBundleId.native.js +14 -14
- package/src/gridDecodePipeline.js +32 -32
- package/src/gridDecodeWorker.js +24 -24
- package/src/index.js +48 -48
- package/src/map-styles.js +101 -101
- package/src/nexradTiltCoalesce.js +95 -95
- package/src/nexradTilts.js +138 -128
- package/src/nexrad_level3_catalog.js +26 -26
- package/src/nexrad_support.js +40 -6
- package/src/nws/nwsAlertsFetchSpec.js +93 -93
- package/src/nws/nwsEventColorsDefaults.js +133 -133
- package/src/nws/nwsSdkConstants.js +368 -368
- package/src/satellite_support.js +376 -376
- package/src/spawnGridDecodeWorker.js +5 -5
- package/src/unitConversions.js +102 -102
package/dist/events.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.EventEmitter = void 0;
|
|
7
7
|
// aguacero-api/src/events.js
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* A simple class for emitting and listening to events.
|
|
9
|
+
/**
|
|
10
|
+
* A simple class for emitting and listening to events.
|
|
11
11
|
*/
|
|
12
12
|
class EventEmitter {
|
|
13
13
|
constructor() {
|
package/dist/getBundleId.js
CHANGED
|
@@ -4,23 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getBundleId = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// to the native version.
|
|
17
|
-
getBundleIdImpl = () => DeviceInfo.getBundleId();
|
|
18
|
-
} catch (e) {
|
|
19
|
-
// If require() fails, we know we are in a non-React Native environment
|
|
20
|
-
// (like the web). We set the implementation to a "dummy" function
|
|
21
|
-
// that does nothing and returns null.
|
|
22
|
-
getBundleIdImpl = () => null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Export the chosen implementation.
|
|
26
|
-
const getBundleId = exports.getBundleId = getBundleIdImpl;
|
|
7
|
+
/**
|
|
8
|
+
* Default implementation for web and Node bundlers (Vite, webpack).
|
|
9
|
+
* Do not import react-native-device-info here: static analysis would pull in
|
|
10
|
+
* `react-native` (Flow sources) and break esbuild.
|
|
11
|
+
*
|
|
12
|
+
* Metro resolves `getBundleId.native.js` on iOS/Android instead of this file.
|
|
13
|
+
*/
|
|
14
|
+
const getBundleId = () => null;
|
|
15
|
+
exports.getBundleId = getBundleId;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBundleId = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* React Native (Metro picks this file over getBundleId.js on native platforms).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
let getBundleIdImpl;
|
|
12
|
+
try {
|
|
13
|
+
const DeviceInfo = require('react-native-device-info');
|
|
14
|
+
getBundleIdImpl = () => DeviceInfo.getBundleId();
|
|
15
|
+
} catch {
|
|
16
|
+
getBundleIdImpl = () => null;
|
|
17
|
+
}
|
|
18
|
+
const getBundleId = exports.getBundleId = getBundleIdImpl;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.processCompressedGrid = processCompressedGrid;
|
|
7
|
+
var _fzstd = require("fzstd");
|
|
8
|
+
function reconstructData(decompressedDeltas, encoding) {
|
|
9
|
+
const expectedLength = encoding.length;
|
|
10
|
+
const reconstructedData = new Int8Array(expectedLength);
|
|
11
|
+
if (decompressedDeltas.length > 0 && expectedLength > 0) {
|
|
12
|
+
reconstructedData[0] = decompressedDeltas[0] > 127 ? decompressedDeltas[0] - 256 : decompressedDeltas[0];
|
|
13
|
+
for (let i = 1; i < expectedLength; i++) {
|
|
14
|
+
const delta = decompressedDeltas[i] > 127 ? decompressedDeltas[i] - 256 : decompressedDeltas[i];
|
|
15
|
+
reconstructedData[i] = reconstructedData[i - 1] + delta;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return new Uint8Array(reconstructedData.buffer);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* zstd decompress → delta reconstruction → unsigned byte offset for GPU lookup.
|
|
23
|
+
* Used on the main thread as a fallback and inside {@link ./gridDecodeWorker.js}.
|
|
24
|
+
*/
|
|
25
|
+
function processCompressedGrid(compressedData, encoding) {
|
|
26
|
+
const decompressedDeltas = (0, _fzstd.decompress)(compressedData);
|
|
27
|
+
const finalData = reconstructData(decompressedDeltas, encoding);
|
|
28
|
+
const transformedData = new Uint8Array(finalData.length);
|
|
29
|
+
for (let i = 0; i < finalData.length; i++) {
|
|
30
|
+
const signedValue = finalData[i] > 127 ? finalData[i] - 256 : finalData[i];
|
|
31
|
+
transformedData[i] = signedValue + 128;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
data: transformedData,
|
|
35
|
+
encoding
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _gridDecodePipeline = require("./gridDecodePipeline.js");
|
|
4
|
+
self.onmessage = e => {
|
|
5
|
+
const {
|
|
6
|
+
id,
|
|
7
|
+
encoding,
|
|
8
|
+
compressedBuffer,
|
|
9
|
+
compressedByteOffset,
|
|
10
|
+
compressedByteLength
|
|
11
|
+
} = e.data;
|
|
12
|
+
try {
|
|
13
|
+
const compressedData = new Uint8Array(compressedBuffer, compressedByteOffset, compressedByteLength);
|
|
14
|
+
const {
|
|
15
|
+
data,
|
|
16
|
+
encoding: enc
|
|
17
|
+
} = (0, _gridDecodePipeline.processCompressedGrid)(compressedData, encoding);
|
|
18
|
+
self.postMessage({
|
|
19
|
+
id,
|
|
20
|
+
encoding: enc,
|
|
21
|
+
dataBuffer: data.buffer,
|
|
22
|
+
dataByteOffset: data.byteOffset,
|
|
23
|
+
dataByteLength: data.byteLength
|
|
24
|
+
}, [data.buffer]);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
self.postMessage({
|
|
27
|
+
id,
|
|
28
|
+
error: (err === null || err === void 0 ? void 0 : err.message) || String(err)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,43 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
AguaceroCore: true,
|
|
8
|
+
EventEmitter: true,
|
|
9
|
+
THEME_CONFIGS: true,
|
|
10
|
+
DICTIONARIES: true,
|
|
11
|
+
DEFAULT_COLORMAPS: true,
|
|
12
|
+
getUnitConversionFunction: true,
|
|
13
|
+
SATELLITE_FRAMES_URL: true,
|
|
14
|
+
GOES_EAST_SATELLITE_SECTORS: true,
|
|
15
|
+
GOES_SATELLITE_CHANNELS: true,
|
|
16
|
+
GOES_SATELLITE_CHANNEL_LABELS: true,
|
|
17
|
+
SATELLITE_DURATION_CONFIG: true,
|
|
18
|
+
TIMELINE_DURATION_MAX_HOURS: true,
|
|
19
|
+
TIMELINE_DURATION_HOUR_VALUES: true,
|
|
20
|
+
formatTimelineDurationValue: true,
|
|
21
|
+
normalizeTimelineDurationValue: true,
|
|
22
|
+
parseTimelineDurationHours: true,
|
|
23
|
+
resolveSatelliteDurationOption: true,
|
|
24
|
+
getDefaultSatelliteDurationOption: true,
|
|
25
|
+
buildSatelliteTimelineForSelection: true,
|
|
26
|
+
getAllGoesEastSatelliteSelections: true,
|
|
27
|
+
calculateUnixTimeFromSatelliteKey: true,
|
|
28
|
+
resolveSatelliteS3FileName: true,
|
|
29
|
+
resolveSatelliteSectorLabel: true
|
|
30
|
+
};
|
|
6
31
|
Object.defineProperty(exports, "AguaceroCore", {
|
|
7
32
|
enumerable: true,
|
|
8
33
|
get: function () {
|
|
9
34
|
return _AguaceroCore.AguaceroCore;
|
|
10
35
|
}
|
|
11
36
|
});
|
|
37
|
+
Object.defineProperty(exports, "DEFAULT_COLORMAPS", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _defaultColormaps.DEFAULT_COLORMAPS;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
12
43
|
Object.defineProperty(exports, "DICTIONARIES", {
|
|
13
44
|
enumerable: true,
|
|
14
45
|
get: function () {
|
|
@@ -21,20 +52,160 @@ Object.defineProperty(exports, "EventEmitter", {
|
|
|
21
52
|
return _events.EventEmitter;
|
|
22
53
|
}
|
|
23
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "GOES_EAST_SATELLITE_SECTORS", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _satellite_support.GOES_EAST_SATELLITE_SECTORS;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "GOES_SATELLITE_CHANNELS", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return _satellite_support.GOES_SATELLITE_CHANNELS;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "GOES_SATELLITE_CHANNEL_LABELS", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _satellite_support.GOES_SATELLITE_CHANNEL_LABELS;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "SATELLITE_DURATION_CONFIG", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return _satellite_support.SATELLITE_DURATION_CONFIG;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, "SATELLITE_FRAMES_URL", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _satellite_support.SATELLITE_FRAMES_URL;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
24
85
|
Object.defineProperty(exports, "THEME_CONFIGS", {
|
|
25
86
|
enumerable: true,
|
|
26
87
|
get: function () {
|
|
27
88
|
return _mapStyles.THEME_CONFIGS;
|
|
28
89
|
}
|
|
29
90
|
});
|
|
91
|
+
Object.defineProperty(exports, "TIMELINE_DURATION_HOUR_VALUES", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return _satellite_support.TIMELINE_DURATION_HOUR_VALUES;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "TIMELINE_DURATION_MAX_HOURS", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return _satellite_support.TIMELINE_DURATION_MAX_HOURS;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, "buildSatelliteTimelineForSelection", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return _satellite_support.buildSatelliteTimelineForSelection;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "calculateUnixTimeFromSatelliteKey", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _satellite_support.calculateUnixTimeFromSatelliteKey;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, "formatTimelineDurationValue", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return _satellite_support.formatTimelineDurationValue;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, "getAllGoesEastSatelliteSelections", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () {
|
|
124
|
+
return _satellite_support.getAllGoesEastSatelliteSelections;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(exports, "getDefaultSatelliteDurationOption", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return _satellite_support.getDefaultSatelliteDurationOption;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
30
133
|
Object.defineProperty(exports, "getUnitConversionFunction", {
|
|
31
134
|
enumerable: true,
|
|
32
135
|
get: function () {
|
|
33
136
|
return _unitConversions.getUnitConversionFunction;
|
|
34
137
|
}
|
|
35
138
|
});
|
|
139
|
+
Object.defineProperty(exports, "normalizeTimelineDurationValue", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return _satellite_support.normalizeTimelineDurationValue;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, "parseTimelineDurationHours", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return _satellite_support.parseTimelineDurationHours;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, "resolveSatelliteDurationOption", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function () {
|
|
154
|
+
return _satellite_support.resolveSatelliteDurationOption;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, "resolveSatelliteS3FileName", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function () {
|
|
160
|
+
return _satellite_support.resolveSatelliteS3FileName;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(exports, "resolveSatelliteSectorLabel", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () {
|
|
166
|
+
return _satellite_support.resolveSatelliteSectorLabel;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
36
169
|
var _AguaceroCore = require("./AguaceroCore.js");
|
|
37
170
|
var _events = require("./events.js");
|
|
38
171
|
var _mapStyles = require("./map-styles.js");
|
|
39
172
|
var _dictionaries = require("./dictionaries.js");
|
|
40
|
-
var
|
|
173
|
+
var _defaultColormaps = require("./default-colormaps.js");
|
|
174
|
+
var _unitConversions = require("./unitConversions.js");
|
|
175
|
+
var _satellite_support = require("./satellite_support.js");
|
|
176
|
+
var _nexradTilts = require("./nexradTilts.js");
|
|
177
|
+
Object.keys(_nexradTilts).forEach(function (key) {
|
|
178
|
+
if (key === "default" || key === "__esModule") return;
|
|
179
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
180
|
+
if (key in exports && exports[key] === _nexradTilts[key]) return;
|
|
181
|
+
Object.defineProperty(exports, key, {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function () {
|
|
184
|
+
return _nexradTilts[key];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
var _nexradTiltCoalesce = require("./nexradTiltCoalesce.js");
|
|
189
|
+
Object.keys(_nexradTiltCoalesce).forEach(function (key) {
|
|
190
|
+
if (key === "default" || key === "__esModule") return;
|
|
191
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
192
|
+
if (key in exports && exports[key] === _nexradTiltCoalesce[key]) return;
|
|
193
|
+
Object.defineProperty(exports, key, {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function () {
|
|
196
|
+
return _nexradTiltCoalesce[key];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
var _nexrad_support = require("./nexrad_support.js");
|
|
201
|
+
Object.keys(_nexrad_support).forEach(function (key) {
|
|
202
|
+
if (key === "default" || key === "__esModule") return;
|
|
203
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
204
|
+
if (key in exports && exports[key] === _nexrad_support[key]) return;
|
|
205
|
+
Object.defineProperty(exports, key, {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function () {
|
|
208
|
+
return _nexrad_support[key];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NEXRAD_TILT_COALESCE_MAX_GAP = void 0;
|
|
7
|
+
exports.chainCoalesceToCanonical = chainCoalesceToCanonical;
|
|
8
|
+
exports.coalesceNexradTiltOptionsForDisplay = coalesceNexradTiltOptionsForDisplay;
|
|
9
|
+
exports.nexradLayerTiltToDisplayOption = nexradLayerTiltToDisplayOption;
|
|
10
|
+
/**
|
|
11
|
+
* NEXRAD tilt coalescing (matches aguacero-frontend `nexradTiltCoalesce.ts`).
|
|
12
|
+
* Adjacent manifest tilts within {@link NEXRAD_TILT_COALESCE_MAX_GAP}° are merged for UI/listings:
|
|
13
|
+
* pairs → higher tilt; runs of three or more consecutive steps merge the first two into the lower tilt.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Adjacent tilts (sorted) within this gap share one listing / control. */
|
|
17
|
+
const NEXRAD_TILT_COALESCE_MAX_GAP = exports.NEXRAD_TILT_COALESCE_MAX_GAP = 0.1;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {number[]} segment
|
|
21
|
+
* @param {Map<number, number>} map
|
|
22
|
+
*/
|
|
23
|
+
function mergeCoalesceSegment(segment, map) {
|
|
24
|
+
if (segment.length === 0) return;
|
|
25
|
+
if (segment.length === 1) {
|
|
26
|
+
map.set(segment[0], segment[0]);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (segment.length === 2) {
|
|
30
|
+
const canonical = Math.max(segment[0], segment[1]);
|
|
31
|
+
map.set(segment[0], canonical);
|
|
32
|
+
map.set(segment[1], canonical);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const low = segment[0];
|
|
36
|
+
map.set(segment[0], low);
|
|
37
|
+
map.set(segment[1], low);
|
|
38
|
+
mergeCoalesceSegment(segment.slice(2), map);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {number[]} sortedUnique
|
|
43
|
+
* @returns {Map<number, number>}
|
|
44
|
+
*/
|
|
45
|
+
function chainCoalesceToCanonical(sortedUnique) {
|
|
46
|
+
const map = new Map();
|
|
47
|
+
let i = 0;
|
|
48
|
+
while (i < sortedUnique.length) {
|
|
49
|
+
let j = i + 1;
|
|
50
|
+
while (j < sortedUnique.length && sortedUnique[j] - sortedUnique[j - 1] <= NEXRAD_TILT_COALESCE_MAX_GAP + 1e-9) {
|
|
51
|
+
j++;
|
|
52
|
+
}
|
|
53
|
+
const segment = sortedUnique.slice(i, j);
|
|
54
|
+
mergeCoalesceSegment(segment, map);
|
|
55
|
+
i = j;
|
|
56
|
+
}
|
|
57
|
+
return map;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Manifest tilt list with adjacent options merged (pairs → higher; triple+ splits per merge rules).
|
|
62
|
+
* @param {number[]} tilts
|
|
63
|
+
* @returns {number[]}
|
|
64
|
+
*/
|
|
65
|
+
function coalesceNexradTiltOptionsForDisplay(tilts) {
|
|
66
|
+
const sorted = [...new Set(tilts)].filter(t => Number.isFinite(t)).sort((a, b) => a - b);
|
|
67
|
+
if (sorted.length <= 1) return sorted;
|
|
68
|
+
const tiltToCanonical = chainCoalesceToCanonical(sorted);
|
|
69
|
+
const reps = [];
|
|
70
|
+
let prevRep;
|
|
71
|
+
for (const t of sorted) {
|
|
72
|
+
const c = tiltToCanonical.get(t);
|
|
73
|
+
if (c === undefined) continue;
|
|
74
|
+
if (c !== prevRep) {
|
|
75
|
+
reps.push(c);
|
|
76
|
+
prevRep = c;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return reps;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Map stored/clamped tilt to the coalesced elevation value (same rules as {@link coalesceNexradTiltOptionsForDisplay}).
|
|
84
|
+
* @param {number} layerTilt
|
|
85
|
+
* @param {number[]} manifestTilts raw manifest tilts (before coalescing)
|
|
86
|
+
* @returns {number}
|
|
87
|
+
*/
|
|
88
|
+
function nexradLayerTiltToDisplayOption(layerTilt, manifestTilts) {
|
|
89
|
+
const sorted = [...new Set(manifestTilts)].filter(t => Number.isFinite(t)).sort((a, b) => a - b);
|
|
90
|
+
if (sorted.length === 0) return layerTilt;
|
|
91
|
+
const tiltToCanonical = chainCoalesceToCanonical(sorted);
|
|
92
|
+
if (tiltToCanonical.has(layerTilt)) return tiltToCanonical.get(layerTilt);
|
|
93
|
+
const nearest = sorted.reduce((best, x) => Math.abs(x - layerTilt) < Math.abs(best - layerTilt) ? x : best, sorted[0]);
|
|
94
|
+
return tiltToCanonical.get(nearest) ?? layerTilt;
|
|
95
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RADAR_TILTS_MANIFEST_URL = void 0;
|
|
7
|
+
exports.clampNexradTiltForVariable = clampNexradTiltForVariable;
|
|
8
|
+
exports.fetchRadarTiltsManifestFromNetwork = fetchRadarTiltsManifestFromNetwork;
|
|
9
|
+
exports.formatTiltForApi = formatTiltForApi;
|
|
10
|
+
exports.getDefaultRadarTilt = getDefaultRadarTilt;
|
|
11
|
+
exports.getRadarTilts = getRadarTilts;
|
|
12
|
+
exports.getRadarTiltsManifest = getRadarTiltsManifest;
|
|
13
|
+
exports.isNexradTdwrSiteId = isNexradTdwrSiteId;
|
|
14
|
+
exports.isTerminalRadar = isTerminalRadar;
|
|
15
|
+
exports.setRadarTiltsManifest = setRadarTiltsManifest;
|
|
16
|
+
/**
|
|
17
|
+
* NEXRAD tilt helpers (mirrors aguacero-frontend dictionaries + radar tilts manifest behavior).
|
|
18
|
+
* When {@link setRadarTiltsManifest} has been called with a non-empty map, per-site tilts follow it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const WSR88D_TILTS = [0.5, 0.9, 1.3, 1.8, 2.4, 3.1, 4.0, 5.1, 6.4];
|
|
22
|
+
const TDWR_TILTS = [0.3, 1.0, 2, 6.5, 8.8, 16.0, 21.3];
|
|
23
|
+
const WSR88D_SITE_IDS_WITH_T_PREFIX = new Set(['TJUA']);
|
|
24
|
+
|
|
25
|
+
/** @type {Record<string, { g1_tilts: number[]; g2_tilts: number[]; last_seen?: number }>} */
|
|
26
|
+
let manifestBySite = {};
|
|
27
|
+
function setRadarTiltsManifest(map) {
|
|
28
|
+
manifestBySite = map && typeof map === 'object' ? map : {};
|
|
29
|
+
}
|
|
30
|
+
function getRadarTiltsManifest() {
|
|
31
|
+
return manifestBySite;
|
|
32
|
+
}
|
|
33
|
+
function isNexradTdwrSiteId(siteId) {
|
|
34
|
+
const id = String(siteId ?? '').trim().toUpperCase();
|
|
35
|
+
if (!id) return false;
|
|
36
|
+
if (WSR88D_SITE_IDS_WITH_T_PREFIX.has(id)) return false;
|
|
37
|
+
return id.startsWith('T');
|
|
38
|
+
}
|
|
39
|
+
function isTerminalRadar(siteId) {
|
|
40
|
+
return isNexradTdwrSiteId(siteId);
|
|
41
|
+
}
|
|
42
|
+
const NEXRAD_G2_VARIABLES = new Set(['VEL', 'SW']);
|
|
43
|
+
const TDWR_DUAL_POL_CAPPED = new Set(['ZDR', 'PHI', 'RHO', 'KDP']);
|
|
44
|
+
const TDWR_DUAL_POL_MAX_TILT = 0.3;
|
|
45
|
+
function uniqSorted(nums) {
|
|
46
|
+
const arr = nums.filter(n => typeof n === 'number' && Number.isFinite(n));
|
|
47
|
+
const rounded = arr.map(n => Math.round(n * 1000) / 1000);
|
|
48
|
+
return [...new Set(rounded)].sort((a, b) => a - b);
|
|
49
|
+
}
|
|
50
|
+
function computeRadarTiltsFromManifestEntry(entry, siteId, radarVariable) {
|
|
51
|
+
const v = (radarVariable || 'REF').toUpperCase();
|
|
52
|
+
let base;
|
|
53
|
+
if (NEXRAD_G2_VARIABLES.has(v)) {
|
|
54
|
+
base = uniqSorted(entry.g2_tilts || []);
|
|
55
|
+
} else {
|
|
56
|
+
base = uniqSorted([...(entry.g1_tilts || []), ...(entry.g2_tilts || [])]);
|
|
57
|
+
}
|
|
58
|
+
if (isNexradTdwrSiteId(siteId) && TDWR_DUAL_POL_CAPPED.has(v)) {
|
|
59
|
+
return base.filter(t => t <= TDWR_DUAL_POL_MAX_TILT);
|
|
60
|
+
}
|
|
61
|
+
return base;
|
|
62
|
+
}
|
|
63
|
+
function getDefaultTiltFromManifestEntry(entry) {
|
|
64
|
+
const g1 = entry.g1_tilts;
|
|
65
|
+
if (!Array.isArray(g1) || g1.length === 0) return null;
|
|
66
|
+
const sorted = uniqSorted(g1);
|
|
67
|
+
return sorted[0] ?? null;
|
|
68
|
+
}
|
|
69
|
+
function getDefaultRadarTilt(siteId) {
|
|
70
|
+
const id = siteId === null || siteId === void 0 ? void 0 : siteId.toUpperCase();
|
|
71
|
+
const entry = id ? manifestBySite[id] : undefined;
|
|
72
|
+
if (entry) {
|
|
73
|
+
const t = getDefaultTiltFromManifestEntry(entry);
|
|
74
|
+
if (t != null) return t;
|
|
75
|
+
}
|
|
76
|
+
return isTerminalRadar(siteId) ? 0.3 : 0.5;
|
|
77
|
+
}
|
|
78
|
+
function getRadarTilts(siteId, radarVariable) {
|
|
79
|
+
const id = siteId === null || siteId === void 0 ? void 0 : siteId.toUpperCase();
|
|
80
|
+
const entry = id ? manifestBySite[id] : undefined;
|
|
81
|
+
if (entry) {
|
|
82
|
+
const fromManifest = computeRadarTiltsFromManifestEntry(entry, siteId, radarVariable);
|
|
83
|
+
if (fromManifest.length) return fromManifest;
|
|
84
|
+
}
|
|
85
|
+
const base = isTerminalRadar(siteId) ? TDWR_TILTS : WSR88D_TILTS;
|
|
86
|
+
if (!radarVariable || !isTerminalRadar(siteId)) return [...base];
|
|
87
|
+
const v = radarVariable.toUpperCase();
|
|
88
|
+
if (['ZDR', 'PHI', 'RHO'].includes(v)) {
|
|
89
|
+
return base.filter(t => t <= TDWR_DUAL_POL_MAX_TILT);
|
|
90
|
+
}
|
|
91
|
+
return [...base];
|
|
92
|
+
}
|
|
93
|
+
function clampNexradTiltForVariable(siteId, variable, tilt) {
|
|
94
|
+
if (!isTerminalRadar(siteId)) return tilt;
|
|
95
|
+
const v = (variable || 'REF').toUpperCase();
|
|
96
|
+
if (['ZDR', 'PHI', 'RHO'].includes(v)) {
|
|
97
|
+
return Math.min(tilt, TDWR_DUAL_POL_MAX_TILT);
|
|
98
|
+
}
|
|
99
|
+
return tilt;
|
|
100
|
+
}
|
|
101
|
+
function formatTiltForApi(tilt) {
|
|
102
|
+
return tilt.toFixed(2);
|
|
103
|
+
}
|
|
104
|
+
const RADAR_TILTS_MANIFEST_URL = exports.RADAR_TILTS_MANIFEST_URL = 'https://radar-tilts.s3.us-east-2.amazonaws.com/manifest.json';
|
|
105
|
+
async function fetchRadarTiltsManifestFromNetwork() {
|
|
106
|
+
try {
|
|
107
|
+
const res = await fetch(RADAR_TILTS_MANIFEST_URL, {
|
|
108
|
+
cache: 'no-store'
|
|
109
|
+
});
|
|
110
|
+
if (!res.ok) return null;
|
|
111
|
+
const raw = await res.json();
|
|
112
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
113
|
+
const out = {};
|
|
114
|
+
for (const [key, val] of Object.entries(raw)) {
|
|
115
|
+
if (!val || typeof val !== 'object' || Array.isArray(val)) continue;
|
|
116
|
+
const g1 = val.g1_tilts;
|
|
117
|
+
const g2 = val.g2_tilts;
|
|
118
|
+
if (!Array.isArray(g1) || !Array.isArray(g2)) continue;
|
|
119
|
+
out[key.toUpperCase()] = {
|
|
120
|
+
g1_tilts: g1.filter(n => typeof n === 'number' && Number.isFinite(n)),
|
|
121
|
+
g2_tilts: g2.filter(n => typeof n === 'number' && Number.isFinite(n)),
|
|
122
|
+
last_seen: typeof val.last_seen === 'number' ? val.last_seen : undefined
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return Object.keys(out).length ? out : null;
|
|
126
|
+
} catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NEXRAD_LEVEL3_MOTION_PRODUCT = exports.NEXRAD_LEVEL3_ELEV = void 0;
|
|
7
|
+
exports.getNexradLevel3EntryByRadarKey = getNexradLevel3EntryByRadarKey;
|
|
8
|
+
/** Subset of aguacero-frontend NEXRAD_LEVEL3_MENU for API product resolution. */
|
|
9
|
+
|
|
10
|
+
const NEXRAD_LEVEL3_ELEV = exports.NEXRAD_LEVEL3_ELEV = '0.50';
|
|
11
|
+
const NEXRAD_LEVEL3_MOTION_PRODUCT = exports.NEXRAD_LEVEL3_MOTION_PRODUCT = 'N0S';
|
|
12
|
+
const MENU = [{
|
|
13
|
+
radarKey: 'VEL',
|
|
14
|
+
product: 'N0G',
|
|
15
|
+
fldKey: 'nexrad_vel'
|
|
16
|
+
}, {
|
|
17
|
+
radarKey: 'KDP',
|
|
18
|
+
product: 'N0K',
|
|
19
|
+
fldKey: 'nexrad_l3_n0k'
|
|
20
|
+
}, {
|
|
21
|
+
radarKey: 'N0H',
|
|
22
|
+
product: 'N0H',
|
|
23
|
+
fldKey: 'nexrad_l3_n0h'
|
|
24
|
+
}, {
|
|
25
|
+
radarKey: 'HHC',
|
|
26
|
+
product: 'HHC',
|
|
27
|
+
fldKey: 'nexrad_l3_hhc'
|
|
28
|
+
}, {
|
|
29
|
+
radarKey: 'EET',
|
|
30
|
+
product: 'EET',
|
|
31
|
+
fldKey: 'nexrad_l3_eet'
|
|
32
|
+
}, {
|
|
33
|
+
radarKey: 'DVL',
|
|
34
|
+
product: 'DVL',
|
|
35
|
+
fldKey: 'nexrad_l3_dvl'
|
|
36
|
+
}, {
|
|
37
|
+
radarKey: 'DAA',
|
|
38
|
+
product: 'DAA',
|
|
39
|
+
fldKey: 'nexrad_l3_daa'
|
|
40
|
+
}, {
|
|
41
|
+
radarKey: 'DU3',
|
|
42
|
+
product: 'DU3',
|
|
43
|
+
fldKey: 'nexrad_l3_du3'
|
|
44
|
+
}, {
|
|
45
|
+
radarKey: 'DTA',
|
|
46
|
+
product: 'DTA',
|
|
47
|
+
fldKey: 'nexrad_l3_dta'
|
|
48
|
+
}];
|
|
49
|
+
const byRadarKey = new Map();
|
|
50
|
+
for (const e of MENU) {
|
|
51
|
+
byRadarKey.set(e.radarKey, e);
|
|
52
|
+
}
|
|
53
|
+
byRadarKey.set('NVL', byRadarKey.get('DVL'));
|
|
54
|
+
function getNexradLevel3EntryByRadarKey(radarKey) {
|
|
55
|
+
return byRadarKey.get(radarKey);
|
|
56
|
+
}
|