@deck.gl/aggregation-layers 9.0.34 → 9.1.0-beta.1

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 (318) hide show
  1. package/dist/common/aggregation-layer.d.ts +30 -0
  2. package/dist/common/aggregation-layer.d.ts.map +1 -0
  3. package/dist/common/aggregation-layer.js +69 -0
  4. package/dist/common/aggregator/aggregator.d.ts +76 -0
  5. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  6. package/dist/common/aggregator/aggregator.js +4 -0
  7. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  8. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.js +66 -0
  10. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  11. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  12. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +139 -0
  13. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  14. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +43 -0
  16. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  17. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  18. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +55 -0
  19. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  20. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  21. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +20 -0
  22. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  23. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  24. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +17 -0
  25. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  26. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/utils.js +24 -0
  28. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  29. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  30. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +215 -0
  31. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  32. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +201 -0
  34. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  35. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  36. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +223 -0
  37. package/dist/common/aggregator/index.d.ts +6 -0
  38. package/dist/common/aggregator/index.d.ts.map +1 -0
  39. package/dist/common/aggregator/index.js +5 -0
  40. package/dist/common/types.d.ts +11 -0
  41. package/dist/common/types.d.ts.map +1 -0
  42. package/dist/common/types.js +4 -0
  43. package/dist/common/utils/bounds-utils.d.ts +10 -0
  44. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  45. package/dist/common/utils/bounds-utils.js +20 -0
  46. package/dist/common/utils/color-utils.d.ts +10 -0
  47. package/dist/common/utils/color-utils.d.ts.map +1 -0
  48. package/dist/common/utils/color-utils.js +65 -0
  49. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  50. package/dist/common/utils/prop-utils.js +12 -0
  51. package/dist/common/utils/scale-utils.d.ts +46 -0
  52. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  53. package/dist/common/utils/scale-utils.js +180 -0
  54. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  55. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  56. package/dist/contour-layer/bin-options-uniforms.js +17 -0
  57. package/dist/contour-layer/contour-layer.d.ts +42 -50
  58. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  59. package/dist/contour-layer/contour-layer.js +232 -192
  60. package/dist/contour-layer/contour-utils.d.ts +36 -15
  61. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  62. package/dist/contour-layer/contour-utils.js +24 -29
  63. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  64. package/dist/contour-layer/marching-squares-codes.js +3 -0
  65. package/dist/contour-layer/marching-squares.d.ts +22 -6
  66. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  67. package/dist/contour-layer/marching-squares.js +71 -68
  68. package/dist/contour-layer/value-reader.d.ts +10 -0
  69. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  70. package/dist/contour-layer/value-reader.js +46 -0
  71. package/dist/dist.dev.js +4842 -4081
  72. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/grid-layer/bin-options-uniforms.js +17 -0
  75. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  76. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  77. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
  78. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  79. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  80. package/dist/grid-layer/grid-cell-layer.js +93 -0
  81. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  82. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  83. package/dist/grid-layer/grid-layer-uniforms.js +23 -0
  84. package/dist/grid-layer/grid-layer.d.ts +175 -13
  85. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  86. package/dist/grid-layer/grid-layer.js +342 -46
  87. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  88. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  89. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +6 -21
  90. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  91. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  92. package/dist/heatmap-layer/heatmap-layer-uniforms.js +32 -0
  93. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  94. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  95. package/dist/heatmap-layer/heatmap-layer-utils.js +3 -0
  96. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  97. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  98. package/dist/heatmap-layer/heatmap-layer.js +43 -33
  99. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  100. package/dist/heatmap-layer/max-fs.glsl.js +3 -0
  101. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  102. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  103. package/dist/heatmap-layer/max-vs.glsl.js +6 -4
  104. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  105. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  106. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +5 -23
  107. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  108. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  109. package/dist/heatmap-layer/triangle-layer-uniforms.js +22 -0
  110. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  111. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  112. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +10 -30
  113. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  114. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  115. package/dist/heatmap-layer/triangle-layer.js +17 -30
  116. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  117. package/dist/heatmap-layer/weights-fs.glsl.js +3 -0
  118. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  119. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  120. package/dist/heatmap-layer/weights-vs.glsl.js +6 -7
  121. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  122. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  123. package/dist/hexagon-layer/bin-options-uniforms.js +17 -0
  124. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  125. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  126. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
  127. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  128. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  129. package/dist/hexagon-layer/hexagon-cell-layer.js +94 -0
  130. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  131. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  132. package/dist/hexagon-layer/hexagon-layer-uniforms.js +21 -0
  133. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  134. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  135. package/dist/hexagon-layer/hexagon-layer.js +307 -123
  136. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  137. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  138. package/dist/hexagon-layer/hexbin.js +69 -0
  139. package/dist/index.cjs +3025 -2946
  140. package/dist/index.cjs.map +4 -4
  141. package/dist/index.d.ts +7 -13
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +5 -27
  144. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  145. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  146. package/dist/screen-grid-layer/bin-options-uniforms.js +15 -0
  147. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  148. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  149. package/dist/screen-grid-layer/screen-grid-cell-layer.js +52 -134
  150. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  151. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  152. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +4 -24
  153. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  154. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  155. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +19 -0
  156. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  157. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  158. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +21 -62
  159. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  160. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  161. package/dist/screen-grid-layer/screen-grid-layer.js +157 -174
  162. package/dist.min.js +401 -382
  163. package/package.json +10 -9
  164. package/src/common/aggregation-layer.ts +107 -0
  165. package/src/common/aggregator/aggregator.ts +88 -0
  166. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  167. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  168. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  169. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  170. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  171. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  172. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  173. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  174. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  175. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  176. package/src/common/aggregator/index.ts +10 -0
  177. package/src/{types.ts → common/types.ts} +10 -4
  178. package/src/common/utils/bounds-utils.ts +34 -0
  179. package/src/common/utils/color-utils.ts +86 -0
  180. package/src/common/utils/prop-utils.ts +13 -0
  181. package/src/common/utils/scale-utils.ts +236 -0
  182. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  183. package/src/contour-layer/contour-layer.ts +300 -265
  184. package/src/contour-layer/contour-utils.ts +68 -39
  185. package/src/contour-layer/marching-squares-codes.ts +4 -0
  186. package/src/contour-layer/marching-squares.ts +93 -82
  187. package/src/contour-layer/value-reader.ts +65 -0
  188. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  189. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  190. package/src/grid-layer/grid-cell-layer.ts +141 -0
  191. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  192. package/src/grid-layer/grid-layer.ts +614 -73
  193. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  194. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  195. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  196. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  197. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  198. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  199. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  200. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  201. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  202. package/src/heatmap-layer/triangle-layer.ts +26 -31
  203. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  204. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  205. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  206. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  207. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  208. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  209. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  210. package/src/hexagon-layer/hexbin.ts +79 -0
  211. package/src/index.ts +21 -34
  212. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  213. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  214. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  215. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  216. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  217. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  218. package/dist/aggregation-layer.d.ts.map +0 -1
  219. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  220. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  221. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  222. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  223. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  224. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  225. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  226. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  227. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  228. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  229. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  230. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  231. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  232. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  233. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  234. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  235. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  236. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  237. package/dist/grid-aggregation-layer.d.ts +0 -67
  238. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  239. package/dist/grid-aggregation-layer.js +0 -173
  240. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  241. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  242. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  243. package/dist/types.d.ts +0 -12
  244. package/dist/types.d.ts.map +0 -1
  245. package/dist/types.js +0 -1
  246. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  247. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  248. package/dist/utils/aggregation-operation-utils.js +0 -94
  249. package/dist/utils/bin-sorter.d.ts +0 -52
  250. package/dist/utils/bin-sorter.d.ts.map +0 -1
  251. package/dist/utils/bin-sorter.js +0 -167
  252. package/dist/utils/color-utils.d.ts +0 -3
  253. package/dist/utils/color-utils.d.ts.map +0 -1
  254. package/dist/utils/color-utils.js +0 -53
  255. package/dist/utils/cpu-aggregator.d.ts +0 -169
  256. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  257. package/dist/utils/cpu-aggregator.js +0 -421
  258. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  259. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  260. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  261. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  262. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  263. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  264. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  265. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  266. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  267. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  268. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  269. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  270. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  271. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  272. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  273. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  274. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  275. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  276. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  277. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  278. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  279. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  280. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  281. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  282. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  283. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  284. package/dist/utils/grid-aggregation-utils.js +0 -114
  285. package/dist/utils/prop-utils.d.ts.map +0 -1
  286. package/dist/utils/prop-utils.js +0 -28
  287. package/dist/utils/resource-utils.d.ts +0 -14
  288. package/dist/utils/resource-utils.d.ts.map +0 -1
  289. package/dist/utils/resource-utils.js +0 -38
  290. package/dist/utils/scale-utils.d.ts +0 -15
  291. package/dist/utils/scale-utils.d.ts.map +0 -1
  292. package/dist/utils/scale-utils.js +0 -184
  293. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  294. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  295. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  296. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  297. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  298. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  299. package/src/grid-aggregation-layer.ts +0 -243
  300. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  301. package/src/utils/aggregation-operation-utils.ts +0 -118
  302. package/src/utils/bin-sorter.ts +0 -218
  303. package/src/utils/color-utils.ts +0 -57
  304. package/src/utils/cpu-aggregator.ts +0 -503
  305. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  306. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  307. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  308. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  309. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  310. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  311. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  312. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  313. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  314. package/src/utils/grid-aggregation-utils.ts +0 -147
  315. package/src/utils/prop-utils.ts +0 -29
  316. package/src/utils/resource-utils.ts +0 -53
  317. package/src/utils/scale-utils.js +0 -219
  318. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
package/dist.min.js CHANGED
@@ -4,404 +4,415 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['deck'] = factory();
6
6
  else root['deck'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var li=Object.create;var De=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var ui=Object.getOwnPropertyNames;var gi=Object.getPrototypeOf,fi=Object.prototype.hasOwnProperty;var Xe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),di=(n,e)=>{for(var t in e)De(n,t,{get:e[t],enumerable:!0})},Ne=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ui(e))!fi.call(n,i)&&i!==t&&De(n,i,{get:()=>e[i],enumerable:!(o=ci(e,i))||o.enumerable});return n},B=(n,e,t)=>(Ne(n,e,"default"),t&&Ne(t,e,"default")),M=(n,e,t)=>(t=n!=null?li(gi(n)):{},Ne(e||!n||!n.__esModule?De(t,"default",{value:n,enumerable:!0}):t,n)),pi=n=>Ne(De({},"__esModule",{value:!0}),n);var X=Xe((Pr,ct)=>{ct.exports=globalThis.deck});var E=Xe((Dr,gt)=>{gt.exports=globalThis.deck});var k=Xe((Lr,ft)=>{ft.exports=globalThis.luma});var Pe={};di(Pe,{AGGREGATION_OPERATION:()=>T,CPUGridLayer:()=>Se,ContourLayer:()=>Go,GPUGridLayer:()=>Te,GridLayer:()=>Yo,HeatmapLayer:()=>si,HexagonLayer:()=>ao,ScreenGridLayer:()=>Kt,_AggregationLayer:()=>O,_BinSorter:()=>F,_CPUAggregator:()=>w,_GPUGridAggregator:()=>C});var L={},ut=M(X(),1);B(L,M(X(),1));if(!ut.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");B(Pe,L);var $t=M(E(),1);var me=M(k(),1);function qe(n,e=[],t=0){let o=Math.fround(n),i=n-o;return e[t]=o,e[t+1]=i,e}function dt(n){return n-Math.fround(n)}function pt(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let o=0;o<4;++o){let i=t*4+o;qe(n[o*4+t],e,i*2)}return e}var mt=`uniform float ONE;
8
- vec2 split(float a) {
9
- const float SPLIT = 4097.0;
10
- float t = a * SPLIT;
11
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
12
- float a_hi = t * ONE - (t - a);
13
- float a_lo = a * ONE - a_hi;
14
- #else
15
- float a_hi = t - (t - a);
16
- float a_lo = a - a_hi;
17
- #endif
18
- return vec2(a_hi, a_lo);
19
- }
20
- vec2 split2(vec2 a) {
21
- vec2 b = split(a.x);
22
- b.y += a.y;
23
- return b;
24
- }
25
- vec2 quickTwoSum(float a, float b) {
26
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
27
- float sum = (a + b) * ONE;
28
- float err = b - (sum - a) * ONE;
7
+ "use strict";var __exports__=(()=>{var Lo=Object.create;var Et=Object.defineProperty;var Po=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var No=Object.getPrototypeOf,Oo=Object.prototype.hasOwnProperty;var Jt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Ro=(n,t)=>{for(var e in t)Et(n,e,{get:t[e],enumerable:!0})},bt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wo(t))!Oo.call(n,r)&&r!==e&&Et(n,r,{get:()=>t[r],enumerable:!(o=Po(t,r))||o.enumerable});return n},j=(n,t,e)=>(bt(n,t,"default"),e&&bt(e,t,"default")),L=(n,t,e)=>(e=n!=null?Lo(No(n)):{},bt(t||!n||!n.__esModule?Et(e,"default",{value:n,enumerable:!0}):e,n)),_o=n=>bt(Et({},"__esModule",{value:!0}),n);var Z=Jt((zr,ue)=>{ue.exports=globalThis.deck});var I=Jt((Fr,xe)=>{xe.exports=globalThis.deck});var X=Jt((jr,be)=>{be.exports=globalThis.luma});var Ct={};Ro(Ct,{CPUAggregator:()=>O,ContourLayer:()=>Jn,GridLayer:()=>so,HeatmapLayer:()=>To,HexagonLayer:()=>Xe,ScreenGridLayer:()=>We,WebGLAggregator:()=>P,_AggregationLayer:()=>U});var B={},me=L(Z(),1);j(B,L(Z(),1));if(!me.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");j(Ct,B);var Fe=L(I(),1);var Ce=L(I(),1);function ve({pointCount:n,getBinId:t}){let e=new Map;for(let o=0;o<n;o++){let r=t(o);if(r===null)continue;let i=e.get(String(r));i?i.points.push(o):(i={id:r,index:e.size,points:[o]},e.set(String(r),i))}return Array.from(e.values())}function Me({bins:n,dimensions:t,target:e}){let o=n.length*t;(!e||e.length<o)&&(e=new Float32Array(o));for(let r=0;r<n.length;r++){let{id:i}=n[r];Array.isArray(i)?e.set(i,r*t):e[r]=i}return e}var zo=n=>n.length,ye=(n,t)=>{let e=0;for(let o of n)e+=t(o);return e},Io=(n,t)=>n.length===0?NaN:ye(n,t)/n.length,Fo=(n,t)=>{let e=1/0;for(let o of n){let r=t(o);r<e&&(e=r)}return e},Wo=(n,t)=>{let e=-1/0;for(let o of n){let r=t(o);r>e&&(e=r)}return e},Se={COUNT:zo,SUM:ye,MEAN:Io,MIN:Fo,MAX:Wo};function Ae({bins:n,getValue:t,operation:e,target:o}){(!o||o.length<n.length)&&(o=new Float32Array(n.length));let r=1/0,i=-1/0;for(let s=0;s<n.length;s++){let{points:a}=n[s];o[s]=e(a,t),o[s]<r&&(r=o[s]),o[s]>i&&(i=o[s])}return{value:o,domain:[r,i]}}function te(n,t,e){let o={};for(let i of n.sources||[]){let s=t[i];if(s)o[i]=Do(s);else throw new Error(`Cannot find attribute ${i}`)}let r={};return i=>{for(let s in o)r[s]=o[s](i);return n.getValue(r,i,e)}}function Do(n){let t=n.value,{offset:e=0,stride:o,size:r}=n.getAccessor(),i=t.BYTES_PER_ELEMENT,s=e/i,a=o?o/i:r;if(r===1)return n.isConstant?()=>t[0]:g=>{let h=s+a*g;return t[h]};let c;return n.isConstant?(c=Array.from(t),()=>c):(c=new Array(r),g=>{let h=s+a*g;for(let f=0;f<r;f++)c[f]=t[h+f];return c})}var O=class{constructor(t){this.bins=[],this.binIds=null,this.results=[],this.dimensions=t.dimensions,this.channelCount=t.getValue.length,this.props={...t,binOptions:{},pointCount:0,operations:[],customOperations:[],attributes:{}},this.needsUpdate=!0,this.setProps(t)}destroy(){}get binCount(){return this.bins.length}setProps(t){let e=this.props;if(t.binOptions&&((0,Ce._deepEqual)(t.binOptions,e.binOptions,2)||this.setNeedsUpdate()),t.operations)for(let o=0;o<this.channelCount;o++)t.operations[o]!==e.operations[o]&&this.setNeedsUpdate(o);if(t.customOperations)for(let o=0;o<this.channelCount;o++)Boolean(t.customOperations[o])!==Boolean(e.customOperations[o])&&this.setNeedsUpdate(o);t.pointCount!==void 0&&t.pointCount!==e.pointCount&&this.setNeedsUpdate(),t.attributes&&(t.attributes={...e.attributes,...t.attributes}),Object.assign(this.props,t)}setNeedsUpdate(t){t===void 0?this.needsUpdate=!0:this.needsUpdate!==!0&&(this.needsUpdate=this.needsUpdate||[],this.needsUpdate[t]=!0)}update(){if(this.needsUpdate===!0){this.bins=ve({pointCount:this.props.pointCount,getBinId:te(this.props.getBin,this.props.attributes,this.props.binOptions)});let t=Me({bins:this.bins,dimensions:this.dimensions,target:this.binIds?.value});this.binIds={value:t,type:"float32",size:this.dimensions}}for(let t=0;t<this.channelCount;t++)if(this.needsUpdate===!0||this.needsUpdate[t]){let e=this.props.customOperations[t]||Se[this.props.operations[t]],{value:o,domain:r}=Ae({bins:this.bins,getValue:te(this.props.getValue[t],this.props.attributes,void 0),operation:e,target:this.results[t]?.value});this.results[t]={value:o,domain:r,type:"float32",size:1},this.props.onUpdate?.({channel:t})}this.needsUpdate=!1}preDraw(){}getBins(){return this.binIds}getResult(t){return this.results[t]}getResultDomain(t){return this.results[t]?.domain??[1/0,-1/0]}getBin(t){let e=this.bins[t];if(!e)return null;let o=new Array(this.channelCount);for(let r=0;r<o.length;r++){let i=this.results[r];o[r]=i?.value[t]}return{id:e.id,value:o,count:e.points.length,pointIndices:e.points}}};var Le=L(X(),1);function Tt(n,t,e){return n.createFramebuffer({width:t,height:e,colorAttachments:[n.createTexture({width:t,height:e,format:"rgba32float",mipmaps:!1,sampler:{minFilter:"nearest",magFilter:"nearest"}})]})}var Vo=`uniform binSorterUniforms {
8
+ ivec4 binIdRange;
9
+ ivec2 targetSize;
10
+ } binSorter;
11
+ `,Ee={name:"binSorter",vs:Vo,uniformTypes:{binIdRange:"vec4<i32>",targetSize:"vec2<i32>"}};var Pe=[1,2,4,8],Te=3e38,Bo={SUM:0,MEAN:0,MIN:0,MAX:0,COUNT:0},dt=1024,Lt=class{constructor(t,e){this.binsFBO=null,this.device=t,this.model=Ho(t,e)}get texture(){return this.binsFBO?this.binsFBO.colorAttachments[0].texture:null}destroy(){this.model.destroy(),this.binsFBO?.colorAttachments[0].texture.destroy(),this.binsFBO?.destroy()}getBinValues(t){if(!this.binsFBO)return null;let e=t%dt,o=Math.floor(t/dt),r=this.device.readPixelsToArrayWebGL(this.binsFBO,{sourceX:e,sourceY:o,sourceWidth:1,sourceHeight:1}).buffer;return new Float32Array(r)}setDimensions(t,e){let o=dt,r=Math.ceil(t/o);this.binsFBO?this.binsFBO.height<r&&this.binsFBO.resize({width:o,height:r}):this.binsFBO=Tt(this.device,o,r);let i={binIdRange:[e[0][0],e[0][1],e[1]?.[0]||0,e[1]?.[1]||0],targetSize:[this.binsFBO.width,this.binsFBO.height]};this.model.shaderInputs.setProps({binSorter:i})}setModelProps(t){let e=this.model;t.attributes&&e.setAttributes(t.attributes),t.constantAttributes&&e.setConstantAttributes(t.constantAttributes),t.vertexCount!==void 0&&e.setVertexCount(t.vertexCount),t.shaderModuleProps&&e.shaderInputs.setProps(t.shaderModuleProps)}update(t){if(!this.binsFBO)return;let e=Uo(t);this._updateBins("SUM",e.SUM+e.MEAN),this._updateBins("MIN",e.MIN),this._updateBins("MAX",e.MAX)}_updateBins(t,e){if(e===0)return;e|=Pe[3];let o=this.model,r=this.binsFBO,i=t==="MAX"?-Te:t==="MIN"?Te:0,s=this.device.beginRenderPass({id:`gpu-aggregation-${t}`,framebuffer:r,parameters:{viewport:[0,0,r.width,r.height],colorMask:e},clearColor:[i,i,i,0],clearDepth:!1,clearStencil:!1});o.setParameters({blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:t==="MAX"?"max":t==="MIN"?"min":"add",blendAlphaOperation:"add"}),o.draw(s),s.end()}};function Uo(n){let t={...Bo};for(let e=0;e<n.length;e++){let o=n[e];o&&(t[o]+=Pe[e])}return t}function Ho(n,t){let e=t.vs;t.dimensions===2&&(e+=`
12
+ void getBin(out int binId) {
13
+ ivec2 binId2;
14
+ getBin(binId2);
15
+ if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) {
16
+ binId = -1;
17
+ } else {
18
+ binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x;
19
+ }
20
+ }
21
+ `);let o=`#version 300 es
22
+ #define SHADER_NAME gpu-aggregation-sort-bins-vertex
23
+
24
+ ${e}
25
+
26
+ out vec3 v_Value;
27
+
28
+ void main() {
29
+ int binIndex;
30
+ getBin(binIndex);
31
+ binIndex = binIndex - binSorter.binIdRange.x;
32
+ if (binIndex < 0) {
33
+ gl_Position = vec4(0.);
34
+ return;
35
+ }
36
+ int row = binIndex / binSorter.targetSize.x;
37
+ int col = binIndex - row * binSorter.targetSize.x;
38
+ vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0;
39
+ gl_Position = vec4(position, 0.0, 1.0);
40
+ gl_PointSize = 1.0;
41
+
42
+ #if NUM_CHANNELS == 3
43
+ getValue(v_Value);
44
+ #elif NUM_CHANNELS == 2
45
+ getValue(v_Value.xy);
29
46
  #else
30
- float sum = a + b;
31
- float err = b - (sum - a);
47
+ getValue(v_Value.x);
32
48
  #endif
33
- return vec2(sum, err);
34
49
  }
35
- vec2 twoSum(float a, float b) {
36
- float s = (a + b);
37
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
38
- float v = (s * ONE - a) * ONE;
39
- float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);
50
+ `,r=`#version 300 es
51
+ #define SHADER_NAME gpu-aggregation-sort-bins-fragment
52
+
53
+ precision highp float;
54
+
55
+ in vec3 v_Value;
56
+ out vec4 fragColor;
57
+
58
+ void main() {
59
+ fragColor.xyz = v_Value;
60
+
61
+ #ifdef MODULE_GEOMETRY
62
+ geometry.uv = vec2(0.);
63
+ DECKGL_FILTER_COLOR(fragColor, geometry);
64
+ #endif
65
+
66
+ fragColor.w = 1.0;
67
+ }
68
+ `;return new Le.Model(n,{bufferLayout:t.bufferLayout,modules:[...t.modules||[],Ee],defines:{...t.defines,NON_INSTANCED_MODEL:1,NUM_CHANNELS:t.channelCount},isInstanced:!1,vs:o,fs:r,topology:"point-list"})}var Ne=L(X(),1);var ko=`uniform aggregatorTransformUniforms {
69
+ ivec4 binIdRange;
70
+ bvec3 isCount;
71
+ bvec3 isMean;
72
+ float naN;
73
+ } aggregatorTransform;
74
+ `,we={name:"aggregatorTransform",vs:ko,uniformTypes:{binIdRange:"vec4<i32>",isCount:"vec3<f32>",isMean:"vec3<f32>"}};var ee=3e38,Pt=class{constructor(t,e){this.binBuffer=null,this.valueBuffer=null,this._domains=null,this.device=t,this.channelCount=e.channelCount,this.transform=jo(t,e),this.domainFBO=Tt(t,2,1)}destroy(){this.transform.destroy(),this.binBuffer?.destroy(),this.valueBuffer?.destroy(),this.domainFBO.colorAttachments[0].texture.destroy(),this.domainFBO.destroy()}get domains(){if(!this._domains){let t=this.device.readPixelsToArrayWebGL(this.domainFBO).buffer,e=new Float32Array(t);this._domains=[[-e[4],e[0]],[-e[5],e[1]],[-e[6],e[2]]].slice(0,this.channelCount)}return this._domains}setDimensions(t,e){let{model:o,transformFeedback:r}=this.transform;o.setVertexCount(t);let i={binIdRange:[e[0][0],e[0][1],e[1]?.[0]||0,e[1]?.[1]||0]};o.shaderInputs.setProps({aggregatorTransform:i});let s=t*e.length*4;(!this.binBuffer||this.binBuffer.byteLength<s)&&(this.binBuffer?.destroy(),this.binBuffer=this.device.createBuffer({byteLength:s}),r.setBuffer("binIds",this.binBuffer));let a=t*this.channelCount*4;(!this.valueBuffer||this.valueBuffer.byteLength<a)&&(this.valueBuffer?.destroy(),this.valueBuffer=this.device.createBuffer({byteLength:a}),r.setBuffer("values",this.valueBuffer))}update(t,e){if(!t)return;let o=this.transform,r=this.domainFBO,i=[0,1,2].map(c=>e[c]==="COUNT"?1:0),s=[0,1,2].map(c=>e[c]==="MEAN"?1:0),a={isCount:i,isMean:s,bins:t};o.model.shaderInputs.setProps({aggregatorTransform:a}),o.run({id:"gpu-aggregation-domain",framebuffer:r,parameters:{viewport:[0,0,2,1]},clearColor:[-ee,-ee,-ee,0],clearDepth:!1,clearStencil:!1}),this._domains=null}};function jo(n,t){let e=`#version 300 es
75
+ #define SHADER_NAME gpu-aggregation-domain-vertex
76
+
77
+ uniform sampler2D bins;
78
+
79
+ #if NUM_DIMS == 1
80
+ out float binIds;
40
81
  #else
41
- float v = s - a;
42
- float err = (a - (s - v)) + (b - v);
82
+ out vec2 binIds;
43
83
  #endif
44
- return vec2(s, err);
45
- }
46
- vec2 twoSub(float a, float b) {
47
- float s = (a - b);
48
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
49
- float v = (s * ONE - a) * ONE;
50
- float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);
84
+
85
+ #if NUM_CHANNELS == 1
86
+ flat out float values;
87
+ #elif NUM_CHANNELS == 2
88
+ flat out vec2 values;
51
89
  #else
