@deck.gl/aggregation-layers 9.0.35 → 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
@@ -0,0 +1,258 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {Model, ModelProps} from '@luma.gl/engine';
6
+ import {createRenderTarget} from './utils';
7
+
8
+ import type {Device, Framebuffer, Texture} from '@luma.gl/core';
9
+ import type {WebGLAggregatorProps} from './webgl-aggregator';
10
+ import type {AggregationOperation} from '../aggregator';
11
+ import {BinSorterProps, binSorterUniforms} from './bin-sorter-uniforms';
12
+
13
+ const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPU color mask RED, GREEN, BLUE, ALPHA
14
+ const MAX_FLOAT32 = 3e38;
15
+ const EMPTY_MASKS = {SUM: 0, MEAN: 0, MIN: 0, MAX: 0, COUNT: 0};
16
+
17
+ export const TEXTURE_WIDTH = 1024;
18
+
19
+ /**
20
+ * This class manages the resources for performing the first step of aggregation
21
+ * Sort a list of data points into a number of bins
22
+ */
23
+ export class WebGLBinSorter {
24
+ device: Device;
25
+ model: Model;
26
+
27
+ /**
28
+ * A packed texture in which each pixel represents a bin.
29
+ * The index of the pixel in the memory layout is the bin index.
30
+ * Alpha value is the count of data points that fall into this bin
31
+ * R,G,B values are the aggregated values of each channel:
32
+ * - Sum of all data points if operation is 'SUM', or 'MEAN'
33
+ * - Min of all data points if operation is 'MIN'
34
+ * - Max of all data points if operation is 'MAX'
35
+ */
36
+ private binsFBO: Framebuffer | null = null;
37
+
38
+ constructor(device: Device, props: WebGLAggregatorProps) {
39
+ this.device = device;
40
+ this.model = createModel(device, props);
41
+ }
42
+
43
+ get texture(): Texture | null {
44
+ return this.binsFBO ? this.binsFBO.colorAttachments[0].texture : null;
45
+ }
46
+
47
+ destroy() {
48
+ this.model.destroy();
49
+ this.binsFBO?.colorAttachments[0].texture.destroy();
50
+ this.binsFBO?.destroy();
51
+ }
52
+
53
+ getBinValues(index: number): Float32Array | null {
54
+ if (!this.binsFBO) {
55
+ return null;
56
+ }
57
+ const x = index % TEXTURE_WIDTH;
58
+ const y = Math.floor(index / TEXTURE_WIDTH);
59
+ const buffer = this.device.readPixelsToArrayWebGL(this.binsFBO, {
60
+ sourceX: x,
61
+ sourceY: y,
62
+ sourceWidth: 1,
63
+ sourceHeight: 1
64
+ }).buffer;
65
+ return new Float32Array(buffer);
66
+ }
67
+
68
+ setDimensions(binCount: number, binIdRange: [number, number][]) {
69
+ const width = TEXTURE_WIDTH;
70
+ const height = Math.ceil(binCount / width);
71
+
72
+ // Only destroy existing texture if it is not large enough
73
+ if (!this.binsFBO) {
74
+ this.binsFBO = createRenderTarget(this.device, width, height);
75
+ } else if (this.binsFBO.height < height) {
76
+ this.binsFBO.resize({width, height});
77
+ }
78
+
79
+ const binSorterProps: BinSorterProps = {
80
+ binIdRange: [
81
+ binIdRange[0][0],
82
+ binIdRange[0][1],
83
+ binIdRange[1]?.[0] || 0,
84
+ binIdRange[1]?.[1] || 0
85
+ ],
86
+ targetSize: [this.binsFBO.width, this.binsFBO.height]
87
+ };
88
+ this.model.shaderInputs.setProps({binSorter: binSorterProps});
89
+ }
90
+
91
+ setModelProps(
92
+ props: Pick<ModelProps, 'vertexCount' | 'uniforms' | 'attributes' | 'constantAttributes'> & {
93
+ shaderModuleProps?: Record<string, any>;
94
+ }
95
+ ) {
96
+ const model = this.model;
97
+ if (props.attributes) {
98
+ model.setAttributes(props.attributes);
99
+ }
100
+ if (props.constantAttributes) {
101
+ model.setConstantAttributes(props.constantAttributes);
102
+ }
103
+ if (props.vertexCount !== undefined) {
104
+ model.setVertexCount(props.vertexCount);
105
+ }
106
+ if (props.shaderModuleProps) {
107
+ model.shaderInputs.setProps(props.shaderModuleProps);
108
+ }
109
+ }
110
+
111
+ /** Update aggregation */
112
+ update(
113
+ /** The aggregation operation for each channel. Use null to skip update. */
114
+ operations: (AggregationOperation | null)[]
115
+ ) {
116
+ if (!this.binsFBO) {
117
+ return;
118
+ }
119
+ const masks = getMaskByOperation(operations);
120
+ this._updateBins('SUM', masks.SUM + masks.MEAN);
121
+ this._updateBins('MIN', masks.MIN);
122
+ this._updateBins('MAX', masks.MAX);
123
+ }
124
+
125
+ /** Recalculate aggregation on the given channels using the given operation */
126
+ private _updateBins(
127
+ operation: AggregationOperation,
128
+ /** GPU bit mask of one or more channels that should be updated */
129
+ colorMask: number
130
+ ) {
131
+ if (colorMask === 0) {
132
+ return;
133
+ }
134
+ colorMask |= COLOR_CHANNELS[3]; // Also renders to the alpha channel (point count)
135
+
136
+ const model = this.model;
137
+ const target = this.binsFBO!;
138
+
139
+ const initialValue = operation === 'MAX' ? -MAX_FLOAT32 : operation === 'MIN' ? MAX_FLOAT32 : 0;
140
+ const renderPass = this.device.beginRenderPass({
141
+ id: `gpu-aggregation-${operation}`,
142
+ framebuffer: target,
143
+ parameters: {
144
+ viewport: [0, 0, target.width, target.height],
145
+ colorMask
146
+ },
147
+ clearColor: [initialValue, initialValue, initialValue, 0],
148
+ clearDepth: false,
149
+ clearStencil: false
150
+ });
151
+ model.setParameters({
152
+ blend: true,
153
+ blendColorSrcFactor: 'one',
154
+ blendColorDstFactor: 'one',
155
+ blendAlphaSrcFactor: 'one',
156
+ blendAlphaDstFactor: 'one',
157
+ blendColorOperation: operation === 'MAX' ? 'max' : operation === 'MIN' ? 'min' : 'add',
158
+ blendAlphaOperation: 'add'
159
+ });
160
+ model.draw(renderPass);
161
+ renderPass.end();
162
+ }
163
+ }
164
+
165
+ /** Convert a [channel -> operation] map to a [operation -> GPU color mask] map */
166
+ function getMaskByOperation(
167
+ operations: (AggregationOperation | null)[]
168
+ ): Record<AggregationOperation, number> {
169
+ const result: Record<AggregationOperation, number> = {...EMPTY_MASKS};
170
+ for (let channel = 0; channel < operations.length; channel++) {
171
+ const op = operations[channel];
172
+ if (op) {
173
+ result[op] += COLOR_CHANNELS[channel];
174
+ }
175
+ }
176
+ return result;
177
+ }
178
+
179
+ function createModel(device: Device, props: WebGLAggregatorProps): Model {
180
+ let userVs = props.vs;
181
+
182
+ if (props.dimensions === 2) {
183
+ // If user provides 2d bin IDs, convert them to 1d indices for data packing
184
+ userVs += /* glsl */ `
185
+ void getBin(out int binId) {
186
+ ivec2 binId2;
187
+ getBin(binId2);
188
+ if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) {
189
+ binId = -1;
190
+ } else {
191
+ binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x;
192
+ }
193
+ }
194
+ `;
195
+ }
196
+
197
+ const vs = `\
198
+ #version 300 es
199
+ #define SHADER_NAME gpu-aggregation-sort-bins-vertex
200
+
201
+ ${userVs}
202
+
203
+ out vec3 v_Value;
204
+
205
+ void main() {
206
+ int binIndex;
207
+ getBin(binIndex);
208
+ binIndex = binIndex - binSorter.binIdRange.x;
209
+ if (binIndex < 0) {
210
+ gl_Position = vec4(0.);
211
+ return;
212
+ }
213
+ int row = binIndex / binSorter.targetSize.x;
214
+ int col = binIndex - row * binSorter.targetSize.x;
215
+ vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0;
216
+ gl_Position = vec4(position, 0.0, 1.0);
217
+ gl_PointSize = 1.0;
218
+
219
+ #if NUM_CHANNELS == 3
220
+ getValue(v_Value);
221
+ #elif NUM_CHANNELS == 2
222
+ getValue(v_Value.xy);
223
+ #else
224
+ getValue(v_Value.x);
225
+ #endif
226
+ }
227
+ `;
228
+ const fs = /* glsl */ `\
229
+ #version 300 es
230
+ #define SHADER_NAME gpu-aggregation-sort-bins-fragment
231
+
232
+ precision highp float;
233
+
234
+ in vec3 v_Value;
235
+ out vec4 fragColor;
236
+
237
+ void main() {
238
+ fragColor.xyz = v_Value;
239
+
240
+ #ifdef MODULE_GEOMETRY
241
+ geometry.uv = vec2(0.);
242
+ DECKGL_FILTER_COLOR(fragColor, geometry);
243
+ #endif
244
+
245
+ fragColor.w = 1.0;
246
+ }
247
+ `;
248
+ const model = new Model(device, {
249
+ bufferLayout: props.bufferLayout,
250
+ modules: [...(props.modules || []), binSorterUniforms],
251
+ defines: {...props.defines, NON_INSTANCED_MODEL: 1, NUM_CHANNELS: props.channelCount},
252
+ isInstanced: false,
253
+ vs,
254
+ fs,
255
+ topology: 'point-list'
256
+ });
257
+ return model;
258
+ }
@@ -0,0 +1,10 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export {CPUAggregator} from './cpu-aggregator/cpu-aggregator';
6
+ export {WebGLAggregator} from './gpu-aggregator/webgl-aggregator';
7
+
8
+ export type {Aggregator, AggregatedBin, AggregationOperation, AggregationProps} from './aggregator';
9
+ export type {CPUAggregatorProps} from './cpu-aggregator/cpu-aggregator';
10
+ export type {WebGLAggregatorProps} from './gpu-aggregator/webgl-aggregator';
@@ -1,11 +1,17 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  /** Type assigned to e.g. getColorValue/getElevationValue props in aggregation layers (e.g. CPUGridLayer, HexagonLayer)*/
2
- export type AggregateAccessor<DataT = any> = (args: {
6
+ export type AggregateAccessor<DataT = any> = (
3
7
  /** a list of objects whose positions fall inside this cell. */
4
- objects: DataT[];
8
+ objects: DataT[],
5
9
  objectInfo: {
6
10
  /** the indices of `objects` in the original data. */
7
11
  indices: number[];
8
12
  /** the value of the `data` prop */
9
13
  data: any;
10
- };
11
- }) => number;
14
+ }
15
+ ) => number;
16
+
17
+ export type ScaleType = 'linear' | 'quantize' | 'quantile' | 'ordinal';
@@ -0,0 +1,34 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /** Utility to estimate binIdRange as expected by AggregatorProps */
6
+ export function getBinIdRange({
7
+ dataBounds,
8
+ getBinId,
9
+ padding = 0
10
+ }: {
11
+ /** Bounds of the input data */
12
+ dataBounds: [min: number[], max: number[]];
13
+ /** Given a data point, returns the bin id that it belongs to */
14
+ getBinId: (p: number[]) => number[];
15
+ /** Add a border around the result to avoid clipping */
16
+ padding?: number;
17
+ }): [number, number][] {
18
+ const corners = [
19
+ dataBounds[0],
20
+ dataBounds[1],
21
+ [dataBounds[0][0], dataBounds[1][1]],
22
+ [dataBounds[1][0], dataBounds[0][1]]
23
+ ].map(p => getBinId(p));
24
+
25
+ const minX = Math.min(...corners.map(p => p[0])) - padding;
26
+ const minY = Math.min(...corners.map(p => p[1])) - padding;
27
+ const maxX = Math.max(...corners.map(p => p[0])) + padding + 1;
28
+ const maxY = Math.max(...corners.map(p => p[1])) + padding + 1;
29
+
30
+ return [
31
+ [minX, maxX],
32
+ [minY, maxY]
33
+ ];
34
+ }
@@ -0,0 +1,86 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {Color} from '@deck.gl/core';
6
+ import type {Device, Texture} from '@luma.gl/core';
7
+ import type {NumericArray, TypedArray, TypedArrayConstructor} from '@math.gl/types';
8
+ import type {ScaleType} from '../types';
9
+
10
+ export const defaultColorRange: Color[] = [
11
+ [255, 255, 178],
12
+ [254, 217, 118],
13
+ [254, 178, 76],
14
+ [253, 141, 60],
15
+ [240, 59, 32],
16
+ [189, 0, 38]
17
+ ];
18
+
19
+ // Converts a colorRange array to a flat array with 4 components per color
20
+ export function colorRangeToFlatArray(
21
+ colorRange: Color[] | NumericArray,
22
+ normalize = false,
23
+ ArrayType: TypedArrayConstructor = Float32Array
24
+ ): TypedArray {
25
+ let flatArray: TypedArray;
26
+
27
+ if (Number.isFinite(colorRange[0])) {
28
+ // its already a flat array.
29
+ flatArray = new ArrayType(colorRange as NumericArray);
30
+ } else {
31
+ // flatten it
32
+ flatArray = new ArrayType(colorRange.length * 4);
33
+ let index = 0;
34
+
35
+ for (let i = 0; i < colorRange.length; i++) {
36
+ const color = colorRange[i];
37
+ flatArray[index++] = color[0];
38
+ flatArray[index++] = color[1];
39
+ flatArray[index++] = color[2];
40
+ flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
41
+ }
42
+ }
43
+
44
+ if (normalize) {
45
+ for (let i = 0; i < flatArray.length; i++) {
46
+ flatArray[i] /= 255;
47
+ }
48
+ }
49
+ return flatArray;
50
+ }
51
+
52
+ export const COLOR_RANGE_FILTER: Record<ScaleType, 'linear' | 'nearest'> = {
53
+ linear: 'linear',
54
+ quantile: 'nearest',
55
+ quantize: 'nearest',
56
+ ordinal: 'nearest'
57
+ } as const;
58
+
59
+ export function updateColorRangeTexture(texture: Texture, type: ScaleType) {
60
+ texture.setSampler({
61
+ minFilter: COLOR_RANGE_FILTER[type],
62
+ magFilter: COLOR_RANGE_FILTER[type]
63
+ });
64
+ }
65
+
66
+ export function createColorRangeTexture(
67
+ device: Device,
68
+ colorRange: Color[] | NumericArray,
69
+ type: ScaleType = 'linear'
70
+ ): Texture {
71
+ const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
72
+
73
+ return device.createTexture({
74
+ format: 'rgba8unorm',
75
+ mipmaps: false,
76
+ sampler: {
77
+ minFilter: COLOR_RANGE_FILTER[type],
78
+ magFilter: COLOR_RANGE_FILTER[type],
79
+ addressModeU: 'clamp-to-edge',
80
+ addressModeV: 'clamp-to-edge'
81
+ },
82
+ data: colors,
83
+ width: colors.length / 4,
84
+ height: 1
85
+ });
86
+ }
@@ -0,0 +1,13 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export function filterProps(props, filterKeys) {
6
+ const filteredProps = {};
7
+ for (const key in props) {
8
+ if (!filterKeys.includes(key)) {
9
+ filteredProps[key] = props[key];
10
+ }
11
+ }
12
+ return filteredProps;
13
+ }
@@ -0,0 +1,236 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {BinaryAttribute} from '@deck.gl/core';
6
+ import type {ScaleType} from '../types';
7
+
8
+ type ScaleProps = {
9
+ scaleType: ScaleType;
10
+ /** Trim the lower end of the domain by this percentile. Set to `0` to disable. */
11
+ lowerPercentile: number;
12
+ /** Trim the upper end of the domain by this percentile. Set to `100` to disable. */
13
+ upperPercentile: number;
14
+ };
15
+
16
+ /** Applies a scale to BinaryAttribute */
17
+ export class AttributeWithScale {
18
+ /** Input values accessor. Has either a `value` (CPU aggregation) or a `buffer` (GPU aggregation) */
19
+ private readonly input: BinaryAttribute;
20
+ private readonly inputLength: number;
21
+
22
+ private props: ScaleProps = {
23
+ scaleType: 'linear',
24
+ lowerPercentile: 0,
25
+ upperPercentile: 100
26
+ };
27
+
28
+ // cached calculations
29
+ private _percentile?: {attribute: BinaryAttribute; domain: number[]};
30
+ private _ordinal?: {attribute: BinaryAttribute; domain: number[]};
31
+
32
+ /** Output values accessor */
33
+ attribute: BinaryAttribute;
34
+ /** [min, max] of attribute values, or null if unknown */
35
+ domain: [number, number] | null = null;
36
+ /** Valid domain if lower/upper percentile are defined */
37
+ cutoff: [number, number] | null = null;
38
+
39
+ constructor(input: BinaryAttribute, inputLength: number) {
40
+ this.input = input;
41
+ this.inputLength = inputLength;
42
+ // No processing is needed with the default scale
43
+ this.attribute = input;
44
+ }
45
+
46
+ private getScalePercentile() {
47
+ if (!this._percentile) {
48
+ const value = getAttributeValue(this.input, this.inputLength);
49
+ this._percentile = applyScaleQuantile(value);
50
+ }
51
+ return this._percentile;
52
+ }
53
+
54
+ private getScaleOrdinal() {
55
+ if (!this._ordinal) {
56
+ const value = getAttributeValue(this.input, this.inputLength);
57
+ this._ordinal = applyScaleOrdinal(value);
58
+ }
59
+ return this._ordinal;
60
+ }
61
+
62
+ /** Returns the [lowerCutoff, upperCutoff] of scaled values, or null if not applicable */
63
+ private getCutoff({
64
+ scaleType,
65
+ lowerPercentile,
66
+ upperPercentile
67
+ }: ScaleProps): [number, number] | null {
68
+ if (scaleType === 'quantile') {
69
+ return [lowerPercentile, upperPercentile - 1];
70
+ }
71
+
72
+ if (lowerPercentile > 0 || upperPercentile < 100) {
73
+ const {domain: thresholds} = this.getScalePercentile();
74
+ let lowValue = thresholds[Math.floor(lowerPercentile) - 1] ?? -Infinity;
75
+ let highValue = thresholds[Math.floor(upperPercentile) - 1] ?? Infinity;
76
+
77
+ if (scaleType === 'ordinal') {
78
+ const {domain: sortedUniqueValues} = this.getScaleOrdinal();
79
+ lowValue = sortedUniqueValues.findIndex(x => x >= lowValue);
80
+ highValue = sortedUniqueValues.findIndex(x => x > highValue) - 1;
81
+ if (highValue === -2) {
82
+ highValue = sortedUniqueValues.length - 1;
83
+ }
84
+ }
85
+ return [lowValue, highValue];
86
+ }
87
+
88
+ return null;
89
+ }
90
+
91
+ update(props: ScaleProps) {
92
+ const oldProps = this.props;
93
+
94
+ if (props.scaleType !== oldProps.scaleType) {
95
+ switch (props.scaleType) {
96
+ case 'quantile': {
97
+ const {attribute} = this.getScalePercentile();
98
+ this.attribute = attribute;
99
+ this.domain = [0, 99];
100
+ break;
101
+ }
102
+ case 'ordinal': {
103
+ const {attribute, domain} = this.getScaleOrdinal();
104
+ this.attribute = attribute;
105
+ this.domain = [0, domain.length - 1];
106
+ break;
107
+ }
108
+
109
+ default:
110
+ this.attribute = this.input;
111
+ this.domain = null;
112
+ }
113
+ }
114
+ if (
115
+ props.scaleType !== oldProps.scaleType ||
116
+ props.lowerPercentile !== oldProps.lowerPercentile ||
117
+ props.upperPercentile !== oldProps.upperPercentile
118
+ ) {
119
+ this.cutoff = this.getCutoff(props);
120
+ }
121
+ this.props = props;
122
+ return this;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Transform an array of values to ordinal indices
128
+ */
129
+ export function applyScaleOrdinal(values: Float32Array): {
130
+ attribute: BinaryAttribute;
131
+ domain: number[];
132
+ } {
133
+ const uniqueValues = new Set<number>();
134
+ for (const x of values) {
135
+ if (Number.isFinite(x)) {
136
+ uniqueValues.add(x);
137
+ }
138
+ }
139
+ const sortedUniqueValues = Array.from(uniqueValues).sort();
140
+ const domainMap = new Map();
141
+ for (let i = 0; i < sortedUniqueValues.length; i++) {
142
+ domainMap.set(sortedUniqueValues[i], i);
143
+ }
144
+
145
+ return {
146
+ attribute: {
147
+ value: values.map(x => (Number.isFinite(x) ? domainMap.get(x) : NaN)),
148
+ type: 'float32',
149
+ size: 1
150
+ },
151
+ domain: sortedUniqueValues
152
+ };
153
+ }
154
+
155
+ /**
156
+ * Transform an array of values to percentiles
157
+ */
158
+ export function applyScaleQuantile(
159
+ values: Float32Array,
160
+ rangeLength = 100
161
+ ): {
162
+ attribute: BinaryAttribute;
163
+ domain: number[];
164
+ } {
165
+ const sortedValues = Array.from(values).filter(Number.isFinite).sort(ascending);
166
+ let i = 0;
167
+ const n = Math.max(1, rangeLength);
168
+ const thresholds: number[] = new Array(n - 1);
169
+ while (++i < n) {
170
+ thresholds[i - 1] = threshold(sortedValues, i / n);
171
+ }
172
+ return {
173
+ attribute: {
174
+ value: values.map(x => (Number.isFinite(x) ? bisectRight(thresholds, x) : NaN)),
175
+ type: 'float32',
176
+ size: 1
177
+ },
178
+ domain: thresholds
179
+ };
180
+ }
181
+
182
+ function getAttributeValue(attribute: BinaryAttribute, length: number): Float32Array {
183
+ const elementStride = (attribute.stride ?? 4) / 4;
184
+ const elementOffset = (attribute.offset ?? 0) / 4;
185
+ let value = attribute.value as Float32Array;
186
+ if (!value) {
187
+ const bytes = attribute.buffer?.readSyncWebGL(0, elementStride * 4 * length);
188
+ if (bytes) {
189
+ value = new Float32Array(bytes.buffer);
190
+ attribute.value = value;
191
+ }
192
+ }
193
+
194
+ if (elementStride === 1) {
195
+ return value.subarray(0, length);
196
+ }
197
+ const result = new Float32Array(length);
198
+ for (let i = 0; i < length; i++) {
199
+ result[i] = value[i * elementStride + elementOffset];
200
+ }
201
+ return result;
202
+ }
203
+
204
+ function ascending(a: number, b: number): number {
205
+ return a - b;
206
+ }
207
+
208
+ function threshold(domain: number[], fraction: number): number {
209
+ const domainLength = domain.length;
210
+ if (fraction <= 0 || domainLength < 2) {
211
+ return domain[0];
212
+ }
213
+ if (fraction >= 1) {
214
+ return domain[domainLength - 1];
215
+ }
216
+
217
+ const domainFraction = (domainLength - 1) * fraction;
218
+ const lowIndex = Math.floor(domainFraction);
219
+ const low = domain[lowIndex];
220
+ const high = domain[lowIndex + 1];
221
+ return low + (high - low) * (domainFraction - lowIndex);
222
+ }
223
+
224
+ function bisectRight(a: number[], x: number): number {
225
+ let lo = 0;
226
+ let hi = a.length;
227
+ while (lo < hi) {
228
+ const mid = (lo + hi) >>> 1;
229
+ if (a[mid] > x) {
230
+ hi = mid;
231
+ } else {
232
+ lo = mid + 1;
233
+ }
234
+ }
235
+ return lo;
236
+ }
@@ -0,0 +1,26 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {ShaderModule} from '@luma.gl/shadertools';
6
+
7
+ const uniformBlock = /* glsl */ `\
8
+ uniform binOptionsUniforms {
9
+ vec2 cellOriginCommon;
10
+ vec2 cellSizeCommon;
11
+ } binOptions;
12
+ `;
13
+
14
+ export type BinOptions = {
15
+ cellOriginCommon: [number, number];
16
+ cellSizeCommon: [number, number];
17
+ };
18
+
19
+ export const binOptionsUniforms = {
20
+ name: 'binOptions',
21
+ vs: uniformBlock,
22
+ uniformTypes: {
23
+ cellOriginCommon: 'vec2<f32>',
24
+ cellSizeCommon: 'vec2<f32>'
25
+ }
26
+ } as const satisfies ShaderModule<BinOptions>;