@aguacerowx/react-native 0.0.52 → 0.0.54

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.
Files changed (265) hide show
  1. package/LICENSE +21 -0
  2. package/android/src/main/cpp/satellite_ktx_jni.cpp +6 -1
  3. package/android/src/main/java/com/aguacerowx/reactnative/NexradRadarLayerView.java +14 -2
  4. package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayer.java +121 -1
  5. package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayerView.java +556 -392
  6. package/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +77 -0
  7. package/index.js +1 -1
  8. package/ios/SatelliteLayerView.swift +517 -517
  9. package/ios/WeatherFrameProcessorModule.m +19 -15
  10. package/ios/WeatherFrameProcessorModule.swift +65 -0
  11. package/lib/commonjs/AguaceroContext.js +0 -4
  12. package/lib/commonjs/AguaceroContext.js.map +1 -1
  13. package/lib/commonjs/GridRenderLayer.js +62 -76
  14. package/lib/commonjs/GridRenderLayer.js.map +1 -1
  15. package/lib/commonjs/MapManager.js +110 -224
  16. package/lib/commonjs/MapManager.js.map +1 -1
  17. package/lib/commonjs/MapRegistry.js +21 -33
  18. package/lib/commonjs/MapRegistry.js.map +1 -1
  19. package/lib/commonjs/NexradRadarLayer.android.js +28 -100
  20. package/lib/commonjs/NexradRadarLayer.android.js.map +1 -1
  21. package/lib/commonjs/NexradRadarLayer.ios.js +26 -97
  22. package/lib/commonjs/NexradRadarLayer.ios.js.map +1 -1
  23. package/lib/commonjs/NexradSitesMapLayer.js +41 -61
  24. package/lib/commonjs/NexradSitesMapLayer.js.map +1 -1
  25. package/lib/commonjs/SatelliteLayer.android.js +26 -38
  26. package/lib/commonjs/SatelliteLayer.android.js.map +1 -1
  27. package/lib/commonjs/SatelliteLayer.ios.js +30 -42
  28. package/lib/commonjs/SatelliteLayer.ios.js.map +1 -1
  29. package/lib/commonjs/StyleApplicator.js +129 -175
  30. package/lib/commonjs/StyleApplicator.js.map +1 -1
  31. package/lib/commonjs/WeatherLayerManager.js +996 -1627
  32. package/lib/commonjs/WeatherLayerManager.js.map +1 -1
  33. package/lib/commonjs/aguaceroCoreDebugHooks.js +58 -130
  34. package/lib/commonjs/aguaceroCoreDebugHooks.js.map +1 -1
  35. package/lib/commonjs/aguaceroRnDebug.js +147 -287
  36. package/lib/commonjs/aguaceroRnDebug.js.map +1 -1
  37. package/lib/commonjs/cdnAuthenticatedFetch.js +104 -0
  38. package/lib/commonjs/cdnAuthenticatedFetch.js.map +1 -0
  39. package/lib/commonjs/dispatchViewManagerCommandCompat.js +51 -88
  40. package/lib/commonjs/dispatchViewManagerCommandCompat.js.map +1 -1
  41. package/lib/commonjs/gridCdnAuth.js +41 -50
  42. package/lib/commonjs/gridCdnAuth.js.map +1 -1
  43. package/lib/commonjs/index.js +51 -0
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/commonjs/nexrad/nexradAndroidController.js +851 -863
  46. package/lib/commonjs/nexrad/nexradAndroidController.js.map +1 -1
  47. package/lib/commonjs/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +62 -85
  48. package/lib/commonjs/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js.map +1 -1
  49. package/lib/commonjs/nexrad/nexradDiag.js +32 -148
  50. package/lib/commonjs/nexrad/nexradDiag.js.map +1 -1
  51. package/lib/commonjs/nexrad/nexradLevel2Keys.js +261 -0
  52. package/lib/commonjs/nexrad/nexradLevel2Keys.js.map +1 -0
  53. package/lib/commonjs/nexrad/nexradLutBuild.js +64 -111
  54. package/lib/commonjs/nexrad/nexradLutBuild.js.map +1 -1
  55. package/lib/commonjs/nexrad/nexradMapboxFrameOpts.bundled.js +136 -164
  56. package/lib/commonjs/nexrad/nexradMapboxFrameOpts.bundled.js.map +1 -1
  57. package/lib/commonjs/nexrad/nexradSdkImports.js +51 -0
  58. package/lib/commonjs/nexrad/nexradSdkImports.js.map +1 -0
  59. package/lib/commonjs/nexrad/radarArchiveCore.bundled.js +2848 -4455
  60. package/lib/commonjs/nexrad/radarArchiveCore.bundled.js.map +1 -1
  61. package/lib/commonjs/nexrad/radarDecode.worker.bundled.js +445 -648
  62. package/lib/commonjs/nexrad/radarDecode.worker.bundled.js.map +1 -1
  63. package/lib/commonjs/nexrad/radarFrameGpuMatch.bundled.js +52 -68
  64. package/lib/commonjs/nexrad/radarFrameGpuMatch.bundled.js.map +1 -1
  65. package/lib/commonjs/nexradNativeCommandIds.js +24 -0
  66. package/lib/commonjs/nexradNativeCommandIds.js.map +1 -0
  67. package/lib/commonjs/nws/NwsAlertsOverlay.android.js.map +1 -1
  68. package/lib/commonjs/nws/NwsAlertsOverlay.ios.js.map +1 -1
  69. package/lib/commonjs/nws/NwsAlertsOverlay.js +3 -3
  70. package/lib/commonjs/nws/NwsAlertsOverlay.js.map +1 -1
  71. package/lib/commonjs/nws/NwsAlertsOverlay.native.js +235 -361
  72. package/lib/commonjs/nws/NwsAlertsOverlay.native.js.map +1 -1
  73. package/lib/commonjs/nws/eventSourceRnPolyfill.js +92 -146
  74. package/lib/commonjs/nws/eventSourceRnPolyfill.js.map +1 -1
  75. package/lib/commonjs/nws/nwsAndroidConstants.js +2 -8
  76. package/lib/commonjs/nws/nwsAndroidConstants.js.map +1 -1
  77. package/lib/commonjs/satellite/satelliteAndroidController.js +122 -199
  78. package/lib/commonjs/satellite/satelliteAndroidController.js.map +1 -1
  79. package/lib/commonjs/satelliteBridgeDiag.js +3 -13
  80. package/lib/commonjs/satelliteBridgeDiag.js.map +1 -1
  81. package/lib/commonjs/satelliteRnDebug.js +160 -0
  82. package/lib/commonjs/satelliteRnDebug.js.map +1 -0
  83. package/lib/module/AguaceroContext.js +2 -7
  84. package/lib/module/AguaceroContext.js.map +1 -1
  85. package/lib/module/GridRenderLayer.js +66 -80
  86. package/lib/module/GridRenderLayer.js.map +1 -1
  87. package/lib/module/MapManager.js +125 -239
  88. package/lib/module/MapManager.js.map +1 -1
  89. package/lib/module/MapRegistry.js +21 -33
  90. package/lib/module/MapRegistry.js.map +1 -1
  91. package/lib/module/NexradRadarLayer.android.js +32 -104
  92. package/lib/module/NexradRadarLayer.android.js.map +1 -1
  93. package/lib/module/NexradRadarLayer.ios.js +30 -101
  94. package/lib/module/NexradRadarLayer.ios.js.map +1 -1
  95. package/lib/module/NexradSitesMapLayer.js +44 -63
  96. package/lib/module/NexradSitesMapLayer.js.map +1 -1
  97. package/lib/module/SatelliteLayer.android.js +32 -44
  98. package/lib/module/SatelliteLayer.android.js.map +1 -1
  99. package/lib/module/SatelliteLayer.ios.js +36 -48
  100. package/lib/module/SatelliteLayer.ios.js.map +1 -1
  101. package/lib/module/StyleApplicator.js +144 -191
  102. package/lib/module/StyleApplicator.js.map +1 -1
  103. package/lib/module/WeatherLayerManager.js +1024 -1655
  104. package/lib/module/WeatherLayerManager.js.map +1 -1
  105. package/lib/module/aguaceroCoreDebugHooks.js +59 -130
  106. package/lib/module/aguaceroCoreDebugHooks.js.map +1 -1
  107. package/lib/module/aguaceroRnDebug.js +151 -291
  108. package/lib/module/aguaceroRnDebug.js.map +1 -1
  109. package/lib/module/cdnAuthenticatedFetch.js +97 -0
  110. package/lib/module/cdnAuthenticatedFetch.js.map +1 -0
  111. package/lib/module/dispatchViewManagerCommandCompat.js +52 -90
  112. package/lib/module/dispatchViewManagerCommandCompat.js.map +1 -1
  113. package/lib/module/gridCdnAuth.js +38 -50
  114. package/lib/module/gridCdnAuth.js.map +1 -1
  115. package/lib/module/index.js +9 -6
  116. package/lib/module/index.js.map +1 -1
  117. package/lib/module/nexrad/nexradAndroidController.js +865 -876
  118. package/lib/module/nexrad/nexradAndroidController.js.map +1 -1
  119. package/lib/module/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +62 -85
  120. package/lib/module/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js.map +1 -1
  121. package/lib/module/nexrad/nexradDiag.js +31 -145
  122. package/lib/module/nexrad/nexradDiag.js.map +1 -1
  123. package/lib/module/nexrad/nexradLevel2Keys.js +245 -0
  124. package/lib/module/nexrad/nexradLevel2Keys.js.map +1 -0
  125. package/lib/module/nexrad/nexradLutBuild.js +64 -110
  126. package/lib/module/nexrad/nexradLutBuild.js.map +1 -1
  127. package/lib/module/nexrad/nexradMapboxFrameOpts.bundled.js +136 -163
  128. package/lib/module/nexrad/nexradMapboxFrameOpts.bundled.js.map +1 -1
  129. package/lib/module/nexrad/nexradSdkImports.js +4 -0
  130. package/lib/module/nexrad/nexradSdkImports.js.map +1 -0
  131. package/lib/module/nexrad/radarArchiveCore.bundled.js +2839 -4448
  132. package/lib/module/nexrad/radarArchiveCore.bundled.js.map +1 -1
  133. package/lib/module/nexrad/radarDecode.worker.bundled.js +445 -648
  134. package/lib/module/nexrad/radarDecode.worker.bundled.js.map +1 -1
  135. package/lib/module/nexrad/radarFrameGpuMatch.bundled.js +50 -66
  136. package/lib/module/nexrad/radarFrameGpuMatch.bundled.js.map +1 -1
  137. package/lib/module/nexradNativeCommandIds.js +18 -0
  138. package/lib/module/nexradNativeCommandIds.js.map +1 -0
  139. package/lib/module/nws/NwsAlertsOverlay.android.js +1 -1
  140. package/lib/module/nws/NwsAlertsOverlay.android.js.map +1 -1
  141. package/lib/module/nws/NwsAlertsOverlay.ios.js +1 -1
  142. package/lib/module/nws/NwsAlertsOverlay.ios.js.map +1 -1
  143. package/lib/module/nws/NwsAlertsOverlay.js +5 -5
  144. package/lib/module/nws/NwsAlertsOverlay.js.map +1 -1
  145. package/lib/module/nws/NwsAlertsOverlay.native.js +248 -373
  146. package/lib/module/nws/NwsAlertsOverlay.native.js.map +1 -1
  147. package/lib/module/nws/eventSourceRnPolyfill.js +92 -146
  148. package/lib/module/nws/eventSourceRnPolyfill.js.map +1 -1
  149. package/lib/module/nws/nwsAndroidConstants.js +2 -8
  150. package/lib/module/nws/nwsAndroidConstants.js.map +1 -1
  151. package/lib/module/satellite/satelliteAndroidController.js +125 -202
  152. package/lib/module/satellite/satelliteAndroidController.js.map +1 -1
  153. package/lib/module/satelliteBridgeDiag.js +3 -13
  154. package/lib/module/satelliteBridgeDiag.js.map +1 -1
  155. package/lib/module/satelliteRnDebug.js +148 -0
  156. package/lib/module/satelliteRnDebug.js.map +1 -0
  157. package/lib/typescript/AguaceroContext.d.ts +0 -4
  158. package/lib/typescript/AguaceroContext.d.ts.map +1 -1
  159. package/lib/typescript/GridRenderLayer.d.ts.map +1 -1
  160. package/lib/typescript/MapManager.d.ts +0 -12
  161. package/lib/typescript/MapManager.d.ts.map +1 -1
  162. package/lib/typescript/MapRegistry.d.ts +10 -12
  163. package/lib/typescript/MapRegistry.d.ts.map +1 -1
  164. package/lib/typescript/NexradRadarLayer.android.d.ts.map +1 -1
  165. package/lib/typescript/NexradRadarLayer.ios.d.ts.map +1 -1
  166. package/lib/typescript/NexradSitesMapLayer.d.ts +4 -10
  167. package/lib/typescript/NexradSitesMapLayer.d.ts.map +1 -1
  168. package/lib/typescript/SatelliteLayer.android.d.ts.map +1 -1
  169. package/lib/typescript/SatelliteLayer.ios.d.ts.map +1 -1
  170. package/lib/typescript/StyleApplicator.d.ts +1 -1
  171. package/lib/typescript/StyleApplicator.d.ts.map +1 -1
  172. package/lib/typescript/WeatherLayerManager.d.ts.map +1 -1
  173. package/lib/typescript/aguaceroCoreDebugHooks.d.ts +2 -9
  174. package/lib/typescript/aguaceroCoreDebugHooks.d.ts.map +1 -1
  175. package/lib/typescript/aguaceroRnDebug.d.ts +47 -66
  176. package/lib/typescript/aguaceroRnDebug.d.ts.map +1 -1
  177. package/lib/typescript/cdnAuthenticatedFetch.d.ts +10 -0
  178. package/lib/typescript/cdnAuthenticatedFetch.d.ts.map +1 -0
  179. package/lib/typescript/dispatchViewManagerCommandCompat.d.ts +1 -17
  180. package/lib/typescript/dispatchViewManagerCommandCompat.d.ts.map +1 -1
  181. package/lib/typescript/gridCdnAuth.d.ts +16 -21
  182. package/lib/typescript/gridCdnAuth.d.ts.map +1 -1
  183. package/lib/typescript/index.d.ts +2 -0
  184. package/lib/typescript/nexrad/nexradAndroidController.d.ts +39 -89
  185. package/lib/typescript/nexrad/nexradAndroidController.d.ts.map +1 -1
  186. package/lib/typescript/nexrad/nexradCrossSectionSampleAtLatLon.bundled.d.ts +2 -1
  187. package/lib/typescript/nexrad/nexradCrossSectionSampleAtLatLon.bundled.d.ts.map +1 -1
  188. package/lib/typescript/nexrad/nexradDiag.d.ts +13 -101
  189. package/lib/typescript/nexrad/nexradDiag.d.ts.map +1 -1
  190. package/lib/typescript/nexrad/nexradLevel2Keys.d.ts +36 -0
  191. package/lib/typescript/nexrad/nexradLevel2Keys.d.ts.map +1 -0
  192. package/lib/typescript/nexrad/nexradLutBuild.d.ts +3 -10
  193. package/lib/typescript/nexrad/nexradLutBuild.d.ts.map +1 -1
  194. package/lib/typescript/nexrad/nexradMapboxFrameOpts.bundled.d.ts +4 -3
  195. package/lib/typescript/nexrad/nexradMapboxFrameOpts.bundled.d.ts.map +1 -1
  196. package/lib/typescript/nexrad/nexradSdkImports.d.ts +2 -0
  197. package/lib/typescript/nexrad/nexradSdkImports.d.ts.map +1 -0
  198. package/lib/typescript/nexrad/radarArchiveCore.bundled.d.ts +12 -7
  199. package/lib/typescript/nexrad/radarArchiveCore.bundled.d.ts.map +1 -1
  200. package/lib/typescript/nexrad/radarDecode.worker.bundled.d.ts +20 -20
  201. package/lib/typescript/nexrad/radarDecode.worker.bundled.d.ts.map +1 -1
  202. package/lib/typescript/nexrad/radarFrameGpuMatch.bundled.d.ts +4 -3
  203. package/lib/typescript/nexrad/radarFrameGpuMatch.bundled.d.ts.map +1 -1
  204. package/lib/typescript/nexradNativeCommandIds.d.ts +2 -0
  205. package/lib/typescript/nexradNativeCommandIds.d.ts.map +1 -0
  206. package/lib/typescript/nws/NwsAlertsOverlay.native.d.ts +6 -17
  207. package/lib/typescript/nws/NwsAlertsOverlay.native.d.ts.map +1 -1
  208. package/lib/typescript/nws/eventSourceRnPolyfill.d.ts +0 -3
  209. package/lib/typescript/nws/eventSourceRnPolyfill.d.ts.map +1 -1
  210. package/lib/typescript/nws/nwsAndroidConstants.d.ts +0 -5
  211. package/lib/typescript/nws/nwsAndroidConstants.d.ts.map +1 -1
  212. package/lib/typescript/satellite/satelliteAndroidController.d.ts +9 -47
  213. package/lib/typescript/satellite/satelliteAndroidController.d.ts.map +1 -1
  214. package/lib/typescript/satelliteBridgeDiag.d.ts +1 -5
  215. package/lib/typescript/satelliteBridgeDiag.d.ts.map +1 -1
  216. package/lib/typescript/satelliteRnDebug.d.ts +75 -0
  217. package/lib/typescript/satelliteRnDebug.d.ts.map +1 -0
  218. package/package.json +75 -74
  219. package/src/AguaceroContext.js +1 -7
  220. package/src/GridRenderLayer.js +1 -128
  221. package/src/MapManager.js +1 -277
  222. package/src/MapRegistry.js +1 -56
  223. package/src/NexradRadarLayer.android.js +1 -121
  224. package/src/NexradRadarLayer.ios.js +1 -115
  225. package/src/NexradSitesMapLayer.js +1 -75
  226. package/src/SatelliteLayer.android.js +1 -63
  227. package/src/SatelliteLayer.ios.js +1 -70
  228. package/src/StyleApplicator.js +1 -241
  229. package/src/WeatherLayerManager.js +1 -2025
  230. package/src/aguaceroCoreDebugHooks.js +1 -142
  231. package/src/aguaceroRnDebug.js +1 -335
  232. package/src/cdnAuthenticatedFetch.js +1 -0
  233. package/src/dispatchViewManagerCommandCompat.js +1 -100
  234. package/src/gridCdnAuth.js +1 -56
  235. package/src/index.js +1 -19
  236. package/src/nexrad/nexradAndroidController.js +1 -1078
  237. package/src/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +1 -91
  238. package/src/nexrad/nexradDiag.js +1 -150
  239. package/src/nexrad/nexradLevel2Keys.js +1 -0
  240. package/src/nexrad/nexradLutBuild.js +1 -126
  241. package/src/nexrad/nexradMapboxFrameOpts.bundled.js +1 -245
  242. package/src/nexrad/nexradSdkImports.js +1 -0
  243. package/src/nexrad/radarArchiveCore.bundled.js +1 -7085
  244. package/src/nexrad/radarDecode.worker.bundled.js +1 -813
  245. package/src/nexrad/radarFrameGpuMatch.bundled.js +1 -79
  246. package/src/nexradNativeCommandIds.js +1 -0
  247. package/src/nws/NwsAlertsOverlay.android.js +1 -1
  248. package/src/nws/NwsAlertsOverlay.ios.js +1 -1
  249. package/src/nws/NwsAlertsOverlay.js +1 -7
  250. package/src/nws/NwsAlertsOverlay.native.js +1 -463
  251. package/src/nws/eventSourceRnPolyfill.js +7 -193
  252. package/src/nws/nwsAndroidConstants.js +1 -8
  253. package/src/satellite/satelliteAndroidController.js +1 -245
  254. package/src/satelliteBridgeDiag.js +1 -15
  255. package/src/satelliteRnDebug.js +1 -0
  256. package/lib/commonjs/nexrad/nexradNativeCommandIds.js +0 -51
  257. package/lib/commonjs/nexrad/nexradNativeCommandIds.js.map +0 -1
  258. package/lib/module/nexrad/nexradNativeCommandIds.js +0 -44
  259. package/lib/module/nexrad/nexradNativeCommandIds.js.map +0 -1
  260. package/lib/typescript/nexrad/nexradNativeCommandIds.d.ts +0 -9
  261. package/lib/typescript/nexrad/nexradNativeCommandIds.d.ts.map +0 -1
  262. package/src/nexrad/nexradNativeCommandIds.js +0 -44
  263. /package/lib/commonjs/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
  264. /package/lib/module/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
  265. /package/src/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