52
- float v = s - a;
53
- float err = (a - (s - v)) - (b + v);
90
+ flat out vec3 values;
54
91
  #endif
55
- return vec2(s, err);
56
- }
57
- vec2 twoSqr(float a) {
58
- float prod = a * a;
59
- vec2 a_fp64 = split(a);
60
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
61
- float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *
62
- a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;
92
+
93
+ const float NAN = intBitsToFloat(-1);
94
+
95
+ void main() {
96
+ int row = gl_VertexID / SAMPLER_WIDTH;
97
+ int col = gl_VertexID - row * SAMPLER_WIDTH;
98
+ vec4 weights = texelFetch(bins, ivec2(col, row), 0);
99
+ vec3 value3 = mix(
100
+ mix(weights.rgb, vec3(weights.a), aggregatorTransform.isCount),
101
+ weights.rgb / max(weights.a, 1.0),
102
+ aggregatorTransform.isMean
103
+ );
104
+ if (weights.a == 0.0) {
105
+ value3 = vec3(NAN);
106
+ }
107
+
108
+ #if NUM_DIMS == 1
109
+ binIds = float(gl_VertexID + aggregatorTransform.binIdRange.x);
63
110
  #else
64
- float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
65
- #endif
66
- return vec2(prod, err);
67
- }
68
- vec2 twoProd(float a, float b) {
69
- float prod = a * b;
70
- vec2 a_fp64 = split(a);
71
- vec2 b_fp64 = split(b);
72
- float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +
73
- a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;
74
- return vec2(prod, err);
75
- }
76
- vec2 sum_fp64(vec2 a, vec2 b) {
77
- vec2 s, t;
78
- s = twoSum(a.x, b.x);
79
- t = twoSum(a.y, b.y);
80
- s.y += t.x;
81
- s = quickTwoSum(s.x, s.y);
82
- s.y += t.y;
83
- s = quickTwoSum(s.x, s.y);
84
- return s;
85
- }
86
- vec2 sub_fp64(vec2 a, vec2 b) {
87
- vec2 s, t;
88
- s = twoSub(a.x, b.x);
89
- t = twoSub(a.y, b.y);
90
- s.y += t.x;
91
- s = quickTwoSum(s.x, s.y);
92
- s.y += t.y;
93
- s = quickTwoSum(s.x, s.y);
94
- return s;
95
- }
96
- vec2 mul_fp64(vec2 a, vec2 b) {
97
- vec2 prod = twoProd(a.x, b.x);
98
- prod.y += a.x * b.y;
99
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
100
- prod = split2(prod);
101
- #endif
102
- prod = quickTwoSum(prod.x, prod.y);
103
- prod.y += a.y * b.x;
104
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
105
- prod = split2(prod);
111
+ int y = gl_VertexID / (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);
112
+ int x = gl_VertexID - y * (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);
113
+ binIds.y = float(y + aggregatorTransform.binIdRange.z);
114
+ binIds.x = float(x + aggregatorTransform.binIdRange.x);
106
115
  #endif
107
- prod = quickTwoSum(prod.x, prod.y);
108
- return prod;
109
- }
110
- vec2 div_fp64(vec2 a, vec2 b) {
111
- float xn = 1.0 / b.x;
112
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
113
- vec2 yn = mul_fp64(a, vec2(xn, 0));
116
+
117
+ #if NUM_CHANNELS == 3
118
+ values = value3;
119
+ #elif NUM_CHANNELS == 2
120
+ values = value3.xy;
114
121
  #else
115
- vec2 yn = a * xn;
122
+ values = value3.x;
116
123
  #endif
117
- float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
118
- vec2 prod = twoProd(xn, diff);
119
- return sum_fp64(yn, prod);
120
- }
121
- vec2 sqrt_fp64(vec2 a) {
122
- if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
123
- if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
124
- float x = 1.0 / sqrt(a.x);
125
- float yn = a.x * x;
126
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
127
- vec2 yn_sqr = twoSqr(yn) * ONE;
124
+
125
+ gl_Position = vec4(0., 0., 0., 1.);
126
+ // This model renders into a 2x1 texture to obtain min and max simultaneously.
127
+ // See comments in fragment shader
128
+ gl_PointSize = 2.0;
129
+ }
130
+ `,o=`#version 300 es
131
+ #define SHADER_NAME gpu-aggregation-domain-fragment
132
+
133
+ precision highp float;
134
+
135
+ #if NUM_CHANNELS == 1
136
+ flat in float values;
137
+ #elif NUM_CHANNELS == 2
138
+ flat in vec2 values;
128
139
  #else
129
- vec2 yn_sqr = twoSqr(yn);
140
+ flat in vec3 values;
130
141
  #endif
131
- float diff = sub_fp64(a, yn_sqr).x;
132
- vec2 prod = twoProd(x * 0.5, diff);
133
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
134
- return sum_fp64(split(yn), prod);
142
+
143
+ out vec4 fragColor;
144
+
145
+ void main() {
146
+ vec3 value3;
147
+ #if NUM_CHANNELS == 3
148
+ value3 = values;
149
+ #elif NUM_CHANNELS == 2
150
+ value3.xy = values;
135
151
  #else
136
- return sum_fp64(vec2(yn, 0.0), prod);
152
+ value3.x = values;
137
153
  #endif
138
- }
139
- `;var mi={ONE:1};function hi(){return mi}var q={name:"fp64-arithmetic",vs:mt,getUniforms:hi,fp64ify:qe,fp64LowPart:dt,fp64ifyMatrix4:pt};var K=M(E(),1);var T={SUM:1,MEAN:2,MIN:3,MAX:4};function ht(n,e){return n+e}function xi(n,e){return e>n?e:n}function vi(n,e){return e<n?e:n}function Si(n,e){if(Number.isFinite(e))return n.length?e:null;let t=n.map(e).filter(Number.isFinite);return t.length?t.reduce(ht,0)/t.length:null}function yi(n,e){if(Number.isFinite(e))return n.length?n.length*e:null;let t=n.map(e).filter(Number.isFinite);return t.length?t.reduce(ht,0):null}function Ai(n,e){if(Number.isFinite(e))return n.length?e:null;let t=n.map(e).filter(Number.isFinite);return t.length?t.reduce(xi,-1/0):null}function _i(n,e){if(Number.isFinite(e))return n.length?e:null;let t=n.map(e).filter(Number.isFinite);return t.length?t.reduce(vi,1/0):null}function Y(n,e,t){let o=T[n]||T.SUM;switch(e=bi(e,t),o){case T.MIN:return i=>_i(i,e);case T.SUM:return i=>yi(i,e);case T.MEAN:return i=>Si(i,e);case T.MAX:return i=>Ai(i,e);default:return null}}function bi(n,e={}){return Number.isFinite(n)?n:t=>(e.index=t.index,n(t.source,e))}function xt(n,e={}){return t=>(e.indices=t.map(o=>o.index),n(t.map(o=>o.source),e))}var vt={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},U=3402823466e29,Ye=[32775,32774],$e=[32776,32774],St=[32776,32775],Ke={[T.SUM]:32774,[T.MEAN]:32774,[T.MIN]:Ye,[T.MAX]:$e};var yt={size:1,operation:T.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},At=4;var _t=`#version 300 es
140
- #define SHADER_NAME gpu-aggregation-to-grid-vs
141
- in vec3 positions;
142
- in vec3 positions64Low;
143
- in vec3 weights;
144
- uniform vec2 cellSize;
145
- uniform vec2 gridSize;
146
- uniform bool projectPoints;
147
- uniform vec2 translation;
148
- uniform vec3 scaling;
149
- out vec3 vWeights;
150
- vec2 project_to_pixel(vec4 pos) {
151
- vec4 result;
152
- pos.xy = pos.xy/pos.w;
153
- result = pos + vec4(translation, 0., 0.);
154
- result.xy = scaling.z > 0. ? result.xy * scaling.xy : result.xy;
155
- return result.xy;
156
- }
157
- void main(void) {
158
- vWeights = weights;
159
- vec4 windowPos = vec4(positions, 1.);
160
- if (projectPoints) {
161
- windowPos = project_position_to_clipspace(positions, positions64Low, vec3(0));
162
- }
163
- vec2 pos = project_to_pixel(windowPos);
164
- vec2 pixelXY64[2];
165
- pixelXY64[0] = vec2(pos.x, 0.);
166
- pixelXY64[1] = vec2(pos.y, 0.);
167
- vec2 gridXY64[2];
168
- gridXY64[0] = div_fp64(pixelXY64[0], vec2(cellSize.x, 0));
169
- gridXY64[1] = div_fp64(pixelXY64[1], vec2(cellSize.y, 0));
170
- float x = floor(gridXY64[0].x);
171
- float y = floor(gridXY64[1].x);
172
- pos = vec2(x, y);
173
- pos = (pos * (2., 2.) / (gridSize)) - (1., 1.);
174
- vec2 offset = 1.0 / gridSize;
175
- pos = pos + offset;
176
- gl_Position = vec4(pos, 0.0, 1.0);
177
- gl_PointSize = 1.0;
178
- }
179
- `;var bt=`#version 300 es
180
- #define SHADER_NAME gpu-aggregation-to-grid-fs
181
- precision highp float;
182
- in vec3 vWeights;
183
- out vec4 fragColor;
184
- void main(void) {
185
- fragColor = vec4(vWeights, 1.0);
186
- DECKGL_FILTER_COLOR(fragColor, geometry);
187
- }
188
- `;var Mt=`#version 300 es
189
- #define SHADER_NAME gpu-aggregation-all-vs-64
190
- in vec2 position;
191
- uniform ivec2 gridSize;
192
- out vec2 vTextureCoord;
193
- void main(void) {
194
- vec2 pos = vec2(-1.0, -1.0);
195
- vec2 offset = 1.0 / vec2(gridSize);
196
- pos = pos + offset;
197
- gl_Position = vec4(pos, 0.0, 1.0);
198
- int yIndex = gl_InstanceID / gridSize[0];
199
- int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
200
- vec2 yIndexFP64 = vec2(float(yIndex), 0.);
201
- vec2 xIndexFP64 = vec2(float(xIndex), 0.);
202
- vec2 gridSizeYFP64 = vec2(gridSize[1], 0.);
203
- vec2 gridSizeXFP64 = vec2(gridSize[0], 0.);
204
- vec2 texCoordXFP64 = div_fp64(yIndexFP64, gridSizeYFP64);
205
- vec2 texCoordYFP64 = div_fp64(xIndexFP64, gridSizeXFP64);
206
- vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x);
207
- gl_PointSize = 1.0;
208
- }
209
- `;var Tt=`#version 300 es
210
- #define SHADER_NAME gpu-aggregation-all-fs
211
- precision highp float;
212
- in vec2 vTextureCoord;
213
- uniform sampler2D uSampler;
214
- uniform bool combineMaxMin;
215
- out vec4 fragColor;
216
- void main(void) {
217
- vec4 textureColor = texture(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
218
- if (textureColor.a == 0.) {
219
- discard;
220
- }
221
- fragColor.rgb = textureColor.rgb;
222
- fragColor.a = combineMaxMin ? textureColor.r : textureColor.a;
223
- }
224
- `;var Ct=`#version 300 es
225
- #define SHADER_NAME gpu-aggregation-transform-mean-vs
226
- in vec4 aggregationValues;
227
- out vec4 meanValues;
228
- void main()
229
- {
230
- bool isCellValid = bool(aggregationValues.w > 0.);
231
- meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0);
232
- meanValues.w = aggregationValues.w;
233
- gl_PointSize = 1.0;
234
- }
235
- `;var Mi={minFilter:"nearest",magFilter:"nearest"};function $(n,e){let{width:t=1,height:o=1,data:i=null,parameters:r=Mi}=e;return n.createTexture({data:i,format:"rgba32float",mipmaps:!1,sampler:r,width:t,height:o})}function pe(n,e){let{id:t,width:o=1,height:i=1,texture:r}=e;return n.createFramebuffer({id:t,width:o,height:i,colorAttachments:[r]})}var Ti=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],Et={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},Ci=["float32-renderable-webgl","texture-blend-float-webgl"],C=class{static getAggregationData({aggregationData:e,maxData:t,minData:o,maxMinData:i,pixelIndex:r}){let a=r*At,s={};return e&&(s.cellCount=e[a+3],s.cellWeight=e[a]),i?(s.maxCellWieght=i[0],s.minCellWeight=i[3]):(t&&(s.maxCellWieght=t[0],s.totalCount=t[3]),o&&(s.minCellWeight=o[0],s.totalCount=o[3])),s}static getCellData({countsData:e,size:t=1}){let o=e.length/4,i=new Float32Array(o*t),r=new Uint32Array(o);for(let a=0;a<o;a++){for(let s=0;s<t;s++)i[a*t+s]=e[a*4+s];r[a]=e[a*4+3]}return{cellCounts:r,cellWeights:i}}static isSupported(e){return Ci.every(t=>e.features.has(t))}constructor(e,t={}){this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},shaderOptions:{},modelDirty:!1,resources:{},results:{}},this.id=t.id||"gpu-grid-aggregator",this.device=e;let o=["float32-renderable-webgl"];this._hasGPUSupport=o.every(i=>e.features.has(i)),this._hasGPUSupport&&this._setupModels()}delete(){let{gridAggregationModel:e,allAggregationModel:t,meanTransform:o}=this,{textures:i,framebuffers:r,maxMinFramebuffers:a,minFramebuffers:s,maxFramebuffers:l,meanTextures:c,resources:g}=this.state;e?.destroy(),t?.destroy(),o?.destroy(),Pi([r,i,a,s,l,c,g])}run(e={}){this.setState({results:{}});let t=this._normalizeAggregationParams(e);return this._runAggregation(t)}getData(e){let t={},o=this.state.results;o[e].aggregationData||(o[e].aggregationData=o[e].aggregationBuffer.getData()),t.aggregationData=o[e].aggregationData;for(let i in Et){let r=Et[i];(o[e][i]||o[e][r])&&(o[e][i]=o[e][i]||o[e][r].getData(),t[i]=o[e][i])}return t}updateShaders(e={}){this.setState({shaderOptions:e,modelDirty:!0})}_normalizeAggregationParams(e){let t={...vt,...e},{weights:o}=t;return o&&(t.weights=Ei(o)),t}setState(e){Object.assign(this.state,e)}_getAggregateData(e){let t={},{textures:o,framebuffers:i,maxMinFramebuffers:r,minFramebuffers:a,maxFramebuffers:s,resources:l}=this.state,{weights:c}=e;for(let g in c){t[g]={};let{needMin:f,needMax:d,combineMaxMin:p}=c[g];t[g].aggregationTexture=o[g],t[g].aggregationBuffer=this.device.readPixelsToBufferWebGL(i[g],{target:c[g].aggregationBuffer,sourceType:5126}),f&&d&&p?(t[g].maxMinBuffer=this.device.readPixelsToBufferWebGL(r[g],{target:c[g].maxMinBuffer,sourceType:5126}),t[g].maxMinTexture=l[`${g}-maxMinTexture`]):(f&&(t[g].minBuffer=this.device.readPixelsToBufferWebGL(a[g],{target:c[g].minBuffer,sourceType:5126}),t[g].minTexture=l[`${g}-minTexture`]),d&&(t[g].maxBuffer=this.device.readPixelsToBufferWebGL(s[g],{target:c[g].maxBuffer,sourceType:5126}),t[g].maxTexture=l[`${g}-maxTexture`]))}return this._trackGPUResultBuffers(t,c),t}_renderAggregateData(e){let{cellSize:t,projectPoints:o,attributes:i,moduleSettings:r,numCol:a,numRow:s,weights:l,translation:c,scaling:g}=e,{maxMinFramebuffers:f,minFramebuffers:d,maxFramebuffers:p}=this.state,x=[a,s],h={blend:!0,depthTest:!1,blendFunc:[1,1]},y={cellSize:t,gridSize:x,projectPoints:o,translation:c,scaling:g};for(let S in l){let{needMin:A,needMax:_}=l[S],b=A&&_&&l[S].combineMaxMin;this._renderToWeightsTexture({id:S,parameters:h,moduleSettings:r,uniforms:y,gridSize:x,attributes:i,weights:l}),b?this._renderToMaxMinTexture({id:S,parameters:{...h,blendEquation:St},gridSize:x,minOrMaxFb:f[S],clearParams:{clearColor:[0,0,0,U]},combineMaxMin:b}):(A&&this._renderToMaxMinTexture({id:S,parameters:{...h,blendEquation:Ye},gridSize:x,minOrMaxFb:d[S],clearParams:{clearColor:[U,U,U,0]},combineMaxMin:b}),_&&this._renderToMaxMinTexture({id:S,parameters:{...h,blendEquation:$e},gridSize:x,minOrMaxFb:p[S],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:b}))}}_renderToMaxMinTexture(e){let{id:t,gridSize:o,minOrMaxFb:i,combineMaxMin:r,clearParams:a={}}=e,{framebuffers:s}=this.state,{allAggregationModel:l}=this;this.device.withParametersWebGL({...a,framebuffer:i,viewport:[0,0,o[0],o[1]]},()=>{this.device.clearWebGL({color:!0}),l.setUniforms({gridSize:o,combineMaxMin:r}),l.setBindings({uSampler:s[t].texture}),l.draw()})}_renderToWeightsTexture(e){let{id:t,parameters:o,moduleSettings:i,uniforms:r,gridSize:a,weights:s}=e,{framebuffers:l,equations:c,weightAttributes:g}=this.state,{gridAggregationModel:f}=this,{operation:d}=s[t],p=d===T.MIN?[U,U,U,0]:[0,0,0,0];if(this.device.withParametersWebGL({framebuffer:l[t],viewport:[0,0,a[0],a[1]],clearColor:p},()=>{this.device.clearWebGL({color:!0});let x={weights:g[t]};f.draw({parameters:{...o,blendEquation:c[t]},moduleSettings:i,uniforms:r,attributes:x})}),d===T.MEAN){let{meanTextures:x,textures:h}=this.state,y={_sourceTextures:{aggregationValues:x[t]},_targetTexture:h[t],elementCount:h[t].width*h[t].height};this.meanTransform?this.meanTransform.update(y):this.meanTransform=Li(this.device,y),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),l[t].attach({[36064]:h[t]})}}_runAggregation(e){this._updateModels(e),this._setupFramebuffers(e),this._renderAggregateData(e);let t=this._getAggregateData(e);return this.setState({results:t}),t}_setupFramebuffers(e){let{textures:t,framebuffers:o,maxMinFramebuffers:i,minFramebuffers:r,maxFramebuffers:a,meanTextures:s,equations:l}=this.state,{weights:c}=e,{numCol:g,numRow:f}=e,d={width:g,height:f};for(let p in c){let{needMin:x,needMax:h,combineMaxMin:y,operation:S}=c[p];t[p]=c[p].aggregationTexture||t[p]||$(this.device,{id:`${p}-texture`,width:g,height:f}),t[p].resize(d);let A=t[p];S===T.MEAN&&(s[p]=s[p]||$(this.device,{id:`${p}-mean-texture`,width:g,height:f}),s[p].resize(d),A=s[p]),o[p]?o[p].attach({[36064]:A}):o[p]=pe(this.device,{id:`${p}-fb`,width:g,height:f,texture:A}),o[p].resize(d),l[p]=Ke[S]||Ke[T.SUM],(x||h)&&(x&&h&&y?i[p]||(A=c[p].maxMinTexture||this._getMinMaxTexture(`${p}-maxMinTexture`),i[p]=pe(this.device,{id:`${p}-maxMinFb`,texture:A})):(x&&(r[p]||(A=c[p].minTexture||this._getMinMaxTexture(`${p}-minTexture`),r[p]=pe(this.device,{id:`${p}-minFb`,texture:A}))),h&&(a[p]||(A=c[p].maxTexture||this._getMinMaxTexture(`${p}-maxTexture`),a[p]=pe(this.device,{id:`${p}-maxFb`,texture:A})))))}}_getMinMaxTexture(e){let{resources:t}=this.state;return t[e]||(t[e]=$(this.device,{id:"resourceName"})),t[e]}_setupModels({numCol:e=0,numRow:t=0}={}){let{shaderOptions:o}=this.state;if(this.gridAggregationModel?.destroy(),this.gridAggregationModel=Ni(this.device,o),!this.allAggregationModel){let i=e*t;this.allAggregationModel=Di(this.device,i)}}_setupWeightAttributes(e){let{weightAttributes:t}=this.state,{weights:o}=e;for(let i in o)t[i]=e.attributes[i]}_trackGPUResultBuffers(e,t){let{resources:o}=this.state;for(let i in e)if(e[i]){for(let r of Ti)if(e[i][r]&&t[i][r]!==e[i][r]){let a=`gpu-result-${i}-${r}`;o[a]&&o[a].delete(),o[a]=e[i][r]}}}_updateModels(e){let{vertexCount:t,attributes:o,numCol:i,numRow:r}=e,{modelDirty:a}=this.state;a&&(this._setupModels(e),this.setState({modelDirty:!1})),this._setupWeightAttributes(e),this.gridAggregationModel.setVertexCount(t),this.gridAggregationModel.setAttributes(o),this.allAggregationModel.setInstanceCount(i*r)}};function Ei(n){let e={};for(let t in n)e[t]={...yt,...n[t]};return e}function Pi(n){n=Array.isArray(n)?n:[n],n.forEach(e=>{for(let t in e)e[t].delete()})}function Ni(n,e){let t=(0,K._mergeShaders)({vs:_t,fs:bt,modules:[q,K.project32]},e);return new me.Model(n,{id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:(0,K.getShaderAssembler)(),...t})}function Di(n,e){return new me.Model(n,{id:"All-Aggregation-Model",vs:Mt,fs:Tt,modules:[q],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:e,attributes:{position:[0,0]}})}function Li(n,e){return new me.TextureTransform(n,{vs:Ct,_targetTextureVarying:"meanValues",...e})}var Le=M(k(),1),Q=M(E(),1);var N=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function G(n,e=!1,t=Float32Array){let o;if(Number.isFinite(n[0]))o=new t(n);else{o=new t(n.length*4);let i=0;for(let r=0;r<n.length;r++){let a=n[r];o[i++]=a[0],o[i++]=a[1],o[i++]=a[2],o[i++]=Number.isFinite(a[3])?a[3]:255}}if(e)for(let i=0;i<o.length;i++)o[i]/=255;return o}var Pt=`#version 300 es
154
+ if (isnan(value3.x)) discard;
155
+ // This shader renders into a 2x1 texture with blending=max
156
+ // The left pixel yields the max value of each channel
157
+ // The right pixel yields the min value of each channel
158
+ if (gl_FragCoord.x < 1.0) {
159
+ fragColor = vec4(value3, 1.0);
160
+ } else {
161
+ fragColor = vec4(-value3, 1.0);
162
+ }
163
+ }
164
+ `;return new Ne.BufferTransform(n,{vs:e,fs:o,topology:"point-list",modules:[we],parameters:{blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},defines:{NUM_DIMS:t.dimensions,NUM_CHANNELS:t.channelCount,SAMPLER_WIDTH:dt},varyings:["binIds","values"],disableWarnings:!0})}var ut=L(I(),1),P=class{static isSupported(t){return t.features.has("float32-renderable-webgl")&&t.features.has("texture-blend-float-webgl")}constructor(t,e){this.binCount=0,this.binIds=null,this.results=[],this.device=t,this.dimensions=e.dimensions,this.channelCount=e.channelCount,this.props={...e,pointCount:0,binIdRange:[[0,0]],operations:[],attributes:{},binOptions:{}},this.needsUpdate=new Array(this.channelCount).fill(!0),this.binSorter=new Lt(t,e),this.aggregationTransform=new Pt(t,e),this.setProps(e)}getBins(){let t=this.aggregationTransform.binBuffer;return t?(this.binIds?.buffer!==t&&(this.binIds={buffer:t,type:"float32",size:this.dimensions}),this.binIds):null}getResult(t){let e=this.aggregationTransform.valueBuffer;return!e||t>=this.channelCount?null:(this.results[t]?.buffer!==e&&(this.results[t]={buffer:e,type:"float32",size:1,stride:this.channelCount*4,offset:t*4}),this.results[t])}getResultDomain(t){return this.aggregationTransform.domains[t]}getBin(t){if(t<0||t>=this.binCount)return null;let{binIdRange:e}=this.props,o;if(this.dimensions===1)o=[t+e[0][0]];else{let[[a,c],[g]]=e,h=c-a;o=[t%h+a,Math.floor(t/h)+g]}let r=this.binSorter.getBinValues(t);if(!r)return null;let i=r[3],s=[];for(let a=0;a<this.channelCount;a++){let c=this.props.operations[a];c==="COUNT"?s[a]=i:i===0?s[a]=NaN:s[a]=c==="MEAN"?r[a]/i:r[a]}return{id:o,value:s,count:i}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(t){let e=this.props;if("binIdRange"in t&&!(0,ut._deepEqual)(t.binIdRange,e.binIdRange,2)){let o=t.binIdRange;if(ut.log.assert(o.length===this.dimensions),this.dimensions===1){let[[r,i]]=o;this.binCount=i-r}else{let[[r,i],[s,a]]=o;this.binCount=(i-r)*(a-s)}this.binSorter.setDimensions(this.binCount,o),this.aggregationTransform.setDimensions(this.binCount,o),this.setNeedsUpdate()}if(t.operations)for(let o=0;o<this.channelCount;o++)t.operations[o]!==e.operations[o]&&this.setNeedsUpdate(o);if(t.pointCount!==void 0&&t.pointCount!==e.pointCount&&(this.binSorter.setModelProps({vertexCount:t.pointCount}),this.setNeedsUpdate()),t.binOptions&&((0,ut._deepEqual)(t.binOptions,e.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:t.binOptions})),t.attributes){let o={},r={};for(let i of Object.values(t.attributes))for(let[s,a]of Object.entries(i.getValue()))ArrayBuffer.isView(a)?r[s]=a:a&&(o[s]=a);this.binSorter.setModelProps({attributes:o,constantAttributes:r})}t.shaderModuleProps&&this.binSorter.setModelProps({shaderModuleProps:t.shaderModuleProps}),Object.assign(this.props,t)}setNeedsUpdate(t){t===void 0?this.needsUpdate.fill(!0):this.needsUpdate[t]=!0}update(){}preDraw(){if(!this.needsUpdate.some(Boolean))return;let{operations:t}=this.props,e=this.needsUpdate.map((o,r)=>o?t[r]:null);this.binSorter.update(e),this.aggregationTransform.update(this.binSorter.texture,t);for(let o=0;o<this.channelCount;o++)this.needsUpdate[o]&&(this.needsUpdate[o]=!1,this.props.onUpdate?.({channel:o}))}};var Nt=L(I(),1),wt=class extends Nt.CompositeLayer{get isDrawable(){return!0}initializeState(){this.getAttributeManager().remove(["instancePickingColors"])}updateState(t){super.updateState(t);let e=this.getAggregatorType();if(t.changeFlags.extensionsChanged||this.state.aggregatorType!==e){this.state.aggregator?.destroy();let o=this.createAggregator(e);return o.setProps({attributes:this.getAttributeManager()?.attributes}),this.setState({aggregator:o,aggregatorType:e}),!0}return!1}finalizeState(t){super.finalizeState(t),this.state.aggregator.destroy()}updateAttributes(t){let{aggregator:e}=this.state;e.setProps({attributes:t});for(let o in t)this.onAttributeChange(o);e.update()}draw({shaderModuleProps:t}){let{aggregator:e}=this.state;e.setProps({shaderModuleProps:t}),e.preDraw()}_getAttributeManager(){return new Nt.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};wt.layerName="AggregationLayer";var U=wt;var _t=L(X(),1),zt=L(I(),1);var G=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function ne(n,t=!1,e=Float32Array){let o;if(Number.isFinite(n[0]))o=new e(n);else{o=new e(n.length*4);let r=0;for(let i=0;i<n.length;i++){let s=n[i];o[r++]=s[0],o[r++]=s[1],o[r++]=s[2],o[r++]=Number.isFinite(s[3])?s[3]:255}}if(t)for(let r=0;r<o.length;r++)o[r]/=255;return o}var Ot={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function Q(n,t){n.setSampler({minFilter:Ot[t],magFilter:Ot[t]})}function J(n,t,e="linear"){let o=ne(t,!1,Uint8Array);return n.createTexture({format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:Ot[e],magFilter:Ot[e],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:o,width:o.length/4,height:1})}var Oe=`#version 300 es
236
165
  #define SHADER_NAME screen-grid-layer-vertex-shader
