@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
@@ -1,88 +1,80 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
20
4
 
21
5
  import {
6
+ log,
22
7
  Accessor,
23
- AccessorFunction,
24
8
  Color,
25
- log,
26
- Position,
9
+ GetPickingInfoParams,
10
+ CompositeLayerProps,
11
+ createIterable,
12
+ Layer,
27
13
  Material,
14
+ project32,
15
+ LayersList,
16
+ PickingInfo,
17
+ Position,
18
+ Viewport,
28
19
  UpdateParameters,
29
20
  DefaultProps
30
21
  } from '@deck.gl/core';
31
- import {ColumnLayer} from '@deck.gl/layers';
32
-
33
- import {defaultColorRange} from '../utils/color-utils';
34
-
35
- import {pointToHexbin} from './hexagon-aggregator';
36
- import CPUAggregator from '../utils/cpu-aggregator';
37
- import AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';
22
+ import {WebGLAggregator, CPUAggregator, AggregationOperation} from '../common/aggregator/index';
23
+ import AggregationLayer from '../common/aggregation-layer';
24
+ import {AggregateAccessor} from '../common/types';
25
+ import {defaultColorRange} from '../common/utils/color-utils';
26
+ import {AttributeWithScale} from '../common/utils/scale-utils';
27
+ import {getBinIdRange} from '../common/utils/bounds-utils';
38
28
 
39
- import {AggregateAccessor} from '../types';
29
+ import HexagonCellLayer from './hexagon-cell-layer';
30
+ import {pointToHexbin, HexbinVertices, getHexbinCentroid, pointToHexbinGLSL} from './hexbin';
31
+ import {BinOptions, binOptionsUniforms} from './bin-options-uniforms';
40
32
 
41
33
  // eslint-disable-next-line @typescript-eslint/no-empty-function
42
- function nop() {}
34
+ function noop() {}
43
35
 
44
36
  const defaultProps: DefaultProps<HexagonLayerProps> = {
37
+ gpuAggregation: false,
38
+
45
39
  // color
46
40
  colorDomain: null,
47
41
  colorRange: defaultColorRange,
48
- getColorValue: {type: 'accessor', value: null}, // default value is calcuated from `getColorWeight` and `colorAggregation`
42
+ getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`
49
43
  getColorWeight: {type: 'accessor', value: 1},
50
44
  colorAggregation: 'SUM',
51
- lowerPercentile: {type: 'number', value: 0, min: 0, max: 100},
52
- upperPercentile: {type: 'number', value: 100, min: 0, max: 100},
45
+ lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},
46
+ upperPercentile: {type: 'number', min: 0, max: 100, value: 100},
53
47
  colorScaleType: 'quantize',
54
- onSetColorDomain: nop,
48
+ onSetColorDomain: noop,
55
49
 
56
50
  // elevation
57
51
  elevationDomain: null,
58
52
  elevationRange: [0, 1000],
59
- getElevationValue: {type: 'accessor', value: null}, // default value is calcuated from `getElevationWeight` and `elevationAggregation`
53
+ getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`
60
54
  getElevationWeight: {type: 'accessor', value: 1},
61
55
  elevationAggregation: 'SUM',
62
- elevationLowerPercentile: {type: 'number', value: 0, min: 0, max: 100},
63
- elevationUpperPercentile: {type: 'number', value: 100, min: 0, max: 100},
64
56
  elevationScale: {type: 'number', min: 0, value: 1},
57
+ elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},
58
+ elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},
65
59
  elevationScaleType: 'linear',
66
- onSetElevationDomain: nop,
60
+ onSetElevationDomain: noop,
67
61
 
68
- radius: {type: 'number', value: 1000, min: 1},
62
+ // hexbin
63
+ radius: {type: 'number', min: 1, value: 1000},
69
64
  coverage: {type: 'number', min: 0, max: 1, value: 1},
70
- extruded: false,
71
- hexagonAggregator: pointToHexbin,
72
65
  getPosition: {type: 'accessor', value: (x: any) => x.position},
73
- // Optional material for 'lighting' shader module
74
- material: true,
66
+ hexagonAggregator: {type: 'function', optional: true, value: null},
67
+ extruded: false,
75
68
 
