@aguacerowx/javascript-sdk 0.0.15 → 0.0.18
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 +90 -45
- package/dist/default-colormaps.js +524 -437
- package/dist/dictionaries.js +1996 -2411
- package/package.json +1 -1
- package/src/AguaceroCore.js +33 -9
- package/src/default-colormaps.js +1308 -997
- package/src/dictionaries.js +2046 -2548
package/package.json
CHANGED
package/src/AguaceroCore.js
CHANGED
|
@@ -69,11 +69,14 @@ export class AguaceroCore extends EventEmitter {
|
|
|
69
69
|
this.customColormaps = options.customColormaps || {};
|
|
70
70
|
|
|
71
71
|
const userLayerOptions = options.layerOptions || {};
|
|
72
|
+
// EDIT: Determine initial mode from options
|
|
73
|
+
const initialMode = userLayerOptions.mode || 'model';
|
|
72
74
|
const initialVariable = userLayerOptions.variable || null;
|
|
73
75
|
|
|
74
76
|
this.state = {
|
|
75
77
|
model: userLayerOptions.model || 'gfs',
|
|
76
|
-
|
|
78
|
+
// EDIT: Set isMRMS based on the initial mode
|
|
79
|
+
isMRMS: initialMode === 'mrms',
|
|
77
80
|
mrmsTimestamp: null,
|
|
78
81
|
variable: initialVariable,
|
|
79
82
|
date: null,
|
|
@@ -135,15 +138,36 @@ export class AguaceroCore extends EventEmitter {
|
|
|
135
138
|
await this.fetchModelStatus(true);
|
|
136
139
|
await this.fetchMRMSStatus(true);
|
|
137
140
|
|
|
138
|
-
|
|
139
|
-
let initialState = this.state;
|
|
141
|
+
let initialState = { ...this.state };
|
|
140
142
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
initialState.
|
|
143
|
+
// ADD: Logic to handle an initial MRMS state
|
|
144
|
+
if (initialState.isMRMS) {
|
|
145
|
+
const variable = initialState.variable;
|
|
146
|
+
if (variable && this.mrmsStatus && this.mrmsStatus[variable]) {
|
|
147
|
+
const sortedTimestamps = [...(this.mrmsStatus[variable] || [])].sort((a, b) => b - a);
|
|
148
|
+
initialState.mrmsTimestamp = sortedTimestamps.length > 0 ? sortedTimestamps[0] : null;
|
|
149
|
+
} else {
|
|
150
|
+
// Fallback if the provided variable is not valid
|
|
151
|
+
console.warn(`Initial MRMS variable '${variable}' not found. Using default.`);
|
|
152
|
+
const availableMRMSVars = this.getAvailableVariables('mrms');
|
|
153
|
+
if (availableMRMSVars.length > 0) {
|
|
154
|
+
const firstVar = availableMRMSVars[0];
|
|
155
|
+
initialState.variable = firstVar;
|
|
156
|
+
const sortedTimestamps = [...(this.mrmsStatus[firstVar] || [])].sort((a, b) => b - a);
|
|
157
|
+
initialState.mrmsTimestamp = sortedTimestamps.length > 0 ? sortedTimestamps[0] : null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
// EDIT: This is the existing logic, now in an else block
|
|
162
|
+
const latestRun = findLatestModelRun(this.modelStatus, initialState.model);
|
|
163
|
+
if (latestRun) {
|
|
164
|
+
initialState = { ...initialState, ...latestRun, forecastHour: 0 };
|
|
165
|
+
if (!initialState.variable) {
|
|
166
|
+
const availableVariables = this.getAvailableVariables(initialState.model);
|
|
167
|
+
if (availableVariables && availableVariables.length > 0) {
|
|
168
|
+
initialState.variable = availableVariables[0];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
147
171
|
}
|
|
148
172
|
}
|
|
149
173
|
|