237
166
  #define RANGE_COUNT 6
238
- in vec3 positions;
239
- in vec3 instancePositions;
240
- in vec4 instanceCounts;
167
+ in vec2 positions;
168
+ in vec2 instancePositions;
169
+ in float instanceWeights;
241
170
  in vec3 instancePickingColors;
242
- uniform float opacity;
243
- uniform vec3 cellScale;
244
- uniform vec4 minColor;
245
- uniform vec4 maxColor;
246
- uniform vec4 colorRange[RANGE_COUNT];
247
- uniform vec2 colorDomain;
248
- uniform bool shouldUseMinMax;
249
- uniform sampler2D maxTexture;
171
+ uniform sampler2D colorRange;
250
172
  out vec4 vColor;
251
- out float vSampleCount;
252
- vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
253
- vec4 outColor = vec4(0., 0., 0., 0.);
254
- if (value >= domain.x && value <= domain.y) {
255
- float domainRange = domain.y - domain.x;
256
- if (domainRange <= 0.) {
257
- outColor = colorRange[0];
258
- } else {
259
- float rangeCount = float(RANGE_COUNT);
260
- float rangeStep = domainRange / rangeCount;
261
- float idx = floor((value - domain.x) / rangeStep);
262
- idx = clamp(idx, 0., rangeCount - 1.);
263
- int intIdx = int(idx);
264
- outColor = colorRange[intIdx];
265
- }
266
- }
267
- outColor = outColor / 255.;
268
- return outColor;
173
+ vec4 interp(float value, vec2 domain, sampler2D range) {
174
+ float r = (value - domain.x) / (domain.y - domain.x);
175
+ return texture(range, vec2(r, 0.5));
269
176
  }
270
177
  void main(void) {
271
- vSampleCount = instanceCounts.a;
272
- float weight = instanceCounts.r;
273
- float maxWeight = texture(maxTexture, vec2(0.5)).r;
274
- float step = weight / maxWeight;
275
- vec4 minMaxColor = mix(minColor, maxColor, step) / 255.;
276
- vec2 domain = colorDomain;
277
- float domainMaxValid = float(colorDomain.y != 0.);
278
- domain.y = mix(maxWeight, colorDomain.y, domainMaxValid);
279
- vec4 rangeColor = quantizeScale(domain, colorRange, weight);
280
- float rangeMinMax = float(shouldUseMinMax);
281
- vec4 color = mix(rangeColor, minMaxColor, rangeMinMax);
282
- vColor = vec4(color.rgb, color.a * opacity);
178
+ if (isnan(instanceWeights)) {
179
+ gl_Position = vec4(0.);
180
+ return;
181
+ }
182
+ vec2 pos = instancePositions * screenGrid.gridSizeClipspace + positions * screenGrid.cellSizeClipspace;
183
+ pos.x = pos.x - 1.0;
184
+ pos.y = 1.0 - pos.y;
185
+ gl_Position = vec4(pos, 0., 1.);
186
+ vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);
187
+ vColor.a *= layer.opacity;
283
188
  picking_setPickingColor(instancePickingColors);
284
- gl_Position = vec4(instancePositions + positions * cellScale, 1.);
285
189
  }
286
- `;var Nt=`#version 300 es
190
+ `;var Re=`#version 300 es
287
191
  #define SHADER_NAME screen-grid-layer-fragment-shader
288
192
  precision highp float;
289
193
  in vec4 vColor;
290
- in float vSampleCount;
291
194
  out vec4 fragColor;
292
195
  void main(void) {
293
- if (vSampleCount <= 0.0) {
294
- discard;
295
- }
296
196
  fragColor = vColor;
297
197
  DECKGL_FILTER_COLOR(fragColor, geometry);
298
198
  }