76
- // data filter
77
- _filterData: {type: 'function', value: null, optional: true}
69
+ // Optional material for 'lighting' shader module
70
+ material: true
78
71
  };
79
72
 
80
- /** All properties supported by by HexagonLayer. */
81
- export type HexagonLayerProps<DataT = unknown> = _HexagonLayerProps<DataT> &
82
- AggregationLayerProps<DataT>;
73
+ /** All properties supported by HexagonLayer. */
74
+ export type HexagonLayerProps<DataT = unknown> = _HexagonLayerProps<DataT> & CompositeLayerProps;
83
75
 
84
76
  /** Properties added by HexagonLayer. */
85
- type _HexagonLayerProps<DataT = unknown> = {
77
+ type _HexagonLayerProps<DataT> = {
86
78
  /**
87
79
  * Radius of hexagon bin in meters. The hexagons are pointy-topped (rather than flat-topped).
88
80
  * @default 1000
@@ -90,31 +82,31 @@ type _HexagonLayerProps<DataT = unknown> = {
90
82
  radius?: number;
91
83
 
92
84
  /**
93
- * Function to aggregate data into hexagonal bins.
94
- * @default d3-hexbin
85
+ * Custom accessor to retrieve a hexagonal bin index from each data object.
86
+ * Not supported by GPU aggregation.
87
+ * @default null
95
88
  */
96
- hexagonAggregator?: (props: any, params: any) => any;
89
+ hexagonAggregator?: ((position: number[], radius: number) => [number, number]) | null;
97
90
 
98
91
  /**
99
- * Color scale input domain.
92
+ * Color scale domain, default is set to the extent of aggregated weights in each cell.
100
93
  * @default [min(colorWeight), max(colorWeight)]
101
94
  */
102
95
  colorDomain?: [number, number] | null;
103
96
 
104
97
  /**
105
- * Specified as an array of colors [color1, color2, ...].
106
- * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)
98
+ * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
107
99
  */
108
100
  colorRange?: Color[];
109
101
 
110
102
  /**
111
- * Hexagon radius multiplier, clamped between 0 - 1.
103
+ * Cell size multiplier, clamped between 0 - 1.
112
104
  * @default 1
113
105
  */
114
106
  coverage?: number;
115
107
 
116
108
  /**
117
- * Elevation scale input domain. The elevation scale is a linear scale that maps number of counts to elevation.
109
+ * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
118
110
  * @default [0, max(elevationWeight)]
119
111
  */
120
112
  elevationDomain?: [number, number] | null;
@@ -126,54 +118,56 @@ type _HexagonLayerProps<DataT = unknown> = {
126
118
  elevationRange?: [number, number];
127
119
 
128
120
  /**
129
- * Hexagon elevation multiplier.
121
+ * Cell elevation multiplier.
130
122
  * @default 1
131
123
  */
132
124
  elevationScale?: number;
133
125
 
134
126
  /**
135
127
  * Whether to enable cell elevation. If set to false, all cell will be flat.
136
- * @default false
128
+ * @default true
137
129
  */
138
130
  extruded?: boolean;
139
131
 
140
132
  /**
141
- * Filter bins and re-calculate color by `upperPercentile`.
142
- * Hexagons with color value larger than the `upperPercentile` will be hidden.
133
+ * Filter cells and re-calculate color by `upperPercentile`.
134
+ * Cells with value larger than the upperPercentile will be hidden.
143
135
  * @default 100
144
136
  */
145
137
  upperPercentile?: number;
146
138
 
147
139
  /**
148
- * Filter bins and re-calculate color by `lowerPercentile`.
149
- * Hexagons with color value smaller than the `lowerPercentile` will be hidden.
140
+ * Filter cells and re-calculate color by `lowerPercentile`.
141
+ * Cells with value smaller than the lowerPercentile will be hidden.
150
142
  * @default 0
151
143
  */
152
144
  lowerPercentile?: number;
153
145
 
154
146
  /**
155
- * Filter bins and re-calculate elevation by `elevationUpperPercentile`.
156
- * Hexagons with elevation value larger than the `elevationUpperPercentile` will be hidden.
147
+ * Filter cells and re-calculate elevation by `elevationUpperPercentile`.
148
+ * Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.
157
149
  * @default 100
158
150
  */
159
151
  elevationUpperPercentile?: number;
160
152
 
161
153
  /**
162
- * Filter bins and re-calculate elevation by `elevationLowerPercentile`.
163
- * Hexagons with elevation value larger than the `elevationLowerPercentile` will be hidden.
154
+ * Filter cells and re-calculate elevation by `elevationLowerPercentile`.
155
+ * Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.
164
156
  * @default 0
165
157
  */
166
158
  elevationLowerPercentile?: number;
167
159
 
168
160
  /**
169
161
  * Scaling function used to determine the color of the grid cell, default value is 'quantize'.
170
- * Supported Values are 'quantize', 'quantile' and 'ordinal'.
162
+ * Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.
171
163
  * @default 'quantize'
172
164
  */
173
- colorScaleType?: 'quantize' | 'quantile' | 'ordinal';
165
+ colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';
174
166
 
175
167
  /**
176
168
  * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.
169
+ * Supported Values are 'linear' and 'quantile'.
170
+ * @default 'linear'
177
171
  */
178
172
  elevationScaleType?: 'linear';
179
173
 
@@ -187,207 +181,481 @@ type _HexagonLayerProps<DataT = unknown> = {
187
181
 
188
182
  /**
189
183
  * Defines the operation used to aggregate all data object weights to calculate a cell's color value.
184
+ * Valid values are 'SUM', 'MEAN', 'MIN', 'MAX', 'COUNT'.
185
+ *
190
186
  * @default 'SUM'
191
187
  */
192
- colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
188
+ colorAggregation?: AggregationOperation;
193
189
 
194
190
  /**
195
191
  * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
192
+ * Valid values are 'SUM', 'MEAN', 'MIN', 'MAX', 'COUNT'.
193
+ *
196
194
  * @default 'SUM'
197
195
  */
198
- elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
196
+ elevationAggregation?: AggregationOperation;
199
197
 
200
198
  /**
201
199
  * Method called to retrieve the position of each object.
202
200
  * @default object => object.position
203
201
  */
204
- getPosition?: AccessorFunction<DataT, Position>;
202
+ getPosition?: Accessor<DataT, Position>;
205
203
 
206
204
  /**
207
- * The weight of a data object used to calculate the color value for a bin.
205
+ * The weight of a data object used to calculate the color value for a cell.
208
206
  * @default 1
209
207
  */
210
208
  getColorWeight?: Accessor<DataT, number>;
211
209
 
212
210
  /**
213
- * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its color is based on.
211
+ * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.
212
+ * Not supported by GPU aggregation.
214
213
  * @default null
215
214
  */
216
215
  getColorValue?: AggregateAccessor<DataT> | null;
217
216
 
218
217
  /**
219
- * The weight of a data object used to calculate the elevation value for a bin.
218
+ * The weight of a data object used to calculate the elevation value for a cell.
220
219
  * @default 1
221
220
  */
222
221
  getElevationWeight?: Accessor<DataT, number>;
223
222
 
224
223
  /**
225
- * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its elevation is based on.
224
+ * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.
225
+ * Not supported by GPU aggregation.
226
226
  * @default null
227
227
  */
228
228
  getElevationValue?: AggregateAccessor<DataT> | null;
229
229
 
230
230
  /**
231
- * This callback will be called when cell color domain has been calculated.
231
+ * This callback will be called when bin color domain has been calculated.
232
232
  * @default () => {}
233
233
  */
234
234
  onSetColorDomain?: (minMax: [number, number]) => void;
235
235
 
236
236
  /**
237
- * This callback will be called when cell elevation domain has been calculated.
237
+ * This callback will be called when bin elevation domain has been calculated.
238
238
  * @default () => {}
239
239
  */
240
240
  onSetElevationDomain?: (minMax: [number, number]) => void;
241
241
 
242
242
  /**
243
- * (Experimental) Filter data objects
243
+ * When set to true, aggregation is performed on GPU, provided other conditions are met.
244
+ * @default false
244
245
  */
245
- _filterData: null | ((d: DataT) => boolean);
246
+ gpuAggregation?: boolean;
246
247
  };
247
248
 
248
- /** Aggregates data into a hexagon-based heatmap. The color and height of a hexagon are determined based on the objects it contains. */
249
- export default class HexagonLayer<DataT, ExtraPropsT extends {} = {}> extends AggregationLayer<
250
- DataT,
251
- ExtraPropsT & Required<_HexagonLayerProps<DataT>>
252
- > {
249
+ export type HexagonLayerPickingInfo<DataT> = PickingInfo<{
250
+ /** Column index of the picked cell */
251
+ col: number;
252
+ /** Row index of the picked cell */
253
+ row: number;
254
+ /** Aggregated color value, as determined by `getColorWeight` and `colorAggregation` */
255
+ colorValue: number;
256
+ /** Aggregated elevation value, as determined by `getElevationWeight` and `elevationAggregation` */
257
+ elevationValue: number;
258
+ /** Number of data points in the picked cell */
259
+ count: number;
260
+ /** Centroid of the hexagon */
261
+ position: [number, number];
262
+ /** Indices of the data objects in the picked cell. Only available if using CPU aggregation. */
263
+ pointIndices?: number[];
264
+ /** The data objects in the picked cell. Only available if using CPU aggregation and layer data is an array. */
265
+ points?: DataT[];
266
+ }>;
267
+
268
+ /** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
269
+ export default class HexagonLayer<
270
+ DataT = any,
271
+ ExtraPropsT extends {} = {}
272
+ > extends AggregationLayer<DataT, ExtraPropsT & Required<_HexagonLayerProps<DataT>>> {
253
273
  static layerName = 'HexagonLayer';
254
274
  static defaultProps = defaultProps;
255
275
 
256
- state!: AggregationLayer<DataT>['state'] & {
257
- cpuAggregator: CPUAggregator;
258
- aggregatorState: CPUAggregator['state'];
259
- vertices: number[][] | null;
260
- };
261
- initializeState() {
262
- const cpuAggregator = new CPUAggregator({
263
- getAggregator: props => props.hexagonAggregator,
264
- getCellSize: props => props.radius
265
- });
276
+ state!: AggregationLayer<DataT>['state'] &
277
+ BinOptions & {
278
+ // Needed if getColorValue, getElevationValue are used
279
+ dataAsArray?: DataT[];
266
280
 
267
- this.state = {
268
- cpuAggregator,
269
- aggregatorState: cpuAggregator.state,
270
- vertices: null
281
+ colors?: AttributeWithScale;
282
+ elevations?: AttributeWithScale;
283
+
284
+ binIdRange: [number, number][];
285
+ aggregatorViewport: Viewport;
271
286
  };
272
- const attributeManager = this.getAttributeManager()!;
273
- attributeManager.add({
274
- positions: {size: 3, type: 'float64', accessor: 'getPosition'}
275
- });
276
- // color and elevation attributes can't be added as attributes
277
- // they are calculated using 'getValue' accessor that takes an array of pints.
278
- }
279
287
 
280
- updateState(opts: UpdateParameters<this>) {
281
- super.updateState(opts);
288
+ getAggregatorType(): string {
289
+ const {gpuAggregation, hexagonAggregator, getColorValue, getElevationValue} = this.props;
290
+ if (gpuAggregation && (hexagonAggregator || getColorValue || getElevationValue)) {
291
+ // If these features are desired by the app, the user should explicitly use CPU aggregation
292
+ log.warn('Features not supported by GPU aggregation, falling back to CPU')();
293
+ return 'cpu';
294
+ }
282
295
 
283
- if (opts.changeFlags.propsOrDataChanged) {
284
- const aggregatorState = this.state.cpuAggregator.updateState(opts, {
285
- viewport: this.context.viewport,
286
- attributes: this.getAttributes()
287
- });
288
- if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
289
- // if user provided custom aggregator and returns hexagonVertices,
290
- // Need to recalculate radius and angle based on vertices
291
- // @ts-expect-error
292
- const {hexagonVertices} = aggregatorState.layerData || {};
293
- this.setState({
294
- vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
295
- });
296
- }
296
+ if (
297
+ // GPU aggregation is requested
298
+ gpuAggregation &&
299
+ // GPU aggregation is supported by the device
300
+ WebGLAggregator.isSupported(this.context.device)
301
+ ) {
302
+ return 'gpu';
303
+ }
304
+ return 'cpu';
305
+ }
297
306
 
298
- this.setState({
299
- // make a copy of the internal state of cpuAggregator for testing
300
- aggregatorState
307
+ createAggregator(type: string): WebGLAggregator | CPUAggregator {
308
+ if (type === 'cpu') {
309
+ const {hexagonAggregator, radius} = this.props;
310
+ return new CPUAggregator({
311
+ dimensions: 2,
312
+ getBin: {
313
+ sources: ['positions'],
314
+ getValue: ({positions}: {positions: number[]}, index: number, opts: BinOptions) => {
315
+ if (hexagonAggregator) {
316
+ return hexagonAggregator(positions, radius);
317
+ }
318
+ const viewport = this.state.aggregatorViewport;
319
+ // project to common space
320
+ const p = viewport.projectPosition(positions);
321
+ const {radiusCommon, hexOriginCommon} = opts;
322
+ return pointToHexbin(
323
+ [p[0] - hexOriginCommon[0], p[1] - hexOriginCommon[1]],
324
+ radiusCommon
325
+ );
326
+ }
327
+ },
328
+ getValue: [
329
+ {sources: ['colorWeights'], getValue: ({colorWeights}) => colorWeights},
330
+ {sources: ['elevationWeights'], getValue: ({elevationWeights}) => elevationWeights}
331
+ ]
301
332
  });
302
333
  }
334
+ return new WebGLAggregator(this.context.device, {
335
+ dimensions: 2,
336
+ channelCount: 2,
337
+ bufferLayout: this.getAttributeManager()!.getBufferLayouts({isInstanced: false}),
338
+ ...super.getShaders({
339
+ modules: [project32, binOptionsUniforms],
340
+ vs: /* glsl */ `
341
+ in vec3 positions;
342
+ in vec3 positions64Low;
343
+ in float colorWeights;
344
+ in float elevationWeights;
345
+
346
+ ${pointToHexbinGLSL}
347
+
348
+ void getBin(out ivec2 binId) {
349
+ vec3 positionCommon = project_position(positions, positions64Low);
350
+ binId = pointToHexbin(positionCommon.xy, binOptions.radiusCommon);
351
+ }
352
+ void getValue(out vec2 value) {
353
+ value = vec2(colorWeights, elevationWeights);
354
+ }
355
+ `
356
+ })
357
+ });
303
358
  }
