@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
@@ -1,173 +0,0 @@
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.
20
- import { GL } from '@luma.gl/constants';
21
- import { log } from '@deck.gl/core';
22
- import AggregationLayer from "./aggregation-layer.js";
23
- import GPUGridAggregator from "./utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
24
- import BinSorter from "./utils/bin-sorter.js";
25
- import { pointToDensityGridDataCPU } from "./cpu-grid-layer/grid-aggregator.js";
26
- class GridAggregationLayer extends AggregationLayer {
27
- initializeAggregationLayer({ dimensions }) {
28
- super.initializeAggregationLayer(dimensions);
29
- this.setState({
30
- // CPU aggregation results
31
- layerData: {},
32
- gpuGridAggregator: new GPUGridAggregator(this.context.device, {
33
- id: `${this.id}-gpu-aggregator`
34
- }),
35
- cpuGridAggregator: pointToDensityGridDataCPU
36
- });
37
- }
38
- updateState(opts) {
39
- // get current attributes
40
- super.updateState(opts);
41
- this.updateAggregationState(opts);
42
- const { aggregationDataDirty, aggregationWeightsDirty, gpuAggregation } = this.state;
43
- if (this.getNumInstances() <= 0) {
44
- return;
45
- }
46
- let aggregationDirty = false;
47
- // CPU aggregation is two steps
48
- // 1. Create bins (based on cellSize and position) 2. Aggregate weights for each bin
49
- // For GPU aggregation both above steps are combined into one step
50
- // step-1
51
- if (aggregationDataDirty || (gpuAggregation && aggregationWeightsDirty)) {
52
- this._updateAggregation(opts);
53
- aggregationDirty = true;
54
- }
55
- // step-2 (Applicalbe for CPU aggregation only)
56
- if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {
57
- this._updateWeightBins();
58
- this._uploadAggregationResults();
59
- aggregationDirty = true;
60
- }
61
- this.setState({ aggregationDirty });
62
- }
63
- finalizeState(context) {
64
- const { count } = this.state.weights;
65
- if (count && count.aggregationBuffer) {
66
- count.aggregationBuffer.delete();
67
- }
68
- this.state.gpuGridAggregator?.delete();
69
- super.finalizeState(context);
70
- }
71
- updateShaders(shaders) {
72
- if (this.state.gpuAggregation) {
73
- this.state.gpuGridAggregator.updateShaders(shaders);
74
- }
75
- }
76
- // Methods that can be overriden by subclasses for customizations
77
- updateAggregationState(opts) {
78
- // Sublayers should implement this method.
79
- log.assert(false);
80
- }
81
- allocateResources(numRow, numCol) {
82
- if (this.state.numRow !== numRow || this.state.numCol !== numCol) {
83
- const dataBytes = numCol * numRow * 4 * 4;
84
- const { weights } = this.state;
85
- for (const name in weights) {
86
- const weight = weights[name];
87
- if (weight.aggregationBuffer) {
88
- weight.aggregationBuffer.delete();
89
- }
90
- weight.aggregationBuffer = this.context.device.createBuffer({
91
- byteLength: dataBytes,
92
- // @ts-expect-error legacy
93
- accessor: {
94
- size: 4,
95
- type: 5126,
96
- divisor: 1
97
- }
98
- });
99
- }
100
- }
101
- }
102
- updateResults({ aggregationData, maxMinData, maxData, minData }) {
103
- const { count } = this.state.weights;
104
- if (count) {
105
- count.aggregationData = aggregationData;
106
- count.maxMinData = maxMinData;
107
- count.maxData = maxData;
108
- count.minData = minData;
109
- }
110
- }
111
- // Private
112
- _updateAggregation(opts) {
113
- const { cpuGridAggregator, gpuGridAggregator, gridOffset, posOffset, translation = [0, 0], scaling = [0, 0, 0], boundingBox, projectPoints, gpuAggregation, numCol, numRow } = this.state;
114
- const { props } = opts;
115
- const { viewport } = this.context;
116
- const attributes = this.getAttributes();
117
- const vertexCount = this.getNumInstances();
118
- if (!gpuAggregation) {
119
- const result = cpuGridAggregator(props, {
120
- gridOffset,
121
- projectPoints,
122
- attributes,
123
- viewport,
124
- posOffset,
125
- boundingBox
126
- });
127
- this.setState({
128
- layerData: result
129
- });
130
- }
131
- else {
132
- const { weights } = this.state;
133
- gpuGridAggregator.run({
134
- weights,
135
- cellSize: [gridOffset.xOffset, gridOffset.yOffset],
136
- numCol,
137
- numRow,
138
- translation,
139
- scaling,
140
- vertexCount,
141
- projectPoints,
142
- attributes,
143
- moduleSettings: this.getModuleSettings()
144
- });
145
- }
146
- }
147
- _updateWeightBins() {
148
- const { getValue } = this.state;
149
- const sortedBins = new BinSorter(this.state.layerData.data || [], { getValue });
150
- this.setState({ sortedBins });
151
- }
152
- _uploadAggregationResults() {
153
- const { numCol, numRow } = this.state;
154
- const { data } = this.state.layerData;
155
- const { aggregatedBins, minValue, maxValue, totalCount } = this.state.sortedBins;
156
- const ELEMENTCOUNT = 4;
157
- const aggregationSize = numCol * numRow * ELEMENTCOUNT;
158
- const aggregationData = new Float32Array(aggregationSize).fill(0);
159
- for (const bin of aggregatedBins) {
160
- const { lonIdx, latIdx } = data[bin.i];
161
- const { value, counts } = bin;
162
- const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;
163
- aggregationData[cellIndex] = value;
164
- aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;
165
- }
166
- const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);
167
- const maxData = new Float32Array([maxValue, 0, 0, totalCount]);
168
- const minData = new Float32Array([minValue, 0, 0, totalCount]);
169
- this.updateResults({ aggregationData, maxMinData, maxData, minData });
170
- }
171
- }
172
- GridAggregationLayer.layerName = 'GridAggregationLayer';
173
- export default GridAggregationLayer;
@@ -1,27 +0,0 @@
1
- /**
2
- * Use d3-hexbin to performs hexagonal binning from geo points to hexagons
3
- * @param {Iterable} data - array of points
4
- * @param {Number} radius - hexagon radius in meter
5
- * @param {function} getPosition - get points lon lat
6
- * @param {Object} viewport - current viewport object
7
-
8
- * @return {Object} - hexagons and countRange
9
- */
10
- export declare function pointToHexbin(props: any, aggregationParams: any): {
11
- hexagons: any;
12
- radiusCommon: number;
13
- };
14
- /**
15
- * Get the bounding box of all data points
16
- */
17
- export declare function getPointsCenter(data: any, aggregationParams: any): number[] | null;
18
- /**
19
- * Get radius in mercator world space coordinates from meter
20
- * @param {Number} radius - in meter
21
- * @param {Object} viewport - current viewport object
22
- * @param {Array<Number>} center - data center
23
-
24
- * @return {Number} radius in mercator world spcae coordinates
25
- */
26
- export declare function getRadiusInCommon(radius: any, viewport: any, center: any): number;
27
- //# sourceMappingURL=hexagon-aggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hexagon-aggregator.d.ts","sourceRoot":"","sources":["../../src/hexagon-layer/hexagon-aggregator.ts"],"names":[],"mappings":"AAuBA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,KAAA,EAAE,iBAAiB,KAAA;;;EA+CrD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,KAAA,EAAE,iBAAiB,KAAA,mBA4BtD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA,EAAE,MAAM,KAAA,UAIzD"}
@@ -1,112 +0,0 @@
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.
20
- import { hexbin } from 'd3-hexbin';
21
- import { createIterable, log } from '@deck.gl/core';
22
- /**
23
- * Use d3-hexbin to performs hexagonal binning from geo points to hexagons
24
- * @param {Iterable} data - array of points
25
- * @param {Number} radius - hexagon radius in meter
26
- * @param {function} getPosition - get points lon lat
27
- * @param {Object} viewport - current viewport object
28
-
29
- * @return {Object} - hexagons and countRange
30
- */
31
- export function pointToHexbin(props, aggregationParams) {
32
- const { data, radius } = props;
33
- const { viewport, attributes } = aggregationParams;
34
- // get hexagon radius in mercator world unit
35
- const centerLngLat = data.length ? getPointsCenter(data, aggregationParams) : null;
36
- const radiusCommon = getRadiusInCommon(radius, viewport, centerLngLat);
37
- // add world space coordinates to points
38
- const screenPoints = [];
39
- const { iterable, objectInfo } = createIterable(data);
40
- const positions = attributes.positions.value;
41
- const { size } = attributes.positions.getAccessor();
42
- for (const object of iterable) {
43
- objectInfo.index++;
44
- const posIndex = objectInfo.index * size;
45
- const position = [positions[posIndex], positions[posIndex + 1]];
46
- const arrayIsFinite = Number.isFinite(position[0]) && Number.isFinite(position[1]);
47
- if (arrayIsFinite) {
48
- screenPoints.push({
49
- screenCoord: viewport.projectFlat(position),
50
- source: object,
51
- index: objectInfo.index
52
- });
53
- }
54
- else {
55
- log.warn('HexagonLayer: invalid position')();
56
- }
57
- }
58
- const newHexbin = hexbin()
59
- .radius(radiusCommon)
60
- .x(d => d.screenCoord[0])
61
- .y(d => d.screenCoord[1]);
62
- const hexagonBins = newHexbin(screenPoints);
63
- return {
64
- hexagons: hexagonBins.map((hex, index) => ({
65
- position: viewport.unprojectFlat([hex.x, hex.y]),
66
- points: hex,
67
- index
68
- })),
69
- radiusCommon
70
- };
71
- }
72
- /**
73
- * Get the bounding box of all data points
74
- */
75
- export function getPointsCenter(data, aggregationParams) {
76
- const { attributes } = aggregationParams;
77
- const positions = attributes.positions.value;
78
- const { size } = attributes.positions.getAccessor();
79
- let minX = Infinity;
80
- let minY = Infinity;
81
- let maxX = -Infinity;
82
- let maxY = -Infinity;
83
- let i;
84
- for (i = 0; i < size * data.length; i += size) {
85
- const x = positions[i];
86
- const y = positions[i + 1];
87
- const arrayIsFinite = Number.isFinite(x) && Number.isFinite(y);
88
- if (arrayIsFinite) {
89
- minX = Math.min(x, minX);
90
- maxX = Math.max(x, maxX);
91
- minY = Math.min(y, minY);
92
- maxY = Math.max(y, maxY);
93
- }
94
- }
95
- // return center
96
- return [minX, minY, maxX, maxY].every(Number.isFinite)
97
- ? [(minX + maxX) / 2, (minY + maxY) / 2]
98
- : null;
99
- }
100
- /**
101
- * Get radius in mercator world space coordinates from meter
102
- * @param {Number} radius - in meter
103
- * @param {Object} viewport - current viewport object
104
- * @param {Array<Number>} center - data center
105
-
106
- * @return {Number} radius in mercator world spcae coordinates
107
- */
108
- export function getRadiusInCommon(radius, viewport, center) {
109
- const { unitsPerMeter } = viewport.getDistanceScales(center);
110
- // x, y distance should be the same
111
- return radius * unitsPerMeter[0];
112
- }
package/dist/types.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /** Type assigned to e.g. getColorValue/getElevationValue props in aggregation layers (e.g. CPUGridLayer, HexagonLayer)*/
2
- export type AggregateAccessor<DataT = any> = (args: {
3
- /** a list of objects whose positions fall inside this cell. */
4
- objects: DataT[];
5
- objectInfo: {
6
- /** the indices of `objects` in the original data. */
7
- indices: number[];
8
- /** the value of the `data` prop */
9
- data: any;
10
- };
11
- }) => number;
12
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE;IAClD,+DAA+D;IAC/D,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,UAAU,EAAE;QACV,qDAAqD;QACrD,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,mCAAmC;QACnC,IAAI,EAAE,GAAG,CAAC;KACX,CAAC;CACH,KAAK,MAAM,CAAC"}
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- export declare const AGGREGATION_OPERATION: {
2
- SUM: number;
3
- MEAN: number;
4
- MIN: number;
5
- MAX: number;
6
- };
7
- export declare function getMean(pts: any, accessor: any): any;
8
- export declare function getSum(pts: any, accessor: any): any;
9
- export declare function getMax(pts: any, accessor: any): any;
10
- export declare function getMin(pts: any, accessor: any): any;
11
- export declare function getValueFunc(aggregation: any, accessor: any, context: any): ((pts: any) => any) | null;
12
- type AccessorContext = {
13
- data?: any;
14
- index?: number;
15
- indices?: number[];
16
- };
17
- export declare function wrapGetValueFunc(getValue: any, context?: AccessorContext): (pts: any) => any;
18
- export {};
19
- //# sourceMappingURL=aggregation-operation-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aggregation-operation-utils.d.ts","sourceRoot":"","sources":["../../src/utils/aggregation-operation-utils.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,qBAAqB;;;;;CAKjC,CAAC;AAcF,wBAAgB,OAAO,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA,OAOpC;AAED,wBAAgB,MAAM,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA,OAOnC;AAED,wBAAgB,MAAM,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA,OAOnC;AAED,wBAAgB,MAAM,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA,OAOnC;AAGD,wBAAgB,YAAY,CAAC,WAAW,KAAA,EAAE,QAAQ,KAAA,EAAE,OAAO,KAAA,8BAe1D;AAED,KAAK,eAAe,GAAG;IACrB,IAAI,CAAC,MAAC;IACN,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAYF,wBAAgB,gBAAgB,CAAC,QAAQ,KAAA,EAAE,OAAO,GAAE,eAAoB,qBAQvE"}
@@ -1,94 +0,0 @@
1
- // Copyright (c) 2015 - 2019 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.
20
- export const AGGREGATION_OPERATION = {
21
- SUM: 1,
22
- MEAN: 2,
23
- MIN: 3,
24
- MAX: 4
25
- };
26
- function sumReducer(accu, cur) {
27
- return accu + cur;
28
- }
29
- function maxReducer(accu, cur) {
30
- return cur > accu ? cur : accu;
31
- }
32
- function minReducer(accu, cur) {
33
- return cur < accu ? cur : accu;
34
- }
35
- export function getMean(pts, accessor) {
36
- if (Number.isFinite(accessor)) {
37
- return pts.length ? accessor : null;
38
- }
39
- const filtered = pts.map(accessor).filter(Number.isFinite);
40
- return filtered.length ? filtered.reduce(sumReducer, 0) / filtered.length : null;
41
- }
42
- export function getSum(pts, accessor) {
43
- if (Number.isFinite(accessor)) {
44
- return pts.length ? pts.length * accessor : null;
45
- }
46
- const filtered = pts.map(accessor).filter(Number.isFinite);
47
- return filtered.length ? filtered.reduce(sumReducer, 0) : null;
48
- }
49
- export function getMax(pts, accessor) {
50
- if (Number.isFinite(accessor)) {
51
- return pts.length ? accessor : null;
52
- }
53
- const filtered = pts.map(accessor).filter(Number.isFinite);
54
- return filtered.length ? filtered.reduce(maxReducer, -Infinity) : null;
55
- }
56
- export function getMin(pts, accessor) {
57
- if (Number.isFinite(accessor)) {
58
- return pts.length ? accessor : null;
59
- }
60
- const filtered = pts.map(accessor).filter(Number.isFinite);
61
- return filtered.length ? filtered.reduce(minReducer, Infinity) : null;
62
- }
63
- // Function to convert from aggregation/accessor props (like colorAggregation and getColorWeight) to getValue prop (like getColorValue)
64
- export function getValueFunc(aggregation, accessor, context) {
65
- const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
66
- accessor = wrapAccessor(accessor, context);
67
- switch (op) {
68
- case AGGREGATION_OPERATION.MIN:
69
- return pts => getMin(pts, accessor);
70
- case AGGREGATION_OPERATION.SUM:
71
- return pts => getSum(pts, accessor);
72
- case AGGREGATION_OPERATION.MEAN:
73
- return pts => getMean(pts, accessor);
74
- case AGGREGATION_OPERATION.MAX:
75
- return pts => getMax(pts, accessor);
76
- default:
77
- return null;
78
- }
79
- }
80
- function wrapAccessor(accessor, context = {}) {
81
- if (Number.isFinite(accessor)) {
82
- return accessor;
83
- }
84
- return pt => {
85
- context.index = pt.index;
86
- return accessor(pt.source, context);
87
- };
88
- }
89
- export function wrapGetValueFunc(getValue, context = {}) {
90
- return pts => {
91
- context.indices = pts.map(pt => pt.index);
92
- return getValue(pts.map(pt => pt.source), context);
93
- };
94
- }
@@ -1,52 +0,0 @@
1
- declare const defaultProps: {
2
- getValue: (points: any) => any;
3
- getPoints: (bin: any) => any;
4
- getIndex: (bin: any) => any;
5
- filterData: null;
6
- };
7
- export type AggregatedBin = {
8
- i: number;
9
- value: any;
10
- counts: number;
11
- };
12
- export default class BinSorter {
13
- maxCount: number;
14
- maxValue: number;
15
- minValue: number;
16
- totalCount: number;
17
- aggregatedBins: AggregatedBin[];
18
- sortedBins: AggregatedBin[];
19
- binMap: Record<number, AggregatedBin>;
20
- constructor(bins?: unknown[], props?: Partial<typeof defaultProps>);
21
- /**
22
- * Get an array of object with aggregated values and index of bins
23
- * Array object will be sorted by value optionally.
24
- * @param {Array} bins
25
- * @param {Function} getValue
26
- * @return {Array} array of values and index lookup
27
- */
28
- getAggregatedBins(bins: any, props: any): AggregatedBin[];
29
- _percentileToIndex(percentileRange: any): [number, number];
30
- /**
31
- * Get a mapping from cell/hexagon index to sorted bin
32
- * This is used to retrieve bin value for color calculation
33
- * @return {Object} bin index to aggregatedBins
34
- */
35
- getBinMap(): Record<number, AggregatedBin>;
36
- /**
37
- * Get ths max count of all bins
38
- */
39
- _updateMinMaxValues(): void;
40
- /**
41
- * Get range of values of all bins
42
- * @param {Number[]} range
43
- * @param {Number} range[0] - lower bound
44
- * @param {Number} range[1] - upper bound
45
- * @return {Array} array of new value range
46
- */
47
- getValueRange(percentileRange: [number, number]): [number, number];
48
- getValueDomainByScale(scale: string, [lower, upper]?: [(number | undefined)?, (number | undefined)?]): [number, number] | never[];
49
- _getScaleDomain(scaleType: string, [lowerIdx, upperIdx]: [number, number]): [number, number];
50
- }
51
- export {};
52
- //# sourceMappingURL=bin-sorter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin-sorter.d.ts","sourceRoot":"","sources":["../../src/utils/bin-sorter.ts"],"names":[],"mappings":"AAsCA,QAAA,MAAM,YAAY;;;;;CAKjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,QAAQ,EAAG,MAAM,CAAC;IAClB,QAAQ,EAAG,MAAM,CAAC;IAClB,QAAQ,EAAG,MAAM,CAAC;IAClB,UAAU,EAAG,MAAM,CAAC;IAEpB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,UAAU,EAAG,aAAa,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;gBAE1B,IAAI,GAAE,OAAO,EAAO,EAAE,KAAK,GAAE,OAAO,CAAC,OAAO,YAAY,CAAgB;IAMpF;;;;;;OAMG;IACH,iBAAiB,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA,GAAG,aAAa,EAAE;IAqC/C,kBAAkB,CAAC,eAAe,KAAA,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAcrD;;;;OAIG;IACH,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAU1C;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAiB3B;;;;;;OAMG;IACH,aAAa,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAoBlE,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,KAAS,EAAE,KAAW,CAAC,iDAAK;IAYlE,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAkB7F"}
@@ -1,167 +0,0 @@
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.
20
- // getValue takes an array of points returns a value to sort the bins on.
21
- // by default it returns the number of points
22
- // this is where to pass in a function to color the bins by
23
- // avg/mean/max of specific value of the point
24
- const defaultGetValue = points => points.length;
25
- import { clamp, getQuantileDomain, getOrdinalDomain } from "./scale-utils.js";
26
- const MAX_32_BIT_FLOAT = 3.402823466e38;
27
- // access array of points in each bin
28
- const defaultGetPoints = bin => bin.points;
29
- // access index of each bin
30
- const defaultGetIndex = bin => bin.index;
31
- // d3-scending
32
- const ascending = (a, b) => (a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN);
33
- const defaultProps = {
34
- getValue: defaultGetValue,
35
- getPoints: defaultGetPoints,
36
- getIndex: defaultGetIndex,
37
- filterData: null
38
- };
39
- export default class BinSorter {
40
- constructor(bins = [], props = defaultProps) {
41
- this.aggregatedBins = this.getAggregatedBins(bins, props);
42
- this._updateMinMaxValues();
43
- this.binMap = this.getBinMap();
44
- }
45
- /**
46
- * Get an array of object with aggregated values and index of bins
47
- * Array object will be sorted by value optionally.
48
- * @param {Array} bins
49
- * @param {Function} getValue
50
- * @return {Array} array of values and index lookup
51
- */
52
- getAggregatedBins(bins, props) {
53
- const { getValue = defaultGetValue, getPoints = defaultGetPoints, getIndex = defaultGetIndex, filterData } = props;
54
- const hasFilter = typeof filterData === 'function';
55
- const binCount = bins.length;
56
- const aggregatedBins = [];
57
- let index = 0;
58
- for (let binIndex = 0; binIndex < binCount; binIndex++) {
59
- const bin = bins[binIndex];
60
- const points = getPoints(bin);
61
- const i = getIndex(bin);
62
- const filteredPoints = hasFilter ? points.filter(filterData) : points;
63
- bin.filteredPoints = hasFilter ? filteredPoints : null;
64
- const value = filteredPoints.length ? getValue(filteredPoints) : null;
65
- if (value !== null && value !== undefined) {
66
- // filter bins if value is null or undefined
67
- aggregatedBins[index] = {
68
- i: Number.isFinite(i) ? i : binIndex,
69
- value,
70
- counts: filteredPoints.length
71
- };
72
- index++;
73
- }
74
- }
75
- return aggregatedBins;
76
- }
77
- _percentileToIndex(percentileRange) {
78
- const len = this.sortedBins.length;
79
- if (len < 2) {
80
- return [0, 0];
81
- }
82
- const [lower, upper] = percentileRange.map(n => clamp(n, 0, 100));
83
- const lowerIdx = Math.ceil((lower / 100) * (len - 1));
84
- const upperIdx = Math.floor((upper / 100) * (len - 1));
85
- return [lowerIdx, upperIdx];
86
- }
87
- /**
88
- * Get a mapping from cell/hexagon index to sorted bin
89
- * This is used to retrieve bin value for color calculation
90
- * @return {Object} bin index to aggregatedBins
91
- */
92
- getBinMap() {
93
- const binMap = {};
94
- for (const bin of this.aggregatedBins) {
95
- binMap[bin.i] = bin;
96
- }
97
- return binMap;
98
- }
99
- // Private
100
- /**
101
- * Get ths max count of all bins
102
- */
103
- _updateMinMaxValues() {
104
- let maxCount = 0;
105
- let maxValue = 0;
106
- let minValue = MAX_32_BIT_FLOAT;
107
- let totalCount = 0;
108
- for (const x of this.aggregatedBins) {
109
- maxCount = maxCount > x.counts ? maxCount : x.counts;
110
- maxValue = maxValue > x.value ? maxValue : x.value;
111
- minValue = minValue < x.value ? minValue : x.value;
112
- totalCount += x.counts;
113
- }
114
- this.maxCount = maxCount;
115
- this.maxValue = maxValue;
116
- this.minValue = minValue;
117
- this.totalCount = totalCount;
118
- }
119
- /**
120
- * Get range of values of all bins
121
- * @param {Number[]} range
122
- * @param {Number} range[0] - lower bound
123
- * @param {Number} range[1] - upper bound
124
- * @return {Array} array of new value range
125
- */
126
- getValueRange(percentileRange) {
127
- if (!this.sortedBins) {
128
- this.sortedBins = this.aggregatedBins.sort((a, b) => ascending(a.value, b.value));
129
- }
130
- if (!this.sortedBins.length) {
131
- // @ts-expect-error
132
- return [];
133
- }
134
- let lowerIdx = 0;
135
- let upperIdx = this.sortedBins.length - 1;
136
- if (Array.isArray(percentileRange)) {
137
- const idxRange = this._percentileToIndex(percentileRange);
138
- lowerIdx = idxRange[0];
139
- upperIdx = idxRange[1];
140
- }
141
- return [this.sortedBins[lowerIdx].value, this.sortedBins[upperIdx].value];
142
- }
143
- getValueDomainByScale(scale, [lower = 0, upper = 100] = []) {
144
- if (!this.sortedBins) {
145
- this.sortedBins = this.aggregatedBins.sort((a, b) => ascending(a.value, b.value));
146
- }
147
- if (!this.sortedBins.length) {
148
- return [];
149
- }
150
- const indexEdge = this._percentileToIndex([lower, upper]);
151
- return this._getScaleDomain(scale, indexEdge);
152
- }
153
- _getScaleDomain(scaleType, [lowerIdx, upperIdx]) {
154
- const bins = this.sortedBins;
155
- switch (scaleType) {
156
- case 'quantize':
157
- case 'linear':
158
- return [bins[lowerIdx].value, bins[upperIdx].value];
159
- case 'quantile':
160
- return getQuantileDomain(bins.slice(lowerIdx, upperIdx + 1), d => d.value);
161
- case 'ordinal':
162
- return getOrdinalDomain(bins, d => d.value);
163
- default:
164
- return [bins[lowerIdx].value, bins[upperIdx].value];
165
- }
166
- }
167
- }