299
- `;var Oi=[0,0,0,0],Fi=[0,255,0,255],wi=["minColor","maxColor","colorRange","colorDomain"],Ii={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:N},he=class extends Q.Layer{getShaders(){return{vs:Pt,fs:Nt,modules:[Q.picking]}}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e);let{oldProps:t,props:o,changeFlags:i}=e,r=this.getAttributeManager();o.numInstances!==t.numInstances?r.invalidateAll():t.cellSizePixels!==o.cellSizePixels&&r.invalidate("instancePositions"),this._updateUniforms(t,o,i)}draw({uniforms:e}){let{parameters:t,maxTexture:o}=this.props,i=this.props.minColor||Oi,r=this.props.maxColor||Fi,a=this.props.colorDomain||[1,0],s=this.state.model;s.setUniforms(e),s.setBindings({maxTexture:o}),s.setUniforms({minColor:i,maxColor:r,colorDomain:a}),s.setParameters({depthWriteEnabled:!1,...t}),s.draw(this.context.renderPass)}calculateInstancePositions(e,{numInstances:t}){let{width:o,height:i}=this.context.viewport,{cellSizePixels:r}=this.props,a=Math.ceil(o/r),{value:s,size:l}=e;for(let c=0;c<t;c++){let g=c%a,f=Math.floor(c/a);s[c*l+0]=g*r/o*2-1,s[c*l+1]=1-f*r/i*2,s[c*l+2]=0}}_getModel(){return new Le.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Le.Geometry({topology:"triangle-list",attributes:{positions:new Float32Array([0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0])}}),isInstanced:!0})}_shouldUseMinMax(){let{minColor:e,maxColor:t,colorDomain:o,colorRange:i}=this.props;return e||t?(Q.log.deprecated("ScreenGridLayer props: minColor and maxColor","colorRange, colorDomain")(),!0):!(o||i)}_updateUniforms(e,t,o){let i=this.state.model;if(wi.some(r=>e[r]!==t[r])&&i.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),e.colorRange!==t.colorRange&&i.setUniforms({colorRange:G(t.colorRange)}),e.cellMarginPixels!==t.cellMarginPixels||e.cellSizePixels!==t.cellSizePixels||o.viewportChanged){let{width:r,height:a}=this.context.viewport,{cellSizePixels:s,cellMarginPixels:l}=this.props,c=s>l?l:0,g=new Float32Array([(s-c)/r*2,-(s-c)/a*2,1]);i.setUniforms({cellScale:g})}}};he.layerName="ScreenGridCellLayer";he.defaultProps=Ii;var Qe=he;var qt=M(E(),1);var Z=M(E(),1);function Dt(n,e){let t={};for(let o in n)e.includes(o)||(t[o]=n[o]);return t}var Oe=class extends Z.CompositeLayer{initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:Dt(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:t}=e;if(t.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:t,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:t,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,t={}){let{props:o,oldProps:i,changeFlags:r}=e,{compareAll:a=!1,dimension:s}=t,{ignoreProps:l}=this.state,{props:c,accessors:g=[]}=s,{updateTriggersChanged:f}=r;if(r.dataChanged)return!0;if(f){if(f.all)return!0;for(let d of g)if(f[d])return!0}if(a)return r.extensionsChanged?!0:(0,Z._compareProps)({oldProps:i,newProps:o,ignoreProps:l,propTypes:this.constructor._propTypes});for(let d of c)if(o[d]!==i[d])return!0;return!1}isAttributeChanged(e){let{changedAttributes:t}=this.state;return e?t&&t[e]!==void 0:!Ri(t)}_getAttributeManager(){return new Z.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};Oe.layerName="AggregationLayer";var O=Oe;function Ri(n){let e=!0;for(let t in n){e=!1;break}return e}var Ot=M(E(),1);function Fe(n,e,t){let o=t;return o.domain=()=>n,o.range=()=>e,o}function Lt(n,e){return Fe(n,e,o=>ki(n,e,o))}function Bi(n,e){return Fe(n,e,o=>ji(n,e,o))}function Ui(n,e){let t=n.sort(Ft),o=0,i=Math.max(1,e.length),r=new Array(i-1);for(;++o<i;)r[o-1]=Gi(t,o/i);let a=s=>zi(r,e,s);return a.thresholds=()=>r,Fe(n,e,a)}function Ft(n,e){return n-e}function Gi(n,e){let t=n.length;if(e<=0||t<2)return n[0];if(e>=1)return n[t-1];let o=(t-1)*e,i=Math.floor(o),r=n[i],a=n[i+1];return r+(a-r)*(o-i)}function Wi(n,e){let t=0,o=n.length;for(;t<o;){let i=t+o>>>1;Ft(n[i],e)>0?o=i:t=i+1}return t}function zi(n,e,t){return e[Wi(n,t)]}function Hi(n,e,t,o){let i=`${o}`,r=e.get(i);return r===void 0&&(r=n.push(o),e.set(i,r)),t[(r-1)%t.length]}function Vi(n,e){let t=new Map,o=[];for(let r of n){let a=`${r}`;t.has(a)||t.set(a,o.push(r))}return Fe(n,e,r=>Hi(o,t,e,r))}function ki(n,e,t){let o=n[1]-n[0];if(o<=0)return Ot.log.warn("quantizeScale: invalid domain, returning range[0]")(),e[0];let i=o/e.length,r=Math.floor((t-n[0])/i),a=Math.max(Math.min(r,e.length-1),0);return e[a]}function ji(n,e,t){return(t-n[0])/(n[1]-n[0])*(e[1]-e[0])+e[0]}function wt(n){return n!=null}function Xi(n){let e=[];return n.forEach(t=>{!e.includes(t)&&wt(t)&&e.push(t)}),e}function It(n,e){return(typeof e=="function"?n.map(e):n).filter(wt)}function Rt(n,e){return It(n,e)}function Bt(n,e){return Xi(It(n,e))}function Ut(n,e,t){return Math.max(e,Math.min(t,n))}function Gt(n){switch(n){case"quantize":return Lt;case"linear":return Bi;case"quantile":return Ui;case"ordinal":return Vi;default:return Lt}}var zt=n=>n.length,qi=3402823466e29,Ht=n=>n.points,Vt=n=>n.index,Wt=(n,e)=>n<e?-1:n>e?1:n>=e?0:NaN,Yi={getValue:zt,getPoints:Ht,getIndex:Vt,filterData:null},F=class{constructor(e=[],t=Yi){this.aggregatedBins=this.getAggregatedBins(e,t),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(e,t){let{getValue:o=zt,getPoints:i=Ht,getIndex:r=Vt,filterData:a}=t,s=typeof a=="function",l=e.length,c=[],g=0;for(let f=0;f<l;f++){let d=e[f],p=i(d),x=r(d),h=s?p.filter(a):p;d.filteredPoints=s?h:null;let y=h.length?o(h):null;y!=null&&(c[g]={i:Number.isFinite(x)?x:f,value:y,counts:h.length},g++)}return c}_percentileToIndex(e){let t=this.sortedBins.length;if(t<2)return[0,0];let[o,i]=e.map(s=>Ut(s,0,100)),r=Math.ceil(o/100*(t-1)),a=Math.floor(i/100*(t-1));return[r,a]}getBinMap(){let e={};for(let t of this.aggregatedBins)e[t.i]=t;return e}_updateMinMaxValues(){let e=0,t=0,o=qi,i=0;for(let r of this.aggregatedBins)e=e>r.counts?e:r.counts,t=t>r.value?t:r.value,o=o<r.value?o:r.value,i+=r.counts;this.maxCount=e,this.maxValue=t,this.minValue=o,this.totalCount=i}getValueRange(e){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((i,r)=>Wt(i.value,r.value))),!this.sortedBins.length)return[];let t=0,o=this.sortedBins.length-1;if(Array.isArray(e)){let i=this._percentileToIndex(e);t=i[0],o=i[1]}return[this.sortedBins[t].value,this.sortedBins[o].value]}getValueDomainByScale(e,[t=0,o=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((r,a)=>Wt(r.value,a.value))),!this.sortedBins.length)return[];let i=this._percentileToIndex([t,o]);return this._getScaleDomain(e,i)}_getScaleDomain(e,[t,o]){let i=this.sortedBins;switch(e){case"quantize":case"linear":return[i[t].value,i[o].value];case"quantile":return Rt(i.slice(t,o+1),r=>r.value);case"ordinal":return Bt(i,r=>r.value);default:return[i[t].value,i[o].value]}}};var Xt=M(E(),1);var W=M(E(),1),jt=6378e3;function we(n){return Number.isFinite(n)?n:0}function Ie(n,e){let t=n.positions.value,o=1/0,i=-1/0,r=1/0,a=-1/0,s,l;for(let g=0;g<e;g++)l=t[g*3],s=t[g*3+1],o=s<o?s:o,i=s>i?s:i,r=l<r?l:r,a=l>a?l:a;return{xMin:we(r),xMax:we(a),yMin:we(o),yMax:we(i)}}function $i(n,e,t,o){let{width:i,height:r}=o,a=t===W.COORDINATE_SYSTEM.CARTESIAN?[-i/2,-r/2]:[-180,-90];W.log.assert(t===W.COORDINATE_SYSTEM.CARTESIAN||t===W.COORDINATE_SYSTEM.LNGLAT||t===W.COORDINATE_SYSTEM.DEFAULT);let{xMin:s,yMin:l}=n;return[-1*(kt(s-a[0],e.xOffset)+a[0]),-1*(kt(l-a[1],e.yOffset)+a[1])]}function kt(n,e){let t=n<0?-1:1,o=t<0?Math.abs(n)+e:Math.abs(n);return o=Math.floor(o/e)*e,o*t}function Ze(n,e,t=!0){if(!t)return{xOffset:e,yOffset:e};let{yMin:o,yMax:i}=n,r=(o+i)/2;return Ki(e,r)}function Re(n,e,t,o){let i=Ze(n,e,o!==W.COORDINATE_SYSTEM.CARTESIAN),r=$i(n,i,o,t),{xMin:a,yMin:s,xMax:l,yMax:c}=n,g=l-a+i.xOffset,f=c-s+i.yOffset,d=Math.ceil(g/i.xOffset),p=Math.ceil(f/i.yOffset);return{gridOffset:i,translation:r,width:g,height:f,numCol:d,numRow:p}}function Ki(n,e){let t=Qi(n),o=Zi(e,n);return{yOffset:t,xOffset:o}}function Qi(n){return n/jt*(180/Math.PI)}function Zi(n,e){return e/jt*(180/Math.PI)/Math.cos(n*Math.PI/180)}function J(n,e){let t=Ji(n,e),o=er(t);return{gridHash:t.gridHash,gridOffset:t.gridOffset,data:o}}function Ji(n,e){let{data:t=[],cellSize:o}=n,{attributes:i,viewport:r,projectPoints:a,numInstances:s}=e,l=i.positions.value,{size:c}=i.positions.getAccessor(),g=e.boundingBox||tr(i.positions,s),f=e.posOffset||[180,90],d=e.gridOffset||Ze(g,o);if(d.xOffset<=0||d.yOffset<=0)return{gridHash:{},gridOffset:d,offsets:[0,0]};let{width:p,height:x}=r,h=Math.ceil(p/d.xOffset),y=Math.ceil(x/d.yOffset),S={},{iterable:A,objectInfo:_}=(0,Xt.createIterable)(t),b=new Array(3);for(let D of A){_.index++,b[0]=l[_.index*c],b[1]=l[_.index*c+1],b[2]=c>=3?l[_.index*c+2]:0;let[R,fe]=a?r.project(b):b;if(Number.isFinite(R)&&Number.isFinite(fe)){let z=Math.floor((fe+f[1])/d.yOffset),H=Math.floor((R+f[0])/d.xOffset);if(!a||H>=0&&H<h&&z>=0&&z<y){let V=`${z}-${H}`;S[V]=S[V]||{count:0,points:[],lonIdx:H,latIdx:z},S[V].count+=1,S[V].points.push({source:D,index:_.index})}}}return{gridHash:S,gridOffset:d,offsets:[f[0]*-1,f[1]*-1]}}function er({gridHash:n,gridOffset:e,offsets:t}){let o=new Array(Object.keys(n).length),i=0;for(let r in n){let a=r.split("-"),s=parseInt(a[0],10),l=parseInt(a[1],10),c=i++;o[c]={index:c,position:[t[0]+e.xOffset*l,t[1]+e.yOffset*s],...n[r]}}return o}function tr(n,e){let t=n.value,{size:o}=n.getAccessor(),i=1/0,r=-1/0,a=1/0,s=-1/0,l,c;for(let g=0;g<e;g++)c=t[g*o],l=t[g*o+1],Number.isFinite(c)&&Number.isFinite(l)&&(i=l<i?l:i,r=l>r?l:r,a=c<a?c:a,s=c>s?c:s);return{xMin:a,xMax:s,yMin:i,yMax:r}}var Be=class extends O{initializeAggregationLayer({dimensions:e}){super.initializeAggregationLayer(e),this.setState({layerData:{},gpuGridAggregator:new C(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:J})}updateState(e){super.updateState(e),this.updateAggregationState(e);let{aggregationDataDirty:t,aggregationWeightsDirty:o,gpuAggregation:i}=this.state;if(this.getNumInstances()<=0)return;let r=!1;(t||i&&o)&&(this._updateAggregation(e),r=!0),!i&&(t||o)&&(this._updateWeightBins(),this._uploadAggregationResults(),r=!0),this.setState({aggregationDirty:r})}finalizeState(e){let{count:t}=this.state.weights;t&&t.aggregationBuffer&&t.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(e)}updateShaders(e){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(e)}updateAggregationState(e){qt.log.assert(!1)}allocateResources(e,t){if(this.state.numRow!==e||this.state.numCol!==t){let o=t*e*4*4,{weights:i}=this.state;for(let r in i){let a=i[r];a.aggregationBuffer&&a.aggregationBuffer.delete(),a.aggregationBuffer=this.context.device.createBuffer({byteLength:o,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:e,maxMinData:t,maxData:o,minData:i}){let{count:r}=this.state.weights;r&&(r.aggregationData=e,r.maxMinData=t,r.maxData=o,r.minData=i)}_updateAggregation(e){let{cpuGridAggregator:t,gpuGridAggregator:o,gridOffset:i,posOffset:r,translation:a=[0,0],scaling:s=[0,0,0],boundingBox:l,projectPoints:c,gpuAggregation:g,numCol:f,numRow:d}=this.state,{props:p}=e,{viewport:x}=this.context,h=this.getAttributes(),y=this.getNumInstances();if(g){let{weights:S}=this.state;o.run({weights:S,cellSize:[i.xOffset,i.yOffset],numCol:f,numRow:d,translation:a,scaling:s,vertexCount:y,projectPoints:c,attributes:h,moduleSettings:this.getModuleSettings()})}else{let S=t(p,{gridOffset:i,projectPoints:c,attributes:h,viewport:x,posOffset:r,boundingBox:l});this.setState({layerData:S})}}_updateWeightBins(){let{getValue:e}=this.state,t=new F(this.state.layerData.data||[],{getValue:e});this.setState({sortedBins:t})}_uploadAggregationResults(){let{numCol:e,numRow:t}=this.state,{data:o}=this.state.layerData,{aggregatedBins:i,minValue:r,maxValue:a,totalCount:s}=this.state.sortedBins,l=4,c=e*t*l,g=new Float32Array(c).fill(0);for(let x of i){let{lonIdx:h,latIdx:y}=o[x.i],{value:S,counts:A}=x,_=(h+y*e)*l;g[_]=S,g[_+l-1]=A}let f=new Float32Array([a,0,0,r]),d=new Float32Array([a,0,0,s]),p=new Float32Array([r,0,0,s]);this.updateResults({aggregationData:g,maxMinData:f,maxData:d,minData:p})}};Be.layerName="GridAggregationLayer";var ee=Be;var or={...Qe.defaultProps,getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},Yt="positions",ir={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},xe=class extends ee{initializeState(){super.initializeAggregationLayer({dimensions:ir,getCellSize:o=>o.cellSizePixels});let e={count:{size:1,operation:T.SUM,needMax:!0,maxTexture:$(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:e,subLayerData:{attributes:{}},maxTexture:e.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[Yt]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return this.state.supported&&e.somethingChanged}updateState(e){super.updateState(e)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:e,numRow:t,numCol:o,weights:i}=this.state,{updateTriggers:r}=this.props,{aggregationBuffer:a}=i.count,s=this.getSubLayerClass("cells",Qe);return new s(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:r}),{data:{attributes:{instanceCounts:a}},maxTexture:e,numInstances:t*o})}finalizeState(e){super.finalizeState(e);let{aggregationBuffer:t,maxBuffer:o,maxTexture:i}=this.state;t?.delete(),o?.delete(),i?.delete()}getPickingInfo({info:e}){let{index:t}=e;if(t>=0){let{gpuGridAggregator:o,gpuAggregation:i,weights:r}=this.state,a=i?o.getData("count"):r.count;e.object=C.getAggregationData({pixelIndex:t,...a})}return e}updateResults({aggregationData:e,maxData:t}){let{count:o}=this.state.weights;o.aggregationData=e,o.aggregationBuffer.write(e),o.maxData=t,o.maxTexture.setImageData({data:t})}updateAggregationState(e){let t=e.props.cellSizePixels,o=e.oldProps.cellSizePixels!==t,{viewportChanged:i}=e.changeFlags,r=e.props.gpuAggregation;this.state.gpuAggregation!==e.props.gpuAggregation&&r&&!C.isSupported(this.context.device)&&($t.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),r=!1);let a=r!==this.state.gpuAggregation;this.setState({gpuAggregation:r});let s=this.isAttributeChanged(Yt),{dimensions:l}=this.state,{data:c,weights:g}=l,f=s||a||i||this.isAggregationDirty(e,{compareAll:r,dimension:c}),d=this.isAggregationDirty(e,{dimension:g});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:d});let{viewport:p}=this.context;if(i||o){let{width:x,height:h}=p,y=Math.ceil(x/t),S=Math.ceil(h/t);this.allocateResources(S,y),this.setState({scaling:[x/2,-h/2,1],gridOffset:{xOffset:t,yOffset:t},width:x,height:h,numCol:y,numRow:S})}d&&this._updateAccessors(e),(f||d)&&this._resetResults()}_updateAccessors(e){let{getWeight:t,aggregation:o,data:i}=e.props,{count:r}=this.state.weights;r&&(r.getWeight=t,r.operation=T[o]),this.setState({getValue:Y(o,t,{data:i})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}};xe.layerName="ScreenGridLayer";xe.defaultProps=or;var Kt=xe;var to=M(X(),1);function Qt(){}var Zt=["getBins","getDomain","getScaleFunc"],Jt=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],rr=n=>n.cellSize,w=class{constructor(e){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=e.getCellSize||rr,this._getAggregator=e.getAggregator,this._addDimension(e.dimensions||Jt)}static defaultDimensions(){return Jt}updateState(e,t){let{oldProps:o,props:i,changeFlags:r}=e;this.updateGetValueFuncs(o,i,r);let a=this.needsReProjectPoints(o,i,r),s=!1;return r.dataChanged||a?(this.getAggregatedData(i,t),s=!0):((this.getDimensionChanges(o,i,r)||[]).forEach(c=>typeof c=="function"&&c()),s=!0),this.setState({aggregationDirty:s}),this.state}setState(e){this.state={...this.state,...e}}setDimensionState(e,t){this.setState({dimensions:{...this.state.dimensions,[e]:{...this.state.dimensions[e],...t}}})}normalizeResult(e={}){return e.hexagons?{data:e.hexagons,...e}:e.layerData?{data:e.layerData,...e}:e}getAggregatedData(e,t){let i=this._getAggregator(e)(e,t);this.setState({layerData:this.normalizeResult(i)}),this.changeFlags={layerData:!0},this.getSortedBins(e)}updateGetValueFuncs(e,t,o){for(let i in this.dimensionUpdaters){let{value:r,weight:a,aggregation:s}=this.dimensionUpdaters[i].getBins.triggers,l=t[r.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[i].getBins,e,t,o)&&(l?l=xt(l,{data:t.data}):l=Y(t[s.prop],t[a.prop],{data:t.data})),l&&this.setDimensionState(i,{getValue:l})}}needsReProjectPoints(e,t,o){return this._getCellSize(e)!==this._getCellSize(t)||this._getAggregator(e)!==this._getAggregator(t)||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPosition)}addDimension(e){this._addDimension(e)}_addDimension(e=[]){e.forEach(t=>{let{key:o}=t;this.dimensionUpdaters[o]=this.getDimensionUpdaters(t),this.state.dimensions[o]={getValue:null,domain:null,sortedBins:null,scaleFunc:Qt}})}getDimensionUpdaters({key:e,accessor:t,pickingInfo:o,getBins:i,getDomain:r,getScaleFunc:a,nullValue:s}){return{key:e,accessor:t,pickingInfo:o,getBins:{updater:this.getDimensionSortedBins.bind(this),...i},getDomain:{updater:this.getDimensionValueDomain.bind(this),...r},getScaleFunc:{updater:this.getDimensionScale.bind(this),...a},attributeAccessor:this.getSubLayerDimensionAttribute(e,s)}}needUpdateDimensionStep(e,t,o,i){return Object.values(e.triggers).some(r=>r.updateTrigger?i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged[r.updateTrigger]):t[r.prop]!==o[r.prop])}getDimensionChanges(e,t,o){let i=[];for(let r in this.dimensionUpdaters){let a=Zt.find(s=>this.needUpdateDimensionStep(this.dimensionUpdaters[r][s],e,t,o));a&&i.push(this.dimensionUpdaters[r][a].updater.bind(this,t,this.dimensionUpdaters[r]))}return i.length?i:null}getUpdateTriggers(e){let t=e.updateTriggers||{},o={};for(let i in this.dimensionUpdaters){let{accessor:r}=this.dimensionUpdaters[i];o[r]={},Zt.forEach(a=>{Object.values(this.dimensionUpdaters[i][a].triggers).forEach(({prop:s,updateTrigger:l})=>{if(l){let c=t[l];typeof c=="object"&&!Array.isArray(c)?Object.assign(o[r],c):c!==void 0&&(o[r][s]=c)}else o[r][s]=e[s]})})}return o}getSortedBins(e){for(let t in this.dimensionUpdaters)this.getDimensionSortedBins(e,this.dimensionUpdaters[t])}getDimensionSortedBins(e,t){let{key:o}=t,{getValue:i}=this.state.dimensions[o],r=new F(this.state.layerData.data||[],{getValue:i,filterData:e._filterData});this.setDimensionState(o,{sortedBins:r}),this.getDimensionValueDomain(e,t)}getDimensionValueDomain(e,t){let{getDomain:o,key:i}=t,{triggers:{lowerPercentile:r,upperPercentile:a,scaleType:s}}=o,l=this.state.dimensions[i].sortedBins.getValueDomainByScale(e[s.prop],[e[r.prop],e[a.prop]]);this.setDimensionState(i,{valueDomain:l}),this.getDimensionScale(e,t)}getDimensionScale(e,t){let{key:o,getScaleFunc:i,getDomain:r}=t,{domain:a,range:s}=i.triggers,{scaleType:l}=r.triggers,{onSet:c}=i,g=e[s.prop],f=e[a.prop]||this.state.dimensions[o].valueDomain,p=Gt(l&&e[l.prop])(f,g);typeof c=="object"&&typeof e[c.props]=="function"&&e[c.props](p.domain()),this.setDimensionState(o,{scaleFunc:p})}getSubLayerDimensionAttribute(e,t){return o=>{let{sortedBins:i,scaleFunc:r}=this.state.dimensions[e],a=i.binMap[o.index];if(a&&a.counts===0)return t;let s=a&&a.value,l=r.domain();return s>=l[0]&&s<=l[l.length-1]?r(s):t}}getSubLayerAccessors(e){let t={};for(let o in this.dimensionUpdaters){let{accessor:i}=this.dimensionUpdaters[o];t[i]=this.getSubLayerDimensionAttribute(e,o)}return t}getPickingInfo({info:e}){let t=e.picked&&e.index>-1,o=null;if(t){let i=this.state.layerData.data[e.index],r={};for(let a in this.dimensionUpdaters){let{pickingInfo:s}=this.dimensionUpdaters[a],{sortedBins:l}=this.state.dimensions[a],c=l.binMap[i.index]&&l.binMap[i.index].value;r[s]=c}o=Object.assign(r,i,{points:i.filteredPoints||i.points})}return e.picked=Boolean(o),e.object=o,e}getAccessor(e){return this.dimensionUpdaters.hasOwnProperty(e)?this.dimensionUpdaters[e].attributeAccessor:Qt}};function eo(){}var nr={colorDomain:null,colorRange:N,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:eo,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:eo,gridAggregator:J,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},ve=class extends O{initializeState(){let e=new w({getAggregator:o=>o.gridAggregator,getCellSize:o=>o.cellSize});this.state={cpuAggregator:e,aggregatorState:e.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){super.updateState(e),this.setState({aggregatorState:this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:t,cellSize:o,coverage:i,material:r,transitions:a}=this.props,{cpuAggregator:s}=this.state,l=this.getSubLayerClass("grid-cell",to.GridCellLayer),c=this._getSublayerUpdateTriggers();return new l({cellSize:o,coverage:i,material:r,elevationScale:e,extruded:t,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:a&&{getFillColor:a.getColorValue||a.getColorWeight,getElevation:a.getElevationValue||a.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:c}),{data:s.state.layerData.data})}};ve.layerName="CPUGridLayer";ve.defaultProps=nr;var Se=ve;var ro=M(E(),1),no=M(X(),1);var te=Math.PI/3,ar=[0,te,2*te,3*te,4*te,5*te];function sr(n){return n[0]}function lr(n){return n[1]}function Je(){var n=0,e=0,t=1,o=1,i=sr,r=lr,a,s,l;function c(f){var d={},p=[],x,h=f.length;for(x=0;x<h;++x)if(!(isNaN(S=+i.call(null,y=f[x],x,f))||isNaN(A=+r.call(null,y,x,f)))){var y,S,A,_=Math.round(A=A/l),b=Math.round(S=S/s-(_&1)/2),D=A-_;if(Math.abs(D)*3>1){var R=S-b,fe=b+(S<b?-1:1)/2,z=_+(A<_?-1:1),H=S-fe,V=A-z;R*R+D*D>H*H+V*V&&(b=fe+(_&1?1:-1)/2,_=z)}var lt=b+"-"+_,de=d[lt];de?de.push(y):(p.push(de=d[lt]=[y]),de.x=(b+(_&1)/2)*s,de.y=_*l)}return p}function g(f){var d=0,p=0;return ar.map(function(x){var h=Math.sin(x)*f,y=-Math.cos(x)*f,S=h-d,A=y-p;return d=h,p=y,[S,A]})}return c.hexagon=function(f){return"m"+g(f==null?a:+f).join("l")+"z"},c.centers=function(){for(var f=[],d=Math.round(e/l),p=Math.round(n/s),x=d*l;x<o+a;x+=l,++d)for(var h=p*s+(d&1)*s/2;h<t+s/2;h+=s)f.push([h,x]);return f},c.mesh=function(){var f=g(a).slice(0,4).join("l");return c.centers().map(function(d){return"M"+d+"m"+f}).join("")},c.x=function(f){return arguments.length?(i=f,c):i},c.y=function(f){return arguments.length?(r=f,c):r},c.radius=function(f){return arguments.length?(a=+f,s=a*2*Math.sin(te),l=a*1.5,c):a},c.size=function(f){return arguments.length?(n=e=0,t=+f[0],o=+f[1],c):[t-n,o-e]},c.extent=function(f){return arguments.length?(n=+f[0][0],e=+f[0][1],t=+f[1][0],o=+f[1][1],c):[[n,e],[t,o]]},c.radius(1)}var Ue=M(E(),1);function oo(n,e){let{data:t,radius:o}=n,{viewport:i,attributes:r}=e,a=t.length?cr(t,e):null,s=ur(o,i,a),l=[],{iterable:c,objectInfo:g}=(0,Ue.createIterable)(t),f=r.positions.value,{size:d}=r.positions.getAccessor();for(let h of c){g.index++;let y=g.index*d,S=[f[y],f[y+1]];Number.isFinite(S[0])&&Number.isFinite(S[1])?l.push({screenCoord:i.projectFlat(S),source:h,index:g.index}):Ue.log.warn("HexagonLayer: invalid position")()}return{hexagons:Je().radius(s).x(h=>h.screenCoord[0]).y(h=>h.screenCoord[1])(l).map((h,y)=>({position:i.unprojectFlat([h.x,h.y]),points:h,index:y})),radiusCommon:s}}function cr(n,e){let{attributes:t}=e,o=t.positions.value,{size:i}=t.positions.getAccessor(),r=1/0,a=1/0,s=-1/0,l=-1/0,c;for(c=0;c<i*n.length;c+=i){let g=o[c],f=o[c+1];Number.isFinite(g)&&Number.isFinite(f)&&(r=Math.min(g,r),s=Math.max(g,s),a=Math.min(f,a),l=Math.max(f,l))}return[r,a,s,l].every(Number.isFinite)?[(r+s)/2,(a+l)/2]:null}function ur(n,e,t){let{unitsPerMeter:o}=e.getDistanceScales(t);return n*o[0]}function io(){}var gr={colorDomain:null,colorRange:N,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:io,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:io,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:oo,getPosition:{type:"accessor",value:n=>n.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},ye=class extends O{initializeState(){let e=new w({getAggregator:o=>o.hexagonAggregator,getCellSize:o=>o.radius});this.state={cpuAggregator:e,aggregatorState:e.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){if(super.updateState(e),e.changeFlags.propsOrDataChanged){let t=this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==t.layerData){let{hexagonVertices:o}=t.layerData||{};this.setState({vertices:o&&this.convertLatLngToMeterOffset(o)})}this.setState({aggregatorState:t})}}convertLatLngToMeterOffset(e){let{viewport:t}=this.context;if(Array.isArray(e)&&e.length===6){let o=e[0],i=e[3],r=[(o[0]+i[0])/2,(o[1]+i[1])/2],a=t.projectFlat(r),{metersPerUnit:s}=t.getDistanceScales(r);return e.map(c=>{let g=t.projectFlat(c);return[(g[0]-a[0])*s[0],(g[1]-a[1])*s[1]]})}return ro.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:t,coverage:o,material:i,transitions:r}=this.props,{aggregatorState:a,vertices:s}=this.state,l=this.getSubLayerClass("hexagon-cell",no.ColumnLayer),c=this._getSublayerUpdateTriggers(),g=s?{vertices:s,radius:1}:{radius:a.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new l({...g,diskResolution:6,elevationScale:e,extruded:t,coverage:o,material:i,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:r&&{getFillColor:r.getColorValue||r.getColorWeight,getElevation:r.getElevationValue||r.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:c}),{data:a.layerData.data})}};ye.layerName="HexagonLayer";ye.defaultProps=gr;var ao=ye;var Ve=M(X(),1);var Fo=M(E(),1);var v=.16666666666666666,u={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},oe=[u.W,u.SW,u.S],ie=[u.S,u.SE,u.E],re=[u.E,u.NE,u.N],ne=[u.NW,u.W,u.N],ae=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5]],se=[[-v,-.5],[v,-.5],[.5,-v],[.5,v]],le=[[.5,-v],[.5,v],[v,.5],[-v,.5]],ce=[[-.5,v],[-.5,-v],[v,.5],[-v,.5]],so=[u.W,u.SW,u.SE,u.E],lo=[u.S,u.SE,u.NE,u.N],co=[u.NW,u.W,u.E,u.NE],uo=[u.NW,u.SW,u.S,u.N],go=[[-.5,v],[-.5,-v],[.5,-v],[.5,v]],fo=[[-v,-.5],[v,-.5],[v,.5],[-v,.5]],fr=[u.NW,u.SW,u.SE,u.NE],po=[u.NW,u.SW,u.SE,u.E,u.N],mo=[u.W,u.SW,u.SE,u.NE,u.N],ho=[u.NW,u.W,u.S,u.SE,u.NE],xo=[u.NW,u.SW,u.S,u.E,u.NE],vo=[u.NW,u.W,[.5,-v],[.5,v],u.N],So=[[-v,-.5],[v,-.5],u.E,u.NE,u.N],yo=[[-.5,v],[-.5,-v],u.S,u.SE,u.E],Ao=[u.W,u.SW,u.S,[v,.5],[-v,.5]],_o=[u.NW,u.W,[-v,-.5],[v,-.5],u.N],bo=[[-.5,v],[-.5,-v],u.E,u.NE,u.N],Mo=[u.S,u.SE,u.E,[v,.5],[-v,.5]],To=[u.W,u.SW,u.S,[.5,-v],[.5,v]],Co=[u.W,u.SW,u.SE,u.E,[v,.5],[-v,.5]],Eo=[[-.5,v],[-.5,-v],u.S,u.SE,u.NE,u.N],Po=[u.NW,u.W,[-v,-.5],[v,-.5],u.E,u.NE],No=[u.NW,u.SW,u.S,[.5,-v],[.5,v],u.N],ue=[u.W,u.SW,u.S,u.E,u.NE,u.N],ge=[u.NW,u.W,u.S,u.SE,u.E,u.N],Ge=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5],u.E,u.NE,u.N],We=[u.W,u.SW,u.S,[.5,-v],[.5,v],[v,.5],[-v,.5]],ze=[u.NW,u.W,[-v,-.5],[v,-.5],[.5,-v],[.5,v],u.N],He=[[-.5,v],[-.5,-v],u.S,u.SE,u.E,[v,.5],[-v,.5]],Do=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5],[.5,-v],[.5,v],[v,.5],[-v,.5]],Lo={0:[],1:[[u.W,u.S]],2:[[u.S,u.E]],3:[[u.W,u.E]],4:[[u.N,u.E]],5:{0:[[u.W,u.S],[u.N,u.E]],1:[[u.W,u.N],[u.S,u.E]]},6:[[u.N,u.S]],7:[[u.W,u.N]],8:[[u.W,u.N]],9:[[u.N,u.S]],10:{0:[[u.W,u.N],[u.S,u.E]],1:[[u.W,u.S],[u.N,u.E]]},11:[[u.N,u.E]],12:[[u.W,u.E]],13:[[u.S,u.E]],14:[[u.W,u.S]],15:[]};function m(n){return parseInt(n,4)}var Oo={[m("0000")]:[],[m("2222")]:[],[m("2221")]:[oe],[m("2212")]:[ie],[m("2122")]:[re],[m("1222")]:[ne],[m("0001")]:[oe],[m("0010")]:[ie],[m("0100")]:[re],[m("1000")]:[ne],[m("2220")]:[ae],[m("2202")]:[se],[m("2022")]:[le],[m("0222")]:[ce],[m("0002")]:[ae],[m("0020")]:[se],[m("0200")]:[le],[m("2000")]:[ce],[m("0011")]:[so],[m("0110")]:[lo],[m("1100")]:[co],[m("1001")]:[uo],[m("2211")]:[so],[m("2112")]:[lo],[m("1122")]:[co],[m("1221")]:[uo],[m("2200")]:[go],[m("2002")]:[fo],[m("0022")]:[go],[m("0220")]:[fo],[m("1111")]:[fr],[m("1211")]:[po],[m("2111")]:[mo],[m("1112")]:[ho],[m("1121")]:[xo],[m("1011")]:[po],[m("0111")]:[mo],[m("1110")]:[ho],[m("1101")]:[xo],[m("1200")]:[vo],[m("0120")]:[So],[m("0012")]:[yo],[m("2001")]:[Ao],[m("1022")]:[vo],[m("2102")]:[So],[m("2210")]:[yo],[m("0221")]:[Ao],[m("1002")]:[_o],[m("2100")]:[bo],[m("0210")]:[Mo],[m("0021")]:[To],[m("1220")]:[_o],[m("0122")]:[bo],[m("2012")]:[Mo],[m("2201")]:[To],[m("0211")]:[Co],[m("2110")]:[Eo],[m("1102")]:[Po],[m("1021")]:[No],[m("2011")]:[Co],[m("0112")]:[Eo],[m("1120")]:[Po],[m("1201")]:[No],[m("2101")]:[ue],[m("0121")]:[ue],[m("1012")]:[ge],[m("1210")]:[ge],[m("0101")]:{0:[oe,re],1:[ue],2:[ue]},[m("1010")]:{0:[ne,ie],1:[ge],2:[ge]},[m("2121")]:{0:[ue],1:[ue],2:[oe,re]},[m("1212")]:{0:[ge],1:[ge],2:[ne,ie]},[m("2120")]:{0:[Ge],1:[Ge],2:[ae,re]},[m("2021")]:{0:[We],1:[We],2:[oe,le]},[m("1202")]:{0:[ze],1:[ze],2:[ne,se]},[m("0212")]:{0:[He],1:[He],2:[ie,ce]},[m("0102")]:{0:[ae,re],1:[Ge],2:[Ge]},[m("0201")]:{0:[oe,le],1:[We],2:[We]},[m("1020")]:{0:[ne,se],1:[ze],2:[ze]},[m("2010")]:{0:[ie,ce],1:[He],2:[He]},[m("2020")]:{0:[ce,se],1:[Do],2:[ae,le]},[m("0202")]:{0:[le,ae],1:[Do],2:[ce,se]}};var j={ISO_LINES:1,ISO_BANDS:2},dr={zIndex:0,zOffset:.005};function Ae(n,e){return Array.isArray(e)?n<e[0]?0:n<e[1]?1:2:n>=e?1:0}function wo(n){let{cellWeights:e,x:t,y:o,width:i,height:r}=n,a=n.threshold;n.thresholdValue&&(Fo.log.deprecated("thresholdValue","threshold")(),a=n.thresholdValue);let s=t<0,l=t>=i-1,c=o<0,g=o>=r-1,f=s||l||c||g,d={},p={};s||g?p.top=0:(d.top=e[(o+1)*i+t],p.top=Ae(d.top,a)),l||g?p.topRight=0:(d.topRight=e[(o+1)*i+t+1],p.topRight=Ae(d.topRight,a)),l||c?p.right=0:(d.right=e[o*i+t+1],p.right=Ae(d.right,a)),s||c?p.current=0:(d.current=e[o*i+t],p.current=Ae(d.current,a));let{top:x,topRight:h,right:y,current:S}=p,A=-1;Number.isFinite(a)&&(A=x<<3|h<<2|y<<1|S),Array.isArray(a)&&(A=x<<6|h<<4|y<<2|S);let _=0;return f||(_=Ae((d.top+d.topRight+d.right+d.current)/4,a)),{code:A,meanCode:_}}function et(n){let{gridOrigin:e,cellSize:t,x:o,y:i,code:r,meanCode:a,type:s=j.ISO_LINES}=n,l={...dr,...n.thresholdData},c=s===j.ISO_BANDS?Oo[r]:Lo[r];Array.isArray(c)||(c=c[a]);let g=l.zIndex*l.zOffset,f=(o+1)*t[0],d=(i+1)*t[1],p=e[0]+f,x=e[1]+d;if(s===j.ISO_BANDS){let y=[];return c.forEach(S=>{let A=[];S.forEach(_=>{let b=p+_[0]*t[0],D=x+_[1]*t[1];A.push([b,D,g])}),y.push(A)}),y}let h=[];return c.forEach(y=>{y.forEach(S=>{let A=p+S[0]*t[0],_=x+S[1]*t[1];h.push([A,_,g])})}),h}function Io({thresholdData:n,cellWeights:e,gridSize:t,gridOrigin:o,cellSize:i}){let r=[],a=[],s=t[0],l=t[1],c=0,g=0;for(let f of n){let{contour:d}=f,{threshold:p}=d;for(let x=-1;x<s;x++)for(let h=-1;h<l;h++){let{code:y,meanCode:S}=wo({cellWeights:e,threshold:p,x,y:h,width:s,height:l}),A={type:j.ISO_BANDS,gridOrigin:o,cellSize:i,x,y:h,width:s,height:l,code:y,meanCode:S,thresholdData:f};if(Array.isArray(p)){A.type=j.ISO_BANDS;let _=et(A);for(let b of _)a[g++]={vertices:b,contour:d}}else{A.type=j.ISO_LINES;let _=et(A);for(let b=0;b<_.length;b+=2)r[c++]={start:_[b],end:_[b+1],contour:d}}}}return{contourSegments:r,contourPolygons:a}}var Uo=M(E(),1);var Ro=[255,255,255,255],pr=1,mr=1,hr={cellSize:{type:"number",min:1,max:1e3,value:1e3},getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:mr}],optional:!0,compare:3},zOffset:.005},Bo="positions",xr={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},_e=class extends ee{initializeState(){super.initializeAggregationLayer({dimensions:xr}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:T.SUM}}}),this.getAttributeManager().add({[Bo]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(e){super.updateState(e);let t=!1,{oldProps:o,props:i}=e,{aggregationDirty:r}=this.state;(o.contours!==i.contours||o.zOffset!==i.zOffset)&&(t=!0,this._updateThresholdData(e.props)),this.getNumInstances()>0&&(r||t)&&this._generateContours()}renderLayers(){let{contourSegments:e,contourPolygons:t}=this.state.contourData,o=this.getSubLayerClass("lines",Ve.LineLayer),i=this.getSubLayerClass("bands",Ve.SolidPolygonLayer),r=e&&e.length>0&&new o(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:s=>s.start,getTargetPosition:s=>s.end,getColor:s=>s.contour.color||Ro,getWidth:s=>s.contour.strokeWidth||pr}),a=t&&t.length>0&&new i(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:s=>s.vertices,getFillColor:s=>s.contour.color||Ro});return[r,a]}updateAggregationState(e){let{props:t,oldProps:o}=e,{cellSize:i,coordinateSystem:r}=t,{viewport:a}=this.context,s=o.cellSize!==i,l=t.gpuAggregation;this.state.gpuAggregation!==t.gpuAggregation&&l&&!C.isSupported(this.context.device)&&(Uo.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),l=!1);let c=l!==this.state.gpuAggregation;this.setState({gpuAggregation:l});let{dimensions:g}=this.state,f=this.isAttributeChanged(Bo),{data:d,weights:p}=g,{boundingBox:x}=this.state;if(f&&(x=Ie(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:x})),f||s){let{gridOffset:S,translation:A,width:_,height:b,numCol:D,numRow:R}=Re(x,i,a,r);this.allocateResources(R,D),this.setState({gridOffset:S,boundingBox:x,translation:A,posOffset:A.slice(),gridOrigin:[-1*A[0],-1*A[1]],width:_,height:b,numCol:D,numRow:R})}let h=f||c||this.isAggregationDirty(e,{dimension:d,compareAll:l}),y=this.isAggregationDirty(e,{dimension:p});y&&this._updateAccessors(e),(h||y)&&this._resetResults(),this.setState({aggregationDataDirty:h,aggregationWeightsDirty:y})}_updateAccessors(e){let{getWeight:t,aggregation:o,data:i}=e.props,{count:r}=this.state.weights;r&&(r.getWeight=t,r.operation=T[o]),this.setState({getValue:Y(o,t,{data:i})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}_generateContours(){let{numCol:e,numRow:t,gridOrigin:o,gridOffset:i,thresholdData:r}=this.state,{count:a}=this.state.weights,{aggregationData:s}=a;s||(s=a.aggregationBuffer.readSyncWebGL(),a.aggregationData=s);let{cellWeights:l}=C.getCellData({countsData:s}),c=Io({thresholdData:r,cellWeights:l,gridSize:[e,t],gridOrigin:o,cellSize:[i.xOffset,i.yOffset]});this.setState({contourData:c})}_updateThresholdData(e){let{contours:t,zOffset:o}=e,i=t.length,r=new Array(i);for(let a=0;a<i;a++){let s=t[a];r[a]={contour:s,zIndex:s.zIndex||a,zOffset:o}}this.setState({thresholdData:r})}};_e.layerName="ContourLayer";_e.defaultProps=hr;var Go=_e;var qo=M(E(),1);var Xo=M(E(),1);var P=M(E(),1),Ho=M(k(),1);var Vo=M(k(),1);var Wo=`#version 300 es
300
- #define SHADER_NAME gpu-grid-cell-layer-vertex-shader
301
- #define RANGE_COUNT 6
199
+ `;var Go=`uniform screenGridUniforms {
200
+ vec2 cellSizeClipspace;
201
+ vec2 gridSizeClipspace;
202
+ vec2 colorDomain;
203
+ } screenGrid;
204
+ `,_e={name:"screenGrid",vs:Go,uniformTypes:{cellSizeClipspace:"vec2<f32>",gridSizeClipspace:"vec2<f32>",colorDomain:"vec2<f32>"}};var Rt=class extends zt.Layer{getShaders(){return super.getShaders({vs:Oe,fs:Re,modules:[zt.picking,_e]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceWeights:{size:1,type:"float32",accessor:"getWeight"}}),this.state.model=this._getModel()}updateState(t){super.updateState(t);let{props:e,oldProps:o,changeFlags:r}=t,i=this.state.model;if(o.colorRange!==e.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=J(this.context.device,e.colorRange,e.colorScaleType);let s={colorRange:this.state.colorTexture};i.shaderInputs.setProps({screenGrid:s})}else o.colorScaleType!==e.colorScaleType&&Q(this.state.colorTexture,e.colorScaleType);if(o.cellMarginPixels!==e.cellMarginPixels||o.cellSizePixels!==e.cellSizePixels||r.viewportChanged){let{width:s,height:a}=this.context.viewport,{cellSizePixels:c,cellMarginPixels:g}=this.props,h=Math.max(c-g,0),f={gridSizeClipspace:[c/s*2,c/a*2],cellSizeClipspace:[h/s*2,h/a*2]};i.shaderInputs.setProps({screenGrid:f})}}finalizeState(t){super.finalizeState(t),this.state.colorTexture?.destroy()}draw({uniforms:t}){let e=this.props.colorDomain(),o=this.state.model,r={colorDomain:e};o.shaderInputs.setProps({screenGrid:r}),o.draw(this.context.renderPass)}_getModel(){return new _t.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new _t.Geometry({topology:"triangle-strip",attributes:{positions:{value:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}}),isInstanced:!0})}};Rt.layerName="ScreenGridCellLayer";var ze=Rt;var qo=`uniform binOptionsUniforms {
205
+ float cellSizePixels;
206
+ } binOptions;
207
+ `,Ie={name:"binOptions",vs:qo,uniformTypes:{cellSizePixels:"f32"}};var Yo={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0},colorRange:G,colorScaleType:"linear",getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},mt=class extends U{getAggregatorType(){return this.props.gpuAggregation&&P.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){return t==="cpu"||!P.isSupported(this.context.device)?new O({dimensions:2,getBin:{sources:["positions"],getValue:({positions:e},o,r)=>{let i=this.context.viewport,s=i.project(e),a=r.cellSizePixels;return s[0]<0||s[0]>=i.width||s[1]<0||s[1]>=i.height?null:[Math.floor(s[0]/a),Math.floor(s[1]/a)]}},getValue:[{sources:["counts"],getValue:({counts:e})=>e}]}):new P(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Fe.project32,Ie],vs:`
208
+ in vec3 positions;
209
+ in vec3 positions64Low;
210
+ in float counts;
211
+
212
+ void getBin(out ivec2 binId) {
213
+ vec4 pos = project_position_to_clipspace(positions, positions64Low, vec3(0.0));
214
+ vec2 screenCoords = vec2(pos.x / pos.w + 1.0, 1.0 - pos.y / pos.w) / 2.0 * project.viewportSize / project.devicePixelRatio;
215
+ vec2 gridCoords = floor(screenCoords / binOptions.cellSizePixels);
216
+ binId = ivec2(gridCoords);
217
+ }
218
+ void getValue(out float weight) {
219
+ weight = counts;
220
+ }
221
+ `})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){let e=super.updateState(t),{props:o,oldProps:r,changeFlags:i}=t,{cellSizePixels:s,aggregation:a}=o;if(e||i.dataChanged||i.updateTriggersChanged||i.viewportChanged||a!==r.aggregation||s!==r.cellSizePixels){let{width:c,height:g}=this.context.viewport,{aggregator:h}=this.state;h instanceof P&&h.setProps({binIdRange:[[0,Math.ceil(c/s)],[0,Math.ceil(g/s)]]}),h.setProps({pointCount:this.getNumInstances(),operations:[a],binOptions:{cellSizePixels:s}})}return i.viewportChanged&&this.state.aggregator.setNeedsUpdate(),e}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate();break;case"counts":e.setNeedsUpdate(0);break;default:}}renderLayers(){let{aggregator:t}=this.state,e=this.getSubLayerClass("cells",ze),o=t.getBins(),r=t.getResult(0);return new e(this.props,this.getSubLayerProps({id:"cell-layer"}),{data:{length:t.binCount,attributes:{getBin:o,getWeight:r}},dataComparator:(i,s)=>i.length===s.length,updateTriggers:{getBin:[o],getWeight:[r]},parameters:{depthWriteEnabled:!1,...this.props.parameters},colorDomain:()=>this.props.colorDomain||t.getResultDomain(0),extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let r=this.state.aggregator.getBin(o),i;r&&(i={col:r.id[0],row:r.id[1],value:r.value[0],count:r.count},r.pointIndices&&(i.pointIndices=r.pointIndices,i.points=Array.isArray(this.props.data)?r.pointIndices.map(s=>this.props.data[s]):[])),e.object=i}return e}};mt.layerName="ScreenGridLayer";mt.defaultProps=Yo;var We=mt;var Y=L(I(),1);var q=class{constructor(t,e){this.props={scaleType:"linear",lowerPercentile:0,upperPercentile:100},this.domain=null,this.cutoff=null,this.input=t,this.inputLength=e,this.attribute=t}getScalePercentile(){if(!this._percentile){let t=De(this.input,this.inputLength);this._percentile=Xo(t)}return this._percentile}getScaleOrdinal(){if(!this._ordinal){let t=De(this.input,this.inputLength);this._ordinal=$o(t)}return this._ordinal}getCutoff({scaleType:t,lowerPercentile:e,upperPercentile:o}){if(t==="quantile")return[e,o-1];if(e>0||o<100){let{domain:r}=this.getScalePercentile(),i=r[Math.floor(e)-1]??-1/0,s=r[Math.floor(o)-1]??1/0;if(t==="ordinal"){let{domain:a}=this.getScaleOrdinal();i=a.findIndex(c=>c>=i),s=a.findIndex(c=>c>s)-1,s===-2&&(s=a.length-1)}return[i,s]}return null}update(t){let e=this.props;if(t.scaleType!==e.scaleType)switch(t.scaleType){case"quantile":{let{attribute:o}=this.getScalePercentile();this.attribute=o,this.domain=[0,99];break}case"ordinal":{let{attribute:o,domain:r}=this.getScaleOrdinal();this.attribute=o,this.domain=[0,r.length-1];break}default:this.attribute=this.input,this.domain=null}return(t.scaleType!==e.scaleType||t.lowerPercentile!==e.lowerPercentile||t.upperPercentile!==e.upperPercentile)&&(this.cutoff=this.getCutoff(t)),this.props=t,this}};function $o(n){let t=new Set;for(let r of n)Number.isFinite(r)&&t.add(r);let e=Array.from(t).sort(),o=new Map;for(let r=0;r<e.length;r++)o.set(e[r],r);return{attribute:{value:n.map(r=>Number.isFinite(r)?o.get(r):NaN),type:"float32",size:1},domain:e}}function Xo(n,t=100){let e=Array.from(n).filter(Number.isFinite).sort(Ko),o=0,r=Math.max(1,t),i=new Array(r-1);for(;++o<r;)i[o-1]=Zo(e,o/r);return{attribute:{value:n.map(s=>Number.isFinite(s)?Qo(i,s):NaN),type:"float32",size:1},domain:i}}function De(n,t){let e=(n.stride??4)/4,o=(n.offset??0)/4,r=n.value;if(!r){let s=n.buffer?.readSyncWebGL(0,e*4*t);s&&(r=new Float32Array(s.buffer),n.value=r)}if(e===1)return r.subarray(0,t);let i=new Float32Array(t);for(let s=0;s<t;s++)i[s]=r[s*e+o];return i}function Ko(n,t){return n-t}function Zo(n,t){let e=n.length;if(t<=0||e<2)return n[0];if(t>=1)return n[e-1];let o=(e-1)*t,r=Math.floor(o),i=n[r],s=n[r+1];return i+(s-i)*(o-r)}function Qo(n,t){let e=0,o=n.length;for(;e<o;){let r=e+o>>>1;n[r]>t?o=r:e=r+1}return e}function tt({dataBounds:n,getBinId:t,padding:e=0}){let o=[n[0],n[1],[n[0][0],n[1][1]],[n[1][0],n[0][1]]].map(c=>t(c)),r=Math.min(...o.map(c=>c[0]))-e,i=Math.min(...o.map(c=>c[1]))-e,s=Math.max(...o.map(c=>c[0]))+e+1,a=Math.max(...o.map(c=>c[1]))+e+1;return[[r,s],[i,a]]}var Ge=L(Z(),1);var Ve=Math.PI/3,It=2*Math.sin(Ve),Ft=1.5,Be=Array.from({length:6},(n,t)=>{let e=t*Ve;return[Math.sin(e),-Math.cos(e)]});function Wt([n,t],e){let o=Math.round(t=t/e/Ft),r=Math.round(n=n/e/It-(o&1)/2),i=t-o;if(Math.abs(i)*3>1){let s=n-r,a=r+(n<r?-1:1)/2,c=o+(t<o?-1:1),g=n-a,h=t-c;s*s+i*i>g*g+h*h&&(r=a+(o&1?1:-1)/2,o=c)}return[r,o]}var Ue=`
222
+ const vec2 DIST = vec2(${It}, ${Ft});
223
+
224
+ ivec2 pointToHexbin(vec2 p, float radius) {
225
+ p /= radius * DIST;
226
+ float pj = round(p.y);
227
+ float pjm2 = mod(pj, 2.0);
228
+ p.x -= pjm2 * 0.5;
229
+ float pi = round(p.x);
230
+ vec2 d1 = p - vec2(pi, pj);
231
+
232
+ if (abs(d1.y) * 3. > 1.) {
233
+ vec2 v2 = step(0.0, d1) - 0.5;
234
+ v2.y *= 2.0;
235
+ vec2 d2 = d1 - v2;
236
+ if (dot(d1, d1) > dot(d2, d2)) {
237
+ pi += v2.x + pjm2 - 0.5;
238
+ pj += v2.y;
239
+ }
240
+ }
241
+ return ivec2(pi, pj);
242
+ }
243
+ `;function oe([n,t],e){return[(n+(t&1)/2)*e*It,t*e*Ft]}var He=`
244
+ const vec2 DIST = vec2(${It}, ${Ft});
245
+
246
+ vec2 hexbinCentroid(vec2 binId, float radius) {
247
+ binId.x += fract(binId.y * 0.5);
248
+ return binId * DIST * radius;
249
+ }
250
+ `;var ke=`#version 300 es
251
+ #define SHADER_NAME hexagon-cell-layer-vertex-shader
302
252
  in vec3 positions;