@@ -1,91 +1 @@
1
- function wrapAzimuthDeltaDeg(azDeg, azimuthBaseDeg) {
2
- let da = azDeg - azimuthBaseDeg;
3
- da -= Math.floor(da / 360) * 360;
4
- if (da < 0) da += 360;
5
- return da;
6
- }
7
- function snapGateCoord(t, nCells) {
8
- if (nCells <= 1) return 0;
9
- const idx = Math.floor(t * (nCells - 1) + 0.5);
10
- return idx / (nCells - 1);
11
- }
12
- function readGateRawSigned(frame, rayIdx, gateIdx) {
13
- if (rayIdx < 0 || gateIdx < 0 || rayIdx >= frame.nRays || gateIdx >= frame.nGates) return null;
14
- const byteOffset = (rayIdx * frame.nGates + gateIdx) * 2;
15
- const hi = frame.gateData[byteOffset];
16
- const lo = frame.gateData[byteOffset + 1];
17
- const raw = lo + hi * 256;
18
- const rawSigned = raw >= 32768 ? raw - 65536 : raw;
19
- if (rawSigned <= -32768) return null;
20
- return rawSigned;
21
- }
22
- function sampleGateRawBilinearDecoded(frame, gateX, gateY) {
23
- const w = frame.nGates;
24
- const h = frame.nRays;
25
- if (w < 1 || h < 1) return null;
26
- const gx = Math.min(1, Math.max(0, gateX));
27
- const gy = Math.min(1, Math.max(0, gateY));
28
- const sx = gx * Math.max(w - 1, 1);
29
- const sy = gy * Math.max(h - 1, 1);
30
- const i0 = Math.floor(sx);
31
- const j0 = Math.floor(sy);
32
- const i1 = Math.min(i0 + 1, w - 1);
33
- const j1 = Math.min(j0 + 1, h - 1);
34
- const fx = sx - i0;
35
- const fy = sy - j0;
36
- const w00 = (1 - fx) * (1 - fy);
37
- const w10 = fx * (1 - fy);
38
- const w01 = (1 - fx) * fy;
39
- const w11 = fx * fy;
40
- let acc = 0;
41
- let wsum = 0;
42
- const add = (r, wt) => {
43
- if (r !== null) {
44
- acc += r * wt;
45
- wsum += wt;
46
- }
47
- };
48
- add(readGateRawSigned(frame, j0, i0), w00);
49
- add(readGateRawSigned(frame, j0, i1), w10);
50
- add(readGateRawSigned(frame, j1, i0), w01);
51
- add(readGateRawSigned(frame, j1, i1), w11);
52
- if (wsum < 1e-6) return null;
53
- return acc / wsum;
54
- }
55
- function sampleNexradFrameAtLatLon(frame, lat, lon, options) {
56
- const DEG_TO_RAD = Math.PI / 180;
57
- const EARTH_RADIUS_M = 6378137;
58
- const dLatDeg = lat - frame.stationLat;
59
- const dLonDeg = lon - frame.stationLon;
60
- const cosLat = Math.max(Math.cos(lat * DEG_TO_RAD), 1e-6);
61
- const xM = dLonDeg * DEG_TO_RAD * EARTH_RADIUS_M * cosLat;
62
- const yM = dLatDeg * DEG_TO_RAD * EARTH_RADIUS_M;
63
- const rangeM = Math.hypot(xM, yM);
64
- const rangeKm = rangeM / 1e3;
65
- if (rangeKm < frame.firstGateKm) return null;
66
- const spanKm = frame.nGates * frame.gateWidthKm;
67
- if (!(spanKm > 0)) return null;
68
- const maxRangeKm = frame.firstGateKm + spanKm;
69
- if (rangeKm >= maxRangeKm) return null;
70
- let azDeg = Math.atan2(xM, yM) * (180 / Math.PI);
71
- if (azDeg < 0) azDeg += 360;
72
- const boundaries = frame.rayBoundariesDeg;
73
- const azimuthBaseDeg = boundaries.length > 0 ? Number(boundaries[0]) : 0;
74
- const da = wrapAzimuthDeltaDeg(azDeg, azimuthBaseDeg);
75
- let gateY = da / 360;
76
- gateY = Math.min(1, Math.max(0, gateY));
77
- let gateX = (rangeKm - frame.firstGateKm) / spanKm;
78
- gateX = Math.min(1, Math.max(0, gateX));
79
- const smoothPolar = options?.smoothPolar === true;
80
- if (!smoothPolar) {
81
- gateX = snapGateCoord(gateX, frame.nGates);
82
- gateY = snapGateCoord(gateY, frame.nRays);
83
- }
84
- const rawSigned = sampleGateRawBilinearDecoded(frame, gateX, gateY);
85
- if (rawSigned === null) return null;
86
- const physical = rawSigned * frame.valueScale + frame.valueOffset;
87
- return { value: physical, groundRangeKm: rangeKm };
88
- }
89
- export {
90
- sampleNexradFrameAtLatLon
91
- };
1
+ function p(a,t){let n=a-t;return n-=Math.floor(n/360)*360,n<0&&(n+=360),n}function v(a,t){return t<=1?0:Math.floor(a*(t-1)+.5)/(t-1)}function K(a,t,n){if(t<0||n<0||t>=a.nRays||n>=a.nGates)return null;const l=(t*a.nGates+n)*2,e=a.gateData[l],r=a.gateData[l+1]+e*256,M=r>=32768?r-65536:r;return M<=-32768?null:M}function w(a,t,n){const l=a.nGates,e=a.nRays;if(l<1||e<1)return null;const r=Math.min(1,Math.max(0,t)),M=Math.min(1,Math.max(0,n)),g=r*Math.max(l-1,1),G=M*Math.max(e-1,1),o=Math.floor(g),s=Math.floor(G),h=Math.min(o+1,l-1),f=Math.min(s+1,e-1),c=g-o,u=G-s,d=(1-c)*(1-u),R=c*(1-u),i=(1-c)*u,m=c*u;let x=0,D=0;const y=(L,P)=>{L!==null&&(x+=L*P,D+=P)};return y(K(a,s,o),d),y(K(a,s,h),R),y(K(a,f,o),i),y(K(a,f,h),m),D<1e-6?null:x/D}function A(a,t,n,l){const e=Math.PI/180,r=6378137,M=t-a.stationLat,g=n-a.stationLon,G=Math.max(Math.cos(t*e),1e-6),o=g*e*r*G,s=M*e*r,h=Math.hypot(o,s)/1e3;if(h<a.firstGateKm)return null;const f=a.nGates*a.gateWidthKm;if(!(f>0))return null;const c=a.firstGateKm+f;if(h>=c)return null;let u=Math.atan2(o,s)*(180/Math.PI);u<0&&(u+=360);const d=a.rayBoundariesDeg,R=d.length>0?Number(d[0]):0;let i=p(u,R)/360;i=Math.min(1,Math.max(0,i));let m=(h-a.firstGateKm)/f;m=Math.min(1,Math.max(0,m)),l?.smoothPolar===!0||(m=v(m,a.nGates),i=v(i,a.nRays));const x=w(a,m,i);return x===null?null:{value:x*a.valueScale+a.valueOffset,groundRangeKm:h}}export{A as sampleNexradFrameAtLatLon};
@@ -1,150 +1 @@
1
- /**
2
- * NEXRAD pipeline diagnostics (Android / Metro).
3
- *
4
- * Verbose phases / perf: off unless {@code global.__AGUACERO_NEXRAD_DEBUG = true}
5
- * (filter {@code [Aguacero][NEXRAD]} and {@code [Aguacero][NEXRAD][PERF]}).
6
- *
7
- * Legacy pipe line-by-line bridge logs: only if {@code global.__AGUACERO_NEXRAD_PIPE_TRACE = true}.
8
- */
9
-
10
- export function nexradDiagEnabled() {
11
- if (typeof globalThis !== 'undefined' && globalThis.__AGUACERO_NEXRAD_DEBUG === true) {
12
- return true;
13
- }
14
- if (typeof globalThis !== 'undefined' && globalThis.__AGUACERO_DEBUG__ === true) {
15
- return true;
16
- }
17
- return false;
18
- }
19
-
20
- /**
21
- * Opt-in only — line-by-line bridge logs.
22
- * @param {string} tag
23
- * @param {Record<string, unknown>} [detail]
24
- */
25
- export function nexradPipeTrace(tag, detail) {
26
- if (typeof globalThis === 'undefined' || globalThis.__AGUACERO_NEXRAD_PIPE_TRACE !== true) {
27
- return;
28
- }
29
- try {
30
- const msg =
31
- detail !== undefined && detail !== null && typeof detail === 'object'
32
- ? JSON.stringify(detail)
33
- : detail === undefined || detail === null
34
- ? ''
35
- : String(detail);
36
- console.warn(`[Aguacero][NEXRAD][PIPE] ${tag}`, msg);
37
- } catch {
38
- console.warn(`[Aguacero][NEXRAD][PIPE] ${tag}`, '(unserializable detail)');
39
- }
40
- }
41
-
42
- export function nexradDiag(phase, detail) {
43
- if (!nexradDiagEnabled()) return;
44
- if (detail !== undefined) {
45
- console.warn(`[Aguacero][NEXRAD] ${phase}`, detail);
46
- } else {
47
- console.warn(`[Aguacero][NEXRAD] ${phase}`);
48
- }
49
- }
50
-
51
- /**
52
- * @param {string} label
53
- * @returns {{ elapsedMs: () => number, end: (detail?: Record<string, unknown>) => number }}
54
- */
55
- export function nexradPerfSpan(label) {
56
- const hasPerf = typeof performance !== 'undefined' && typeof performance.now === 'function';
57
- const t0 = hasPerf ? performance.now() : Date.now();
58
- return {
59
- elapsedMs() {
60
- const t1 = hasPerf ? performance.now() : Date.now();
61
- return t1 - t0;
62
- },
63
- end(detail) {
64
- const msActual = hasPerf ? performance.now() - t0 : Date.now() - t0;
65
- if (!nexradDiagEnabled()) {
66
- return msActual;
67
- }
68
- const payload =
69
- detail !== undefined && detail !== null && typeof detail === 'object'
70
- ? { ms: msActual, ...detail }
71
- : { ms: msActual };
72
- console.warn(`[Aguacero][NEXRAD][PERF] ${label}`, payload);
73
- return msActual;
74
- },
75
- };
76
- }
77
-
78
- /**
79
- * @param {Record<string, unknown>} [extra]
80
- */
81
- export function nexradDiagBootSnapshot(extra = {}) {
82
- if (!nexradDiagEnabled()) return;
83
- const g = typeof globalThis !== 'undefined' ? globalThis : {};
84
- nexradDiag('boot.snapshot', {
85
- ...extra,
86
- workerType: typeof Worker,
87
- navigatorProduct: typeof navigator !== 'undefined' ? navigator.product : undefined,
88
- hermesInternal: typeof g.HermesInternal !== 'undefined',
89
- });
90
- }
91
-
92
- /**
93
- * @param {Uint8Array} gateData
94
- * @param {number} nGates
95
- * @param {number} nRays
96
- * @param {number} valueScale
97
- * @param {number} valueOffset
98
- * @param {number} lutMin
99
- * @param {number} lutMax
100
- */
101
- export function nexradDiagGateTextureSummary(gateData, nGates, nRays, valueScale, valueOffset, lutMin, lutMax) {
102
- if (!nexradDiagEnabled()) {
103
- return { skipped: true };
104
- }
105
- if (!gateData?.length) return { error: 'empty' };
106
- const pairCount = nGates * nRays;
107
- const expected = pairCount * 2;
108
- if (gateData.length < expected) {
109
- return { error: 'shortBuffer', len: gateData.length, expected };
110
- }
111
- let sampleN = 0;
112
- let nodataN = 0;
113
- let inLutN = 0;
114
- let minRaw = 32767;
115
- let maxRaw = -32768;
116
- let minPhys = Infinity;
117
- let maxPhys = -Infinity;
118
- const stride = Math.max(1, Math.floor(pairCount / 25000));
119
- for (let p = 0; p < pairCount; p += stride) {
120
- const o = p * 2;
121
- const lo = gateData[o];
122
- const hi = gateData[o + 1];
123
- let raw = lo + hi * 256;
124
- if (raw >= 32768) raw -= 65536;
125
- sampleN++;
126
- if (raw <= -32768) {
127
- nodataN++;
128
- continue;
129
- }
130
- if (raw < minRaw) minRaw = raw;
131
- if (raw > maxRaw) maxRaw = raw;
132
- const phys = raw * valueScale + valueOffset;
133
- if (phys < minPhys) minPhys = phys;
134
- if (phys > maxPhys) maxPhys = phys;
135
- if (phys >= lutMin && phys <= lutMax) inLutN++;
136
- }
137
- return {
138
- samples: sampleN,
139
- nodataSamples: nodataN,
140
- inLutSamples: inLutN,
141
- minRaw: minRaw <= maxRaw ? minRaw : null,
142
- maxRaw: minRaw <= maxRaw ? maxRaw : null,
143
- minPhys: Number.isFinite(minPhys) ? minPhys : null,
144
- maxPhys: Number.isFinite(maxPhys) ? maxPhys : null,
145
- lutMin,
146
- lutMax,
147
- valueScale,
148
- valueOffset,
149
- };
150
- }
1
+ import{isAguaceroRnDebugEnabled as f}from"../aguaceroRnDebug";const a="[Aguacero][NEXRAD][pipeline]",c="[Aguacero][NEXRAD][perf]";function r(){try{if(typeof __DEV__<"u"&&__DEV__)return!0}catch{}return f()}export function nexradDiagBootSnapshot(e){r()&&console.warn(`${a} boot`,e)}export function nexradPipelineLog(e,n){r()&&(n!==void 0?console.warn(`${a} ${e}`,n):console.warn(`${a} ${e}`))}export function nexradPerfSpan(e){if(!r())return{end(){}};const n=Date.now();return{end(o){const t=Date.now()-n;o!==void 0?console.warn(`${c} ${e} ${t}ms`,o):console.warn(`${c} ${e} ${t}ms`)}}}export function nexradDiagGateTextureSummary(e,n,o,t,i,s,l){if(!r()||!e)return null;const u={nGates:n,nRays:o,gateBytes:e?.length??0,valueScale:t,valueOffset:i,lutMin:s,lutMax:l};return nexradPipelineLog("gateTexture.summary",u),u}
@@ -0,0 +1 @@
1
+ import{clampNexradTiltForVariable as h,formatTiltForApi as N,getDefaultRadarTilt as S,isNexradTdwrSiteId as L,variableToNexradGroup as j}from"./nexradSdkImports.js";const K=/^[A-Z][A-Z0-9]{3}_\d+\.\d+_\d+_\d+_g[12]\.bin$/,F=4,O=12;function M(e){const t=Number(e),n=Number.isFinite(t)&&t>0?t:1;return Math.min(O,Math.max(n,F))}export function isValidLevel2SweepObjectKey(e){return typeof e!="string"||!e?!1:K.test(e)}function _(e){return e==="g1"?1:2}export function buildLevel2SweepObjectKey(e,t,n,r,o){const i=_(r);return`${e}_${t}_${n}_${o}_g${i}.bin`}export function lookupClenForUnix(e,t){if(!e||typeof e!="object")return null;const n=Number(t);if(!Number.isFinite(n))return null;const r=[String(n),String(Math.floor(n)),String(n*1e3),String(Math.floor(n*1e3))];for(const o of r){const i=e[o];if(i==null||i==="")continue;const l=Number(i);if(Number.isFinite(l)&&l>0)return Math.floor(l)}return null}export function listingContextParams(e){const t=e?.nexradSite,n=(e?.nexradProduct||"REF").toUpperCase(),r=Number.isFinite(e?.nexradTilt)?e.nexradTilt:S(t),o=N(h(t,n,r)),i=j(n);return{site:t,elevNorm:o,group:i,radarVarU:n}}export function rebuildLevel2TimeToKeyMap({stationId:e,elevNorm:t,group:n,timeToKeyMap:r={},level2Clens:o,unixTimes:i}){if(!e||!o||typeof o!="object")return{...r};const l=Array.isArray(i)&&i.length>0?i.map(Number).filter(a=>Number.isFinite(a)):Object.keys(r||{}).map(Number).filter(a=>Number.isFinite(a)),s={};for(const a of l){const m=String(a),f=r[m];if(typeof f=="string"&&isValidLevel2SweepObjectKey(f)){s[m]=f;continue}const p=lookupClenForUnix(o,a);if(p==null)continue;const y=buildLevel2SweepObjectKey(e,t,a,n,p);isValidLevel2SweepObjectKey(y)&&(s[m]=y)}return s}function C(e){return e.map(t=>typeof t=="number"&&t>10**10?Math.floor(t/1e3):t)}function A(e){let t=[],n={};if(Array.isArray(e?.times))t=C(e.times),n=e?.clens&&typeof e.clens=="object"?e.clens:{};else if(e?.body){const r=typeof e.body=="string"?JSON.parse(e.body):e.body;t=Array.isArray(r?.times)?C(r.times):[],n=r?.clens&&typeof r.clens=="object"?r.clens:{}}return{times:t,clens:n}}export function mergeLevel2NexradListingEntry(e,t,n,r={}){const o=Array.isArray(t?.unixTimes)?t.unixTimes:[],i=t?.timeToKeyMap&&typeof t.timeToKeyMap=="object"?t.timeToKeyMap:{},l={...e?.level2Clens&&typeof e.level2Clens=="object"?e.level2Clens:{},...t?.level2Clens&&typeof t.level2Clens=="object"?t.level2Clens:{}};let s=[...new Set([...o,...e?.unixTimes??[]])].sort((c,u)=>c-u);if(n>0&&s.length>0){const c=s[s.length-1]-n*3600;s=s.filter(u=>u>=c)}const a={},m=!r.forceRefresh;for(const c of s){const u=String(c),g=e?.timeToKeyMap?.[u],v=i[u],T=m&&g?g:v||g;T&&(a[u]=T)}let f=s.filter(c=>a[String(c)]),p=a;const{stationId:y,elevNorm:b,group:x}=r;if(y&&b&&x&&Object.keys(l).length>0){const c=rebuildLevel2TimeToKeyMap({stationId:y,elevNorm:b,group:x,timeToKeyMap:a,level2Clens:l,unixTimes:f.length>0?f:s});Object.keys(c).length>0&&(p=c,f=Object.keys(c).map(u=>Number(u)).filter(u=>Number.isFinite(u)).sort((u,g)=>u-g))}return{unixTimes:f,timeToKeyMap:p,level2Clens:l,listWindowHours:n,level2ListingEmpty:f.length===0}}const k="https://ddknicwcw2wyov7v5bzxmbqu440tzntf.lambda-url.us-east-2.on.aws/";export async function fetchAndApplyLevel2ListingToCore(e,t,n={}){const r=e?._nexradTimesCacheKey?.();if(!r||!t?.nexradSite)return!1;const o=typeof n.listingHours=="number"?n.listingHours:typeof e._nexradListingWindowHours=="function"?e._nexradListingWindowHours():1,{site:i,elevNorm:l,group:s}=listingContextParams(t),a=M(o),m=new URLSearchParams({station:i,field:s,elev:l,hours:String(a)}),f=`${k}?${m.toString()}`,p={},y=typeof n.siteOrigin=="string"?n.siteOrigin.trim():"";y&&(p.Origin=y);const b=await fetch(f,{headers:p});if(!b.ok)return!1;const x=await b.json(),{times:c,clens:u}=A(x);if(!c.length&&(!u||!Object.keys(u).length)){const d=e.nexradTimesByStation[r];return e.nexradTimesByStation[r]=mergeLevel2NexradListingEntry(d,{unixTimes:[],timeToKeyMap:{},level2Clens:{}},o),typeof e._emitStateChange=="function"&&e._emitStateChange(),!0}if(!u||!Object.keys(u).length)return!1;const g=rebuildLevel2TimeToKeyMap({stationId:i,elevNorm:l,group:s,level2Clens:u,unixTimes:c}),v=Object.keys(g).map(d=>Number(d)).filter(d=>Number.isFinite(d)).sort((d,w)=>d-w);if(!v.length)return!1;const T=e.nexradTimesByStation[r];return e.nexradTimesByStation[r]=mergeLevel2NexradListingEntry(T,{unixTimes:v,timeToKeyMap:g,level2Clens:u},o,{stationId:i,elevNorm:l,group:s}),typeof e._emitStateChange=="function"&&e._emitStateChange(),!0}export function level2ListingCacheNeedsRefresh(e){if(!e)return!0;if(e.level2ListingEmpty===!0)return!1;const t=e.level2Clens,n=t&&typeof t=="object"&&Object.keys(t).length>0,r=e.timeToKeyMap;if(!n||!r||typeof r!="object"||Object.keys(r).length===0)return!0;const o=Object.values(r).find(i=>typeof i=="string"&&i.length>0);return!o||!isValidLevel2SweepObjectKey(o)}export function resolveLevel2SweepObjectKeyForFetch(e,t){const{stationId:n,elevNorm:r,group:o,unixSec:i,clens:l}=t||{};if(typeof e=="string"&&isValidLevel2SweepObjectKey(e))return e;if(!n||!r||!o||i==null||!l)return null;const s=lookupClenForUnix(l,i);if(s==null)return null;const a=buildLevel2SweepObjectKey(n,r,i,o,s);return isValidLevel2SweepObjectKey(a)?a:null}export function resolveLevel2ObjectKeyForFetch({state:e,listingEntry:t,unix:n,radarVar:r,rawKey:o}){if(typeof o=="string"&&isValidLevel2SweepObjectKey(o))return o;const i=e?.nexradSite,l=t?.level2Clens;if(!i||!l||typeof l!="object")return null;const s=(r||e.nexradProduct||"REF").toUpperCase(),a=Number.isFinite(e.nexradTilt)?e.nexradTilt:S(i),m=N(h(i,s,a)),f=j(s);return resolveLevel2SweepObjectKeyForFetch(o,{stationId:i,elevNorm:m,group:f,unixSec:n,clens:l})}export function level2ListingEmptyHint(e){return L(e)?"TDWR site: Level-II sweep lambda returned no volumes. Try a WSR-88D site (K*) such as KSHV or KTLX.":"Level-II sweep lambda returned no volumes for this site/tilt/window."}
@@ -1,126 +1 @@
1
- /**
2
- * NEXRAD 256×1 RGBA LUT — same rules as mapsgl {@code MapboxRadarLayer.buildLutTextureData}.
3
- */
4
- import { DEFAULT_COLORMAPS } from '@aguacerowx/javascript-sdk';
5
-
6
- const LUT_SIZE = 256;
7
-
8
- function getRefc0DefaultColormap() {
9
- const cm = DEFAULT_COLORMAPS?.refc_0?.units?.dBZ?.colormap;
10
- return Array.isArray(cm) && cm.length >= 2 ? cm : null;
11
- }
12
-
13
- function parseHex(hex) {
14
- const m = String(hex ?? '').match(/^#?([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/);
15
- if (!m) return [0, 0, 0, 255];
16
- const s = m[1];
17
- let r = 0;
18
- let g = 0;
19
- let b = 0;
20
- let a = 255;
21
- if (s.length === 8) {
22
- r = parseInt(s.slice(0, 2), 16);
23
- g = parseInt(s.slice(2, 4), 16);
24
- b = parseInt(s.slice(4, 6), 16);
25
- a = parseInt(s.slice(6, 8), 16);
26
- } else if (s.length === 6) {
27
- r = parseInt(s.slice(0, 2), 16);
28
- g = parseInt(s.slice(2, 4), 16);
29
- b = parseInt(s.slice(4, 6), 16);
30
- } else {
31
- r = parseInt(s[0] + s[0], 16);
32
- g = parseInt(s[1] + s[1], 16);
33
- b = parseInt(s[2] + s[2], 16);
34
- }
35
- return [r, g, b, a];
36
- }
37
-
38
- function shouldUseDiscreteIntegerLut(stops, lutValueMin, lutValueMax, interpolateColormap) {
39
- if (interpolateColormap || stops.length < 2) return false;
40
- const lo = lutValueMin;
41
- const hi = lutValueMax;
42
- if (!Number.isFinite(lo) || !Number.isFinite(hi)) return false;
43
- const nExp = Math.round(hi - lo + 1);
44
- if (stops.length !== nExp) return false;
45
- if (Math.abs(Math.round(lo) - lo) > 1e-3 || Math.abs(Math.round(hi) - hi) > 1e-3) return false;
46
- for (let i = 0; i < stops.length; i++) {
47
- if (Math.abs(stops[i].value - (lo + i)) > 1e-3) return false;
48
- }
49
- return true;
50
- }
51
-
52
- function sampleStops(stops, value, interpolate) {
53
- if (value <= stops[0].value) return stops[0].color;
54
- if (value >= stops[stops.length - 1].value) return stops[stops.length - 1].color;
55
- for (let i = 1; i < stops.length; i++) {
56
- if (interpolate) {
57
- if (value <= stops[i].value) {
58
- const low = stops[i - 1];
59
- const high = stops[i];
60
- const t = (value - low.value) / Math.max(high.value - low.value, 1e-5);
61
- return [
62
- Math.round(low.color[0] + (high.color[0] - low.color[0]) * t),
63
- Math.round(low.color[1] + (high.color[1] - low.color[1]) * t),
64
- Math.round(low.color[2] + (high.color[2] - low.color[2]) * t),
65
- Math.round(low.color[3] + (high.color[3] - low.color[3]) * t),
66
- ];
67
- }
68
- } else if (value < stops[i].value) {
69
- return stops[i - 1].color;
70
- }
71
- }
72
- return stops[stops.length - 1].color;
73
- }
74
-
75
- /**
76
- * @param {number[]|null|undefined} colormapFlat - [v0,c0,v1,c1,...]
77
- * @param {number} lutValueMin
78
- * @param {number} lutValueMax
79
- * @param {boolean} interpolateColormap
80
- * @returns {{ bytes: Uint8Array, discreteIntegerLut: number }}
81
- */
82
- export function buildNexradLutRgba(colormapFlat, lutValueMin, lutValueMax, interpolateColormap) {
83
- const cm = Array.isArray(colormapFlat) && colormapFlat.length >= 2 ? colormapFlat : getRefc0DefaultColormap();
84
- const stops = [];
85
- if (cm && cm.length >= 2) {
86
- for (let i = 0; i < cm.length; i += 2) {
87
- const value = Number(cm[i]);
88
- const hex = String(cm[i + 1] ?? '');
89
- const [r, g, b, a] = parseHex(hex);
90
- stops.push({ value, color: [r, g, b, a] });
91
- }
92
- }
93
-
94
- const out = new Uint8Array(LUT_SIZE * 4);
95
- if (stops.length === 0) {
96
- return { bytes: out, discreteIntegerLut: 0 };
97
- }
98
-
99
- const discrete = shouldUseDiscreteIntegerLut(stops, lutValueMin, lutValueMax, interpolateColormap) ? 1 : 0;
100
-
101
- if (discrete) {
102
- const n = stops.length;
103
- for (let i = 0; i < LUT_SIZE; i++) {
104
- const u = (i + 0.5) / LUT_SIZE;
105
- const bin = Math.min(Math.floor(u * n), n - 1);
106
- const c = stops[bin].color;
107
- const idx = i * 4;
108
- out[idx] = c[0];
109
- out[idx + 1] = c[1];
110
- out[idx + 2] = c[2];
111
- out[idx + 3] = c[3];
112
- }
113
- return { bytes: out, discreteIntegerLut: 1 };
114
- }
115
-
116
- for (let i = 0; i < LUT_SIZE; i++) {
117
- const value = lutValueMin + (i / (LUT_SIZE - 1)) * (lutValueMax - lutValueMin);
118
- const color = sampleStops(stops, value, interpolateColormap);
119
- const idx = i * 4;
120
- out[idx] = color[0];
121
- out[idx + 1] = color[1];
122
- out[idx + 2] = color[2];
123
- out[idx + 3] = color[3];
124
- }
125
- return { bytes: out, discreteIntegerLut: 0 };
126
- }
1
+ const M=256;function h(t){const o=String(t||"").trim(),u=/^#?([0-9a-f]{6,8})$/i.exec(o);if(!u)return[0,0,0,255];const n=u[1];return n.length===8?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),parseInt(n.slice(6,8),16)]:[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),255]}function g(t){const o=[];if(!t||t.length<2)return o;for(let u=0;u<t.length-1;u+=2){const n=Number(t[u]),r=t[u+1];if(!Number.isFinite(n)||r==null)continue;const[e,l,c,i]=h(r);o.push({value:n,color:[e,l,c,i]})}return o}function b(t,o,u,n){if(n||t.length<2)return!1;const r=o,e=u;if(!Number.isFinite(r)||!Number.isFinite(e))return!1;const l=Math.round(e-r+1);if(t.length!==l||Math.abs(Math.round(r)-r)>.001||Math.abs(Math.round(e)-e)>.001)return!1;for(let c=0;c<t.length;c++)if(Math.abs(t[c].value-(r+c))>.001)return!1;return!0}function d(t,o,u){if(o<=t[0].value)return t[0].color;if(o>=t[t.length-1].value)return t[t.length-1].color;for(let n=1;n<t.length;n++)if(u){if(o<=t[n].value){const r=t[n-1],e=t[n],l=(o-r.value)/Math.max(e.value-r.value,1e-5);return[Math.round(r.color[0]+(e.color[0]-r.color[0])*l),Math.round(r.color[1]+(e.color[1]-r.color[1])*l),Math.round(r.color[2]+(e.color[2]-r.color[2])*l),Math.round(r.color[3]+(e.color[3]-r.color[3])*l)]}}else if(o<t[n].value)return t[n-1].color;return t[t.length-1].color}export function buildNexradLutRgba(t,o,u,n){const r=g(t),e=new Uint8Array(256*4);if(r.length===0)return{bytes:e,discreteIntegerLut:!1};if(b(r,o,u,n)){const l=r.length;for(let c=0;c<256;c++){const i=(c+.5)/256,s=Math.min(Math.floor(i*l),l-1),a=r[s].color,f=c*4;e[f]=a[0],e[f+1]=a[1],e[f+2]=a[2],e[f+3]=a[3]}return{bytes:e,discreteIntegerLut:!0}}for(let l=0;l<256;l++){const c=o+l/255*(u-o),i=d(r,c,n),s=l*4;e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3]}return{bytes:e,discreteIntegerLut:!1}}
@@ -1,245 +1 @@
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) return { geometryLayoutKey: "canonical" };
225
- if (state.nexradDataSource !== "level3") return { geometryLayoutKey: "canonical" };
226
- const site = state.nexradSite;
227
- const radarVar = (state.nexradProduct || "REF").toUpperCase();
228
- if (nexradLevel3UsesTiltIndexedS3Products(radarVar) && site) {
229
- const tilt = Number.isFinite(state.nexradTilt) ? Number(state.nexradTilt) : getDefaultRadarTilt2(site);
230
- const kind = radarVar === "KDP" ? "KDP" : "N0H";
231
- const mnemonic = nexradLevel3S3ProductForSiteTilt(site, kind, tilt);
232
- return { geometryLayoutKey: `${site}|${radarVar}|${mnemonic}` };
233
- }
234
- if (radarVar === "VEL" && site) {
235
- const tilt = Number.isFinite(state.nexradTilt) ? Number(state.nexradTilt) : getDefaultRadarTilt2(site);
236
- const mnemonic = nexradLevel3S3VelocityProductForSiteTilt(site, tilt);
237
- return { geometryLayoutKey: `${site}|${radarVar}|${mnemonic}` };
238
- }
239
- return { geometryLayoutKey: "canonical" };
240
- }
241
- export {
242
- mapboxFrameUploadOptionsForNexradState,
243
- nexradLevel3S3ProductForSiteTilt,
244
- nexradLevel3UsesTiltIndexedS3Products
245
- };
1
+ import{clampNexradTiltForVariable as u,getDefaultRadarTilt as y,getRadarTilts as m}from"@aguacerowx/javascript-sdk";import{clampNexradTiltForVariable as _,getRadarTilts as x}from"@aguacerowx/javascript-sdk";var H=[{radarKey:"VEL",product:"N0G",menuLabel:"Storm Relative Velocity",fldKey:"nexrad_vel",cmapPropertyKey:"nexrad_vel",decodeMode:"velocity",stormRelativeVelocity:!0},{radarKey:"KDP",product:"N0K",menuLabel:"Specific Differential Phase",fldKey:"nexrad_l3_n0k",cmapPropertyKey:"nexrad_kdp",defaultUnit:"deg/km",decodeMode:"generic_physical"},{radarKey:"N0H",product:"N0H",menuLabel:"Hydrometeor Classification",fldKey:"nexrad_l3_n0h",cmapPropertyKey:"nexrad_l3_n0h",defaultUnit:"None",decodeMode:"categorical"},{radarKey:"HHC",product:"HHC",menuLabel:"Hybrid Hydrometeor Classification",fldKey:"nexrad_l3_hhc",cmapPropertyKey:"nexrad_l3_hhc",defaultUnit:"None",decodeMode:"categorical"},{radarKey:"EET",product:"EET",menuLabel:"Enhanced Echo Tops",fldKey:"nexrad_l3_eet",cmapPropertyKey:"nexrad_l3_eet",defaultUnit:"kft",decodeMode:"tops_kft"},{radarKey:"DVL",product:"DVL",menuLabel:"Vertically Integrated Liquid",fldKey:"nexrad_l3_dvl",cmapPropertyKey:"nexrad_l3_dvl",defaultUnit:"kg/m\xB2",decodeMode:"vil"},{radarKey:"DAA",product:"DAA",menuLabel:"1-Hour Precipitation",fldKey:"nexrad_l3_daa",cmapPropertyKey:"tp_0_1",defaultUnit:"in",decodeMode:"precip"},{radarKey:"DU3",product:"DU3",menuLabel:"3-Hour Precipitation",fldKey:"nexrad_l3_du3",cmapPropertyKey:"tp_0_total",defaultUnit:"in",decodeMode:"precip"},{radarKey:"DTA",product:"DTA",menuLabel:"Storm Total Precipitation",fldKey:"nexrad_l3_dta",cmapPropertyKey:"tp_0_total",defaultUnit:"in",decodeMode:"precip"}],p=new Map;for(const e of H)p.set(e.radarKey,e),e.radarKey==="DVL"&&p.set("NVL",e);var h=["NXK","NYK","NZK","N0K","NAK","N1K","NBK","N2K","N3K"],L=["NXH","NYH","NZH","N0H","NAH","N1H","NBH","N2H","N3H"],g=h.slice(3),F=L.slice(3),b=["NXG","NYG","NZG","N0G","NAG","N1G","NBG","N2G","N3G"],P=b.slice(3),M=g.length;function D(e){return x(e,"VEL").slice(0,M)}function T(e,r){const t=P,a=D(e);if(!a.length)return t[0];const n=_(e,"VEL",r);let o=a.indexOf(n);return o===-1&&(o=a.reduce((d,l,i)=>Math.abs(l-n)<Math.abs(a[d]-n)?i:d,0)),o=Math.min(o,t.length-1),t[o]}var K=["N0K","NAK","N1K","NBK","N2K","N3K"],v=["N0H","NAH","N1H","NBH","N2H","N3H"],U=K.length;function V(e,r){if(!e.length)return r;let t=e[0],a=Math.abs(t-r);for(let n=1;n<e.length;n++){const o=e[n],d=Math.abs(o-r);(d<a||d===a&&o<t)&&(t=o,a=d)}return t}function N(e,r){return m(e,r).slice(0,U)}function c(e){const r=e||"";return r==="KDP"||r==="N0H"}function A(e,r,t){if(!c(r))return u(e,r,t);const a=N(e,r),n=u(e,r,t);return a.length?V(a,n):n}function s(e,r,t){const a=r==="KDP"?K:v,n=N(e,r);if(!n.length)return a[0];const o=A(e,r,t);let d=n.indexOf(o);return d===-1&&(d=n.reduce((l,i,f)=>Math.abs(i-o)<Math.abs(n[l]-o)?f:l,0)),d=Math.min(d,a.length-1),a[d]}function E(e){if(!e)return{geometryLayoutKey:"canonical"};if(e.nexradDataSource!=="level3")return{geometryLayoutKey:"canonical"};const r=e.nexradSite,t=(e.nexradProduct||"REF").toUpperCase();if(c(t)&&r){const a=Number.isFinite(e.nexradTilt)?Number(e.nexradTilt):y(r),n=s(r,t==="KDP"?"KDP":"N0H",a);return{geometryLayoutKey:`${r}|${t}|${n}`}}if(t==="VEL"&&r){const a=Number.isFinite(e.nexradTilt)?Number(e.nexradTilt):y(r),n=T(r,a);return{geometryLayoutKey:`${r}|${t}|${n}`}}return{geometryLayoutKey:"canonical"}}export{E as mapboxFrameUploadOptionsForNexradState,s as nexradLevel3S3ProductForSiteTilt,c as nexradLevel3UsesTiltIndexedS3Products};
@@ -0,0 +1 @@
1
+ export{getUnitConversionFunction}from"@aguacerowx/javascript-sdk/unitConversions.js";export{variableToNexradGroup,nexradBinGroupIdForKey}from"@aguacerowx/javascript-sdk/nexrad_support.js";export{getDefaultRadarTilt,formatTiltForApi,clampNexradTiltForVariable,isNexradTdwrSiteId}from"@aguacerowx/javascript-sdk/nexradTilts.js";