@aguacerowx/javascript-sdk 0.0.27 → 0.0.28

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.
@@ -1,5 +1,5 @@
1
- export function spawnGridDecodeWorker() {
2
- return new Worker(new URL('./gridDecodeWorker.js', import.meta.url), {
3
- type: 'module',
4
- });
5
- }
1
+ export function spawnGridDecodeWorker() {
2
+ return new Worker(new URL('./gridDecodeWorker.js', import.meta.url), {
3
+ type: 'module',
4
+ });
5
+ }
@@ -1,103 +1,103 @@
1
- /**
2
- * A utility module for converting between different physical units.
3
- * Contains a comprehensive object of conversion functions and a helper
4
- * to retrieve the correct function based on unit names.
5
- */
6
-
7
- // The main object containing all the raw conversion functions.
8
- export const unitConversions = {
9
- kelvin_to_celsius: (data) => data - 273.15,
10
- kelvin_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
11
- kelvin_to_c: (data) => data - 273.15,
12
- kelvin_to_f: (data) => (data - 273.15) * 9/5 + 32,
13
- k_to_celsius: (data) => data - 273.15,
14
- k_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
15
- k_to_c: (data) => data - 273.15,
16
- k_to_f: (data) => (data - 273.15) * 9/5 + 32,
17
- celsius_to_fahrenheit: (data) => (data * 9/5) + 32,
18
- celsius_to_f: (data) => (data * 9/5) + 32,
19
- c_to_fahrenheit: (data) => (data * 9/5) + 32,
20
- c_to_f: (data) => (data * 9/5) + 32,
21
- fahrenheit_to_celsius: (data) => (data - 32) * 5/9,
22
- fahrenheit_to_c: (data) => (data - 32) * 5/9,
23
- f_to_celsius: (data) => (data - 32) * 5/9,
24
- f_to_c: (data) => (data - 32) * 5/9,
25
- meters_to_feet: (data) => data * 3.28084,
26
- meters_to_km: (data) => data / 1000,
27
- m_to_feet: (data) => data * 3.28084,
28
- m_to_ft: (data) => data * 3.28084,
29
- m_to_km: (data) => data / 1000,
30
- kts_to_mph: (data) => data * 1.15078,
31
- mph_to_kts: (data) => data / 1.15078,
32
- kts_to_ms: (data) => data / 1.94384449,
33
- mph_to_ms: (data) => data / 2.23693629,
34
- ms_to_mph: (data) => data * 2.23694,
35
- ms_to_kts: (data) => data * 1.94384,
36
- kts_to_kmh: (data) => data * 1.852,
37
- mph_to_kmh: (data) => data * 1.60934,
38
- ms_to_kmh: (data) => data * 3.6,
39
- kmh_to_kts: (data) => data / 1.852,
40
- kmh_to_mph: (data) => data / 1.60934,
41
- kmh_to_ms: (data) => data / 3.6,
42
- inches_to_mm: (data) => data * 25.4,
43
- inches_to_cm: (data) => data * 2.54,
44
- in_to_mm: (data) => data * 25.4,
45
- in_to_cm: (data) => data * 2.54,
46
- mm_to_in: (data) => data / 25.4,
47
- mm_to_inches: (data) => data / 25.4,
48
- cm_to_in: (data) => data / 2.54,
49
- cm_to_inches: (data) => data / 2.54,
50
- inhr_to_mmhr: (data) => data * 25.4,
51
- inhr_to_cmhr: (data) => data * 2.54,
52
- in_hr_to_mm_hr: (data) => data * 25.4,
53
- in_hr_to_cm_hr: (data) => data * 2.54,
54
- mmhr_to_inhr: (data) => data / 25.4,
55
- cmhr_to_inhr: (data) => data / 2.54,
56
- mm_hr_to_in_hr: (data) => data / 25.4,
57
- cm_hr_to_in_hr: (data) => data / 2.54,
58
- mmhr_to_cmhr: (data) => data / 10,
59
- cmhr_to_mmhr: (data) => data * 10,
60
- mm_hr_to_cm_hr: (data) => data / 10,
61
- cm_hr_to_mm_hr: (data) => data * 10
62
- };
63
-
64
- /**
65
- * Finds and returns the correct conversion function based on "from" and "to" unit strings.
66
- * It normalizes common unit abbreviations to a consistent key.
67
- * @param {string} fromUnit - The starting unit (e.g., 'kelvin', '°C', 'kts').
68
- * @param {string} toUnit - The target unit (e.g., 'fahrenheit', '°F', 'mph').
69
- * @returns {function(number): number | null} The conversion function, or null if not found.
70
- */
71
- export function getUnitConversionFunction(fromUnit, toUnit) {
72
- // A map to standardize various unit string formats to a single key format.
73
- const unitMap = {
74
- '°c': 'c', '°f': 'f', '°k': 'k',
75
- 'celsius': 'c', 'fahrenheit': 'f', 'kelvin': 'k',
76
- 'c': 'c', 'f': 'f', 'k': 'k', '°F': 'f', '°C': 'c',
77
- 'kts': 'kts', 'm/s': 'ms', 'mph': 'mph', 'km/h': 'kmh',
78
- 'knots': 'kts',
79
- 'ft': 'ft', 'feet': 'ft',
80
- 'km': 'km',
81
- 'mm': 'mm',
82
- 'cm': 'cm',
83
- 'm': 'm', 'meters': 'm',
84
- 'in/hr': 'inhr', 'mm/hr': 'mmhr', 'cm/hr': 'cmhr',
85
- 'in': 'in', 'inches': 'in'
86
- };
87
-
88
- // Cleans and standardizes the input unit string.
89
- const normalizeUnit = (unit) => {
90
- if (!unit) return '';
91
- const lowerUnit = unit.toLowerCase().trim();
92
- return unitMap[lowerUnit] || lowerUnit;
93
- };
94
-
95
- const fromNormalized = normalizeUnit(fromUnit);
96
- const toNormalized = normalizeUnit(toUnit);
97
-
98
- // Constructs the key to look up in the `unitConversions` object (e.g., 'k_to_f').
99
- const conversionKey = `${fromNormalized}_to_${toNormalized}`;
100
-
101
- // Return the function if it exists, otherwise return null.
102
- return unitConversions[conversionKey] || null;
1
+ /**
2
+ * A utility module for converting between different physical units.
3
+ * Contains a comprehensive object of conversion functions and a helper
4
+ * to retrieve the correct function based on unit names.
5
+ */
6
+
7
+ // The main object containing all the raw conversion functions.
8
+ export const unitConversions = {
9
+ kelvin_to_celsius: (data) => data - 273.15,
10
+ kelvin_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
11
+ kelvin_to_c: (data) => data - 273.15,
12
+ kelvin_to_f: (data) => (data - 273.15) * 9/5 + 32,
13
+ k_to_celsius: (data) => data - 273.15,
14
+ k_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
15
+ k_to_c: (data) => data - 273.15,
16
+ k_to_f: (data) => (data - 273.15) * 9/5 + 32,
17
+ celsius_to_fahrenheit: (data) => (data * 9/5) + 32,
18
+ celsius_to_f: (data) => (data * 9/5) + 32,
19
+ c_to_fahrenheit: (data) => (data * 9/5) + 32,
20
+ c_to_f: (data) => (data * 9/5) + 32,
21
+ fahrenheit_to_celsius: (data) => (data - 32) * 5/9,
22
+ fahrenheit_to_c: (data) => (data - 32) * 5/9,
23
+ f_to_celsius: (data) => (data - 32) * 5/9,
24
+ f_to_c: (data) => (data - 32) * 5/9,
25
+ meters_to_feet: (data) => data * 3.28084,
26
+ meters_to_km: (data) => data / 1000,
27
+ m_to_feet: (data) => data * 3.28084,
28
+ m_to_ft: (data) => data * 3.28084,
29
+ m_to_km: (data) => data / 1000,
30
+ kts_to_mph: (data) => data * 1.15078,
31
+ mph_to_kts: (data) => data / 1.15078,
32
+ kts_to_ms: (data) => data / 1.94384449,
33
+ mph_to_ms: (data) => data / 2.23693629,
34
+ ms_to_mph: (data) => data * 2.23694,
35
+ ms_to_kts: (data) => data * 1.94384,
36
+ kts_to_kmh: (data) => data * 1.852,
37
+ mph_to_kmh: (data) => data * 1.60934,
38
+ ms_to_kmh: (data) => data * 3.6,
39
+ kmh_to_kts: (data) => data / 1.852,
40
+ kmh_to_mph: (data) => data / 1.60934,
41
+ kmh_to_ms: (data) => data / 3.6,
42
+ inches_to_mm: (data) => data * 25.4,
43
+ inches_to_cm: (data) => data * 2.54,
44
+ in_to_mm: (data) => data * 25.4,
45
+ in_to_cm: (data) => data * 2.54,
46
+ mm_to_in: (data) => data / 25.4,
47
+ mm_to_inches: (data) => data / 25.4,
48
+ cm_to_in: (data) => data / 2.54,
49
+ cm_to_inches: (data) => data / 2.54,
50
+ inhr_to_mmhr: (data) => data * 25.4,
51
+ inhr_to_cmhr: (data) => data * 2.54,
52
+ in_hr_to_mm_hr: (data) => data * 25.4,
53
+ in_hr_to_cm_hr: (data) => data * 2.54,
54
+ mmhr_to_inhr: (data) => data / 25.4,
55
+ cmhr_to_inhr: (data) => data / 2.54,
56
+ mm_hr_to_in_hr: (data) => data / 25.4,
57
+ cm_hr_to_in_hr: (data) => data / 2.54,
58
+ mmhr_to_cmhr: (data) => data / 10,
59
+ cmhr_to_mmhr: (data) => data * 10,
60
+ mm_hr_to_cm_hr: (data) => data / 10,
61
+ cm_hr_to_mm_hr: (data) => data * 10
62
+ };
63
+
64
+ /**
65
+ * Finds and returns the correct conversion function based on "from" and "to" unit strings.
66
+ * It normalizes common unit abbreviations to a consistent key.
67
+ * @param {string} fromUnit - The starting unit (e.g., 'kelvin', '°C', 'kts').
68
+ * @param {string} toUnit - The target unit (e.g., 'fahrenheit', '°F', 'mph').
69
+ * @returns {function(number): number | null} The conversion function, or null if not found.
70
+ */
71
+ export function getUnitConversionFunction(fromUnit, toUnit) {
72
+ // A map to standardize various unit string formats to a single key format.
73
+ const unitMap = {
74
+ '°c': 'c', '°f': 'f', '°k': 'k',
75
+ 'celsius': 'c', 'fahrenheit': 'f', 'kelvin': 'k',
76
+ 'c': 'c', 'f': 'f', 'k': 'k', '°F': 'f', '°C': 'c',
77
+ 'kts': 'kts', 'm/s': 'ms', 'mph': 'mph', 'km/h': 'kmh',
78
+ 'knots': 'kts',
79
+ 'ft': 'ft', 'feet': 'ft',
80
+ 'km': 'km',
81
+ 'mm': 'mm',
82
+ 'cm': 'cm',
83
+ 'm': 'm', 'meters': 'm',
84
+ 'in/hr': 'inhr', 'mm/hr': 'mmhr', 'cm/hr': 'cmhr',
85
+ 'in': 'in', 'inches': 'in'
86
+ };
87
+
88
+ // Cleans and standardizes the input unit string.
89
+ const normalizeUnit = (unit) => {
90
+ if (!unit) return '';
91
+ const lowerUnit = unit.toLowerCase().trim();
92
+ return unitMap[lowerUnit] || lowerUnit;
93
+ };
94
+
95
+ const fromNormalized = normalizeUnit(fromUnit);
96
+ const toNormalized = normalizeUnit(toUnit);
97
+
98
+ // Constructs the key to look up in the `unitConversions` object (e.g., 'k_to_f').
99
+ const conversionKey = `${fromNormalized}_to_${toNormalized}`;
100
+
101
+ // Return the function if it exists, otherwise return null.
102
+ return unitConversions[conversionKey] || null;
103
103
  }
@@ -1,18 +0,0 @@
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;
@@ -1,37 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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
- };
@@ -1,95 +0,0 @@
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
- }
@@ -1,129 +0,0 @@
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
- }
@@ -1,56 +0,0 @@
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
- }