303
253
  in vec3 normals;
304
- in vec4 colors;
305
- in vec4 elevations;
254
+ in vec2 instancePositions;
255
+ in float instanceElevationValues;
256
+ in float instanceColorValues;
306
257
  in vec3 instancePickingColors;
307
- uniform vec2 offset;
308
- uniform bool extruded;
309
- uniform float cellSize;
310
- uniform float coverage;
311
- uniform float opacity;
312
- uniform float elevationScale;
313
- uniform ivec2 gridSize;
314
- uniform vec2 gridOrigin;
315
- uniform vec2 gridOriginLow;
316
- uniform vec2 gridOffset;
317
- uniform vec2 gridOffsetLow;
318
- uniform vec4 colorRange[RANGE_COUNT];
319
- uniform vec2 elevationRange;
320
- uniform vec2 colorDomain;
321
- uniform bool colorDomainValid;
322
- uniform vec2 elevationDomain;
323
- uniform bool elevationDomainValid;
324
- layout(std140) uniform;
325
- uniform ColorData
326
- {
327
- vec4 maxMinCount;
328
- } colorData;
329
- uniform ElevationData
330
- {
331
- vec4 maxMinCount;
332
- } elevationData;
333
- #define EPSILON 0.00001
258
+ uniform sampler2D colorRange;
334
259
  out vec4 vColor;
335
- vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
336
- vec4 outColor = vec4(0., 0., 0., 0.);
337
- if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
338
- float domainRange = domain.y - domain.x;
339
- if (domainRange <= 0.) {
340
- outColor = colorRange[0];
341
- } else {
342
- float rangeCount = float(RANGE_COUNT);
343
- float rangeStep = domainRange / rangeCount;
344
- float idx = floor((value - domain.x) / rangeStep);
345
- idx = clamp(idx, 0., rangeCount - 1.);
346
- int intIdx = int(idx);
347
- outColor = colorRange[intIdx];
348
- }
349
- }
350
- return outColor;
351
- }
352
- float linearScale(vec2 domain, vec2 range, float value) {
353
- if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
354
- return ((value - domain.x) / (domain.y - domain.x)) * (range.y - range.x) + range.x;
260
+ ${He}
261
+ float interp(float value, vec2 domain, vec2 range) {
262
+ float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);
263
+ return mix(range.x, range.y, r);
355
264
  }
356
- return -1.;
265
+ vec4 interp(float value, vec2 domain, sampler2D range) {
266
+ float r = (value - domain.x) / (domain.y - domain.x);
267
+ return texture(range, vec2(r, 0.5));
357
268
  }
358
269
  void main(void) {
359
- vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r);
360
- vec4 color = quantizeScale(clrDomain, colorRange, colors.r);
270
+ geometry.pickingColor = instancePickingColors;
271
+ if (isnan(instanceColorValues) ||
272
+ instanceColorValues < hexagon.colorDomain.z ||
273
+ instanceColorValues > hexagon.colorDomain.w ||
274
+ instanceElevationValues < hexagon.elevationDomain.z ||
275
+ instanceElevationValues > hexagon.elevationDomain.w
276
+ ) {
277
+ gl_Position = vec4(0.);
278
+ return;
279
+ }
280
+ vec2 commonPosition = hexbinCentroid(instancePositions, column.radius) + (hexagon.originCommon - project.commonOrigin.xy);
281
+ commonPosition += positions.xy * column.radius * column.coverage;
282
+ geometry.position = vec4(commonPosition, 0.0, 1.0);
283
+ geometry.normal = project_normal(normals);
361
284
  float elevation = 0.0;