304
359
 
305
- convertLatLngToMeterOffset(hexagonVertices) {
306
- const {viewport} = this.context;
307
- if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {
308
- // get centroid of hexagons
309
- const vertex0 = hexagonVertices[0];
310
- const vertex3 = hexagonVertices[3];
311
-
312
- const centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];
313
- const centroidFlat = viewport.projectFlat(centroid);
314
-
315
- const {metersPerUnit} = viewport.getDistanceScales(centroid);
360
+ initializeState() {
361
+ super.initializeState();
316
362
 
317
- // offset all points by centroid to meter offset
318
- const vertices = hexagonVertices.map(vt => {
319
- const vtFlat = viewport.projectFlat(vt);
363
+ const attributeManager = this.getAttributeManager()!;
364
+ attributeManager.add({
365
+ positions: {
366
+ size: 3,
367
+ accessor: 'getPosition',
368
+ type: 'float64',
369
+ fp64: this.use64bitPositions()
370
+ },
371
+ colorWeights: {size: 1, accessor: 'getColorWeight'},
372
+ elevationWeights: {size: 1, accessor: 'getElevationWeight'}
373
+ });
374
+ }
320
375
 
321
- return [
322
- (vtFlat[0] - centroidFlat[0]) * metersPerUnit[0],
323
- (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]
324
- ];
376
+ updateState(params: UpdateParameters<this>) {
377
+ const aggregatorChanged = super.updateState(params);
378
+
379
+ const {props, oldProps, changeFlags} = params;
380
+ const {aggregator} = this.state;
381
+ if (
382
+ (changeFlags.dataChanged || !this.state.dataAsArray) &&
383
+ (props.getColorValue || props.getElevationValue)
384
+ ) {
385
+ // Convert data to array
386
+ this.state.dataAsArray = Array.from(createIterable(props.data).iterable);
387
+ }
388
+ if (
389
+ aggregatorChanged ||
390
+ changeFlags.dataChanged ||
391
+ props.radius !== oldProps.radius ||
392
+ props.getColorValue !== oldProps.getColorValue ||
393
+ props.getElevationValue !== oldProps.getElevationValue ||
394
+ props.colorAggregation !== oldProps.colorAggregation ||
395
+ props.elevationAggregation !== oldProps.elevationAggregation
396
+ ) {
397
+ this._updateBinOptions();
398
+ const {radiusCommon, hexOriginCommon, binIdRange, dataAsArray} = this.state;
399
+
400
+ aggregator.setProps({
401
+ // @ts-expect-error only used by GPUAggregator
402
+ binIdRange,
403
+ pointCount: this.getNumInstances(),
404
+ operations: [props.colorAggregation, props.elevationAggregation],
405
+ binOptions: {
406
+ radiusCommon,
407
+ hexOriginCommon
408
+ },
409
+ onUpdate: this._onAggregationUpdate.bind(this)
325
410
  });
326
411
 
327
- return vertices;
412
+ if (dataAsArray) {
413
+ const {getColorValue, getElevationValue} = this.props;
414
+ aggregator.setProps({
415
+ // @ts-expect-error only used by CPUAggregator
416
+ customOperations: [
417
+ getColorValue &&
418
+ ((indices: number[]) =>
419
+ getColorValue(
420
+ indices.map(i => dataAsArray[i]),
421
+ {indices, data: props.data}
422
+ )),
423
+ getElevationValue &&
424
+ ((indices: number[]) =>
425
+ getElevationValue(
426
+ indices.map(i => dataAsArray[i]),
427
+ {indices, data: props.data}
428
+ ))
429
+ ]
430
+ });
431
+ }
432
+ }
433
+ if (changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getColorValue) {
434
+ aggregator.setNeedsUpdate(0);
435
+ }
436
+ if (changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getElevationValue) {
437
+ aggregator.setNeedsUpdate(1);
328
438
  }
329
439
 
330
- log.error('HexagonLayer: hexagonVertices needs to be an array of 6 points')();
331
- return null;
440
+ return aggregatorChanged;
332
441
  }
333
442
 
334
- getPickingInfo({info}) {
335
- return this.state.cpuAggregator.getPickingInfo({info});
443
+ private _updateBinOptions() {
444
+ const bounds = this.getBounds();
445
+ let radiusCommon = 1;
446
+ let hexOriginCommon: [number, number] = [0, 0];
447
+ let binIdRange: [number, number][] = [
448
+ [0, 1],
449
+ [0, 1]
450
+ ];
451
+ let viewport = this.context.viewport;
452
+
453
+ if (bounds && Number.isFinite(bounds[0][0])) {
454
+ let centroid = [(bounds[0][0] + bounds[1][0]) / 2, (bounds[0][1] + bounds[1][1]) / 2];
455
+ const {radius} = this.props;
456
+ const {unitsPerMeter} = viewport.getDistanceScales(centroid);
457
+ radiusCommon = unitsPerMeter[0] * radius;
458
+
459
+ // Use the centroid of the hex at the center of the data
460
+ // This offsets the common space without changing the bins
461
+ const centerHex = pointToHexbin(viewport.projectFlat(centroid), radiusCommon);
462
+ centroid = viewport.unprojectFlat(getHexbinCentroid(centerHex, radiusCommon));
463
+
464
+ const ViewportType = viewport.constructor as any;
465
+ // We construct a viewport for the GPU aggregator's project module
466
+ // This viewport is determined by data
467
+ // removes arbitrary precision variance that depends on initial view state
468
+ viewport = viewport.isGeospatial
469
+ ? new ViewportType({longitude: centroid[0], latitude: centroid[1], zoom: 12})
470
+ : new Viewport({position: [centroid[0], centroid[1], 0], zoom: 12});
471
+
472
+ hexOriginCommon = [Math.fround(viewport.center[0]), Math.fround(viewport.center[1])];
473
+
474
+ binIdRange = getBinIdRange({
475
+ dataBounds: bounds,
476
+ getBinId: (p: number[]) => {
477
+ const positionCommon = viewport.projectFlat(p);
478
+ positionCommon[0] -= hexOriginCommon[0];
479
+ positionCommon[1] -= hexOriginCommon[1];
480
+ return pointToHexbin(positionCommon, radiusCommon);
481
+ },
482
+ padding: 1
483
+ });
484
+ }
485
+
486
+ this.setState({radiusCommon, hexOriginCommon, binIdRange, aggregatorViewport: viewport});
336
487
  }
337
488
 
338
- // create a method for testing
339
- _onGetSublayerColor(cell) {
340
- return this.state.cpuAggregator.getAccessor('fillColor')(cell);
489
+ override draw(opts) {
490
+ // Replaces render time viewport with our own
491
+ if (opts.shaderModuleProps.project) {
492
+ opts.shaderModuleProps.project.viewport = this.state.aggregatorViewport;
493
+ }
494
+ super.draw(opts);
341
495
  }
342
496
 
343
- // create a method for testing
344
- _onGetSublayerElevation(cell) {
345
- return this.state.cpuAggregator.getAccessor('elevation')(cell);
497
+ private _onAggregationUpdate({channel}: {channel: number}) {
498
+ const props = this.getCurrentLayer()!.props;
499
+ const {aggregator} = this.state;
500
+ if (channel === 0) {
501
+ const result = aggregator.getResult(0)!;
502
+ this.setState({
503
+ colors: new AttributeWithScale(result, aggregator.binCount)
504
+ });
505
+ props.onSetColorDomain(aggregator.getResultDomain(0));
506
+ } else if (channel === 1) {
507
+ const result = aggregator.getResult(1)!;
508
+ this.setState({
509
+ elevations: new AttributeWithScale(result, aggregator.binCount)
510
+ });
511
+ props.onSetElevationDomain(aggregator.getResultDomain(1));
512
+ }
346
513
  }
347
514
 
348
- _getSublayerUpdateTriggers() {
349
- return this.state.cpuAggregator.getUpdateTriggers(this.props);
515
+ onAttributeChange(id: string) {
516
+ const {aggregator} = this.state;
517
+ switch (id) {
518
+ case 'positions':
519
+ aggregator.setNeedsUpdate();
520
+
521
+ this._updateBinOptions();
522
+ const {radiusCommon, hexOriginCommon, binIdRange} = this.state;
523
+ aggregator.setProps({
524
+ // @ts-expect-error only used by GPUAggregator
525
+ binIdRange,
526
+ binOptions: {
527
+ radiusCommon,
528
+ hexOriginCommon
529
+ }
530
+ });
531
+ break;
532
+
533
+ case 'colorWeights':
534
+ aggregator.setNeedsUpdate(0);
535
+ break;
536
+
537
+ case 'elevationWeights':
538
+ aggregator.setNeedsUpdate(1);
539
+ break;
540
+
541
+ default:
542
+ // This should not happen
543
+ }
350
544
  }
351
545
 
352
- renderLayers() {
353
- const {elevationScale, extruded, coverage, material, transitions} = this.props;
354
- const {aggregatorState, vertices} = this.state;
355
-
356
- const SubLayerClass = this.getSubLayerClass('hexagon-cell', ColumnLayer);
357
- const updateTriggers = this._getSublayerUpdateTriggers();
358
-
359
- const geometry = vertices
360
- ? {vertices, radius: 1}
361
- : {
362
- // default geometry
363
- // @ts-expect-error TODO - undefined property?
364
- radius: aggregatorState.layerData.radiusCommon || 1,
365
- radiusUnits: 'common',
366
- angle: 90
367
- };
368
- return new SubLayerClass(
546
+ renderLayers(): LayersList | Layer | null {
547
+ const {aggregator, radiusCommon, hexOriginCommon} = this.state;
548
+ const {
549
+ elevationScale,
550
+ colorRange,
551
+ elevationRange,
552
+ extruded,
553
+ coverage,
554
+ material,
555
+ transitions,
556
+ colorScaleType,
557
+ lowerPercentile,
558
+ upperPercentile,
559
+ colorDomain,
560
+ elevationScaleType,
561
+ elevationLowerPercentile,
562
+ elevationUpperPercentile,
563
+ elevationDomain
564
+ } = this.props;
565
+ const CellLayerClass = this.getSubLayerClass('cells', HexagonCellLayer);
566
+ const binAttribute = aggregator.getBins();
567
+
568
+ const colors = this.state.colors?.update({
569
+ scaleType: colorScaleType,
570
+ lowerPercentile,
571
+ upperPercentile
572
+ });
573
+ const elevations = this.state.elevations?.update({
574
+ scaleType: elevationScaleType,
575
+ lowerPercentile: elevationLowerPercentile,
576
+ upperPercentile: elevationUpperPercentile
577
+ });
578
+
579
+ if (!colors || !elevations) {
580
+ return null;
581
+ }
582
+
583
+ return new CellLayerClass(
584
+ this.getSubLayerProps({
585
+ id: 'cells'
586
+ }),
369
587
  {
370
- ...geometry,
588
+ data: {
589
+ length: aggregator.binCount,
590
+ attributes: {
591
+ getBin: binAttribute,
592
+ getColorValue: colors.attribute,
593
+ getElevationValue: elevations.attribute
594
+ }
595
+ },
596
+ // Data has changed shallowly, but we likely don't need to update the attributes
597
+ dataComparator: (data, oldData) => data.length === oldData.length,
598
+ updateTriggers: {
599
+ getBin: [binAttribute],
600
+ getColorValue: [colors.attribute],
601
+ getElevationValue: [elevations.attribute]
602
+ },
371
603
  diskResolution: 6,
604
+ vertices: HexbinVertices,
605
+ radius: radiusCommon,
606
+ hexOriginCommon,
372
607
  elevationScale,
608
+ colorRange,
609
+ colorScaleType,
610
+ elevationRange,
373
611
  extruded,
374
612
  coverage,
375
613
  material,
376
-
377
- getFillColor: this._onGetSublayerColor.bind(this),
378
- getElevation: this._onGetSublayerElevation.bind(this),
614
+ colorDomain: colors.domain || colorDomain || aggregator.getResultDomain(0),
615
+ elevationDomain: elevations.domain || elevationDomain || aggregator.getResultDomain(1),
616
+ colorCutoff: colors.cutoff,
617
+ elevationCutoff: elevations.cutoff,
379
618
  transitions: transitions && {
380
619
  getFillColor: transitions.getColorValue || transitions.getColorWeight,
381
620
  getElevation: transitions.getElevationValue || transitions.getElevationWeight
382
- }
383
- },
384
- this.getSubLayerProps({
385
- id: 'hexagon-cell',
386
- updateTriggers
387
- }),
388
- {
389
- data: aggregatorState.layerData.data
621
+ },
622
+ // Extensions are already handled by the GPUAggregator, do not pass it down
623
+ extensions: []
390
624
  }
391
625
  );
392
626
  }
627
+
628
+ getPickingInfo(params: GetPickingInfoParams): HexagonLayerPickingInfo<DataT> {
629
+ const info: HexagonLayerPickingInfo<DataT> = params.info;
630
+ const {index} = info;
631
+ if (index >= 0) {
632
+ const bin = this.state.aggregator.getBin(index);
633
+ let object: HexagonLayerPickingInfo<DataT>['object'];
634
+ if (bin) {
635
+ const centroidCommon = getHexbinCentroid(
636
+ bin.id as [number, number],
637
+ this.state.radiusCommon
638
+ );
639
+ const centroid = this.context.viewport.unprojectFlat(centroidCommon);
640
+
641
+ object = {
642
+ col: bin.id[0],
643
+ row: bin.id[1],
644
+ position: centroid,
645
+ colorValue: bin.value[0],
646
+ elevationValue: bin.value[1],
647
+ count: bin.count
648
+ };
649
+ if (bin.pointIndices) {
650
+ object.pointIndices = bin.pointIndices;
651
+ object.points = Array.isArray(this.props.data)
652
+ ? bin.pointIndices.map(i => (this.props.data as DataT[])[i])
653
+ : [];
654
+ }
655
+ }
656
+ info.object = object;
657
+ }
658
+
659
+ return info;
660
+ }
393
661
  }