@aguacerowx/mapsgl 0.0.52 → 0.0.53
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aguacerowx/mapsgl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepublishOnly": "npm run bundle-nexrad",
|
|
12
|
-
"bundle-nexrad": "esbuild src/nexrad/radarDecode.worker.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/radarDecode.worker.bundled.js && esbuild src/nexrad/radarArchiveCore.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/radarArchiveCore.bundled.js --external:@aguacerowx/javascript-sdk && esbuild src/nexrad/MapboxRadarLayer.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/MapboxRadarLayer.bundled.js --external:mapbox-gl --external:@aguacerowx/javascript-sdk && esbuild src/nexrad/nexradCrossSectionSampleAtLatLon.ts --format=esm --platform=browser --outfile=src/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js && esbuild src/nexrad/radarFrameGpuMatch.ts --format=esm --platform=browser --outfile=src/nexrad/radarFrameGpuMatch.bundled.js",
|
|
12
|
+
"bundle-nexrad": "esbuild src/nexrad/radarDecode.worker.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/radarDecode.worker.bundled.js && esbuild src/nexrad/radarArchiveCore.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/radarArchiveCore.bundled.js --external:@aguacerowx/javascript-sdk && esbuild src/nexrad/MapboxRadarLayer.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/MapboxRadarLayer.bundled.js --external:mapbox-gl --external:@aguacerowx/javascript-sdk && esbuild src/nexrad/nexradCrossSectionSampleAtLatLon.ts --format=esm --platform=browser --outfile=src/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js && esbuild src/nexrad/radarFrameGpuMatch.ts --format=esm --platform=browser --outfile=src/nexrad/radarFrameGpuMatch.bundled.js && esbuild src/nexrad/nexradMapboxFrameOpts.ts --bundle --format=esm --platform=browser --outfile=src/nexrad/nexradMapboxFrameOpts.bundled.js --external:@aguacerowx/javascript-sdk",
|
|
13
13
|
"gen:nws-key": "esbuild ../../../aguacero-frontend/src/components/WarningsMenu/nwsWarningCustomizationKey.ts --bundle --format=esm --platform=neutral --outfile=src/nwsWarningCustomizationKey.gen.js"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -8,7 +8,7 @@ import { MapboxRadarLayer } from './nexrad/MapboxRadarLayer.bundled.js';
|
|
|
8
8
|
import { nexradBinGroupIdForKey, variableToNexradGroup } from '@aguacerowx/javascript-sdk';
|
|
9
9
|
import { sampleNexradFrameAtLatLon } from './nexrad/nexradCrossSectionSampleAtLatLon.bundled.js';
|
|
10
10
|
import { prepareRadarFrameForGpuReadout } from './nexrad/radarFrameGpuMatch.bundled.js';
|
|
11
|
-
import { mapboxFrameUploadOptionsForNexradState } from './nexrad/nexradMapboxFrameOpts.
|
|
11
|
+
import { mapboxFrameUploadOptionsForNexradState } from './nexrad/nexradMapboxFrameOpts.bundled.js';
|
|
12
12
|
|
|
13
13
|
function pickNearestLevel3ObjectKey(unixTime, timeToKeyMap, maxDeltaSec = 600) {
|
|
14
14
|
const direct = timeToKeyMap[String(unixTime)];
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// src/nexrad/nexradMapboxFrameOpts.ts
|
|
2
|
+
import { clampNexradTiltForVariable as clampNexradTiltForVariable2, getDefaultRadarTilt as getDefaultRadarTilt2, getRadarTilts as getRadarTilts2 } from "@aguacerowx/javascript-sdk";
|
|
3
|
+
|
|
4
|
+
// src/nexrad/nexradLevel3Products.ts
|
|
5
|
+
import {
|
|
6
|
+
clampNexradTiltForVariable,
|
|
7
|
+
formatTiltForApi,
|
|
8
|
+
getDefaultRadarTilt,
|
|
9
|
+
getRadarTilts,
|
|
10
|
+
isTerminalRadar
|
|
11
|
+
} from "@aguacerowx/javascript-sdk";
|
|
12
|
+
var NEXRAD_LEVEL3_MENU = [
|
|
13
|
+
{
|
|
14
|
+
radarKey: "VEL",
|
|
15
|
+
product: "N0G",
|
|
16
|
+
menuLabel: "Storm Relative Velocity",
|
|
17
|
+
fldKey: "nexrad_vel",
|
|
18
|
+
cmapPropertyKey: "nexrad_vel",
|
|
19
|
+
decodeMode: "velocity",
|
|
20
|
+
stormRelativeVelocity: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
radarKey: "KDP",
|
|
24
|
+
product: "N0K",
|
|
25
|
+
menuLabel: "Specific Differential Phase",
|
|
26
|
+
fldKey: "nexrad_l3_n0k",
|
|
27
|
+
cmapPropertyKey: "nexrad_kdp",
|
|
28
|
+
defaultUnit: "deg/km",
|
|
29
|
+
decodeMode: "generic_physical"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
radarKey: "N0H",
|
|
33
|
+
product: "N0H",
|
|
34
|
+
menuLabel: "Hydrometeor Classification",
|
|
35
|
+
fldKey: "nexrad_l3_n0h",
|
|
36
|
+
cmapPropertyKey: "nexrad_l3_n0h",
|
|
37
|
+
defaultUnit: "None",
|
|
38
|
+
decodeMode: "categorical"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
radarKey: "HHC",
|
|
42
|
+
product: "HHC",
|
|
43
|
+
menuLabel: "Hybrid Hydrometeor Classification",
|
|
44
|
+
fldKey: "nexrad_l3_hhc",
|
|
45
|
+
cmapPropertyKey: "nexrad_l3_hhc",
|
|
46
|
+
defaultUnit: "None",
|
|
47
|
+
decodeMode: "categorical"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
radarKey: "EET",
|
|
51
|
+
product: "EET",
|
|
52
|
+
menuLabel: "Enhanced Echo Tops",
|
|
53
|
+
fldKey: "nexrad_l3_eet",
|
|
54
|
+
cmapPropertyKey: "nexrad_l3_eet",
|
|
55
|
+
defaultUnit: "kft",
|
|
56
|
+
decodeMode: "tops_kft"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
radarKey: "DVL",
|
|
60
|
+
product: "DVL",
|
|
61
|
+
menuLabel: "Vertically Integrated Liquid",
|
|
62
|
+
fldKey: "nexrad_l3_dvl",
|
|
63
|
+
cmapPropertyKey: "nexrad_l3_dvl",
|
|
64
|
+
defaultUnit: "kg/m\xB2",
|
|
65
|
+
decodeMode: "vil"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
radarKey: "DAA",
|
|
69
|
+
product: "DAA",
|
|
70
|
+
menuLabel: "1-Hour Precipitation",
|
|
71
|
+
fldKey: "nexrad_l3_daa",
|
|
72
|
+
cmapPropertyKey: "tp_0_1",
|
|
73
|
+
defaultUnit: "in",
|
|
74
|
+
decodeMode: "precip"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
radarKey: "DU3",
|
|
78
|
+
product: "DU3",
|
|
79
|
+
menuLabel: "3-Hour Precipitation",
|
|
80
|
+
fldKey: "nexrad_l3_du3",
|
|
81
|
+
cmapPropertyKey: "tp_0_total",
|
|
82
|
+
defaultUnit: "in",
|
|
83
|
+
decodeMode: "precip"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
radarKey: "DTA",
|
|
87
|
+
product: "DTA",
|
|
88
|
+
menuLabel: "Storm Total Precipitation",
|
|
89
|
+
fldKey: "nexrad_l3_dta",
|
|
90
|
+
cmapPropertyKey: "tp_0_total",
|
|
91
|
+
defaultUnit: "in",
|
|
92
|
+
decodeMode: "precip"
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
var byRadarKey = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const e of NEXRAD_LEVEL3_MENU) {
|
|
97
|
+
byRadarKey.set(e.radarKey, e);
|
|
98
|
+
if (e.radarKey === "DVL") byRadarKey.set("NVL", e);
|
|
99
|
+
}
|
|
100
|
+
var NEXRAD_LEVEL3_KDP_PRODUCTS = [
|
|
101
|
+
"NXK",
|
|
102
|
+
"NYK",
|
|
103
|
+
"NZK",
|
|
104
|
+
"N0K",
|
|
105
|
+
"NAK",
|
|
106
|
+
"N1K",
|
|
107
|
+
"NBK",
|
|
108
|
+
"N2K",
|
|
109
|
+
"N3K"
|
|
110
|
+
];
|
|
111
|
+
var NEXRAD_LEVEL3_DHC_PRODUCTS = [
|
|
112
|
+
"NXH",
|
|
113
|
+
"NYH",
|
|
114
|
+
"NZH",
|
|
115
|
+
"N0H",
|
|
116
|
+
"NAH",
|
|
117
|
+
"N1H",
|
|
118
|
+
"NBH",
|
|
119
|
+
"N2H",
|
|
120
|
+
"N3H"
|
|
121
|
+
];
|
|
122
|
+
var NEXRAD_LEVEL3_KDP_PRODUCTS_FOR_MANIFEST = NEXRAD_LEVEL3_KDP_PRODUCTS.slice(3);
|
|
123
|
+
var NEXRAD_LEVEL3_DHC_PRODUCTS_FOR_MANIFEST = NEXRAD_LEVEL3_DHC_PRODUCTS.slice(3);
|
|
124
|
+
var NEXRAD_LEVEL3_VELOCITY_PRODUCTS = [
|
|
125
|
+
"NXG",
|
|
126
|
+
"NYG",
|
|
127
|
+
"NZG",
|
|
128
|
+
"N0G",
|
|
129
|
+
"NAG",
|
|
130
|
+
"N1G",
|
|
131
|
+
"NBG",
|
|
132
|
+
"N2G",
|
|
133
|
+
"N3G"
|
|
134
|
+
];
|
|
135
|
+
var NEXRAD_LEVEL3_VELOCITY_PRODUCTS_FOR_MANIFEST = NEXRAD_LEVEL3_VELOCITY_PRODUCTS.slice(3);
|
|
136
|
+
var NEXRAD_LEVEL3_MANIFEST_TILT_COUNT = NEXRAD_LEVEL3_KDP_PRODUCTS_FOR_MANIFEST.length;
|
|
137
|
+
function getNexradLevel3RadarTiltsForVelocity(siteId) {
|
|
138
|
+
return getRadarTilts(siteId, "VEL").slice(0, NEXRAD_LEVEL3_MANIFEST_TILT_COUNT);
|
|
139
|
+
}
|
|
140
|
+
function nexradLevel3S3VelocityProductForSiteTilt(siteId, tilt) {
|
|
141
|
+
const products = NEXRAD_LEVEL3_VELOCITY_PRODUCTS_FOR_MANIFEST;
|
|
142
|
+
const tilts = getNexradLevel3RadarTiltsForVelocity(siteId);
|
|
143
|
+
if (!tilts.length) {
|
|
144
|
+
return products[0];
|
|
145
|
+
}
|
|
146
|
+
const clamped = clampNexradTiltForVariable(siteId, "VEL", tilt);
|
|
147
|
+
let idx = tilts.indexOf(clamped);
|
|
148
|
+
if (idx === -1) {
|
|
149
|
+
idx = tilts.reduce(
|
|
150
|
+
(bestI, t, i) => Math.abs(t - clamped) < Math.abs(tilts[bestI] - clamped) ? i : bestI,
|
|
151
|
+
0
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
idx = Math.min(idx, products.length - 1);
|
|
155
|
+
return products[idx];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/nexrad/nexradMapboxFrameOpts.ts
|
|
159
|
+
var NEXRAD_LEVEL3_KDP_PRODUCTS_FOR_MANIFEST2 = [
|
|
160
|
+
"N0K",
|
|
161
|
+
"NAK",
|
|
162
|
+
"N1K",
|
|
163
|
+
"NBK",
|
|
164
|
+
"N2K",
|
|
165
|
+
"N3K"
|
|
166
|
+
];
|
|
167
|
+
var NEXRAD_LEVEL3_DHC_PRODUCTS_FOR_MANIFEST2 = [
|
|
168
|
+
"N0H",
|
|
169
|
+
"NAH",
|
|
170
|
+
"N1H",
|
|
171
|
+
"NBH",
|
|
172
|
+
"N2H",
|
|
173
|
+
"N3H"
|
|
174
|
+
];
|
|
175
|
+
var NEXRAD_LEVEL3_MANIFEST_TILT_COUNT2 = NEXRAD_LEVEL3_KDP_PRODUCTS_FOR_MANIFEST2.length;
|
|
176
|
+
function nearestTiltInSortedList(tilts, target) {
|
|
177
|
+
if (!tilts.length) return target;
|
|
178
|
+
let best = tilts[0];
|
|
179
|
+
let bestD = Math.abs(best - target);
|
|
180
|
+
for (let i = 1; i < tilts.length; i++) {
|
|
181
|
+
const t = tilts[i];
|
|
182
|
+
const d = Math.abs(t - target);
|
|
183
|
+
if (d < bestD || d === bestD && t < best) {
|
|
184
|
+
best = t;
|
|
185
|
+
bestD = d;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return best;
|
|
189
|
+
}
|
|
190
|
+
function getNexradLevel3RadarTilts(siteId, radarVariable) {
|
|
191
|
+
return getRadarTilts2(siteId, radarVariable).slice(0, NEXRAD_LEVEL3_MANIFEST_TILT_COUNT2);
|
|
192
|
+
}
|
|
193
|
+
function nexradLevel3UsesTiltIndexedS3Products(radarVariable) {
|
|
194
|
+
const v = radarVariable || "";
|
|
195
|
+
return v === "KDP" || v === "N0H";
|
|
196
|
+
}
|
|
197
|
+
function clampTiltForLevel3CompositeKey(siteId, radarVariable, tilt) {
|
|
198
|
+
if (!nexradLevel3UsesTiltIndexedS3Products(radarVariable)) {
|
|
199
|
+
return clampNexradTiltForVariable2(siteId, radarVariable, tilt);
|
|
200
|
+
}
|
|
201
|
+
const tilts = getNexradLevel3RadarTilts(siteId, radarVariable);
|
|
202
|
+
const c = clampNexradTiltForVariable2(siteId, radarVariable, tilt);
|
|
203
|
+
if (!tilts.length) return c;
|
|
204
|
+
return nearestTiltInSortedList(tilts, c);
|
|
205
|
+
}
|
|
206
|
+
function nexradLevel3S3ProductForSiteTilt(siteId, radarVariable, tilt) {
|
|
207
|
+
const products = radarVariable === "KDP" ? NEXRAD_LEVEL3_KDP_PRODUCTS_FOR_MANIFEST2 : NEXRAD_LEVEL3_DHC_PRODUCTS_FOR_MANIFEST2;
|
|
208
|
+
const tilts = getNexradLevel3RadarTilts(siteId, radarVariable);
|
|
209
|
+
if (!tilts.length) {
|
|
210
|
+
return products[0];
|
|
211
|
+
}
|
|
212
|
+
const clamped = clampTiltForLevel3CompositeKey(siteId, radarVariable, tilt);
|
|
213
|
+
let idx = tilts.indexOf(clamped);
|
|
214
|
+
if (idx === -1) {
|
|
215
|
+
idx = tilts.reduce(
|
|
216
|
+
(bestI, t, i) => Math.abs(t - clamped) < Math.abs(tilts[bestI] - clamped) ? i : bestI,
|
|
217
|
+
0
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
idx = Math.min(idx, products.length - 1);
|
|
221
|
+
return products[idx];
|
|
222
|
+
}
|
|
223
|
+
function mapboxFrameUploadOptionsForNexradState(state) {
|
|
224
|
+
if (!state || state.nexradDataSource !== "level3") return void 0;
|
|
225
|
+
const site = state.nexradSite;
|
|
226
|
+
const radarVar = (state.nexradProduct || "REF").toUpperCase();
|
|
227
|
+
if (nexradLevel3UsesTiltIndexedS3Products(radarVar) && site) {
|
|
228
|
+
const tilt = Number.isFinite(state.nexradTilt) ? Number(state.nexradTilt) : getDefaultRadarTilt2(site);
|
|
229
|
+
const kind = radarVar === "KDP" ? "KDP" : "N0H";
|
|
230
|
+
const mnemonic = nexradLevel3S3ProductForSiteTilt(site, kind, tilt);
|
|
231
|
+
return { geometryLayoutKey: `${site}|${radarVar}|${mnemonic}` };
|
|
232
|
+
}
|
|
233
|
+
if (radarVar === "VEL" && site) {
|
|
234
|
+
const tilt = Number.isFinite(state.nexradTilt) ? Number(state.nexradTilt) : getDefaultRadarTilt2(site);
|
|
235
|
+
const mnemonic = nexradLevel3S3VelocityProductForSiteTilt(site, tilt);
|
|
236
|
+
return { geometryLayoutKey: `${site}|${radarVar}|${mnemonic}` };
|
|
237
|
+
}
|
|
238
|
+
return { geometryCacheKeysRayBoundaries: true };
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
mapboxFrameUploadOptionsForNexradState,
|
|
242
|
+
nexradLevel3S3ProductForSiteTilt,
|
|
243
|
+
nexradLevel3UsesTiltIndexedS3Products
|
|
244
|
+
};
|