362
- if (extruded) {
363
- vec2 elvDomain = elevationDomainValid ? elevationDomain : vec2(elevationData.maxMinCount.a, elevationData.maxMinCount.r);
364
- elevation = linearScale(elvDomain, elevationRange, elevations.r);
365
- elevation = elevation * (positions.z + 1.0) / 2.0 * elevationScale;
366
- }
367
- float shouldRender = float(color.r > 0.0 && elevations.r >= 0.0);
368
- float dotRadius = cellSize / 2. * coverage * shouldRender;
369
- int yIndex = (gl_InstanceID / gridSize[0]);
370
- int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
371
- vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(float(xIndex), 0.));
372
- instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0]));
373
- vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(float(yIndex), 0.));
374
- instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1]));
375
- vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation);
376
- vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0);
377
- geometry.worldPosition = centroidPosition;
378
- vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.);
379
- picking_setPickingColor(instancePickingColors);
380
- gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
381
- vec3 normals_commonspace = project_normal(normals);
382
- if (extruded) {
383
- vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, normals_commonspace);
384
- vColor = vec4(lightColor, color.a * opacity) / 255.;
385
- } else {
386
- vColor = vec4(color.rgb, color.a * opacity) / 255.;
285
+ if (column.extruded) {
286
+ elevation = interp(instanceElevationValues, hexagon.elevationDomain.xy, hexagon.elevationRange);
287
+ elevation = project_size(elevation);
288
+ geometry.position.z = (positions.z + 1.0) / 2.0 * elevation;
289
+ }
290
+ gl_Position = project_common_position_to_clipspace(geometry.position);
291
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
292
+ vColor = interp(instanceColorValues, hexagon.colorDomain.xy, colorRange);
293
+ vColor.a *= layer.opacity;
294
+ if (column.extruded) {
295
+ vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
296
+ }
297
+ DECKGL_FILTER_COLOR(vColor, geometry);
298
+ }
299
+ `;var Jo=`uniform hexagonUniforms {
300
+ vec4 colorDomain;
301
+ vec4 elevationDomain;
302
+ vec2 elevationRange;
303
+ vec2 originCommon;
304
+ } hexagon;
305
+ `,je={name:"hexagon",vs:Jo,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>"}};var Dt=class extends Ge.ColumnLayer{getShaders(){let t=super.getShaders();return t.modules.push(je),{...t,vs:ke}}initializeState(){super.initializeState();let t=this.getAttributeManager();t.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),t.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(t){super.updateState(t);let{props:e,oldProps:o}=t,r=this.state.fillModel;if(o.colorRange!==e.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=J(this.context.device,e.colorRange,e.colorScaleType);let i={colorRange:this.state.colorTexture};r.shaderInputs.setProps({hexagon:i})}else o.colorScaleType!==e.colorScaleType&&Q(this.state.colorTexture,e.colorScaleType)}finalizeState(t){super.finalizeState(t),this.state.colorTexture?.destroy()}draw({uniforms:t}){let{radius:e,hexOriginCommon:o,elevationRange:r,elevationScale:i,extruded:s,coverage:a,colorDomain:c,elevationDomain:g}=this.props,h=this.props.colorCutoff||[-1/0,1/0],f=this.props.elevationCutoff||[-1/0,1/0],p=this.state.fillModel;p.vertexArray.indexBuffer&&p.setIndexBuffer(null),p.setVertexCount(this.state.fillVertexCount);let d={colorDomain:[Math.max(c[0],h[0]),Math.min(c[1],h[1]),Math.max(c[0]-1,h[0]),Math.min(c[1]+1,h[1])],elevationDomain:[Math.max(g[0],f[0]),Math.min(g[1],f[1]),Math.max(g[0]-1,f[0]),Math.min(g[1]+1,f[1])],elevationRange:[r[0]*i,r[1]*i],originCommon:o};p.shaderInputs.setProps({column:{extruded:s,coverage:a,radius:e},hexagon:d}),p.draw(this.context.renderPass)}};Dt.layerName="HexagonCellLayer";var qe=Dt;var tr=`uniform binOptionsUniforms {
306
+ vec2 hexOriginCommon;
307
+ float radiusCommon;
308
+ } binOptions;
309
+ `,Ye={name:"binOptions",vs:tr,uniformTypes:{hexOriginCommon:"vec2<f32>",radiusCommon:"f32"}};function $e(){}var er={gpuAggregation:!1,colorDomain:null,colorRange:G,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:$e,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:$e,radius:{type:"number",min:1,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},hexagonAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},xt=class extends U{getAggregatorType(){let{gpuAggregation:t,hexagonAggregator:e,getColorValue:o,getElevationValue:r}=this.props;return t&&(e||o||r)?(Y.log.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):t&&P.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){if(t==="cpu"){let{hexagonAggregator:e,radius:o}=this.props;return new O({dimensions:2,getBin:{sources:["positions"],getValue:({positions:r},i,s)=>{if(e)return e(r,o);let c=this.state.aggregatorViewport.projectPosition(r),{radiusCommon:g,hexOriginCommon:h}=s;return Wt([c[0]-h[0],c[1]-h[1]],g)}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:r})=>r},{sources:["elevationWeights"],getValue:({elevationWeights:r})=>r}]})}return new P(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Y.project32,Ye],vs:`
310
+ in vec3 positions;
311
+ in vec3 positions64Low;
312
+ in float colorWeights;
313
+ in float elevationWeights;
314
+
315
+ ${Ue}
316
+
317
+ void getBin(out ivec2 binId) {
318
+ vec3 positionCommon = project_position(positions, positions64Low);
319
+ binId = pointToHexbin(positionCommon.xy, binOptions.radiusCommon);
320
+ }
321
+ void getValue(out vec2 value) {
322
+ value = vec2(colorWeights, elevationWeights);
323
+ }
324
+ `})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:r,changeFlags:i}=t,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from((0,Y.createIterable)(o.data).iterable)),e||i.dataChanged||o.radius!==r.radius||o.getColorValue!==r.getColorValue||o.getElevationValue!==r.getElevationValue||o.colorAggregation!==r.colorAggregation||o.elevationAggregation!==r.elevationAggregation){this._updateBinOptions();let{radiusCommon:a,hexOriginCommon:c,binIdRange:g,dataAsArray:h}=this.state;if(s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{radiusCommon:a,hexOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),h){let{getColorValue:f,getElevationValue:p}=this.props;s.setProps({customOperations:[f&&(d=>f(d.map(x=>h[x]),{indices:d,data:o.data})),p&&(d=>p(d.map(x=>h[x]),{indices:d,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),e}_updateBinOptions(){let t=this.getBounds(),e=1,o=[0,0],r=[[0,1],[0,1]],i=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{radius:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);e=c[0]*a;let g=Wt(i.projectFlat(s),e);s=i.unprojectFlat(oe(g,e));let h=i.constructor;i=i.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new Y.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({dataBounds:t,getBinId:f=>{let p=i.projectFlat(f);return p[0]-=o[0],p[1]-=o[1],Wt(p,e)},padding:1})}this.setState({radiusCommon:e,hexOriginCommon:o,binIdRange:r,aggregatorViewport:i})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate({channel:t}){let e=this.getCurrentLayer().props,{aggregator:o}=this.state;if(t===0){let r=o.getResult(0);this.setState({colors:new q(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new q(r,o.binCount)}),e.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{radiusCommon:o,hexOriginCommon:r,binIdRange:i}=this.state;e.setProps({binIdRange:i,binOptions:{radiusCommon:o,hexOriginCommon:r}});break;case"colorWeights":e.setNeedsUpdate(0);break;case"elevationWeights":e.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:t,radiusCommon:e,hexOriginCommon:o}=this.state,{elevationScale:r,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:g,transitions:h,colorScaleType:f,lowerPercentile:p,upperPercentile:d,colorDomain:x,elevationScaleType:v,elevationLowerPercentile:S,elevationUpperPercentile:C,elevationDomain:E}=this.props,M=this.getSubLayerClass("cells",qe),b=t.getBins(),y=this.state.colors?.update({scaleType:f,lowerPercentile:p,upperPercentile:d}),A=this.state.elevations?.update({scaleType:v,lowerPercentile:S,upperPercentile:C});return!y||!A?null:new M(this.getSubLayerProps({id:"cells"}),{data:{length:t.binCount,attributes:{getBin:b,getColorValue:y.attribute,getElevationValue:A.attribute}},dataComparator:(w,N)=>w.length===N.length,updateTriggers:{getBin:[b],getColorValue:[y.attribute],getElevationValue:[A.attribute]},diskResolution:6,vertices:Be,radius:e,hexOriginCommon:o,elevationScale:r,colorRange:i,colorScaleType:f,elevationRange:s,extruded:a,coverage:c,material:g,colorDomain:y.domain||x||t.getResultDomain(0),elevationDomain:A.domain||E||t.getResultDomain(1),colorCutoff:y.cutoff,elevationCutoff:A.cutoff,transitions:h&&{getFillColor:h.getColorValue||h.getColorWeight,getElevation:h.getElevationValue||h.getElevationWeight},extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let r=this.state.aggregator.getBin(o),i;if(r){let s=oe(r.id,this.state.radiusCommon),a=this.context.viewport.unprojectFlat(s);i={col:r.id[0],row:r.id[1],position:a,colorValue:r.value[0],elevationValue:r.value[1],count:r.count},r.pointIndices&&(i.pointIndices=r.pointIndices,i.points=Array.isArray(this.props.data)?r.pointIndices.map(c=>this.props.data[c]):[])}e.object=i}return e}};xt.layerName="HexagonLayer";xt.defaultProps=er;var Xe=xt;var H=L(I(),1),Xt=L(Z(),1);var m=.16666666666666666,l={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},et=[l.W,l.SW,l.S],nt=[l.S,l.SE,l.E],ot=[l.E,l.NE,l.N],rt=[l.NW,l.W,l.N],it=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5]],st=[[-m,-.5],[m,-.5],[.5,-m],[.5,m]],at=[[.5,-m],[.5,m],[m,.5],[-m,.5]],ct=[[-.5,m],[-.5,-m],[m,.5],[-m,.5]],Ke=[l.W,l.SW,l.SE,l.E],Ze=[l.S,l.SE,l.NE,l.N],Qe=[l.NW,l.W,l.E,l.NE],Je=[l.NW,l.SW,l.S,l.N],tn=[[-.5,m],[-.5,-m],[.5,-m],[.5,m]],en=[[-m,-.5],[m,-.5],[m,.5],[-m,.5]],nr=[l.NW,l.SW,l.SE,l.NE],nn=[l.NW,l.SW,l.SE,l.E,l.N],on=[l.W,l.SW,l.SE,l.NE,l.N],rn=[l.NW,l.W,l.S,l.SE,l.NE],sn=[l.NW,l.SW,l.S,l.E,l.NE],an=[l.NW,l.W,[.5,-m],[.5,m],l.N],cn=[[-m,-.5],[m,-.5],l.E,l.NE,l.N],ln=[[-.5,m],[-.5,-m],l.S,l.SE,l.E],gn=[l.W,l.SW,l.S,[m,.5],[-m,.5]],hn=[l.NW,l.W,[-m,-.5],[m,-.5],l.N],pn=[[-.5,m],[-.5,-m],l.E,l.NE,l.N],fn=[l.S,l.SE,l.E,[m,.5],[-m,.5]],dn=[l.W,l.SW,l.S,[.5,-m],[.5,m]],un=[l.W,l.SW,l.SE,l.E,[m,.5],[-m,.5]],mn=[[-.5,m],[-.5,-m],l.S,l.SE,l.NE,l.N],xn=[l.NW,l.W,[-m,-.5],[m,-.5],l.E,l.NE],vn=[l.NW,l.SW,l.S,[.5,-m],[.5,m],l.N],lt=[l.W,l.SW,l.S,l.E,l.NE,l.N],gt=[l.NW,l.W,l.S,l.SE,l.E,l.N],Vt=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5],l.E,l.NE,l.N],Bt=[l.W,l.SW,l.S,[.5,-m],[.5,m],[m,.5],[-m,.5]],Ut=[l.NW,l.W,[-m,-.5],[m,-.5],[.5,-m],[.5,m],l.N],Ht=[[-.5,m],[-.5,-m],l.S,l.SE,l.E,[m,.5],[-m,.5]],Mn=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5],[.5,-m],[.5,m],[m,.5],[-m,.5]],yn={0:[],1:[[l.W,l.S]],2:[[l.S,l.E]],3:[[l.W,l.E]],4:[[l.N,l.E]],5:{0:[[l.W,l.S],[l.N,l.E]],1:[[l.W,l.N],[l.S,l.E]]},6:[[l.N,l.S]],7:[[l.W,l.N]],8:[[l.W,l.N]],9:[[l.N,l.S]],10:{0:[[l.W,l.N],[l.S,l.E]],1:[[l.W,l.S],[l.N,l.E]]},11:[[l.N,l.E]],12:[[l.W,l.E]],13:[[l.S,l.E]],14:[[l.W,l.S]],15:[]};function u(n){return parseInt(n,4)}var Sn={[u("0000")]:[],[u("2222")]:[],[u("2221")]:[et],[u("2212")]:[nt],[u("2122")]:[ot],[u("1222")]:[rt],[u("0001")]:[et],[u("0010")]:[nt],[u("0100")]:[ot],[u("1000")]:[rt],[u("2220")]:[it],[u("2202")]:[st],[u("2022")]:[at],[u("0222")]:[ct],[u("0002")]:[it],[u("0020")]:[st],[u("0200")]:[at],[u("2000")]:[ct],[u("0011")]:[Ke],[u("0110")]:[Ze],[u("1100")]:[Qe],[u("1001")]:[Je],[u("2211")]:[Ke],[u("2112")]:[Ze],[u("1122")]:[Qe],[u("1221")]:[Je],[u("2200")]:[tn],[u("2002")]:[en],[u("0022")]:[tn],[u("0220")]:[en],[u("1111")]:[nr],[u("1211")]:[nn],[u("2111")]:[on],[u("1112")]:[rn],[u("1121")]:[sn],[u("1011")]:[nn],[u("0111")]:[on],[u("1110")]:[rn],[u("1101")]:[sn],[u("1200")]:[an],[u("0120")]:[cn],[u("0012")]:[ln],[u("2001")]:[gn],[u("1022")]:[an],[u("2102")]:[cn],[u("2210")]:[ln],[u("0221")]:[gn],[u("1002")]:[hn],[u("2100")]:[pn],[u("0210")]:[fn],[u("0021")]:[dn],[u("1220")]:[hn],[u("0122")]:[pn],[u("2012")]:[fn],[u("2201")]:[dn],[u("0211")]:[un],[u("2110")]:[mn],[u("1102")]:[xn],[u("1021")]:[vn],[u("2011")]:[un],[u("0112")]:[mn],[u("1120")]:[xn],[u("1201")]:[vn],[u("2101")]:[lt],[u("0121")]:[lt],[u("1012")]:[gt],[u("1210")]:[gt],[u("0101")]:{0:[et,ot],1:[lt],2:[lt]},[u("1010")]:{0:[rt,nt],1:[gt],2:[gt]},[u("2121")]:{0:[lt],1:[lt],2:[et,ot]},[u("1212")]:{0:[gt],1:[gt],2:[rt,nt]},[u("2120")]:{0:[Vt],1:[Vt],2:[it,ot]},[u("2021")]:{0:[Bt],1:[Bt],2:[et,at]},[u("1202")]:{0:[Ut],1:[Ut],2:[rt,st]},[u("0212")]:{0:[Ht],1:[Ht],2:[nt,ct]},[u("0102")]:{0:[it,ot],1:[Vt],2:[Vt]},[u("0201")]:{0:[et,at],1:[Bt],2:[Bt]},[u("1020")]:{0:[rt,st],1:[Ut],2:[Ut]},[u("2010")]:{0:[nt,ct],1:[Ht],2:[Ht]},[u("2020")]:{0:[ct,st],1:[Mn],2:[it,at]},[u("0202")]:{0:[at,it],1:[Mn],2:[ct,st]}};function vt(n,t){return Number.isNaN(n)?0:Array.isArray(t)?n<t[0]?0:n<t[1]?1:2:n>=t?1:0}function An(n){let{x:t,y:e,xRange:o,yRange:r,getValue:i,threshold:s}=n,a=t<o[0],c=t>=o[1]-1,g=e<r[0],h=e>=r[1]-1,f=a||c||g||h,p=0,d,x,v,S;if(a||h)v=0;else{let M=i(t,e+1);v=vt(M,s),p+=M}if(c||h)S=0;else{let M=i(t+1,e+1);S=vt(M,s),p+=M}if(c||g)x=0;else{let M=i(t+1,e);x=vt(M,s),p+=M}if(a||g)d=0;else{let M=i(t,e);d=vt(M,s),p+=M}let C=-1;Number.isFinite(s)&&(C=v<<3|S<<2|x<<1|d),Array.isArray(s)&&(C=v<<6|S<<4|x<<2|d);let E=0;return f||(E=vt(p/4,s)),{code:C,meanCode:E}}function Cn(n){let{x:t,y:e,z:o,code:r,meanCode:i}=n,s=Sn[r];Array.isArray(s)||(s=s[i]);let a=t+1,c=e+1,g=[];return s.forEach(h=>{let f=[];h.forEach(p=>{let d=a+p[0],x=c+p[1];f.push([d,x,o])}),g.push(f)}),g}function bn(n){let{x:t,y:e,z:o,code:r,meanCode:i}=n,s=yn[r];Array.isArray(s)||(s=s[i]);let a=t+1,c=e+1,g=[];return s.forEach(h=>{h.forEach(f=>{let p=a+f[0],d=c+f[1];g.push([p,d,o])})}),g}function En({contours:n,getValue:t,xRange:e,yRange:o}){let r=[],i=[],s=0,a=0;for(let c=0;c<n.length;c++){let g=n[c],h=g.zIndex??c,{threshold:f}=g;for(let p=e[0]-1;p<e[1];p++)for(let d=o[0]-1;d<o[1];d++){let{code:x,meanCode:v}=An({getValue:t,threshold:f,x:p,y:d,xRange:e,yRange:o}),S={x:p,y:d,z:h,code:x,meanCode:v};if(Array.isArray(f)){let C=Cn(S);for(let E of C)i[a++]={vertices:E,contour:g}}else{let C=bn(S);C.length>0&&(r[s++]={vertices:C,contour:g})}}}return{lines:r,polygons:i}}function Tn(n){let{aggregator:t,binIdRange:e,channel:o}=n;if(t instanceof P){let r=t.getResult(o)?.buffer;if(r){let i=new Float32Array(r.readSyncWebGL().buffer);return or(i,e)}}if(t instanceof O){let r=t.getResult(o)?.value,i=t.getBins()?.value;if(i&&r)return rr(r,i,t.binCount)}return null}function or(n,t){let[[e,o],[r,i]]=t,s=o-e,a=i-r;return(c,g)=>(c-=e,g-=r,c<0||c>=s||g<0||g>=a?NaN:n[g*s+c])}function rr(n,t,e){let o={};for(let r=0;r<e;r++){let i=t[r*2],s=t[r*2+1];o[i]=o[i]||{},o[i][s]=n[r]}return(r,i)=>o[r]?.[i]??NaN}var Zi=1/Math.PI*180,Qi=1/180*Math.PI,ir={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ir}};var R=globalThis.mathgl.config;function Ln(n,{precision:t=R.precision}={}){return n=sr(n),`${parseFloat(n.toPrecision(t))}`}function kt(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function re(n,t,e){let o=R.EPSILON;e&&(R.EPSILON=e);try{if(n===t)return!0;if(kt(n)&&kt(t)){if(n.length!==t.length)return!1;for(let r=0;r<n.length;++r)if(!re(n[r],t[r]))return!1;return!0}return n&&n.equals?n.equals(t):t&&t.equals?t.equals(n):typeof n=="number"&&typeof t=="number"?Math.abs(n-t)<=R.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{R.EPSILON=o}}function sr(n){return Math.round(n/R.EPSILON)*R.EPSILON}var jt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let o=0;o<this.ELEMENTS;++o)this[o]=t[o+e];return this.check()}toArray(t=[],e=0){for(let o=0;o<this.ELEMENTS;++o)t[e+o]=this[o];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:kt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(R)}formatString(t){let e="";for(let o=0;o<this.ELEMENTS;++o)e+=(o>0?", ":"")+Ln(this[o],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!re(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,o){if(o===void 0)return this.lerp(this,t,e);for(let r=0;r<this.ELEMENTS;++r){let i=t[r],s=typeof e=="number"?e:e[r];this[r]=i+o*(s-i)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],t[o]),e[o]);return this.check()}add(...t){for(let e of t)for(let o=0;o<this.ELEMENTS;++o)this[o]+=e[o];return this.check()}subtract(...t){for(let e of t)for(let o=0;o<this.ELEMENTS;++o)this[o]-=e[o];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(R.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],t),e);return this.check()}get elements(){return this}};function ar(n,t){if(n.length!==t)return!1;for(let e=0;e<n.length;++e)if(!Number.isFinite(n[e]))return!1;return!0}function Pn(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function Gt(n,t,e=""){if(R.debug&&!ar(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}var k=typeof Float32Array<"u"?Float32Array:Array;var rs=Math.PI/180;function cr(){let n=new k(2);return k!=Float32Array&&(n[0]=0,n[1]=0),n}function On(n,t,e){let o=t[0],r=t[1];return n[0]=e[0]*o+e[4]*r+e[12],n[1]=e[1]*o+e[5]*r+e[13],n}var is=function(){let n=cr();return function(t,e,o,r,i,s){let a,c;for(e||(e=2),o||(o=0),r?c=Math.min(r*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],i(n,n,s),t[a]=n[0],t[a+1]=n[1];return t}}();function Rn(n,t,e){let o=t[0],r=t[1],i=e[3]*o+e[7]*r||1;return n[0]=(e[0]*o+e[4]*r)/i,n[1]=(e[1]*o+e[5]*r)/i,n}function _n(n,t,e){let o=t[0],r=t[1],i=t[2],s=e[3]*o+e[7]*r+e[11]*i||1;return n[0]=(e[0]*o+e[4]*r+e[8]*i)/s,n[1]=(e[1]*o+e[5]*r+e[9]*i)/s,n[2]=(e[2]*o+e[6]*r+e[10]*i)/s,n}function lr(){let n=new k(3);return k!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function zn(n,t,e){let o=t[0],r=t[1],i=t[2],s=e[3]*o+e[7]*r+e[11]*i+e[15];return s=s||1,n[0]=(e[0]*o+e[4]*r+e[8]*i+e[12])/s,n[1]=(e[1]*o+e[5]*r+e[9]*i+e[13])/s,n[2]=(e[2]*o+e[6]*r+e[10]*i+e[14])/s,n}var cs=function(){let n=lr();return function(t,e,o,r,i,s){let a,c;for(e||(e=3),o||(o=0),r?c=Math.min(r*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],n[2]=t[a+2],i(n,n,s),t[a]=n[0],t[a+1]=n[1],t[a+2]=n[2];return t}}();var qt=class extends jt{toString(){let t="[";if(R.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let o=0;o<this.RANK;++o)t+=` ${this[o*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,o){return this[e*this.RANK+t]=Pn(o),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let o=t*this.RANK;for(let r=0;r<this.RANK;++r)e[r]=this[o+r];return e}setColumn(t,e){let o=t*this.RANK;for(let r=0;r<this.RANK;++r)this[o+r]=e[r];return this}};function gr(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function In(n,t){if(n===t){let e=t[1],o=t[2],r=t[3],i=t[6],s=t[7],a=t[11];n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[6]=t[9],n[7]=t[13],n[8]=o,n[9]=i,n[11]=t[14],n[12]=r,n[13]=s,n[14]=a}else n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15];return n}function Fn(n,t){let e=t[0],o=t[1],r=t[2],i=t[3],s=t[4],a=t[5],c=t[6],g=t[7],h=t[8],f=t[9],p=t[10],d=t[11],x=t[12],v=t[13],S=t[14],C=t[15],E=e*a-o*s,M=e*c-r*s,b=e*g-i*s,y=o*c-r*a,A=o*g-i*a,w=r*g-i*c,N=h*v-f*x,_=h*S-p*x,z=h*C-d*x,F=f*S-p*v,W=f*C-d*v,D=p*C-d*S,T=E*D-M*W+b*F+y*z-A*_+w*N;return T?(T=1/T,n[0]=(a*D-c*W+g*F)*T,n[1]=(r*W-o*D-i*F)*T,n[2]=(v*w-S*A+C*y)*T,n[3]=(p*A-f*w-d*y)*T,n[4]=(c*z-s*D-g*_)*T,n[5]=(e*D-r*z+i*_)*T,n[6]=(S*b-x*w-C*M)*T,n[7]=(h*w-p*b+d*M)*T,n[8]=(s*W-a*z+g*N)*T,n[9]=(o*z-e*W-i*N)*T,n[10]=(x*A-v*b+C*E)*T,n[11]=(f*b-h*A-d*E)*T,n[12]=(a*_-s*F-c*N)*T,n[13]=(e*F-o*_+r*N)*T,n[14]=(v*M-x*y-S*E)*T,n[15]=(h*y-f*M+p*E)*T,n):null}function Wn(n){let t=n[0],e=n[1],o=n[2],r=n[3],i=n[4],s=n[5],a=n[6],c=n[7],g=n[8],h=n[9],f=n[10],p=n[11],d=n[12],x=n[13],v=n[14],S=n[15],C=t*s-e*i,E=t*a-o*i,M=e*a-o*s,b=g*x-h*d,y=g*v-f*d,A=h*v-f*x,w=t*A-e*y+o*b,N=i*A-s*y+a*b,_=g*M-h*E+f*C,z=d*M-x*E+v*C;return c*w-r*N+S*_-p*z}function se(n,t,e){let o=t[0],r=t[1],i=t[2],s=t[3],a=t[4],c=t[5],g=t[6],h=t[7],f=t[8],p=t[9],d=t[10],x=t[11],v=t[12],S=t[13],C=t[14],E=t[15],M=e[0],b=e[1],y=e[2],A=e[3];return n[0]=M*o+b*a+y*f+A*v,n[1]=M*r+b*c+y*p+A*S,n[2]=M*i+b*g+y*d+A*C,n[3]=M*s+b*h+y*x+A*E,M=e[4],b=e[5],y=e[6],A=e[7],n[4]=M*o+b*a+y*f+A*v,n[5]=M*r+b*c+y*p+A*S,n[6]=M*i+b*g+y*d+A*C,n[7]=M*s+b*h+y*x+A*E,M=e[8],b=e[9],y=e[10],A=e[11],n[8]=M*o+b*a+y*f+A*v,n[9]=M*r+b*c+y*p+A*S,n[10]=M*i+b*g+y*d+A*C,n[11]=M*s+b*h+y*x+A*E,M=e[12],b=e[13],y=e[14],A=e[15],n[12]=M*o+b*a+y*f+A*v,n[13]=M*r+b*c+y*p+A*S,n[14]=M*i+b*g+y*d+A*C,n[15]=M*s+b*h+y*x+A*E,n}function Dn(n,t,e){let o=e[0],r=e[1],i=e[2],s,a,c,g,h,f,p,d,x,v,S,C;return t===n?(n[12]=t[0]*o+t[4]*r+t[8]*i+t[12],n[13]=t[1]*o+t[5]*r+t[9]*i+t[13],n[14]=t[2]*o+t[6]*r+t[10]*i+t[14],n[15]=t[3]*o+t[7]*r+t[11]*i+t[15]):(s=t[0],a=t[1],c=t[2],g=t[3],h=t[4],f=t[5],p=t[6],d=t[7],x=t[8],v=t[9],S=t[10],C=t[11],n[0]=s,n[1]=a,n[2]=c,n[3]=g,n[4]=h,n[5]=f,n[6]=p,n[7]=d,n[8]=x,n[9]=v,n[10]=S,n[11]=C,n[12]=s*o+h*r+x*i+t[12],n[13]=a*o+f*r+v*i+t[13],n[14]=c*o+p*r+S*i+t[14],n[15]=g*o+d*r+C*i+t[15]),n}function Vn(n,t,e){let o=e[0],r=e[1],i=e[2];return n[0]=t[0]*o,n[1]=t[1]*o,n[2]=t[2]*o,n[3]=t[3]*o,n[4]=t[4]*r,n[5]=t[5]*r,n[6]=t[6]*r,n[7]=t[7]*r,n[8]=t[8]*i,n[9]=t[9]*i,n[10]=t[10]*i,n[11]=t[11]*i,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function Bn(n,t,e,o){let r=o[0],i=o[1],s=o[2],a=Math.sqrt(r*r+i*i+s*s),c,g,h,f,p,d,x,v,S,C,E,M,b,y,A,w,N,_,z,F,W,D,T,ft;return a<1e-6?null:(a=1/a,r*=a,i*=a,s*=a,g=Math.sin(e),c=Math.cos(e),h=1-c,f=t[0],p=t[1],d=t[2],x=t[3],v=t[4],S=t[5],C=t[6],E=t[7],M=t[8],b=t[9],y=t[10],A=t[11],w=r*r*h+c,N=i*r*h+s*g,_=s*r*h-i*g,z=r*i*h-s*g,F=i*i*h+c,W=s*i*h+r*g,D=r*s*h+i*g,T=i*s*h-r*g,ft=s*s*h+c,n[0]=f*w+v*N+M*_,n[1]=p*w+S*N+b*_,n[2]=d*w+C*N+y*_,n[3]=x*w+E*N+A*_,n[4]=f*z+v*F+M*W,n[5]=p*z+S*F+b*W,n[6]=d*z+C*F+y*W,n[7]=x*z+E*F+A*W,n[8]=f*D+v*T+M*ft,n[9]=p*D+S*T+b*ft,n[10]=d*D+C*T+y*ft,n[11]=x*D+E*T+A*ft,t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n)}function Un(n,t,e){let o=Math.sin(e),r=Math.cos(e),i=t[4],s=t[5],a=t[6],c=t[7],g=t[8],h=t[9],f=t[10],p=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=i*r+g*o,n[5]=s*r+h*o,n[6]=a*r+f*o,n[7]=c*r+p*o,n[8]=g*r-i*o,n[9]=h*r-s*o,n[10]=f*r-a*o,n[11]=p*r-c*o,n}function Hn(n,t,e){let o=Math.sin(e),r=Math.cos(e),i=t[0],s=t[1],a=t[2],c=t[3],g=t[8],h=t[9],f=t[10],p=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*r-g*o,n[1]=s*r-h*o,n[2]=a*r-f*o,n[3]=c*r-p*o,n[8]=i*o+g*r,n[9]=s*o+h*r,n[10]=a*o+f*r,n[11]=c*o+p*r,n}function kn(n,t,e){let o=Math.sin(e),r=Math.cos(e),i=t[0],s=t[1],a=t[2],c=t[3],g=t[4],h=t[5],f=t[6],p=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*r+g*o,n[1]=s*r+h*o,n[2]=a*r+f*o,n[3]=c*r+p*o,n[4]=g*r-i*o,n[5]=h*r-s*o,n[6]=f*r-a*o,n[7]=p*r-c*o,n}function jn(n,t){let e=t[0],o=t[1],r=t[2],i=t[3],s=e+e,a=o+o,c=r+r,g=e*s,h=o*s,f=o*a,p=r*s,d=r*a,x=r*c,v=i*s,S=i*a,C=i*c;return n[0]=1-f-x,n[1]=h+C,n[2]=p-S,n[3]=0,n[4]=h-C,n[5]=1-g-x,n[6]=d+v,n[7]=0,n[8]=p+S,n[9]=d-v,n[10]=1-g-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Gn(n,t,e,o,r,i,s){let a=1/(e-t),c=1/(r-o),g=1/(i-s);return n[0]=i*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*c,n[6]=0,n[7]=0,n[8]=(e+t)*a,n[9]=(r+o)*c,n[10]=(s+i)*g,n[11]=-1,n[12]=0,n[13]=0,n[14]=s*i*2*g,n[15]=0,n}function hr(n,t,e,o,r){let i=1/Math.tan(t/2);if(n[0]=i/e,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let s=1/(o-r);n[10]=(r+o)*s,n[14]=2*r*o*s}else n[10]=-1,n[14]=-2*o;return n}var qn=hr;function pr(n,t,e,o,r,i,s){let a=1/(t-e),c=1/(o-r),g=1/(i-s);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*g,n[11]=0,n[12]=(t+e)*a,n[13]=(r+o)*c,n[14]=(s+i)*g,n[15]=1,n}var Yn=pr;function $n(n,t,e,o){let r,i,s,a,c,g,h,f,p,d,x=t[0],v=t[1],S=t[2],C=o[0],E=o[1],M=o[2],b=e[0],y=e[1],A=e[2];return Math.abs(x-b)<1e-6&&Math.abs(v-y)<1e-6&&Math.abs(S-A)<1e-6?gr(n):(f=x-b,p=v-y,d=S-A,r=1/Math.sqrt(f*f+p*p+d*d),f*=r,p*=r,d*=r,i=E*d-M*p,s=M*f-C*d,a=C*p-E*f,r=Math.sqrt(i*i+s*s+a*a),r?(r=1/r,i*=r,s*=r,a*=r):(i=0,s=0,a=0),c=p*a-d*s,g=d*i-f*a,h=f*s-p*i,r=Math.sqrt(c*c+g*g+h*h),r?(r=1/r,c*=r,g*=r,h*=r):(c=0,g=0,h=0),n[0]=i,n[1]=c,n[2]=f,n[3]=0,n[4]=s,n[5]=g,n[6]=p,n[7]=0,n[8]=a,n[9]=h,n[10]=d,n[11]=0,n[12]=-(i*x+s*v+a*S),n[13]=-(c*x+g*v+h*S),n[14]=-(f*x+p*v+d*S),n[15]=1,n)}function fr(){let n=new k(4);return k!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Xn(n,t,e){let o=t[0],r=t[1],i=t[2],s=t[3];return n[0]=e[0]*o+e[4]*r+e[8]*i+e[12]*s,n[1]=e[1]*o+e[5]*r+e[9]*i+e[13]*s,n[2]=e[2]*o+e[6]*r+e[10]*i+e[14]*s,n[3]=e[3]*o+e[7]*r+e[11]*i+e[15]*s,n}var us=function(){let n=fr();return function(t,e,o,r,i,s){let a,c;for(e||(e=4),o||(o=0),r?c=Math.min(r*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],n[2]=t[a+2],n[3]=t[a+3],i(n,n,s),t[a]=n[0],t[a+1]=n[1],t[a+2]=n[2],t[a+3]=n[3];return t}}();var le;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(le||(le={}));var dr=45*Math.PI/180,ur=1,ae=.1,ce=500,mr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),K=class extends qt{static get IDENTITY(){return vr()}static get ZERO(){return xr()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return le}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,o,r,i,s,a,c,g,h,f,p,d,x,v,S){return this[0]=t,this[1]=e,this[2]=o,this[3]=r,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=g,this[9]=h,this[10]=f,this[11]=p,this[12]=d,this[13]=x,this[14]=v,this[15]=S,this.check()}setRowMajor(t,e,o,r,i,s,a,c,g,h,f,p,d,x,v,S){return this[0]=t,this[1]=i,this[2]=g,this[3]=d,this[4]=e,this[5]=s,this[6]=h,this[7]=x,this[8]=o,this[9]=a,this[10]=f,this[11]=v,this[12]=r,this[13]=c,this[14]=p,this[15]=S,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(mr)}fromObject(t){return this.check()}fromQuaternion(t){return jn(this,t),this.check()}frustum(t){let{left:e,right:o,bottom:r,top:i,near:s=ae,far:a=ce}=t;return a===1/0?Mr(this,e,o,r,i,s):Gn(this,e,o,r,i,s,a),this.check()}lookAt(t){let{eye:e,center:o=[0,0,0],up:r=[0,1,0]}=t;return $n(this,e,o,r),this.check()}ortho(t){let{left:e,right:o,bottom:r,top:i,near:s=ae,far:a=ce}=t;return Yn(this,e,o,r,i,s,a),this.check()}orthographic(t){let{fovy:e=dr,aspect:o=ur,focalDistance:r=1,near:i=ae,far:s=ce}=t;Kn(e);let a=e/2,c=r*Math.tan(a),g=c*o;return this.ortho({left:-g,right:g,bottom:-c,top:c,near:i,far:s})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:o=1,near:r=.1,far:i=500}=t;return Kn(e),qn(this,e,o,r,i),this.check()}determinant(){return Wn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let o=this.getScale(e),r=1/o[0],i=1/o[1],s=1/o[2];return t[0]=this[0]*r,t[1]=this[1]*i,t[2]=this[2]*s,t[3]=0,t[4]=this[4]*r,t[5]=this[5]*i,t[6]=this[6]*s,t[7]=0,t[8]=this[8]*r,t[9]=this[9]*i,t[10]=this[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let o=this.getScale(e),r=1/o[0],i=1/o[1],s=1/o[2];return t[0]=this[0]*r,t[1]=this[1]*i,t[2]=this[2]*s,t[3]=this[4]*r,t[4]=this[5]*i,t[5]=this[6]*s,t[6]=this[8]*r,t[7]=this[9]*i,t[8]=this[10]*s,t}transpose(){return In(this,this),this.check()}invert(){return Fn(this,this),this.check()}multiplyLeft(t){return se(this,t,this),this.check()}multiplyRight(t){return se(this,this,t),this.check()}rotateX(t){return Un(this,this,t),this.check()}rotateY(t){return Hn(this,this,t),this.check()}rotateZ(t){return kn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return Bn(this,this,t,e),this.check()}scale(t){return Vn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Dn(this,this,t),this.check()}transform(t,e){return t.length===4?(e=Xn(e||[-0,-0,-0,-0],t,this),Gt(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:o}=t,r;switch(o){case 2:r=On(e||[-0,-0],t,this);break;case 3:r=zn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Gt(r,t.length),r}transformAsVector(t,e){let o;switch(t.length){case 2:o=Rn(e||[-0,-0],t,this);break;case 3:o=_n(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Gt(o,t.length),o}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,o){return this.identity().translate([t,e,o])}},Yt,$t;function xr(){return Yt||(Yt=new K([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Yt)),Yt}function vr(){return $t||($t=new K,Object.freeze($t)),$t}function Kn(n){if(n>Math.PI*2)throw Error("expected radians")}function Mr(n,t,e,o,r,i){let s=2*i/(e-t),a=2*i/(r-o),c=(e+t)/(e-t),g=(r+o)/(r-o),h=-1,f=-1,p=-2*i;return n[0]=s,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=g,n[10]=h,n[11]=f,n[12]=0,n[13]=0,n[14]=p,n[15]=0,n}var yr=`uniform binOptionsUniforms {
325
+ vec2 cellOriginCommon;
326
+ vec2 cellSizeCommon;
327
+ } binOptions;
328
+ `,Zn={name:"binOptions",vs:yr,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};var Qn=[255,255,255,255],Sr=1,Ar={cellSize:{type:"number",min:1,value:1e3},gridOrigin:{type:"array",compare:!0,value:[0,0]},getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:1}],optional:!0,compare:3},zOffset:.005},Mt=class extends U{getAggregatorType(){return this.props.gpuAggregation&&P.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){return t==="cpu"?new O({dimensions:2,getBin:{sources:["positions"],getValue:({positions:e},o,r)=>{let s=this.state.aggregatorViewport.projectPosition(e),{cellSizeCommon:a,cellOriginCommon:c}=r;return[Math.floor((s[0]-c[0])/a[0]),Math.floor((s[1]-c[1])/a[1])]}},getValue:[{sources:["counts"],getValue:({counts:e})=>e}],onUpdate:this._onAggregationUpdate.bind(this)}):new P(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[H.project32,Zn],vs:`
329
+ in vec3 positions;
330
+ in vec3 positions64Low;
331
+ in float counts;
332
+
333
+ void getBin(out ivec2 binId) {
334
+ vec3 positionCommon = project_position(positions, positions64Low);
335
+ vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
336
+ binId = ivec2(gridCoords);
337
+ }
338
+ void getValue(out float value) {
339
+ value = counts;
340
+ }
341
+ `}),onUpdate:this._onAggregationUpdate.bind(this)})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:r,changeFlags:i}=t,{aggregator:s}=this.state;if(e||i.dataChanged||o.cellSize!==r.cellSize||!(0,H._deepEqual)(o.gridOrigin,r.gridOrigin,1)||o.aggregation!==r.aggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:g}=this.state;s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.aggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c}})}return(0,H._deepEqual)(r.contours,o.contours,2)||this.setState({contourData:null}),e}_updateBinOptions(){let t=this.getBounds(),e=[1,1],o=[0,0],r=[[0,1],[0,1]],i=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{cellSize:a,gridOrigin:c}=this.props,{unitsPerMeter:g}=i.getDistanceScales(s);e[0]=g[0]*a,e[1]=g[1]*a;let h=i.projectFlat(s);o=[Math.floor((h[0]-c[0])/e[0])*e[0]+c[0],Math.floor((h[1]-c[1])/e[1])*e[1]+c[1]],s=i.unprojectFlat(o);let f=i.constructor;i=i.isGeospatial?new f({longitude:s[0],latitude:s[1],zoom:12}):new H.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({dataBounds:t,getBinId:p=>{let d=i.projectFlat(p);return[Math.floor((d[0]-o[0])/e[0]),Math.floor((d[1]-o[1])/e[1])]}})}this.setState({cellSizeCommon:e,cellOriginCommon:o,binIdRange:r,aggregatorViewport:i})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate(){let{aggregator:t,binIdRange:e}=this.state;this.setState({aggregatedValueReader:Tn({aggregator:t,binIdRange:e,channel:0}),contourData:null})}_getContours(){let{aggregatedValueReader:t}=this.state;if(!t)return null;if(!this.state.contourData){let{binIdRange:e}=this.state,{contours:o}=this.props,r=En({contours:o,getValue:t,xRange:e[0],yRange:e[1]});this.state.contourData=r}return this.state.contourData}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:r,binIdRange:i}=this.state;e.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:r}});break;case"counts":e.setNeedsUpdate(0);break;default:}}renderLayers(){let t=this._getContours();if(!t)return null;let{lines:e,polygons:o}=t,{zOffset:r}=this.props,{cellOriginCommon:i,cellSizeCommon:s}=this.state,a=this.getSubLayerClass("lines",Xt.PathLayer),c=this.getSubLayerClass("bands",Xt.SolidPolygonLayer),g=new K().translate([i[0],i[1],0]).scale([s[0],s[1],r]),h=e&&e.length>0&&new a(this.getSubLayerProps({id:"lines"}),{data:e,coordinateSystem:H.COORDINATE_SYSTEM.CARTESIAN,modelMatrix:g,getPath:p=>p.vertices,getColor:p=>p.contour.color??Qn,getWidth:p=>p.contour.strokeWidth??Sr,widthUnits:"pixels"}),f=o&&o.length>0&&new c(this.getSubLayerProps({id:"bands"}),{data:o,coordinateSystem:H.COORDINATE_SYSTEM.CARTESIAN,modelMatrix:g,getPolygon:p=>p.vertices,getFillColor:p=>p.contour.color??Qn});return[h,f]}getPickingInfo(t){let e=t.info,{object:o}=e;return o&&(e.object={contour:o.contour}),e}};Mt.layerName="ContourLayer";Mt.defaultProps=Ar;var Jn=Mt;var $=L(I(),1);var no=L(Z(),1),oo=L(X(),1);var to=`#version 300 es
342
+ #define SHADER_NAME grid-cell-layer-vertex-shader
343
+ in vec3 positions;
344
+ in vec3 normals;
345
+ in vec2 instancePositions;
346
+ in float instanceElevationValues;
347
+ in float instanceColorValues;
348
+ in vec3 instancePickingColors;
349
+ uniform sampler2D colorRange;
350
+ out vec4 vColor;
351
+ float interp(float value, vec2 domain, vec2 range) {
352
+ float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);
353
+ return mix(range.x, range.y, r);
387
354
  }
355
+ vec4 interp(float value, vec2 domain, sampler2D range) {
356
+ float r = (value - domain.x) / (domain.y - domain.x);
357
+ return texture(range, vec2(r, 0.5));
388
358
  }
389
- `;var zo=`#version 300 es
390
- #define SHADER_NAME gpu-grid-cell-layer-fragment-shader
391
- precision highp float;
392
- in vec4 vColor;
393
- out vec4 fragColor;
394
359
  void main(void) {
395
- fragColor = vColor;
396
- fragColor = picking_filterColor(fragColor);
397
- }
398
- `;var tt=0,ot=1,vr={colorDomain:null,colorRange:N,elevationDomain:null,elevationRange:[0,1e3],elevationScale:{type:"number",min:0,value:1},gridSize:{type:"array",value:[1,1]},gridOrigin:{type:"array",value:[0,0]},gridOffset:{type:"array",value:[0,0]},cellSize:{type:"number",min:0,max:1e3,value:1e3},offset:{type:"array",value:[1,1]},coverage:{type:"number",min:0,max:1,value:1},extruded:!0,material:!0},be=class extends P.Layer{getShaders(){return super.getShaders({vs:Wo,fs:zo,modules:[P.project32,P.gouraudLighting,P.picking,q]})}initializeState(){this.getAttributeManager().addInstanced({colors:{size:4,noAlloc:!0},elevations:{size:4,noAlloc:!0}});let t=this._getModel();this._setupUniformBuffer(t),this.setState({model:t})}_getModel(){return new Vo.Model(this.context.device,{...this.getShaders(),id:this.props.id,geometry:new Ho.CubeGeometry,isInstanced:!0})}draw({uniforms:e}){let{cellSize:t,offset:o,extruded:i,elevationScale:r,coverage:a,gridSize:s,gridOrigin:l,gridOffset:c,elevationRange:g,colorMaxMinBuffer:f,elevationMaxMinBuffer:d}=this.props,p=this.state.model,x=[(0,P.fp64LowPart)(l[0]),(0,P.fp64LowPart)(l[1])],h=[(0,P.fp64LowPart)(c[0]),(0,P.fp64LowPart)(c[1])],y=this.getDomainUniforms(),S=G(this.props.colorRange);this.bindUniformBuffers(f,d),p.setUniforms(e),p.setUniforms(y),p.setUniforms({cellSize:t,offset:o,extruded:i,elevationScale:r,coverage:a,gridSize:s,gridOrigin:l,gridOriginLow:x,gridOffset:c,gridOffsetLow:h,colorRange:S,elevationRange:g}),p.draw(this.context.renderPass),this.unbindUniformBuffers(f,d)}bindUniformBuffers(e,t){e.bind({target:35345,index:tt}),t.bind({target:35345,index:ot})}unbindUniformBuffers(e,t){e.unbind({target:35345,index:tt}),t.unbind({target:35345,index:ot})}getDomainUniforms(){let{colorDomain:e,elevationDomain:t}=this.props,o={};return e!==null?(o.colorDomainValid=!0,o.colorDomain=e):o.colorDomainValid=!1,t!==null?(o.elevationDomainValid=!0,o.elevationDomain=t):o.elevationDomainValid=!1,o}_setupUniformBuffer(e){let t=e.pipeline.handle,o=this.context.gl,i=o.getUniformBlockIndex(t,"ColorData"),r=o.getUniformBlockIndex(t,"ElevationData");o.uniformBlockBinding(t,i,tt),o.uniformBlockBinding(t,r,ot)}};be.layerName="GPUGridCellLayer";be.defaultProps=vr;var ko=be;var Sr={colorDomain:null,colorRange:N,getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",elevationDomain:null,elevationRange:[0,1e3],getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},cellSize:{type:"number",min:1,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},extruded:!1,material:!0},yr={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},jo="positions",Me=class extends ee{initializeState({device:e}){let t=C.isSupported(e);t||Xo.log.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),super.initializeAggregationLayer({dimensions:yr}),this.setState({gpuAggregation:!1,projectPoints:!1,isSupported:t,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"}),this.getAttributeManager().add({[jo]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},color:{size:3,accessor:"getColorWeight"},elevation:{size:3,accessor:"getElevationWeight"}})}updateState(e){if(this.state.isSupported===!1)return;super.updateState(e);let{aggregationDirty:t}=this.state;t&&this.setState({gridHash:null})}getHashKeyForIndex(e){let{numRow:t,numCol:o,boundingBox:i,gridOffset:r}=this.state,a=[o,t],s=[i.xMin,i.yMin],l=[r.xOffset,r.yOffset],c=Math.floor(e/a[0]),g=e-c*a[0],f=Math.floor((c*l[1]+s[1]+90+l[1]/2)/l[1]),d=Math.floor((g*l[0]+s[0]+180+l[0]/2)/l[0]);return`${f}-${d}`}getPositionForIndex(e){let{numRow:t,numCol:o,boundingBox:i,gridOffset:r}=this.state,a=[o,t],s=[i.xMin,i.yMin],l=[r.xOffset,r.yOffset],c=Math.floor(e/a[0]),g=e-c*a[0],f=c*l[1]+s[1];return[g*l[0]+s[0],f]}getPickingInfo({info:e,mode:t}){let{index:o}=e,i=null;if(o>=0){let r=this.state.gpuGridAggregator,a=this.getPositionForIndex(o),s=C.getAggregationData({pixelIndex:o,...r.getData("color")}),l=C.getAggregationData({pixelIndex:o,...r.getData("elevation")});if(i={colorValue:s.cellWeight,elevationValue:l.cellWeight,count:s.cellCount||l.cellCount,position:a,totalCount:s.totalCount||l.totalCount},t!=="hover"){let{props:c}=this,{gridHash:g}=this.state;if(!g){let{gridOffset:p,translation:x,boundingBox:h}=this.state,{viewport:y}=this.context,S=this.getAttributes();g=J(c,{gridOffset:p,attributes:S,viewport:y,translation:x,boundingBox:h}).gridHash,this.setState({gridHash:g})}let f=this.getHashKeyForIndex(o),d=g[f];Object.assign(i,d)}}return e.picked=Boolean(i),e.object=i,e}renderLayers(){if(!this.state.isSupported)return null;let{elevationScale:e,extruded:t,cellSize:o,coverage:i,material:r,elevationRange:a,colorDomain:s,elevationDomain:l}=this.props,{weights:c,numRow:g,numCol:f,gridOrigin:d,gridOffset:p}=this.state,{color:x,elevation:h}=c,y=G(this.props.colorRange),S=this.getSubLayerClass("gpu-grid-cell",ko);return new S({gridSize:[f,g],gridOrigin:d,gridOffset:[p.xOffset,p.yOffset],colorRange:y,elevationRange:a,colorDomain:s,elevationDomain:l,cellSize:o,coverage:i,material:r,elevationScale:e,extruded:t},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:x.aggregationBuffer,elevations:h.aggregationBuffer}},colorMaxMinBuffer:x.maxMinBuffer,elevationMaxMinBuffer:h.maxMinBuffer,numInstances:f*g})}finalizeState(e){let{color:t,elevation:o}=this.state.weights;[t,o].forEach(i=>{let{aggregationBuffer:r,maxMinBuffer:a}=i;a?.destroy(),r?.destroy()}),super.finalizeState(e)}updateAggregationState(e){let{props:t,oldProps:o}=e,{cellSize:i,coordinateSystem:r}=t,{viewport:a}=this.context,s=o.cellSize!==i,{dimensions:l}=this.state,c=this.isAttributeChanged(jo),g=c||this.isAttributeChanged(),{boundingBox:f}=this.state;if(c&&(f=Ie(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:f})),c||s){let{gridOffset:p,translation:x,width:h,height:y,numCol:S,numRow:A}=Re(f,i,a,r);this.allocateResources(A,S),this.setState({gridOffset:p,translation:x,gridOrigin:[-1*x[0],-1*x[1]],width:h,height:y,numCol:S,numRow:A})}let d=g||this.isAggregationDirty(e,{dimension:l.data,compareAll:!0});d&&this._updateAccessors(e),this.setState({aggregationDataDirty:d})}_updateAccessors(e){let{colorAggregation:t,elevationAggregation:o}=e.props,{color:i,elevation:r}=this.state.weights;i.operation=T[t],r.operation=T[o]}};Me.layerName="GPUGridLayer";Me.defaultProps=Sr;var Te=Me;var Ar={...Te.defaultProps,...Se.defaultProps,gpuAggregation:!1},Ce=class extends qo.CompositeLayer{initializeState(){this.state={useGPUAggregation:!1}}updateState({props:e}){this.setState({useGPUAggregation:!1})}renderLayers(){let{data:e,updateTriggers:t}=this.props,o=this.state.useGPUAggregation?"GPU":"CPU",i=this.state.useGPUAggregation?this.getSubLayerClass("GPU",Te):this.getSubLayerClass("CPU",Se);return new i(this.props,this.getSubLayerProps({id:o,updateTriggers:t}),{data:e})}canUseGPUAggregation(e){let{gpuAggregation:t,lowerPercentile:o,upperPercentile:i,getColorValue:r,getElevationValue:a,colorScaleType:s}=e;return!(!t||!C.isSupported(this.context.device)||o!==0||i!==100||r!==null||a!==null||s==="quantile"||s==="ordinal")}};Ce.layerName="GridLayer";Ce.defaultProps=Ar;var Yo=Ce;function Ko(n){let e=n.map(s=>s[0]),t=n.map(s=>s[1]),o=Math.min.apply(null,e),i=Math.max.apply(null,e),r=Math.min.apply(null,t),a=Math.max.apply(null,t);return[o,r,i,a]}function Qo(n,e){return e[0]>=n[0]&&e[2]<=n[2]&&e[1]>=n[1]&&e[3]<=n[3]}var $o=new Float32Array(12);function it(n,e=2){let t=0;for(let o of n)for(let i=0;i<e;i++)$o[t++]=o[i]||0;return $o}function Zo(n,e,t){let[o,i,r,a]=n,s=r-o,l=a-i,c=s,g=l;s/l<e/t?c=e/t*l:g=t/e*s,c<e&&(c=e,g=t);let f=(r+o)/2,d=(a+i)/2;return[f-c/2,d-g/2,f+c/2,d+g/2]}function Jo(n,e){let[t,o,i,r]=e;return[(n[0]-t)/(i-t),(n[1]-o)/(r-o)]}var st=M(k(),1),I=M(E(),1);var oi=M(k(),1),je=M(E(),1);var ei=`#version 300 es
360
+ geometry.pickingColor = instancePickingColors;
361
+ if (isnan(instanceColorValues) ||
362
+ instanceColorValues < grid.colorDomain.z ||
363
+ instanceColorValues > grid.colorDomain.w ||
364
+ instanceElevationValues < grid.elevationDomain.z ||
365
+ instanceElevationValues > grid.elevationDomain.w
366
+ ) {
367
+ gl_Position = vec4(0.);
368
+ return;
369
+ }
370
+ vec2 commonPosition = (instancePositions + (positions.xy + 1.0) / 2.0 * column.coverage) * grid.sizeCommon + grid.originCommon - project.commonOrigin.xy;
371
+ geometry.position = vec4(commonPosition, 0.0, 1.0);
372
+ geometry.normal = project_normal(normals);
373
+ float elevation = 0.0;
374
+ if (column.extruded) {
375
+ elevation = interp(instanceElevationValues, grid.elevationDomain.xy, grid.elevationRange);
376
+ elevation = project_size(elevation);
377
+ geometry.position.z = (positions.z + 1.0) / 2.0 * elevation;
378
+ }
379
+ gl_Position = project_common_position_to_clipspace(geometry.position);
380
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
381
+ vColor = interp(instanceColorValues, grid.colorDomain.xy, colorRange);
382
+ vColor.a *= layer.opacity;
383
+ if (column.extruded) {
384
+ vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
385
+ }
386
+ DECKGL_FILTER_COLOR(vColor, geometry);
387
+ }
388
+ `;var Cr=`uniform gridUniforms {
389
+ vec4 colorDomain;
390
+ vec4 elevationDomain;
391
+ vec2 elevationRange;
392
+ vec2 originCommon;
393
+ vec2 sizeCommon;
394
+ } grid;
395
+ `,eo={name:"grid",vs:Cr,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>",sizeCommon:"vec2<f32>"}};var yt=class extends no.ColumnLayer{getShaders(){let t=super.getShaders();return t.modules.push(eo),{...t,vs:to}}initializeState(){super.initializeState();let t=this.getAttributeManager();t.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),t.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(t){super.updateState(t);let{props:e,oldProps:o}=t,r=this.state.fillModel;if(o.colorRange!==e.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=J(this.context.device,e.colorRange,e.colorScaleType);let i={colorRange:this.state.colorTexture};r.shaderInputs.setProps({grid:i})}else o.colorScaleType!==e.colorScaleType&&Q(this.state.colorTexture,e.colorScaleType)}finalizeState(t){super.finalizeState(t),this.state.colorTexture?.destroy()}_updateGeometry(){let t=new oo.CubeGeometry;this.state.fillModel.setGeometry(t)}draw({uniforms:t}){let{cellOriginCommon:e,cellSizeCommon:o,elevationRange:r,elevationScale:i,extruded:s,coverage:a,colorDomain:c,elevationDomain:g}=this.props,h=this.props.colorCutoff||[-1/0,1/0],f=this.props.elevationCutoff||[-1/0,1/0],p=this.state.fillModel,d={colorDomain:[Math.max(c[0],h[0]),Math.min(c[1],h[1]),Math.max(c[0]-1,h[0]),Math.min(c[1]+1,h[1])],elevationDomain:[Math.max(g[0],f[0]),Math.min(g[1],f[1]),Math.max(g[0]-1,f[0]),Math.min(g[1]+1,f[1])],elevationRange:[r[0]*i,r[1]*i],originCommon:e,sizeCommon:o};p.shaderInputs.setProps({column:{extruded:s,coverage:a},grid:d}),p.draw(this.context.renderPass)}};yt.layerName="GridCellLayer";var br=`uniform binOptionsUniforms {
396
+ vec2 cellOriginCommon;
397
+ vec2 cellSizeCommon;
398
+ } binOptions;
399
+ `,ro={name:"binOptions",vs:br,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};function io(){}var Er={gpuAggregation:!1,colorDomain:null,colorRange:G,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:io,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:io,cellSize:{type:"number",min:0,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},gridAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},St=class extends U{getAggregatorType(){let{gpuAggregation:t,gridAggregator:e,getColorValue:o,getElevationValue:r}=this.props;return t&&(e||o||r)?($.log.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):t&&P.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){if(t==="cpu"){let{gridAggregator:e,cellSize:o}=this.props;return new O({dimensions:2,getBin:{sources:["positions"],getValue:({positions:r},i,s)=>{if(e)return e(r,o);let c=this.state.aggregatorViewport.projectPosition(r),{cellSizeCommon:g,cellOriginCommon:h}=s;return[Math.floor((c[0]-h[0])/g[0]),Math.floor((c[1]-h[1])/g[1])]}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:r})=>r},{sources:["elevationWeights"],getValue:({elevationWeights:r})=>r}]})}return new P(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[$.project32,ro],vs:`
400
+ in vec3 positions;
401
+ in vec3 positions64Low;
402
+ in float colorWeights;
403
+ in float elevationWeights;
404
+
405
+ void getBin(out ivec2 binId) {
406
+ vec3 positionCommon = project_position(positions, positions64Low);
407
+ vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
408
+ binId = ivec2(gridCoords);
409
+ }
410
+ void getValue(out vec2 value) {
411
+ value = vec2(colorWeights, elevationWeights);
412
+ }
413
+ `})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:r,changeFlags:i}=t,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from((0,$.createIterable)(o.data).iterable)),e||i.dataChanged||o.cellSize!==r.cellSize||o.getColorValue!==r.getColorValue||o.getElevationValue!==r.getElevationValue||o.colorAggregation!==r.colorAggregation||o.elevationAggregation!==r.elevationAggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:g,dataAsArray:h}=this.state;if(s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),h){let{getColorValue:f,getElevationValue:p}=this.props;s.setProps({customOperations:[f&&(d=>f(d.map(x=>h[x]),{indices:d,data:o.data})),p&&(d=>p(d.map(x=>h[x]),{indices:d,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),e}_updateBinOptions(){let t=this.getBounds(),e=[1,1],o=[0,0],r=[[0,1],[0,1]],i=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{cellSize:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);e[0]=c[0]*a,e[1]=c[1]*a;let g=i.projectFlat(s);o=[Math.floor(g[0]/e[0])*e[0],Math.floor(g[1]/e[1])*e[1]],s=i.unprojectFlat(o);let h=i.constructor;i=i.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new $.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({dataBounds:t,getBinId:f=>{let p=i.projectFlat(f);return[Math.floor((p[0]-o[0])/e[0]),Math.floor((p[1]-o[1])/e[1])]}})}this.setState({cellSizeCommon:e,cellOriginCommon:o,binIdRange:r,aggregatorViewport:i})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate({channel:t}){let e=this.getCurrentLayer().props,{aggregator:o}=this.state;if(t===0){let r=o.getResult(0);this.setState({colors:new q(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new q(r,o.binCount)}),e.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:r,binIdRange:i}=this.state;e.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:r}});break;case"colorWeights":e.setNeedsUpdate(0);break;case"elevationWeights":e.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:t,cellOriginCommon:e,cellSizeCommon:o}=this.state,{elevationScale:r,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:g,transitions:h,colorScaleType:f,lowerPercentile:p,upperPercentile:d,colorDomain:x,elevationScaleType:v,elevationLowerPercentile:S,elevationUpperPercentile:C,elevationDomain:E}=this.props,M=this.getSubLayerClass("cells",yt),b=t.getBins(),y=this.state.colors?.update({scaleType:f,lowerPercentile:p,upperPercentile:d}),A=this.state.elevations?.update({scaleType:v,lowerPercentile:S,upperPercentile:C});return!y||!A?null:new M(this.getSubLayerProps({id:"cells"}),{data:{length:t.binCount,attributes:{getBin:b,getColorValue:y.attribute,getElevationValue:A.attribute}},dataComparator:(w,N)=>w.length===N.length,updateTriggers:{getBin:[b],getColorValue:[y.attribute],getElevationValue:[A.attribute]},cellOriginCommon:e,cellSizeCommon:o,elevationScale:r,colorRange:i,colorScaleType:f,elevationRange:s,extruded:a,coverage:c,material:g,colorDomain:y.domain||x||t.getResultDomain(0),elevationDomain:A.domain||E||t.getResultDomain(1),colorCutoff:y.cutoff,elevationCutoff:A.cutoff,transitions:h&&{getFillColor:h.getColorValue||h.getColorWeight,getElevation:h.getElevationValue||h.getElevationWeight},extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let r=this.state.aggregator.getBin(o),i;r&&(i={col:r.id[0],row:r.id[1],colorValue:r.value[0],elevationValue:r.value[1],count:r.count},r.pointIndices&&(i.pointIndices=r.pointIndices,i.points=Array.isArray(this.props.data)?r.pointIndices.map(s=>this.props.data[s]):[])),e.object=i}return e}};St.layerName="GridLayer";St.defaultProps=Er;var so=St;function co(n){let t=n.map(a=>a[0]),e=n.map(a=>a[1]),o=Math.min.apply(null,t),r=Math.max.apply(null,t),i=Math.min.apply(null,e),s=Math.max.apply(null,e);return[o,i,r,s]}function lo(n,t){return t[0]>=n[0]&&t[2]<=n[2]&&t[1]>=n[1]&&t[3]<=n[3]}var ao=new Float32Array(12);function ge(n,t=2){let e=0;for(let o of n)for(let r=0;r<t;r++)ao[e++]=o[r]||0;return ao}function go(n,t,e){let[o,r,i,s]=n,a=i-o,c=s-r,g=a,h=c;a/c<t/e?g=t/e*c:h=e/t*a,g<t&&(g=t,h=e);let f=(i+o)/2,p=(s+r)/2;return[f-g/2,p-h/2,f+g/2,p+h/2]}function ho(n,t){let[e,o,r,i]=t;return[(n[0]-e)/(r-e),(n[1]-o)/(i-o)]}var de=L(X(),1),V=L(I(),1);var xo=L(X(),1),Zt=L(I(),1);var po=`#version 300 es
399
414
  #define SHADER_NAME heatp-map-layer-vertex-shader
