@aguacerowx/javascript-sdk 0.0.24 → 0.0.26
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 +32 -0
- package/dist/dictionaries.js +73 -0
- 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/package.json +37 -2
- package/src/AguaceroCore.js +15 -6
- package/src/index.js +7 -1
- package/src/nws/NwsWatchesWarningsOverlay.js +977 -0
- package/src/nws/nwsAlertsFetchSpec.js +93 -0
- package/src/nws/nwsAlertsSupport.js +1337 -0
- package/src/nws/nwsEventColorsDefaults.js +133 -0
- package/src/nws/nwsSdkConstants.js +368 -0
- package/src/nws/nwsWarningCustomizationKey.gen.js +493 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TIMELINE_DURATION_MAX_HOURS = exports.TIMELINE_DURATION_HOUR_VALUES = exports.SECTOR_CODE_MAP = exports.SATELLITE_FRAMES_URL = exports.SATELLITE_DURATION_CONFIG = exports.GOES_SATELLITE_CHANNEL_LABELS = exports.GOES_SATELLITE_CHANNELS = exports.GOES_EAST_SATELLITE_SECTORS = void 0;
|
|
7
|
+
exports.buildSatelliteTimelineForSelection = buildSatelliteTimelineForSelection;
|
|
8
|
+
exports.calculateUnixTimeFromSatelliteKey = calculateUnixTimeFromSatelliteKey;
|
|
9
|
+
exports.formatTimelineDurationValue = formatTimelineDurationValue;
|
|
10
|
+
exports.getAllGoesEastSatelliteSelections = getAllGoesEastSatelliteSelections;
|
|
11
|
+
exports.getDefaultSatelliteDurationOption = getDefaultSatelliteDurationOption;
|
|
12
|
+
exports.normalizeTimelineDurationValue = normalizeTimelineDurationValue;
|
|
13
|
+
exports.parseTimelineDurationHours = parseTimelineDurationHours;
|
|
14
|
+
exports.resolveSatelliteDurationOption = resolveSatelliteDurationOption;
|
|
15
|
+
exports.resolveSatelliteS3FileName = resolveSatelliteS3FileName;
|
|
16
|
+
exports.resolveSatelliteSectorLabel = resolveSatelliteSectorLabel;
|
|
17
|
+
/**
|
|
18
|
+
* Satellite listing / timeline helpers aligned with aguacero-frontend (ActiveTimeContext + satelliteAvailability).
|
|
19
|
+
* Used by AguaceroCore for GOES-East WebGL satellite mode.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const SATELLITE_FRAMES_URL = exports.SATELLITE_FRAMES_URL = 'https://rhnq3edhcry5n6nljn6my4o3h40zwxze.lambda-url.us-east-2.on.aws/';
|
|
23
|
+
|
|
24
|
+
/** Same sector labels as production bundle / ActiveTimeContext SECTOR_CODE_MAP (inverse). */
|
|
25
|
+
const GOES_EAST_SATELLITE_SECTORS = exports.GOES_EAST_SATELLITE_SECTORS = ['GOES-EAST CONUS', 'GOES-EAST FULL DISK', 'GOES-EAST MESOSCALE 1', 'GOES-EAST MESOSCALE 2'];
|
|
26
|
+
const SECTOR_SYNONYM_TO_LABEL = {
|
|
27
|
+
conus: 'GOES-EAST CONUS',
|
|
28
|
+
full_disk: 'GOES-EAST FULL DISK',
|
|
29
|
+
fulldisk: 'GOES-EAST FULL DISK',
|
|
30
|
+
mesoscale_1: 'GOES-EAST MESOSCALE 1',
|
|
31
|
+
mesoscale1: 'GOES-EAST MESOSCALE 1',
|
|
32
|
+
m1: 'GOES-EAST MESOSCALE 1',
|
|
33
|
+
mesoscale_2: 'GOES-EAST MESOSCALE 2',
|
|
34
|
+
mesoscale2: 'GOES-EAST MESOSCALE 2',
|
|
35
|
+
m2: 'GOES-EAST MESOSCALE 2'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Normalizes a sector argument to the listing sector label (middle segment; must match archive paths).
|
|
40
|
+
* Accepts short tokens (<code>conus</code>, <code>full_disk</code>, …), synonyms (<code>m1</code>, <code>fulldisk</code>, …), or full labels (passthrough for West / custom feeds).
|
|
41
|
+
* @param {string} [sector]
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
function resolveSatelliteSectorLabel(sector) {
|
|
45
|
+
if (sector == null || sector === '') return 'GOES-EAST CONUS';
|
|
46
|
+
const raw = String(sector).trim();
|
|
47
|
+
const norm = raw.toLowerCase().replace(/[\s-]+/g, '_');
|
|
48
|
+
if (SECTOR_SYNONYM_TO_LABEL[norm]) return SECTOR_SYNONYM_TO_LABEL[norm];
|
|
49
|
+
if (GOES_EAST_SATELLITE_SECTORS.includes(raw)) return raw;
|
|
50
|
+
return raw;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Flat channel ids matching CHANNEL_CATEGORIES in frontend dictionaries. */
|
|
54
|
+
const GOES_SATELLITE_CHANNELS = exports.GOES_SATELLITE_CHANNELS = [...['true_color', 'geocolor', 'ntmicro', 'day_cloud_phase', 'day_land_cloud_fire', 'air_mass', 'sandwich', 'simple_water_vapor', 'dust', 'fire_temperature'], 'C01', 'C02', 'C03', 'C04', 'C05', 'C06', 'C07', 'C08', 'C09', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16'];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Human-readable labels for {@link GOES_SATELLITE_CHANNELS}, aligned with aguacero-frontend `CHANNEL_LABELS`.
|
|
58
|
+
*/
|
|
59
|
+
const GOES_SATELLITE_CHANNEL_LABELS = exports.GOES_SATELLITE_CHANNEL_LABELS = {
|
|
60
|
+
true_color: 'True Color',
|
|
61
|
+
ntmicro: 'Night Microphysics',
|
|
62
|
+
day_cloud_phase: 'Day Cloud Phase',
|
|
63
|
+
day_land_cloud_fire: 'Natural Color Fire',
|
|
64
|
+
air_mass: 'Air Mass',
|
|
65
|
+
sandwich: 'Sandwich',
|
|
66
|
+
simple_water_vapor: 'Simple Water Vapor',
|
|
67
|
+
dust: 'Dust',
|
|
68
|
+
geocolor: 'Geocolor',
|
|
69
|
+
fire_temperature: 'Fire Temperature',
|
|
70
|
+
C01: 'Blue - Visible',
|
|
71
|
+
C02: 'Red - Visible',
|
|
72
|
+
C03: 'Veggie - Near IR',
|
|
73
|
+
C04: 'Cirrus - Near IR',
|
|
74
|
+
C05: 'Snow/Ice - Near IR',
|
|
75
|
+
C06: 'Cloud Particle - Near IR',
|
|
76
|
+
C07: 'Shortwave Window - IR',
|
|
77
|
+
C08: 'Upper-Level Water Vapor - IR',
|
|
78
|
+
C09: 'Mid-Level Water Vapor - IR',
|
|
79
|
+
C10: 'Lower-Level Water Vapor - IR',
|
|
80
|
+
C11: 'Cloud Top - IR',
|
|
81
|
+
C12: 'Ozone - IR',
|
|
82
|
+
C13: 'Clean Longwave Window - IR',
|
|
83
|
+
C14: 'Longwave Window - IR',
|
|
84
|
+
C15: 'Dirty Longwave Window - IR',
|
|
85
|
+
C16: 'CO2 Longwave - IR'
|
|
86
|
+
};
|
|
87
|
+
const SECTOR_CODE_MAP = exports.SECTOR_CODE_MAP = {
|
|
88
|
+
'GOES-EAST CONUS': 'C',
|
|
89
|
+
'GOES-EAST FULL DISK': 'F',
|
|
90
|
+
'GOES-EAST MESOSCALE 1': 'M1',
|
|
91
|
+
'GOES-EAST MESOSCALE 2': 'M2'
|
|
92
|
+
};
|
|
93
|
+
const LUMPED_MULTIBAND_SATELLITE_SECTORS = new Set(['GOES-EAST CONUS', 'GOES-EAST FULL DISK']);
|
|
94
|
+
|
|
95
|
+
/** Uppercase RGB channel tokens as in production (CHANNEL_CATEGORIES.RGB). */
|
|
96
|
+
const SATELLITE_RGB_PRODUCT_UPPER = new Set(['TRUE_COLOR', 'GEOCOLOR', 'NTMICRO', 'DAY_CLOUD_PHASE', 'DAY_LAND_CLOUD_FIRE', 'AIR_MASS', 'SANDWICH', 'SIMPLE_WATER_VAPOR', 'DUST', 'FIRE_TEMPERATURE']);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Maximum timeline window length in hours for satellite, MRMS, and NEXRAD. Values are clamped to (0, this].
|
|
100
|
+
*/
|
|
101
|
+
const TIMELINE_DURATION_MAX_HOURS = exports.TIMELINE_DURATION_MAX_HOURS = 12;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Preset hour buttons (UI). Any positive duration ≤ {@link TIMELINE_DURATION_MAX_HOURS} is valid via {@link formatTimelineDurationValue}.
|
|
105
|
+
*/
|
|
106
|
+
const TIMELINE_DURATION_HOUR_VALUES = exports.TIMELINE_DURATION_HOUR_VALUES = ['1', '4', '6', '12'];
|
|
107
|
+
const LEGACY_SATELLITE_DURATION_ALIASES = {
|
|
108
|
+
'0.5': '1'
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** Tier keys used in SATELLITE_DURATION_CONFIG (frontend dictionaries). */
|
|
112
|
+
const SATELLITE_DURATION_CONFIG = exports.SATELLITE_DURATION_CONFIG = {
|
|
113
|
+
CONUS: {
|
|
114
|
+
basic: [{
|
|
115
|
+
label: '1 Hr',
|
|
116
|
+
value: '1',
|
|
117
|
+
interval: 300
|
|
118
|
+
}, {
|
|
119
|
+
label: '4 Hr',
|
|
120
|
+
value: '4',
|
|
121
|
+
interval: 300
|
|
122
|
+
}, {
|
|
123
|
+
label: '6 Hr',
|
|
124
|
+
value: '6',
|
|
125
|
+
interval: 300
|
|
126
|
+
}, {
|
|
127
|
+
label: '12 Hr',
|
|
128
|
+
value: '12',
|
|
129
|
+
interval: 300
|
|
130
|
+
}]
|
|
131
|
+
},
|
|
132
|
+
FULL_DISK: {
|
|
133
|
+
basic: [{
|
|
134
|
+
label: '1 Hr',
|
|
135
|
+
value: '1',
|
|
136
|
+
interval: 600
|
|
137
|
+
}, {
|
|
138
|
+
label: '4 Hr',
|
|
139
|
+
value: '4',
|
|
140
|
+
interval: 600
|
|
141
|
+
}, {
|
|
142
|
+
label: '6 Hr',
|
|
143
|
+
value: '6',
|
|
144
|
+
interval: 600
|
|
145
|
+
}, {
|
|
146
|
+
label: '12 Hr',
|
|
147
|
+
value: '12',
|
|
148
|
+
interval: 600
|
|
149
|
+
}]
|
|
150
|
+
},
|
|
151
|
+
MESOSCALE: {
|
|
152
|
+
basic: [{
|
|
153
|
+
label: '1 Hr',
|
|
154
|
+
value: '1',
|
|
155
|
+
interval: 120
|
|
156
|
+
}, {
|
|
157
|
+
label: '4 Hr',
|
|
158
|
+
value: '4',
|
|
159
|
+
interval: 120
|
|
160
|
+
}, {
|
|
161
|
+
label: '6 Hr',
|
|
162
|
+
value: '6',
|
|
163
|
+
interval: 120
|
|
164
|
+
}, {
|
|
165
|
+
label: '12 Hr',
|
|
166
|
+
value: '12',
|
|
167
|
+
interval: 120
|
|
168
|
+
}]
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Parses a user duration to hours, then clamps to a positive value not exceeding {@link TIMELINE_DURATION_MAX_HOURS}.
|
|
174
|
+
* @param {string|number} value
|
|
175
|
+
* @returns {number}
|
|
176
|
+
*/
|
|
177
|
+
function parseTimelineDurationHours(value) {
|
|
178
|
+
let s = value == null ? '1' : String(value).trim();
|
|
179
|
+
s = LEGACY_SATELLITE_DURATION_ALIASES[s] || s;
|
|
180
|
+
const n = Number(s);
|
|
181
|
+
if (!Number.isFinite(n) || n <= 0) return 1;
|
|
182
|
+
if (n > TIMELINE_DURATION_MAX_HOURS) return TIMELINE_DURATION_MAX_HOURS;
|
|
183
|
+
return n;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Canonical string for AguaceroCore state (stable for equality checks). Supports fractional hours (e.g. <code>'2.5'</code>).
|
|
188
|
+
* @param {string|number} value
|
|
189
|
+
* @returns {string}
|
|
190
|
+
*/
|
|
191
|
+
function formatTimelineDurationValue(value) {
|
|
192
|
+
const n = parseTimelineDurationHours(value);
|
|
193
|
+
if (Math.abs(n - Math.round(n)) < 1e-6) return String(Math.round(n));
|
|
194
|
+
return String(Math.round(n * 10000) / 10000);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** @returns {string} Same as {@link formatTimelineDurationValue} (backward-compatible name). */
|
|
198
|
+
function normalizeTimelineDurationValue(value) {
|
|
199
|
+
return formatTimelineDurationValue(value);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Picks a preset GOES duration option when one matches; otherwise builds a custom option using the same cadence as the 1 hr preset for that sector/tier.
|
|
204
|
+
* @param {string} sectorName - e.g. <code>GOES-EAST CONUS</code>
|
|
205
|
+
* @param {string} [tier='basic']
|
|
206
|
+
* @param {string|number} durationValue
|
|
207
|
+
* @returns {{ label: string, value: string, interval: number }}
|
|
208
|
+
*/
|
|
209
|
+
function resolveSatelliteDurationOption(sectorName, tier, durationValue) {
|
|
210
|
+
var _SATELLITE_DURATION_C, _tierConfig$find;
|
|
211
|
+
let sectorType = 'CONUS';
|
|
212
|
+
if (sectorName.includes('FULL DISK')) sectorType = 'FULL_DISK';else if (sectorName.includes('MESOSCALE')) sectorType = 'MESOSCALE';
|
|
213
|
+
const t = tier || 'basic';
|
|
214
|
+
const tierConfig = ((_SATELLITE_DURATION_C = SATELLITE_DURATION_CONFIG[sectorType]) === null || _SATELLITE_DURATION_C === void 0 ? void 0 : _SATELLITE_DURATION_C[t]) || SATELLITE_DURATION_CONFIG.CONUS.basic;
|
|
215
|
+
const key = formatTimelineDurationValue(durationValue);
|
|
216
|
+
const preset = tierConfig.find(o => String(o.value) === String(key));
|
|
217
|
+
if (preset) return preset;
|
|
218
|
+
const interval = ((_tierConfig$find = tierConfig.find(o => o.value === '1')) === null || _tierConfig$find === void 0 ? void 0 : _tierConfig$find.interval) || 300;
|
|
219
|
+
return {
|
|
220
|
+
label: `${key} Hr`,
|
|
221
|
+
value: key,
|
|
222
|
+
interval
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function getDefaultSatelliteDurationOption(sectorName, tier = 'basic') {
|
|
226
|
+
var _SATELLITE_DURATION_C2;
|
|
227
|
+
let sectorType = 'CONUS';
|
|
228
|
+
if (sectorName.includes('FULL DISK')) sectorType = 'FULL_DISK';else if (sectorName.includes('MESOSCALE')) sectorType = 'MESOSCALE';
|
|
229
|
+
const tierConfig = ((_SATELLITE_DURATION_C2 = SATELLITE_DURATION_CONFIG[sectorType]) === null || _SATELLITE_DURATION_C2 === void 0 ? void 0 : _SATELLITE_DURATION_C2[tier]) || SATELLITE_DURATION_CONFIG.CONUS.basic;
|
|
230
|
+
return tierConfig.find(o => o.value === '1') || tierConfig[0];
|
|
231
|
+
}
|
|
232
|
+
function calculateUnixTimeFromSatelliteKey(fileKey) {
|
|
233
|
+
try {
|
|
234
|
+
const match = fileKey.match(/_(\d{10})(?:\.ktx2)?$/);
|
|
235
|
+
if (match) return parseInt(match[1], 10);
|
|
236
|
+
const oldMatch = fileKey.match(/_s(\d{4})(\d{3})(\d{2})(\d{2})(\d{2})/);
|
|
237
|
+
if (oldMatch) {
|
|
238
|
+
const [, year, dayOfYear, hour, minute, second] = oldMatch.map(Number);
|
|
239
|
+
const date = new Date(Date.UTC(year, 0, 1));
|
|
240
|
+
date.setUTCDate(dayOfYear);
|
|
241
|
+
date.setUTCHours(hour, minute, second, 0);
|
|
242
|
+
return date.getTime() / 1000;
|
|
243
|
+
}
|
|
244
|
+
return 0;
|
|
245
|
+
} catch {
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @param {{ satelliteInstrumentId: string, satelliteSectorLabel: string, satelliteChannel: string }} selection
|
|
252
|
+
* @param {string[]} allFiles S3 keys from satellite listing API
|
|
253
|
+
* @param {{ value: string, interval: number }} durationOption
|
|
254
|
+
*/
|
|
255
|
+
function buildSatelliteTimelineForSelection(selection, allFiles, durationOption) {
|
|
256
|
+
const satelliteName = selection === null || selection === void 0 ? void 0 : selection.satelliteInstrumentId;
|
|
257
|
+
const categoryName = selection === null || selection === void 0 ? void 0 : selection.satelliteSectorLabel;
|
|
258
|
+
const channelName = selection === null || selection === void 0 ? void 0 : selection.satelliteChannel;
|
|
259
|
+
if (!satelliteName || !categoryName || !channelName) {
|
|
260
|
+
return {
|
|
261
|
+
unixTimes: [],
|
|
262
|
+
fileList: [],
|
|
263
|
+
timeToFileMap: {}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const SECTOR_CODE_MAP_LOCAL = {
|
|
267
|
+
'GOES-EAST CONUS': 'C',
|
|
268
|
+
'GOES-EAST FULL DISK': 'F',
|
|
269
|
+
'GOES-EAST MESOSCALE 1': 'M1',
|
|
270
|
+
'GOES-EAST MESOSCALE 2': 'M2'
|
|
271
|
+
};
|
|
272
|
+
const satelliteNum = satelliteName.replace('GOES', '').replace('-EAST', '').replace('-WEST', '');
|
|
273
|
+
const satId = `G${satelliteNum}`;
|
|
274
|
+
const sectorCode = SECTOR_CODE_MAP_LOCAL[categoryName] || 'C';
|
|
275
|
+
let sectorType = 'CONUS';
|
|
276
|
+
if (categoryName.includes('FULL DISK')) sectorType = 'FULL_DISK';else if (categoryName.includes('MESOSCALE')) sectorType = 'MESOSCALE';
|
|
277
|
+
const intervalSeconds = (durationOption === null || durationOption === void 0 ? void 0 : durationOption.interval) || 300;
|
|
278
|
+
const durationHours = durationOption !== null && durationOption !== void 0 && durationOption.value ? parseFloat(durationOption.value) : 1;
|
|
279
|
+
const filePrefix = `${sectorCode}_${satId}_`;
|
|
280
|
+
let searchProduct = channelName.toUpperCase();
|
|
281
|
+
if (!/^C\d{2}$/.test(searchProduct)) {
|
|
282
|
+
if (SATELLITE_RGB_PRODUCT_UPPER.has(searchProduct)) {
|
|
283
|
+
searchProduct = LUMPED_MULTIBAND_SATELLITE_SECTORS.has(categoryName) ? 'MULTI' : searchProduct;
|
|
284
|
+
} else {
|
|
285
|
+
searchProduct = 'MULTI';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const matchString = `${filePrefix}${searchProduct}`;
|
|
289
|
+
let relevantFiles = allFiles.filter(file => file.startsWith(matchString));
|
|
290
|
+
if (relevantFiles.length === 0) {
|
|
291
|
+
return {
|
|
292
|
+
unixTimes: [],
|
|
293
|
+
fileList: [],
|
|
294
|
+
timeToFileMap: {}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
relevantFiles.sort((a, b) => {
|
|
298
|
+
const timeA = calculateUnixTimeFromSatelliteKey(a);
|
|
299
|
+
const timeB = calculateUnixTimeFromSatelliteKey(b);
|
|
300
|
+
return timeA - timeB;
|
|
301
|
+
});
|
|
302
|
+
let cutoffTime = 0;
|
|
303
|
+
if (durationHours > 0) {
|
|
304
|
+
const latestTime = calculateUnixTimeFromSatelliteKey(relevantFiles[relevantFiles.length - 1]);
|
|
305
|
+
cutoffTime = latestTime - durationHours * 3600;
|
|
306
|
+
}
|
|
307
|
+
let processedFiles = relevantFiles.filter(f => calculateUnixTimeFromSatelliteKey(f) >= cutoffTime);
|
|
308
|
+
if (intervalSeconds > 0 && processedFiles.length > 0) {
|
|
309
|
+
const intervalMinutes = intervalSeconds / 60;
|
|
310
|
+
if (sectorType === 'MESOSCALE') {
|
|
311
|
+
processedFiles = processedFiles.filter(file => {
|
|
312
|
+
if (intervalMinutes <= 1.1) return true;
|
|
313
|
+
const t = calculateUnixTimeFromSatelliteKey(file);
|
|
314
|
+
const date = new Date(t * 1000);
|
|
315
|
+
const minutes = date.getUTCMinutes();
|
|
316
|
+
return minutes % intervalMinutes === 0;
|
|
317
|
+
});
|
|
318
|
+
} else {
|
|
319
|
+
if (intervalSeconds >= 300) {
|
|
320
|
+
processedFiles = processedFiles.filter(file => {
|
|
321
|
+
if (Math.abs(intervalMinutes - 5) < 0.1) return true;
|
|
322
|
+
const t = calculateUnixTimeFromSatelliteKey(file);
|
|
323
|
+
const minutes = new Date(t * 1000).getUTCMinutes();
|
|
324
|
+
const remainder = minutes % intervalMinutes;
|
|
325
|
+
const distToInterval = Math.min(remainder, intervalMinutes - remainder);
|
|
326
|
+
return distToInterval < 2.5;
|
|
327
|
+
});
|
|
328
|
+
} else {
|
|
329
|
+
processedFiles = processedFiles.filter(file => {
|
|
330
|
+
const t = calculateUnixTimeFromSatelliteKey(file);
|
|
331
|
+
const minutes = new Date(t * 1000).getUTCMinutes();
|
|
332
|
+
return minutes % intervalMinutes === 0;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (processedFiles.length === 0 && relevantFiles.length > 0) {
|
|
337
|
+
processedFiles = relevantFiles.slice(-1);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const unixTimes = [];
|
|
341
|
+
const timeToFileMap = {};
|
|
342
|
+
processedFiles.forEach(file => {
|
|
343
|
+
const unixTime = calculateUnixTimeFromSatelliteKey(file);
|
|
344
|
+
if (unixTime > 0) {
|
|
345
|
+
unixTimes.push(unixTime);
|
|
346
|
+
timeToFileMap[unixTime] = file;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Chronological (oldest → newest): matches standard time sliders (earlier left, later right).
|
|
351
|
+
unixTimes.sort((a, b) => a - b);
|
|
352
|
+
return {
|
|
353
|
+
unixTimes,
|
|
354
|
+
fileList: processedFiles,
|
|
355
|
+
timeToFileMap
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* All GOES-East spacecraft / sector / channel combinations the SDK knows (same naming as production).
|
|
361
|
+
* @param {string} [satelliteInstrumentId='GOES19-EAST']
|
|
362
|
+
* @returns {Array<{ satelliteInstrumentId: string, satelliteSectorLabel: string, satelliteChannel: string }>}
|
|
363
|
+
*/
|
|
364
|
+
function getAllGoesEastSatelliteSelections(satelliteInstrumentId = 'GOES19-EAST') {
|
|
365
|
+
const out = [];
|
|
366
|
+
for (const sector of GOES_EAST_SATELLITE_SECTORS) {
|
|
367
|
+
for (const ch of GOES_SATELLITE_CHANNELS) {
|
|
368
|
+
out.push({
|
|
369
|
+
satelliteInstrumentId,
|
|
370
|
+
satelliteSectorLabel: sector,
|
|
371
|
+
satelliteChannel: ch
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return out;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @param {string} satelliteChannel — band or RGB id (third segment of the archive descriptor)
|
|
380
|
+
*/
|
|
381
|
+
function resolveSatelliteS3FileName(satelliteChannel, timeToFileMap, satelliteTimestamp) {
|
|
382
|
+
const fileFromMap = timeToFileMap === null || timeToFileMap === void 0 ? void 0 : timeToFileMap[satelliteTimestamp];
|
|
383
|
+
if (fileFromMap) return fileFromMap;
|
|
384
|
+
const channelName = satelliteChannel;
|
|
385
|
+
const channelNameUpper = String(channelName).toUpperCase();
|
|
386
|
+
let name = fileFromMap || '';
|
|
387
|
+
if (!name && satelliteTimestamp != null) {
|
|
388
|
+
const suffix = `_${String(Math.floor(Number(satelliteTimestamp)))}`;
|
|
389
|
+
const multiName = Object.values(timeToFileMap || {}).find(f => f.includes('MULTI') && f.includes(suffix));
|
|
390
|
+
if (multiName) {
|
|
391
|
+
name = multiName.replace('MULTI', channelNameUpper);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return name;
|
|
395
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aguacerowx/javascript-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"private": false,
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
@@ -30,6 +31,36 @@
|
|
|
30
31
|
"import": "./src/nexradTiltCoalesce.js",
|
|
31
32
|
"require": "./src/nexradTiltCoalesce.js",
|
|
32
33
|
"default": "./src/nexradTiltCoalesce.js"
|
|
34
|
+
},
|
|
35
|
+
"./satellite_support.js": {
|
|
36
|
+
"import": "./src/satellite_support.js",
|
|
37
|
+
"require": "./src/satellite_support.js",
|
|
38
|
+
"react-native": "./src/satellite_support.js",
|
|
39
|
+
"default": "./src/satellite_support.js"
|
|
40
|
+
},
|
|
41
|
+
"./nws/NwsWatchesWarningsOverlay.js": {
|
|
42
|
+
"import": "./src/nws/NwsWatchesWarningsOverlay.js",
|
|
43
|
+
"require": "./src/nws/NwsWatchesWarningsOverlay.js",
|
|
44
|
+
"react-native": "./src/nws/NwsWatchesWarningsOverlay.js",
|
|
45
|
+
"default": "./src/nws/NwsWatchesWarningsOverlay.js"
|
|
46
|
+
},
|
|
47
|
+
"./nws/nwsSdkConstants.js": {
|
|
48
|
+
"import": "./src/nws/nwsSdkConstants.js",
|
|
49
|
+
"require": "./src/nws/nwsSdkConstants.js",
|
|
50
|
+
"react-native": "./src/nws/nwsSdkConstants.js",
|
|
51
|
+
"default": "./src/nws/nwsSdkConstants.js"
|
|
52
|
+
},
|
|
53
|
+
"./nws/nwsAlertsSupport.js": {
|
|
54
|
+
"import": "./src/nws/nwsAlertsSupport.js",
|
|
55
|
+
"require": "./src/nws/nwsAlertsSupport.js",
|
|
56
|
+
"react-native": "./src/nws/nwsAlertsSupport.js",
|
|
57
|
+
"default": "./src/nws/nwsAlertsSupport.js"
|
|
58
|
+
},
|
|
59
|
+
"./nws/nwsAlertsFetchSpec.js": {
|
|
60
|
+
"import": "./src/nws/nwsAlertsFetchSpec.js",
|
|
61
|
+
"require": "./src/nws/nwsAlertsFetchSpec.js",
|
|
62
|
+
"react-native": "./src/nws/nwsAlertsFetchSpec.js",
|
|
63
|
+
"default": "./src/nws/nwsAlertsFetchSpec.js"
|
|
33
64
|
}
|
|
34
65
|
},
|
|
35
66
|
"files": [
|
|
@@ -37,10 +68,14 @@
|
|
|
37
68
|
"src"
|
|
38
69
|
],
|
|
39
70
|
"scripts": {
|
|
40
|
-
"build": "babel src -d dist"
|
|
71
|
+
"build": "babel src -d dist",
|
|
72
|
+
"gen:nws-key": "esbuild ../../../aguacero-frontend/src/components/WarningsMenu/nwsWarningCustomizationKey.ts --bundle --format=esm --platform=neutral --outfile=src/nws/nwsWarningCustomizationKey.gen.js"
|
|
41
73
|
},
|
|
42
74
|
"author": "Your Name",
|
|
43
75
|
"license": "MIT",
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"esbuild": "^0.21.5"
|
|
78
|
+
},
|
|
44
79
|
"dependencies": {
|
|
45
80
|
"proj4": "^2.11.0",
|
|
46
81
|
"fzstd": "^0.1.1"
|
package/src/AguaceroCore.js
CHANGED
|
@@ -8,7 +8,7 @@ import { DICTIONARIES, MODEL_CONFIGS } from './dictionaries.js';
|
|
|
8
8
|
import { DEFAULT_COLORMAPS } from './default-colormaps.js';
|
|
9
9
|
import proj4 from 'proj4';
|
|
10
10
|
import { processCompressedGrid } from './gridDecodePipeline.js';
|
|
11
|
-
import { getBundleId } from './getBundleId';
|
|
11
|
+
import { getBundleId } from './getBundleId.js';
|
|
12
12
|
import {
|
|
13
13
|
SATELLITE_FRAMES_URL,
|
|
14
14
|
buildSatelliteTimelineForSelection,
|
|
@@ -115,8 +115,10 @@ export class AguaceroCore extends EventEmitter {
|
|
|
115
115
|
super();
|
|
116
116
|
this.isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
117
117
|
this.apiKey = options.apiKey;
|
|
118
|
-
/**
|
|
119
|
-
|
|
118
|
+
/** Base origin for grid HTTP requests (no trailing slash). Node/SSR: sets Origin + Referer so CloudFront can derive a source; browsers usually omit. */
|
|
119
|
+
const siteOriginRaw =
|
|
120
|
+
typeof options.gridRequestSiteOrigin === 'string' ? options.gridRequestSiteOrigin.trim() : '';
|
|
121
|
+
this.gridRequestSiteOrigin = siteOriginRaw ? siteOriginRaw.replace(/\/+$/, '') : null;
|
|
120
122
|
this.bundleId = getBundleId();
|
|
121
123
|
this.baseGridUrl = 'https://d3dc62msmxkrd7.cloudfront.net';
|
|
122
124
|
/** @type {Worker | null} */
|
|
@@ -1231,12 +1233,16 @@ export class AguaceroCore extends EventEmitter {
|
|
|
1231
1233
|
}
|
|
1232
1234
|
try {
|
|
1233
1235
|
const baseUrl = `${this.baseGridUrl}${resourcePath}`;
|
|
1234
|
-
const urlWithApiKeyParam = `${baseUrl}?apiKey=${this.apiKey}`;
|
|
1236
|
+
const urlWithApiKeyParam = `${baseUrl}?apiKey=${encodeURIComponent(this.apiKey)}`;
|
|
1235
1237
|
const headers = { 'x-api-key': this.apiKey };
|
|
1236
1238
|
if (this.bundleId && this.isReactNative) {
|
|
1237
1239
|
headers['x-app-identifier'] = this.bundleId;
|
|
1238
1240
|
}
|
|
1239
|
-
|
|
1241
|
+
if (this.gridRequestSiteOrigin) {
|
|
1242
|
+
headers['Origin'] = this.gridRequestSiteOrigin;
|
|
1243
|
+
headers['Referer'] = `${this.gridRequestSiteOrigin}/`;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1240
1246
|
const response = await fetch(urlWithApiKeyParam, {
|
|
1241
1247
|
headers: headers,
|
|
1242
1248
|
signal: abortController.signal
|
|
@@ -1302,7 +1308,10 @@ export class AguaceroCore extends EventEmitter {
|
|
|
1302
1308
|
? `mrms-${mrmsTimestamp}-${variable}-${effectiveSmoothing}`
|
|
1303
1309
|
: `${model}-${date}-${run}-${forecastHour}-${variable}-${effectiveSmoothing}`;
|
|
1304
1310
|
|
|
1305
|
-
|
|
1311
|
+
let gridDataPromise = this.dataCache.get(dataUrlIdentifier);
|
|
1312
|
+
if (!gridDataPromise) {
|
|
1313
|
+
gridDataPromise = await this._loadGridData(this.state);
|
|
1314
|
+
}
|
|
1306
1315
|
if (!gridDataPromise) return null;
|
|
1307
1316
|
|
|
1308
1317
|
try {
|
package/src/index.js
CHANGED
|
@@ -40,4 +40,10 @@ export {
|
|
|
40
40
|
/** NEXRAD tilt + listing helpers (also importable via subpaths; root re-export fixes Vite/esbuild subpath resolution). */
|
|
41
41
|
export * from './nexradTilts.js';
|
|
42
42
|
export * from './nexradTiltCoalesce.js';
|
|
43
|
-
export * from './nexrad_support.js';
|
|
43
|
+
export * from './nexrad_support.js';
|
|
44
|
+
|
|
45
|
+
/** NWS watches/warnings (NWWS HTTP + SSE, Mapbox-style paint helpers) — shared by mapsgl and React Native. */
|
|
46
|
+
export { NwsWatchesWarningsOverlay, NWS_DEFAULT_LINE_BEFORE_LAYER_ID } from './nws/NwsWatchesWarningsOverlay.js';
|
|
47
|
+
export * from './nws/nwsSdkConstants.js';
|
|
48
|
+
export * from './nws/nwsAlertsSupport.js';
|
|
49
|
+
export * from './nws/nwsAlertsFetchSpec.js';
|