@aguacerowx/mapsgl 0.0.50 → 0.0.51
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.
|
@@ -745,14 +745,6 @@ export class WeatherLayerManager extends EventEmitter {
|
|
|
745
745
|
async setNexradProduct(product) {
|
|
746
746
|
return this.core.setNexradProduct(product);
|
|
747
747
|
}
|
|
748
|
-
/** @param {'level2'|'level3'} dataSource @param {string} product */
|
|
749
|
-
async setNexradProductMode(dataSource, product) {
|
|
750
|
-
return this.core.setNexradProductMode(dataSource, product);
|
|
751
|
-
}
|
|
752
|
-
/** @param {'level2'|'level3'} source */
|
|
753
|
-
async setNexradDataSource(source) {
|
|
754
|
-
return this.core.setNexradDataSource(source);
|
|
755
|
-
}
|
|
756
748
|
async setNexradTilt(tilt) {
|
|
757
749
|
return this.core.setNexradTilt(tilt);
|
|
758
750
|
}
|
package/src/nwsAlertsSupport.js
CHANGED
|
@@ -1190,6 +1190,56 @@ export function cloneNwwsFeatureCollectionStrippingVolatile(data) {
|
|
|
1190
1190
|
};
|
|
1191
1191
|
}
|
|
1192
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* Parse `properties.parameters` (JSON string or object from NWWS / CAP-style extensions).
|
|
1195
|
+
* @param {unknown} raw
|
|
1196
|
+
* @returns {Record<string, unknown>|null}
|
|
1197
|
+
*/
|
|
1198
|
+
function parseNwsParametersJson(raw) {
|
|
1199
|
+
if (raw == null) return null;
|
|
1200
|
+
if (typeof raw === 'object' && !Array.isArray(raw)) return /** @type {Record<string, unknown>} */ (raw);
|
|
1201
|
+
if (typeof raw === 'string') {
|
|
1202
|
+
try {
|
|
1203
|
+
const o = JSON.parse(raw);
|
|
1204
|
+
return o && typeof o === 'object' && !Array.isArray(o) ? o : null;
|
|
1205
|
+
} catch {
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
return null;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* Human-oriented subset of `parameters` for severe wx / common warning types (hail, wind, radar source).
|
|
1214
|
+
* @param {Record<string, unknown>|null} pObj
|
|
1215
|
+
* @returns {Record<string, string> | null}
|
|
1216
|
+
*/
|
|
1217
|
+
function buildHazardDetailsFromParameters(pObj) {
|
|
1218
|
+
if (!pObj || typeof pObj !== 'object') return null;
|
|
1219
|
+
/** @type {Record<string, string>} */
|
|
1220
|
+
const out = {};
|
|
1221
|
+
const set = (key, from) => {
|
|
1222
|
+
const v = pObj[from];
|
|
1223
|
+
if (v != null && String(v).trim() !== '') out[key] = String(v);
|
|
1224
|
+
};
|
|
1225
|
+
set('source', 'source');
|
|
1226
|
+
set('maxHailSize', 'max_hail_size');
|
|
1227
|
+
set('maxWindGust', 'max_wind_gust');
|
|
1228
|
+
set('damageThreat', 'damage_threat');
|
|
1229
|
+
set('wmo', 'wmo');
|
|
1230
|
+
if (pObj.tornado_detection != null && String(pObj.tornado_detection).trim() !== '')
|
|
1231
|
+
out.tornadoDetection = String(pObj.tornado_detection);
|
|
1232
|
+
if (pObj.flood_detection != null && String(pObj.flood_detection).trim() !== '')
|
|
1233
|
+
out.floodDetection = String(pObj.flood_detection);
|
|
1234
|
+
return Object.keys(out).length ? out : null;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Normalized payload for `nws:alert:click`. Top-level fields are derived from `feature.properties`
|
|
1239
|
+
* so you rarely need the duplicate `properties` object (kept for advanced / forward-compatible use).
|
|
1240
|
+
*
|
|
1241
|
+
* @param {GeoJSON.Feature|{ properties?: Record<string, unknown> }} feature
|
|
1242
|
+
*/
|
|
1193
1243
|
export function buildAlertClickPayload(feature) {
|
|
1194
1244
|
const properties = feature?.properties ? { ...feature.properties } : {};
|
|
1195
1245
|
const eventName = getNwsAlertEventLabelFromProperties(properties);
|
|
@@ -1204,9 +1254,10 @@ export function buildAlertClickPayload(feature) {
|
|
|
1204
1254
|
if (!Array.isArray(tags)) {
|
|
1205
1255
|
tags = tags != null ? [String(tags)] : [];
|
|
1206
1256
|
}
|
|
1207
|
-
const headline = properties.headline != null ? String(properties.headline) : '';
|
|
1208
1257
|
const name =
|
|
1209
|
-
headline
|
|
1258
|
+
(properties.headline != null && String(properties.headline).trim() !== ''
|
|
1259
|
+
? String(properties.headline)
|
|
1260
|
+
: '') ||
|
|
1210
1261
|
eventName ||
|
|
1211
1262
|
(properties.event != null ? String(properties.event) : '') ||
|
|
1212
1263
|
(properties.event_name != null ? String(properties.event_name) : '');
|
|
@@ -1216,8 +1267,6 @@ export function buildAlertClickPayload(feature) {
|
|
|
1216
1267
|
: properties.raw_text != null
|
|
1217
1268
|
? String(properties.raw_text)
|
|
1218
1269
|
: '';
|
|
1219
|
-
const summary = properties.summary != null ? String(properties.summary) : '';
|
|
1220
|
-
const instruction = properties.instruction != null ? String(properties.instruction) : '';
|
|
1221
1270
|
|
|
1222
1271
|
const startUnix =
|
|
1223
1272
|
typeof properties.start_unix === 'number'
|
|
@@ -1232,17 +1281,29 @@ export function buildAlertClickPayload(feature) {
|
|
|
1232
1281
|
? properties.active_start_unix
|
|
1233
1282
|
: getNwsActiveStartUnix(properties);
|
|
1234
1283
|
|
|
1284
|
+
const parametersParsed = parseNwsParametersJson(properties.parameters);
|
|
1285
|
+
const hazardDetails = buildHazardDetailsFromParameters(parametersParsed);
|
|
1286
|
+
|
|
1235
1287
|
return {
|
|
1236
1288
|
name,
|
|
1237
1289
|
eventName,
|
|
1238
|
-
headline,
|
|
1239
|
-
summary,
|
|
1240
1290
|
description,
|
|
1241
|
-
instruction,
|
|
1242
1291
|
tags,
|
|
1243
1292
|
startUnix,
|
|
1244
1293
|
endUnix,
|
|
1245
1294
|
activeStartUnix,
|
|
1295
|
+
/** ISO-ish strings from the feed (see also unix fields above). */
|
|
1296
|
+
issued: properties.issued != null ? String(properties.issued) : '',
|
|
1297
|
+
updatedAt: properties.updated_at != null ? String(properties.updated_at) : '',
|
|
1298
|
+
expiresAt: properties.expires != null ? String(properties.expires) : '',
|
|
1299
|
+
alertId: properties.alert_id != null ? String(properties.alert_id) : '',
|
|
1300
|
+
office: properties.office != null ? String(properties.office) : '',
|
|
1301
|
+
nwsProductKey: properties.nws_product_key != null ? String(properties.nws_product_key) : '',
|
|
1302
|
+
/** Parsed `properties.parameters` JSON when present (hail/wind/source keys vary by product). */
|
|
1303
|
+
parametersParsed,
|
|
1304
|
+
/** Short labels for SV / similar products: source, maxHailSize, maxWindGust, damageThreat, … */
|
|
1305
|
+
hazardDetails,
|
|
1306
|
+
/** Same as `feature.properties` — prefer top-level fields above when possible. */
|
|
1246
1307
|
properties,
|
|
1247
1308
|
};
|
|
1248
1309
|
}
|