400
415
  uniform sampler2D maxTexture;
401
- uniform float intensity;
402
- uniform vec2 colorDomain;
403
- uniform float threshold;
404
- uniform float aggregationMode;
405
416
  in vec3 positions;
406
417
  in vec2 texCoords;
407
418
  out vec2 vTexCoords;
@@ -411,22 +422,20 @@ void main(void) {
411
422
  gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
412
423
  vTexCoords = texCoords;
413
424
  vec4 maxTexture = texture(maxTexture, vec2(0.5));
414
- float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
415
- float minValue = maxValue * threshold;
416
- if (colorDomain[1] > 0.) {
417
- maxValue = colorDomain[1];
418
- minValue = colorDomain[0];
425
+ float maxValue = triangle.aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
426
+ float minValue = maxValue * triangle.threshold;
427
+ if (triangle.colorDomain[1] > 0.) {
428
+ maxValue = triangle.colorDomain[1];
429
+ minValue = triangle.colorDomain[0];
419
430
  }
420
- vIntensityMax = intensity / maxValue;
421
- vIntensityMin = intensity / minValue;
431
+ vIntensityMax = triangle.intensity / maxValue;
432
+ vIntensityMin = triangle.intensity / minValue;
422
433
  }
423
- `;var ti=`#version 300 es
434
+ `;var fo=`#version 300 es
424
435
  #define SHADER_NAME triangle-layer-fragment-shader
425
436
  precision highp float;
426
- uniform float opacity;
427
437
  uniform sampler2D weightsTexture;
428
438
  uniform sampler2D colorTexture;
429
- uniform float aggregationMode;
430
439
  in vec2 vTexCoords;
431
440
  in float vIntensityMin;
432
441
  in float vIntensityMax;
@@ -440,36 +449,38 @@ return color;
440
449
  void main(void) {
441
450
  vec4 weights = texture(weightsTexture, vTexCoords);
442
451
  float weight = weights.r;
443
- if (aggregationMode > 0.5) {
452
+ if (triangle.aggregationMode > 0.5) {
444
453
  weight /= max(1.0, weights.a);
445
454
  }
446
455
  if (weight <= 0.) {
447
456
  discard;
448
457
  }
449
458
  vec4 linearColor = getLinearColor(weight);
450
- linearColor.a *= opacity;
459
+ linearColor.a *= layer.opacity;
451
460
  fragColor = linearColor;
452
461
  }
453
- `;var ke=class extends je.Layer{getShaders(){return{vs:ei,fs:ti,modules:[je.project32]}}initializeState({device:e}){this.setState({model:this._getModel(e)})}_getModel(e){let{vertexCount:t,data:o,weightsTexture:i,maxTexture:r,colorTexture:a}=this.props;return new oi.Model(e,{...this.getShaders(),id:this.props.id,bindings:{weightsTexture:i,maxTexture:r,colorTexture:a},attributes:o.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-fan-webgl",vertexCount:t})}draw({uniforms:e}){let{model:t}=this.state,{intensity:o,threshold:i,aggregationMode:r,colorDomain:a}=this.props;t.setUniforms({...e,intensity:o,threshold:i,aggregationMode:r,colorDomain:a}),t.draw(this.context.renderPass)}};ke.layerName="TriangleLayer";var ii=ke;var rt=`#version 300 es
462
+ `;var uo=`uniform triangleUniforms {
463
+ float aggregationMode;
464
+ vec2 colorDomain;
465
+ float intensity;
466
+ float threshold;
467
+ } triangle;
468
+ `,mo={name:"triangle",vs:uo,fs:uo,uniformTypes:{aggregationMode:"f32",colorDomain:"vec2<f32>",intensity:"f32",threshold:"f32"}};var Kt=class extends Zt.Layer{getShaders(){return super.getShaders({vs:po,fs:fo,modules:[Zt.project32,mo]})}initializeState({device:t}){this.setState({model:this._getModel(t)})}_getModel(t){let{vertexCount:e,data:o}=this.props;return new xo.Model(t,{...this.getShaders(),id:this.props.id,attributes:o.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-strip",vertexCount:e})}draw(){let{model:t}=this.state,{aggregationMode:e,colorDomain:o,intensity:r,threshold:i,colorTexture:s,maxTexture:a,weightsTexture:c}=this.props,g={aggregationMode:e,colorDomain:o,intensity:r,threshold:i,colorTexture:s,maxTexture:a,weightsTexture:c};t.shaderInputs.setProps({triangle:g}),t.draw(this.context.renderPass)}};Kt.layerName="TriangleLayer";var vo=Kt;var pt=L(I(),1);function Mo(n,t){let e={};for(let o in n)t.includes(o)||(e[o]=n[o]);return e}var Qt=class extends pt.CompositeLayer{initializeAggregationLayer(t){super.initializeState(this.context),this.setState({ignoreProps:Mo(this.constructor._propTypes,t.data.props),dimensions:t})}updateState(t){super.updateState(t);let{changeFlags:e}=t;if(e.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(t){this.setState({changedAttributes:t})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:t,mousePosition:e,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:t,mousePosition:e,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(t){}isAggregationDirty(t,e={}){let{props:o,oldProps:r,changeFlags:i}=t,{compareAll:s=!1,dimension:a}=e,{ignoreProps:c}=this.state,{props:g,accessors:h=[]}=a,{updateTriggersChanged:f}=i;if(i.dataChanged)return!0;if(f){if(f.all)return!0;for(let p of h)if(f[p])return!0}if(s)return i.extensionsChanged?!0:(0,pt._compareProps)({oldProps:r,newProps:o,ignoreProps:c,propTypes:this.constructor._propTypes});for(let p of g)if(o[p]!==r[p])return!0;return!1}isAttributeChanged(t){let{changedAttributes:e}=this.state;return t?e&&e[t]!==void 0:!Tr(e)}_getAttributeManager(){return new pt.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};Qt.layerName="AggregationLayer";var yo=Qt;function Tr(n){let t=!0;for(let e in n){t=!1;break}return t}var he=`#version 300 es
454
469
  in vec3 positions;
455
470
  in vec3 positions64Low;
456
471
  in float weights;
457
472
  out vec4 weightsTexture;
458
- uniform float radiusPixels;
459
- uniform float textureWidth;
460
- uniform vec4 commonBounds;
461
- uniform float weightsScale;
462
473
  void main()
463
474
  {
464
- weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);
465
- float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);
475
+ weightsTexture = vec4(weights * weight.weightsScale, 0., 0., 1.);
476
+ float radiusTexels = project_pixel_size(weight.radiusPixels) * weight.textureWidth / (weight.commonBounds.z - weight.commonBounds.x);
466
477
  gl_PointSize = radiusTexels * 2.;
467
478
  vec3 commonPosition = project_position(positions, positions64Low);
468
- gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;
479
+ gl_Position.xy = (commonPosition.xy - weight.commonBounds.xy) / (weight.commonBounds.zw - weight.commonBounds.xy) ;
469
480
  gl_Position.xy = (gl_Position.xy * 2.) - (1.);
470
481
  gl_Position.w = 1.0;
471
482
  }
472
- `;var nt=`#version 300 es
483
+ `;var pe=`#version 300 es
473
484
  in vec4 weightsTexture;
474
485
  out vec4 fragColor;
475
486
  float gaussianKDE(float u){
@@ -484,26 +495,34 @@ discard;
484
495
  fragColor = weightsTexture * gaussianKDE(2. * dist);
485
496
  DECKGL_FILTER_COLOR(fragColor, geometry);
486
497
  }
487
- `;var ri=`#version 300 es
498
+ `;var So=`#version 300 es
488
499
  uniform sampler2D inTexture;
489
- uniform float textureSize;
490
500
  out vec4 outTexture;
491
501
  void main()
492
502
  {
493
- int yIndex = gl_VertexID / int(textureSize);
494
- int xIndex = gl_VertexID - (yIndex * int(textureSize));
495
- vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;
503
+ int yIndex = gl_VertexID / int(maxWeight.textureSize);
504
+ int xIndex = gl_VertexID - (yIndex * int(maxWeight.textureSize));
505
+ vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / maxWeight.textureSize;
496
506
  outTexture = texture(inTexture, uv);
497
507
  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
498
508
  gl_PointSize = 1.0;
499
509
  }
500
- `;var ni=`#version 300 es
510
+ `;var Ao=`#version 300 es
501
511
  in vec4 outTexture;
502
512
  out vec4 fragColor;
503
513
  void main() {
504
514
  fragColor = outTexture;
505
515
  fragColor.g = outTexture.r / max(1.0, outTexture.a);
506
516
  }
507
- `;var _r=2,at={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},ai=[0,0],br={SUM:0,MEAN:1},Mr={getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:N,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Tr=["float32-renderable-webgl","texture-blend-float-webgl"],Cr={data:{props:["radiusPixels"]}},Ee=class extends O{initializeState(){super.initializeAggregationLayer(Cr),this.setState({colorDomain:ai}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:t,oldProps:o}=e,i=this._getChangeFlags(e);(i.dataChanged||i.viewportChanged)&&(i.boundsChanged=this._updateBounds(i.dataChanged),this._updateTextureRenderingBounds()),i.dataChanged||i.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):i.viewportZoomChanged&&this._debouncedUpdateWeightmap(),t.colorRange!==o.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:t,triTexCoordBuffer:o,maxWeightsTexture:i,colorTexture:r,colorDomain:a}=this.state,{updateTriggers:s,intensity:l,threshold:c,aggregation:g}=this.props,f=this.getSubLayerClass("triangle",ii);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:s}),{coordinateSystem:I.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:t,texCoords:o}},vertexCount:4,maxTexture:i,colorTexture:r,aggregationMode:br[g]||0,weightsTexture:e,intensity:l,threshold:c,colorDomain:a})}finalizeState(e){super.finalizeState(e);let{weightsTransform:t,weightsTexture:o,maxWeightTransform:i,maxWeightsTexture:r,triPositionBuffer:a,triTexCoordBuffer:s,colorTexture:l,updateTimer:c}=this.state;t?.destroy(),o?.destroy(),i?.destroy(),r?.destroy(),a?.destroy(),s?.destroy(),l?.destroy(),c&&clearTimeout(c)}_getAttributeManager(){return new I.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let t={},{dimensions:o}=this.state;t.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:o.data})&&"aggregation is dirty",t.viewportChanged=e.changeFlags.viewportChanged;let{zoom:i}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==i)&&(t.viewportZoomChanged=!0),t}_createTextures(){let{textureSize:e,format:t}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...at,width:e,height:e,format:t}),maxWeightsTexture:this.context.device.createTexture({...at,width:1,height:1,format:t})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:t}=this.props,o=Math.min(t,e.limits.maxTextureDimension2D),i=Tr.every(s=>e.features.has(s)),r=i?"rgba32float":"rgba8unorm",a=i?1:1/255;this.setState({textureSize:o,format:r,weightsScale:a}),i||I.log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:t}=this.state,{weightsTexture:o}=this.state,i=this.getAttributeManager();t?.destroy(),t=new st.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:i.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...e}),this.setState({weightsTransform:t})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:t,weightsTexture:o,maxWeightsTexture:i}=this.state,r=this.getShaders({vs:rt,fs:nt});this._createWeightsTransform(r);let a=this.getShaders({vs:ri,fs:ni}),s=new st.TextureTransform(e,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:o},uniforms:{textureSize:t},targetTexture:i,...a,vertexCount:t*t,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:o,maxWeightsTexture:i,maxWeightTransform:s,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:rt,fs:nt,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:t}=this.context,o=[t.unproject([0,0]),t.unproject([t.width,0]),t.unproject([t.width,t.height]),t.unproject([0,t.height])].map(s=>s.map(Math.fround)),i=Ko(o),r={visibleWorldBounds:i,viewportCorners:o},a=!1;if(e||!this.state.worldBounds||!Qo(this.state.worldBounds,i)){let s=this._worldToCommonBounds(i),l=this._commonToWorldBounds(s);this.props.coordinateSystem===I.COORDINATE_SYSTEM.LNGLAT&&(l[1]=Math.max(l[1],-85.051129),l[3]=Math.min(l[3],85.051129),l[0]=Math.max(l[0],-360),l[2]=Math.min(l[2],360));let c=this._worldToCommonBounds(l);r.worldBounds=l,r.normalizedCommonBounds=c,a=!0}return this.setState(r),a}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:t,normalizedCommonBounds:o,viewportCorners:i}=this.state,{viewport:r}=this.context;e.write(it(i,3));let a=i.map(s=>Jo(r.projectPosition(s),o));t.write(it(a,2))}_updateColorTexture(e){let{colorRange:t}=e.props,{colorTexture:o}=this.state,i=G(t,!1,Uint8Array);o&&o?.width===t.length?o.setSubImageData({data:i}):(o?.destroy(),o=this.context.device.createTexture({...at,data:i,width:t.length,height:1})),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:e,colorDomain:t,aggregation:o}=this.props,{worldBounds:i,textureSize:r,weightsScale:a}=this.state,s=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let l=this._worldToCommonBounds(i,{useLayerCoordinateSystem:!0});if(t&&o==="SUM"){let{viewport:p}=this.context,x=p.distanceScales.metersPerUnit[2]*(l[2]-l[0])/r;this.state.colorDomain=t.map(h=>h*x*a)}else this.state.colorDomain=t||ai;let g=this.getAttributeManager().getAttributes(),f=this.getModuleSettings(),d={radiusPixels:e,commonBounds:l,textureWidth:r,weightsScale:a};this._setModelAttributes(s.model,g),s.model.setVertexCount(this.getNumInstances()),s.model.setUniforms(d),s.model.updateModuleSettings(f),s.run({parameters:{viewport:[0,0,r,r]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:t}=this.state,{debounceTimeout:o}=this.props;e?(t=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(t),t=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),o)),this.setState({updateTimer:t})}_worldToCommonBounds(e,t={}){let{useLayerCoordinateSystem:o=!1}=t,[i,r,a,s]=e,{viewport:l}=this.context,{textureSize:c}=this.state,{coordinateSystem:g}=this.props,f=o&&(g===I.COORDINATE_SYSTEM.LNGLAT_OFFSETS||g===I.COORDINATE_SYSTEM.METER_OFFSETS),d=f?l.projectPosition(this.props.coordinateOrigin):[0,0],p=c*_r/l.scale,x,h;return o&&!f?(x=this.projectPosition([i,r,0]),h=this.projectPosition([a,s,0])):(x=l.projectPosition([i,r,0]),h=l.projectPosition([a,s,0])),Zo([x[0]-d[0],x[1]-d[1],h[0]-d[0],h[1]-d[1]],p,p)}_commonToWorldBounds(e){let[t,o,i,r]=e,{viewport:a}=this.context,s=a.unprojectPosition([t,o]),l=a.unprojectPosition([i,r]);return s.slice(0,2).concat(l.slice(0,2))}};Ee.layerName="HeatmapLayer";Ee.defaultProps=Mr;var si=Ee;return pi(Pe);})();
517
+ `;var Lr=`uniform weightUniforms {
518
+ vec4 commonBounds;
519
+ float radiusPixels;
520
+ float textureWidth;
521
+ float weightsScale;
522
+ } weight;
523
+ `,Co={name:"weight",vs:Lr,uniformTypes:{commonBounds:"vec4<f32>",radiusPixels:"f32",textureWidth:"f32",weightsScale:"f32"}},bo={name:"maxWeight",vs:`uniform maxWeightUniforms {
524
+ float textureSize;
525
+ } maxWeight;
526
+ `,uniformTypes:{textureSize:"f32"}};var Pr=2,fe={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},Eo=[0,0],wr={SUM:0,MEAN:1},Nr={getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:G,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Or=["float32-renderable-webgl","texture-blend-float-webgl"],Rr={data:{props:["radiusPixels"]}},At=class extends yo{getShaders(t){let e=[V.project32];return t.modules&&(e=[...e,...t.modules]),super.getShaders({...t,modules:e})}initializeState(){super.initializeAggregationLayer(Rr),this.setState({colorDomain:Eo}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t),this._updateHeatmapState(t)}_updateHeatmapState(t){let{props:e,oldProps:o}=t,r=this._getChangeFlags(t);(r.dataChanged||r.viewportChanged)&&(r.boundsChanged=this._updateBounds(r.dataChanged),this._updateTextureRenderingBounds()),r.dataChanged||r.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):r.viewportZoomChanged&&this._debouncedUpdateWeightmap(),e.colorRange!==o.colorRange&&this._updateColorTexture(t),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:t.context.viewport.zoom})}renderLayers(){let{weightsTexture:t,triPositionBuffer:e,triTexCoordBuffer:o,maxWeightsTexture:r,colorTexture:i,colorDomain:s}=this.state,{updateTriggers:a,intensity:c,threshold:g,aggregation:h}=this.props,f=this.getSubLayerClass("triangle",vo);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:V.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:e,texCoords:o}},vertexCount:4,maxTexture:r,colorTexture:i,aggregationMode:wr[h]||0,weightsTexture:t,intensity:c,threshold:g,colorDomain:s})}finalizeState(t){super.finalizeState(t);let{weightsTransform:e,weightsTexture:o,maxWeightTransform:r,maxWeightsTexture:i,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:c,updateTimer:g}=this.state;e?.destroy(),o?.destroy(),r?.destroy(),i?.destroy(),s?.destroy(),a?.destroy(),c?.destroy(),g&&clearTimeout(g)}_getAttributeManager(){return new V.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(t){let e={},{dimensions:o}=this.state;e.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(t,{compareAll:!0,dimension:o.data})&&"aggregation is dirty",e.viewportChanged=t.changeFlags.viewportChanged;let{zoom:r}=this.state;return(!t.context.viewport||t.context.viewport.zoom!==r)&&(e.viewportZoomChanged=!0),e}_createTextures(){let{textureSize:t,format:e}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...fe,width:t,height:t,format:e}),maxWeightsTexture:this.context.device.createTexture({...fe,width:1,height:1,format:e})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:t}=this.context,{weightsTextureSize:e}=this.props,o=Math.min(e,t.limits.maxTextureDimension2D),r=Or.every(a=>t.features.has(a)),i=r?"rgba32float":"rgba8unorm",s=r?1:1/255;this.setState({textureSize:o,format:i,weightsScale:s}),r||V.log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(t){let{weightsTransform:e}=this.state,{weightsTexture:o}=this.state,r=this.getAttributeManager();e?.destroy(),e=new de.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:r.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...t,modules:[...t.modules,Co]}),this.setState({weightsTransform:e})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:e,weightsTexture:o,maxWeightsTexture:r}=this.state,i=this.getShaders({vs:he,fs:pe});this._createWeightsTransform(i);let s=this.getShaders({vs:So,fs:Ao,modules:[bo]}),a=new de.TextureTransform(t,{id:`${this.id}-max-weights-transform`,targetTexture:r,...s,vertexCount:e*e,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}}),c={inTexture:o,textureSize:e};a.model.shaderInputs.setProps({maxWeight:c}),this.setState({weightsTexture:o,maxWeightsTexture:r,maxWeightTransform:a,zoom:null,triPositionBuffer:t.createBuffer({byteLength:48}),triTexCoordBuffer:t.createBuffer({byteLength:48})})}updateShaders(t){this._createWeightsTransform({vs:he,fs:pe,...t})}_updateMaxWeightValue(){let{maxWeightTransform:t}=this.state;t.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(t=!1){let{viewport:e}=this.context,o=[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([0,e.height]),e.unproject([e.width,e.height])].map(a=>a.map(Math.fround)),r=co(o),i={visibleWorldBounds:r,viewportCorners:o},s=!1;if(t||!this.state.worldBounds||!lo(this.state.worldBounds,r)){let a=this._worldToCommonBounds(r),c=this._commonToWorldBounds(a);this.props.coordinateSystem===V.COORDINATE_SYSTEM.LNGLAT&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let g=this._worldToCommonBounds(c);i.worldBounds=c,i.normalizedCommonBounds=g,s=!0}return this.setState(i),s}_updateTextureRenderingBounds(){let{triPositionBuffer:t,triTexCoordBuffer:e,normalizedCommonBounds:o,viewportCorners:r}=this.state,{viewport:i}=this.context;t.write(ge(r,3));let s=r.map(a=>ho(i.projectPosition(a),o));e.write(ge(s,2))}_updateColorTexture(t){let{colorRange:e}=t.props,{colorTexture:o}=this.state,r=ne(e,!1,Uint8Array);o&&o?.width===e.length?o.setTexture2DData({data:r}):(o?.destroy(),o=this.context.device.createTexture({...fe,data:r,width:e.length,height:1})),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:t,colorDomain:e,aggregation:o}=this.props,{worldBounds:r,textureSize:i,weightsScale:s,weightsTexture:a}=this.state,c=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let g=this._worldToCommonBounds(r,{useLayerCoordinateSystem:!0});if(e&&o==="SUM"){let{viewport:M}=this.context,b=M.distanceScales.metersPerUnit[2]*(g[2]-g[0])/i;this.state.colorDomain=e.map(y=>y*b*s)}else this.state.colorDomain=e||Eo;let f=this.getAttributeManager().getAttributes(),p=this.getModuleSettings();this._setModelAttributes(c.model,f),c.model.setVertexCount(this.getNumInstances());let d={radiusPixels:t,commonBounds:g,textureWidth:i,weightsScale:s,weightsTexture:a},{viewport:x,devicePixelRatio:v,coordinateSystem:S,coordinateOrigin:C}=p,{modelMatrix:E}=this.props;c.model.shaderInputs.setProps({project:{viewport:x,devicePixelRatio:v,modelMatrix:E,coordinateSystem:S,coordinateOrigin:C},weight:d}),c.run({parameters:{viewport:[0,0,i,i]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(t=!1){let{updateTimer:e}=this.state,{debounceTimeout:o}=this.props;t?(e=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(e),e=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),o)),this.setState({updateTimer:e})}_worldToCommonBounds(t,e={}){let{useLayerCoordinateSystem:o=!1}=e,[r,i,s,a]=t,{viewport:c}=this.context,{textureSize:g}=this.state,{coordinateSystem:h}=this.props,f=o&&(h===V.COORDINATE_SYSTEM.LNGLAT_OFFSETS||h===V.COORDINATE_SYSTEM.METER_OFFSETS),p=f?c.projectPosition(this.props.coordinateOrigin):[0,0],d=g*Pr/c.scale,x,v;return o&&!f?(x=this.projectPosition([r,i,0]),v=this.projectPosition([s,a,0])):(x=c.projectPosition([r,i,0]),v=c.projectPosition([s,a,0])),go([x[0]-p[0],x[1]-p[1],v[0]-p[0],v[1]-p[1]],d,d)}_commonToWorldBounds(t){let[e,o,r,i]=t,{viewport:s}=this.context,a=s.unprojectPosition([e,o]),c=s.unprojectPosition([r,i]);return a.slice(0,2).concat(c.slice(0,2))}};At.layerName="HeatmapLayer";At.defaultProps=Nr;var To=At;return _o(Ct);})();
508
527
  return __exports__;
509
528
  });