@deck.gl/aggregation-layers 8.8.0-alpha.5 → 8.8.0-beta.2

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 (269) hide show
  1. package/dist/dist.dev.js +753 -640
  2. package/dist/es5/aggregation-layer.js +19 -7
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +5 -5
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/contour-layer/contour-utils.js +1 -1
  7. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  8. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  9. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  10. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +5 -3
  11. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  12. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  13. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +8 -12
  14. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  15. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +12 -12
  16. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  17. package/dist/es5/grid-aggregation-layer.js +25 -12
  18. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  19. package/dist/es5/grid-layer/grid-layer.js +18 -9
  20. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  21. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +5 -2
  22. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  23. package/dist/es5/heatmap-layer/heatmap-layer.js +19 -7
  24. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  25. package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
  26. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
  27. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
  28. package/dist/es5/heatmap-layer/triangle-layer.js +7 -7
  29. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  30. package/dist/es5/heatmap-layer/weights-fs.glsl.js +1 -1
  31. package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
  32. package/dist/es5/hexagon-layer/hexagon-layer.js +16 -5
  33. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  34. package/dist/es5/index.js.map +1 -1
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +26 -19
  36. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  37. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
  38. package/dist/es5/screen-grid-layer/screen-grid-layer.js +18 -8
  39. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  40. package/dist/es5/types.js +2 -0
  41. package/dist/es5/types.js.map +1 -0
  42. package/dist/es5/utils/bin-sorter.js +9 -0
  43. package/dist/es5/utils/bin-sorter.js.map +1 -1
  44. package/dist/es5/utils/color-utils.js.map +1 -1
  45. package/dist/esm/aggregation-layer.js +12 -5
  46. package/dist/esm/aggregation-layer.js.map +1 -1
  47. package/dist/esm/contour-layer/contour-layer.js +6 -3
  48. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  49. package/dist/esm/contour-layer/contour-utils.js +1 -1
  50. package/dist/esm/contour-layer/contour-utils.js.map +1 -1
  51. package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
  52. package/dist/esm/contour-layer/marching-squares.js.map +1 -1
  53. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -3
  54. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  55. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
  56. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  57. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  58. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +8 -10
  59. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  60. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +11 -9
  61. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  62. package/dist/esm/grid-aggregation-layer.js +13 -5
  63. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  64. package/dist/esm/grid-layer/grid-layer.js +15 -8
  65. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  66. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +5 -2
  67. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  68. package/dist/esm/heatmap-layer/heatmap-layer.js +24 -14
  69. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  70. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
  71. package/dist/esm/heatmap-layer/max-vs.glsl.js +1 -1
  72. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
  73. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
  74. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
  75. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
  76. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
  77. package/dist/esm/heatmap-layer/triangle-layer.js +6 -5
  78. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  79. package/dist/esm/heatmap-layer/weights-fs.glsl.js +1 -1
  80. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
  81. package/dist/esm/heatmap-layer/weights-vs.glsl.js +1 -1
  82. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
  83. package/dist/esm/hexagon-layer/hexagon-layer.js +11 -2
  84. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  85. package/dist/esm/index.js.map +1 -1
  86. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +16 -10
  87. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  88. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
  89. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
  90. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  91. package/dist/esm/screen-grid-layer/screen-grid-layer.js +15 -7
  92. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  93. package/dist/esm/types.js +2 -0
  94. package/dist/esm/types.js.map +1 -0
  95. package/dist/esm/utils/bin-sorter.js +16 -0
  96. package/dist/esm/utils/bin-sorter.js.map +1 -1
  97. package/dist/esm/utils/color-utils.js.map +1 -1
  98. package/dist.min.js +1 -1
  99. package/package.json +7 -5
  100. package/src/{aggregation-layer.js → aggregation-layer.ts} +32 -15
  101. package/src/contour-layer/{contour-layer.js → contour-layer.ts} +97 -16
  102. package/src/contour-layer/{contour-utils.js → contour-utils.ts} +11 -5
  103. package/src/contour-layer/{marching-squares-codes.js → marching-squares-codes.ts} +0 -0
  104. package/src/contour-layer/{marching-squares.js → marching-squares.ts} +6 -6
  105. package/src/cpu-grid-layer/cpu-grid-layer.ts +324 -0
  106. package/src/gpu-grid-layer/{gpu-grid-cell-layer-fragment.glsl.js → gpu-grid-cell-layer-fragment.glsl.ts} +0 -0
  107. package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts} +0 -0
  108. package/src/gpu-grid-layer/{gpu-grid-cell-layer.js → gpu-grid-cell-layer.ts} +36 -19
  109. package/src/gpu-grid-layer/{gpu-grid-layer.js → gpu-grid-layer.ts} +125 -18
  110. package/src/{grid-aggregation-layer.js → grid-aggregation-layer.ts} +25 -13
  111. package/src/grid-layer/{grid-layer.js → grid-layer.ts} +45 -14
  112. package/src/heatmap-layer/{heatmap-layer-utils.js → heatmap-layer-utils.ts} +15 -10
  113. package/src/heatmap-layer/{heatmap-layer.js → heatmap-layer.ts} +147 -32
  114. package/src/heatmap-layer/{max-fs.glsl.js → max-fs.glsl.ts} +0 -0
  115. package/src/heatmap-layer/{max-vs.glsl.js → max-vs.glsl.ts} +0 -0
  116. package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts} +0 -0
  117. package/src/heatmap-layer/{triangle-layer-vertex.glsl.js → triangle-layer-vertex.glsl.ts} +0 -0
  118. package/src/heatmap-layer/{triangle-layer.js → triangle-layer.ts} +20 -10
  119. package/src/heatmap-layer/{weights-fs.glsl.js → weights-fs.glsl.ts} +0 -0
  120. package/src/heatmap-layer/{weights-vs.glsl.js → weights-vs.glsl.ts} +0 -0
  121. package/src/hexagon-layer/{hexagon-layer.js → hexagon-layer.ts} +194 -9
  122. package/src/index.ts +9 -0
  123. package/src/screen-grid-layer/{screen-grid-cell-layer.js → screen-grid-cell-layer.ts} +33 -15
  124. package/src/screen-grid-layer/{screen-grid-layer-fragment.glsl.js → screen-grid-layer-fragment.glsl.ts} +0 -0
  125. package/src/screen-grid-layer/{screen-grid-layer-vertex.glsl.js → screen-grid-layer-vertex.glsl.ts} +0 -0
  126. package/src/screen-grid-layer/{screen-grid-layer.js → screen-grid-layer.ts} +119 -16
  127. package/src/types.ts +10 -0
  128. package/src/utils/{bin-sorter.js → bin-sorter.ts} +26 -11
  129. package/src/utils/{color-utils.js → color-utils.ts} +1 -1
  130. package/typed/aggregation-layer.d.ts +38 -0
  131. package/typed/aggregation-layer.d.ts.map +1 -0
  132. package/typed/aggregation-layer.js +151 -0
  133. package/typed/contour-layer/contour-layer.d.ts +74 -0
  134. package/typed/contour-layer/contour-layer.d.ts.map +1 -0
  135. package/typed/contour-layer/contour-layer.js +234 -0
  136. package/typed/contour-layer/contour-utils.d.ts +18 -0
  137. package/typed/contour-layer/contour-utils.d.ts.map +1 -0
  138. package/typed/contour-layer/contour-utils.js +64 -0
  139. package/typed/contour-layer/marching-squares-codes.d.ts +32 -0
  140. package/typed/contour-layer/marching-squares-codes.d.ts.map +1 -0
  141. package/typed/contour-layer/marching-squares-codes.js +337 -0
  142. package/typed/contour-layer/marching-squares.d.ts +10 -0
  143. package/typed/contour-layer/marching-squares.d.ts.map +1 -0
  144. package/typed/contour-layer/marching-squares.js +147 -0
  145. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +152 -0
  146. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -0
  147. package/typed/cpu-grid-layer/cpu-grid-layer.js +129 -0
  148. package/typed/cpu-grid-layer/grid-aggregator.d.ts +23 -0
  149. package/typed/cpu-grid-layer/grid-aggregator.d.ts.map +1 -0
  150. package/typed/cpu-grid-layer/grid-aggregator.js +141 -0
  151. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +3 -0
  152. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +1 -0
  153. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
  154. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +3 -0
  155. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  156. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +141 -0
  157. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +34 -0
  158. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -0
  159. package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +143 -0
  160. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +96 -0
  161. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -0
  162. package/typed/gpu-grid-layer/gpu-grid-layer.js +289 -0
  163. package/typed/grid-aggregation-layer.d.ts +32 -0
  164. package/typed/grid-aggregation-layer.d.ts.map +1 -0
  165. package/typed/grid-aggregation-layer.js +172 -0
  166. package/typed/grid-layer/grid-layer.d.ts +31 -0
  167. package/typed/grid-layer/grid-layer.d.ts.map +1 -0
  168. package/typed/grid-layer/grid-layer.js +60 -0
  169. package/typed/heatmap-layer/heatmap-layer-utils.d.ts +13 -0
  170. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
  171. package/typed/heatmap-layer/heatmap-layer-utils.js +78 -0
  172. package/typed/heatmap-layer/heatmap-layer.d.ts +116 -0
  173. package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  174. package/typed/heatmap-layer/heatmap-layer.js +478 -0
  175. package/typed/heatmap-layer/max-fs.glsl.d.ts +3 -0
  176. package/typed/heatmap-layer/max-fs.glsl.d.ts.map +1 -0
  177. package/typed/heatmap-layer/max-fs.glsl.js +7 -0
  178. package/typed/heatmap-layer/max-vs.glsl.d.ts +3 -0
  179. package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -0
  180. package/typed/heatmap-layer/max-vs.glsl.js +12 -0
  181. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
  182. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -0
  183. package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +58 -0
  184. package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts +3 -0
  185. package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -0
  186. package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +51 -0
  187. package/typed/heatmap-layer/triangle-layer.d.ts +27 -0
  188. package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -0
  189. package/typed/heatmap-layer/triangle-layer.js +67 -0
  190. package/typed/heatmap-layer/weights-fs.glsl.d.ts +3 -0
  191. package/typed/heatmap-layer/weights-fs.glsl.d.ts.map +1 -0
  192. package/typed/heatmap-layer/weights-fs.glsl.js +19 -0
  193. package/typed/heatmap-layer/weights-vs.glsl.d.ts +3 -0
  194. package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -0
  195. package/typed/heatmap-layer/weights-vs.glsl.js +23 -0
  196. package/typed/hexagon-layer/hexagon-aggregator.d.ts +24 -0
  197. package/typed/hexagon-layer/hexagon-aggregator.d.ts.map +1 -0
  198. package/typed/hexagon-layer/hexagon-aggregator.js +112 -0
  199. package/typed/hexagon-layer/hexagon-layer.d.ts +165 -0
  200. package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -0
  201. package/typed/hexagon-layer/hexagon-layer.js +171 -0
  202. package/typed/index.d.ts +20 -0
  203. package/typed/index.d.ts.map +1 -0
  204. package/typed/index.js +33 -0
  205. package/typed/package.json +6 -0
  206. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +42 -0
  207. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -0
  208. package/typed/screen-grid-layer/screen-grid-cell-layer.js +159 -0
  209. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +3 -0
  210. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -0
  211. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +37 -0
  212. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +3 -0
  213. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -0
  214. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +83 -0
  215. package/typed/screen-grid-layer/screen-grid-layer.d.ts +95 -0
  216. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -0
  217. package/typed/screen-grid-layer/screen-grid-layer.js +216 -0
  218. package/typed/types.d.ts +11 -0
  219. package/typed/types.d.ts.map +1 -0
  220. package/typed/types.js +1 -0
  221. package/typed/utils/aggregation-operation-utils.d.ts +13 -0
  222. package/typed/utils/aggregation-operation-utils.d.ts.map +1 -0
  223. package/typed/utils/aggregation-operation-utils.js +94 -0
  224. package/typed/utils/bin-sorter.d.ts +52 -0
  225. package/typed/utils/bin-sorter.d.ts.map +1 -0
  226. package/typed/utils/bin-sorter.js +167 -0
  227. package/typed/utils/color-utils.d.ts +3 -0
  228. package/typed/utils/color-utils.d.ts.map +1 -0
  229. package/typed/utils/color-utils.js +53 -0
  230. package/typed/utils/cpu-aggregator.d.ts +155 -0
  231. package/typed/utils/cpu-aggregator.d.ts.map +1 -0
  232. package/typed/utils/cpu-aggregator.js +417 -0
  233. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +3 -0
  234. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +1 -0
  235. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
  236. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +3 -0
  237. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +1 -0
  238. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
  239. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +3 -0
  240. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +1 -0
  241. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +31 -0
  242. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +3 -0
  243. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +1 -0
  244. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +77 -0
  245. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +36 -0
  246. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +1 -0
  247. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  248. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +1 -0
  249. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +1 -0
  250. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  251. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +66 -0
  252. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -0
  253. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +562 -0
  254. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +3 -0
  255. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +1 -0
  256. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +36 -0
  257. package/typed/utils/grid-aggregation-utils.d.ts +24 -0
  258. package/typed/utils/grid-aggregation-utils.d.ts.map +1 -0
  259. package/typed/utils/grid-aggregation-utils.js +114 -0
  260. package/typed/utils/prop-utils.d.ts +2 -0
  261. package/typed/utils/prop-utils.d.ts.map +1 -0
  262. package/typed/utils/prop-utils.js +28 -0
  263. package/typed/utils/resource-utils.d.ts +4 -0
  264. package/typed/utils/resource-utils.d.ts.map +1 -0
  265. package/typed/utils/resource-utils.js +40 -0
  266. package/typed/utils/scale-utils.d.ts +15 -0
  267. package/typed/utils/scale-utils.d.ts.map +1 -0
  268. package/typed/utils/scale-utils.js +184 -0
  269. package/src/cpu-grid-layer/cpu-grid-layer.js +0 -153
@@ -0,0 +1,143 @@
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 { Layer, fp64LowPart, project32, gouraudLighting, picking } from '@deck.gl/core';
21
+ import GL from '@luma.gl/constants';
22
+ import { Model, CubeGeometry } from '@luma.gl/core';
23
+ import { fp64arithmetic } from '@luma.gl/shadertools';
24
+ import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
25
+ import vs from './gpu-grid-cell-layer-vertex.glsl';
26
+ import fs from './gpu-grid-cell-layer-fragment.glsl';
27
+ const COLOR_DATA_UBO_INDEX = 0;
28
+ const ELEVATION_DATA_UBO_INDEX = 1;
29
+ const defaultProps = {
30
+ // color
31
+ colorDomain: null,
32
+ colorRange: defaultColorRange,
33
+ // elevation
34
+ elevationDomain: null,
35
+ elevationRange: [0, 1000],
36
+ elevationScale: { type: 'number', min: 0, value: 1 },
37
+ // grid
38
+ gridSize: { type: 'array', min: 0, value: [1, 1] },
39
+ gridOrigin: { type: 'array', min: 0, value: [0, 0] },
40
+ gridOffset: { type: 'array', min: 0, value: [0, 0] },
41
+ cellSize: { type: 'number', min: 0, max: 1000, value: 1000 },
42
+ offset: { type: 'array', min: 0, value: [1, 1] },
43
+ coverage: { type: 'number', min: 0, max: 1, value: 1 },
44
+ extruded: true,
45
+ material: true // Use lighting module defaults
46
+ };
47
+ export default class GPUGridCellLayer extends Layer {
48
+ getShaders() {
49
+ return super.getShaders({
50
+ vs,
51
+ fs,
52
+ modules: [project32, gouraudLighting, picking, fp64arithmetic]
53
+ });
54
+ }
55
+ initializeState({ gl }) {
56
+ const attributeManager = this.getAttributeManager();
57
+ attributeManager.addInstanced({
58
+ colors: {
59
+ size: 4,
60
+ noAlloc: true
61
+ },
62
+ elevations: {
63
+ size: 4,
64
+ noAlloc: true
65
+ }
66
+ });
67
+ const model = this._getModel(gl);
68
+ this._setupUniformBuffer(model);
69
+ this.setState({ model });
70
+ }
71
+ _getModel(gl) {
72
+ return new Model(gl, {
73
+ ...this.getShaders(),
74
+ id: this.props.id,
75
+ geometry: new CubeGeometry(),
76
+ isInstanced: true
77
+ });
78
+ }
79
+ draw({ uniforms }) {
80
+ const { cellSize, offset, extruded, elevationScale, coverage, gridSize, gridOrigin, gridOffset, elevationRange, colorMaxMinBuffer, elevationMaxMinBuffer } = this.props;
81
+ const gridOriginLow = [fp64LowPart(gridOrigin[0]), fp64LowPart(gridOrigin[1])];
82
+ const gridOffsetLow = [fp64LowPart(gridOffset[0]), fp64LowPart(gridOffset[1])];
83
+ const domainUniforms = this.getDomainUniforms();
84
+ const colorRange = colorRangeToFlatArray(this.props.colorRange);
85
+ this.bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
86
+ this.state.model
87
+ .setUniforms(uniforms)
88
+ .setUniforms(domainUniforms)
89
+ .setUniforms({
90
+ cellSize,
91
+ offset,
92
+ extruded,
93
+ elevationScale,
94
+ coverage,
95
+ gridSize,
96
+ gridOrigin,
97
+ gridOriginLow,
98
+ gridOffset,
99
+ gridOffsetLow,
100
+ colorRange,
101
+ elevationRange
102
+ })
103
+ .draw();
104
+ this.unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
105
+ }
106
+ bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
107
+ colorMaxMinBuffer.bind({ target: GL.UNIFORM_BUFFER, index: COLOR_DATA_UBO_INDEX });
108
+ elevationMaxMinBuffer.bind({ target: GL.UNIFORM_BUFFER, index: ELEVATION_DATA_UBO_INDEX });
109
+ }
110
+ unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
111
+ colorMaxMinBuffer.unbind({ target: GL.UNIFORM_BUFFER, index: COLOR_DATA_UBO_INDEX });
112
+ elevationMaxMinBuffer.unbind({ target: GL.UNIFORM_BUFFER, index: ELEVATION_DATA_UBO_INDEX });
113
+ }
114
+ getDomainUniforms() {
115
+ const { colorDomain, elevationDomain } = this.props;
116
+ const domainUniforms = {};
117
+ if (colorDomain !== null) {
118
+ domainUniforms.colorDomainValid = true;
119
+ domainUniforms.colorDomain = colorDomain;
120
+ }
121
+ else {
122
+ domainUniforms.colorDomainValid = false;
123
+ }
124
+ if (elevationDomain !== null) {
125
+ domainUniforms.elevationDomainValid = true;
126
+ domainUniforms.elevationDomain = elevationDomain;
127
+ }
128
+ else {
129
+ domainUniforms.elevationDomainValid = false;
130
+ }
131
+ return domainUniforms;
132
+ }
133
+ _setupUniformBuffer(model) {
134
+ const gl = this.context.gl;
135
+ const programHandle = model.program.handle;
136
+ const colorIndex = gl.getUniformBlockIndex(programHandle, 'ColorData');
137
+ const elevationIndex = gl.getUniformBlockIndex(programHandle, 'ElevationData');
138
+ gl.uniformBlockBinding(programHandle, colorIndex, COLOR_DATA_UBO_INDEX);
139
+ gl.uniformBlockBinding(programHandle, elevationIndex, ELEVATION_DATA_UBO_INDEX);
140
+ }
141
+ }
142
+ GPUGridCellLayer.layerName = 'GPUGridCellLayer';
143
+ GPUGridCellLayer.defaultProps = defaultProps;
@@ -0,0 +1,96 @@
1
+ import { Accessor, AccessorFunction, Color, Material, GetPickingInfoParams, LayerContext, PickingInfo, Position, DefaultProps } from '@deck.gl/core/typed';
2
+ import GPUGridCellLayer from './gpu-grid-cell-layer';
3
+ import GridAggregationLayer, { GridAggregationLayerProps } from '../grid-aggregation-layer';
4
+ /** All properties supported by GPUGridLayer. */
5
+ export declare type GPUGridLayerProps<DataT = any> = _GPUGridLayerProps<DataT> & GridAggregationLayerProps<DataT>;
6
+ /** Properties added by GPUGridLayer. */
7
+ export declare type _GPUGridLayerProps<DataT> = {
8
+ /**
9
+ * Size of each cell in meters.
10
+ * @default 1000
11
+ */
12
+ cellSize?: number;
13
+ /**
14
+ * Color scale domain, default is set to the extent of aggregated weights in each cell.
15
+ * @default [min(colorWeight), max(colorWeight)]
16
+ */
17
+ colorDomain?: [number, number] | null;
18
+ /**
19
+ * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
20
+ */
21
+ colorRange?: Color[];
22
+ /**
23
+ * Cell size multiplier, clamped between 0 - 1.
24
+ * @default 1
25
+ */
26
+ coverage?: number;
27
+ /**
28
+ * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
29
+ * @default [0, max(elevationWeight)]
30
+ */
31
+ elevationDomain?: [number, number] | null;
32
+ /**
33
+ * Elevation scale output range.
34
+ * @default [0, 1000]
35
+ */
36
+ elevationRange?: [number, number];
37
+ /**
38
+ * Cell elevation multiplier.
39
+ * @default 1
40
+ */
41
+ elevationScale?: number;
42
+ /**
43
+ * Whether to enable cell elevation. If set to false, all cell will be flat.
44
+ * @default true
45
+ */
46
+ extruded?: boolean;
47
+ /**
48
+ * Material settings for lighting effect. Applies if `extruded: true`.
49
+ *
50
+ * @default true
51
+ * @see https://deck.gl/docs/developer-guide/using-lighting
52
+ */
53
+ material?: Material;
54
+ /**
55
+ * Defines the operation used to aggregate all data object weights to calculate a cell's color value.
56
+ * @default 'SUM'
57
+ */
58
+ colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
59
+ /**
60
+ * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
61
+ * @default 'SUM'
62
+ */
63
+ elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
64
+ /**
65
+ * Method called to retrieve the position of each object.
66
+ * @default object => object.position
67
+ */
68
+ getPosition?: AccessorFunction<DataT, Position>;
69
+ /**
70
+ * The weight of a data object used to calculate the color value for a cell.
71
+ * @default 1
72
+ */
73
+ getColorWeight?: Accessor<DataT, number>;
74
+ /**
75
+ * The weight of a data object used to calculate the elevation value for a cell.
76
+ * @default 1
77
+ */
78
+ getElevationWeight?: Accessor<DataT, number>;
79
+ };
80
+ /**
81
+ * The `GPUGridLayer` renders a grid heatmap based on an array of inputs.
82
+ */
83
+ export default class GPUGridLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<ExtraPropsT & Required<_GPUGridLayerProps<DataT>>> {
84
+ static layerName: string;
85
+ static defaultProps: DefaultProps<GPUGridLayerProps<any>>;
86
+ initializeState({ gl }: LayerContext): void;
87
+ updateState(opts: any): void;
88
+ getHashKeyForIndex(index: number): string;
89
+ getPositionForIndex(index: number): Position;
90
+ getPickingInfo({ info, mode }: GetPickingInfoParams): PickingInfo;
91
+ renderLayers(): GPUGridCellLayer | null;
92
+ finalizeState(context: LayerContext): void;
93
+ updateAggregationState(opts: any): void;
94
+ _updateAccessors(opts: any): void;
95
+ }
96
+ //# sourceMappingURL=gpu-grid-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-grid-layer.d.ts","sourceRoot":"","sources":["../../src/gpu-grid-layer/gpu-grid-layer.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,QAAQ,EACR,oBAAoB,EACpB,YAAY,EAEZ,WAAW,EACX,QAAQ,EACR,YAAY,EACb,MAAM,eAAe,CAAC;AAKvB,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD,OAAO,oBAAoB,EAAE,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AAsC1F,gDAAgD;AAChD,oBAAY,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,GACpE,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAEnC,wCAAwC;AACxC,oBAAY,kBAAkB,CAAC,KAAK,IAAI;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEtC;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE1C;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAElD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAEtD;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEhD;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEzC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,GAAG,EAAE,CAAE,SAAQ,oBAAoB,CAC3F,WAAW,GAAG,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAClD;IACC,MAAM,CAAC,SAAS,SAAkB;IAClC,MAAM,CAAC,YAAY,uCAAgB;IAEnC,eAAe,CAAC,EAAC,EAAE,EAAC,EAAE,YAAY,GAAG,IAAI;IA+CzC,WAAW,CAAC,IAAI,KAAA;IAehB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAkBzC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAa5C,cAAc,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,EAAE,oBAAoB,GAAG,WAAW;IAqD/D,YAAY;IAsDZ,aAAa,CAAC,OAAO,EAAE,YAAY;IAYnC,sBAAsB,CAAC,IAAI,KAAA;IAoD3B,gBAAgB,CAAC,IAAI,KAAA;CAMtB"}
@@ -0,0 +1,289 @@
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 { Buffer } from '@luma.gl/core';
21
+ import GL from '@luma.gl/constants';
22
+ import { log } from '@deck.gl/core';
23
+ import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
24
+ import { AGGREGATION_OPERATION } from '../utils/aggregation-operation-utils';
25
+ import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
26
+ import GPUGridCellLayer from './gpu-grid-cell-layer';
27
+ import { pointToDensityGridDataCPU } from './../cpu-grid-layer/grid-aggregator';
28
+ import GridAggregationLayer from '../grid-aggregation-layer';
29
+ import { getBoundingBox, getGridParams } from '../utils/grid-aggregation-utils';
30
+ const defaultProps = {
31
+ // color
32
+ colorDomain: null,
33
+ colorRange: defaultColorRange,
34
+ getColorWeight: { type: 'accessor', value: 1 },
35
+ colorAggregation: 'SUM',
36
+ // elevation
37
+ elevationDomain: null,
38
+ elevationRange: [0, 1000],
39
+ getElevationWeight: { type: 'accessor', value: 1 },
40
+ elevationAggregation: 'SUM',
41
+ elevationScale: { type: 'number', min: 0, value: 1 },
42
+ // grid
43
+ cellSize: { type: 'number', min: 1, max: 1000, value: 1000 },
44
+ coverage: { type: 'number', min: 0, max: 1, value: 1 },
45
+ getPosition: { type: 'accessor', value: x => x.position },
46
+ extruded: false,
47
+ // Optional material for 'lighting' shader module
48
+ material: true
49
+ };
50
+ // This layer only perform GPU aggregation, no need to seperate data and weight props
51
+ // aggregation will be dirty when any of the props are changed.
52
+ const DIMENSIONS = {
53
+ data: {
54
+ props: ['cellSize', 'colorAggregation', 'elevationAggregation']
55
+ }
56
+ // rest of the changes are detected by `state.attributesChanged`
57
+ };
58
+ const POSITION_ATTRIBUTE_NAME = 'positions';
59
+ /**
60
+ * The `GPUGridLayer` renders a grid heatmap based on an array of inputs.
61
+ */
62
+ export default class GPUGridLayer extends GridAggregationLayer {
63
+ initializeState({ gl }) {
64
+ const isSupported = GPUGridAggregator.isSupported(gl);
65
+ if (!isSupported) {
66
+ log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
67
+ }
68
+ super.initializeAggregationLayer({
69
+ dimensions: DIMENSIONS
70
+ });
71
+ this.setState({
72
+ gpuAggregation: true,
73
+ projectPoints: false,
74
+ isSupported,
75
+ weights: {
76
+ color: {
77
+ needMin: true,
78
+ needMax: true,
79
+ combineMaxMin: true,
80
+ maxMinBuffer: new Buffer(gl, {
81
+ byteLength: 4 * 4,
82
+ accessor: { size: 4, type: GL.FLOAT, divisor: 1 }
83
+ })
84
+ },
85
+ elevation: {
86
+ needMin: true,
87
+ needMax: true,
88
+ combineMaxMin: true,
89
+ maxMinBuffer: new Buffer(gl, {
90
+ byteLength: 4 * 4,
91
+ accessor: { size: 4, type: GL.FLOAT, divisor: 1 }
92
+ })
93
+ }
94
+ },
95
+ positionAttributeName: 'positions'
96
+ });
97
+ const attributeManager = this.getAttributeManager();
98
+ attributeManager.add({
99
+ [POSITION_ATTRIBUTE_NAME]: {
100
+ size: 3,
101
+ accessor: 'getPosition',
102
+ type: GL.DOUBLE,
103
+ fp64: this.use64bitPositions()
104
+ },
105
+ color: { size: 3, accessor: 'getColorWeight' },
106
+ elevation: { size: 3, accessor: 'getElevationWeight' }
107
+ });
108
+ }
109
+ updateState(opts) {
110
+ if (this.state.isSupported === false) {
111
+ // Skip update, layer not supported
112
+ return;
113
+ }
114
+ super.updateState(opts);
115
+ const { aggregationDirty } = this.state;
116
+ if (aggregationDirty) {
117
+ // reset cached CPU Aggregation results (used for picking)
118
+ this.setState({
119
+ gridHash: null
120
+ });
121
+ }
122
+ }
123
+ getHashKeyForIndex(index) {
124
+ const { numRow, numCol, boundingBox, gridOffset } = this.state;
125
+ const gridSize = [numCol, numRow];
126
+ const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
127
+ const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
128
+ const yIndex = Math.floor(index / gridSize[0]);
129
+ const xIndex = index - yIndex * gridSize[0];
130
+ // This will match the index to the hash-key to access aggregation data from CPU aggregation results.
131
+ const latIdx = Math.floor((yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]);
132
+ const lonIdx = Math.floor((xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]);
133
+ return `${latIdx}-${lonIdx}`;
134
+ }
135
+ getPositionForIndex(index) {
136
+ const { numRow, numCol, boundingBox, gridOffset } = this.state;
137
+ const gridSize = [numCol, numRow];
138
+ const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
139
+ const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
140
+ const yIndex = Math.floor(index / gridSize[0]);
141
+ const xIndex = index - yIndex * gridSize[0];
142
+ const yPos = yIndex * cellSize[1] + gridOrigin[1];
143
+ const xPos = xIndex * cellSize[0] + gridOrigin[0];
144
+ return [xPos, yPos];
145
+ }
146
+ getPickingInfo({ info, mode }) {
147
+ const { index } = info;
148
+ let object = null;
149
+ if (index >= 0) {
150
+ const { gpuGridAggregator } = this.state;
151
+ const position = this.getPositionForIndex(index);
152
+ const colorInfo = GPUGridAggregator.getAggregationData({
153
+ pixelIndex: index,
154
+ ...gpuGridAggregator.getData('color')
155
+ });
156
+ const elevationInfo = GPUGridAggregator.getAggregationData({
157
+ pixelIndex: index,
158
+ ...gpuGridAggregator.getData('elevation')
159
+ });
160
+ object = {
161
+ colorValue: colorInfo.cellWeight,
162
+ elevationValue: elevationInfo.cellWeight,
163
+ count: colorInfo.cellCount || elevationInfo.cellCount,
164
+ position,
165
+ totalCount: colorInfo.totalCount || elevationInfo.totalCount
166
+ };
167
+ if (mode !== 'hover') {
168
+ // perform CPU aggregation for full list of points for each cell
169
+ const { props } = this;
170
+ let { gridHash } = this.state;
171
+ if (!gridHash) {
172
+ const { gridOffset, translation, boundingBox } = this.state;
173
+ const { viewport } = this.context;
174
+ const attributes = this.getAttributes();
175
+ const cpuAggregation = pointToDensityGridDataCPU(props, {
176
+ gridOffset,
177
+ attributes,
178
+ viewport,
179
+ translation,
180
+ boundingBox
181
+ });
182
+ gridHash = cpuAggregation.gridHash;
183
+ this.setState({ gridHash });
184
+ }
185
+ const key = this.getHashKeyForIndex(index);
186
+ const cpuAggregationData = gridHash[key];
187
+ Object.assign(object, cpuAggregationData);
188
+ }
189
+ }
190
+ // override object with picked cell
191
+ info.picked = Boolean(object);
192
+ info.object = object;
193
+ return info;
194
+ }
195
+ renderLayers() {
196
+ if (!this.state.isSupported) {
197
+ return null;
198
+ }
199
+ const { elevationScale, extruded, cellSize: cellSizeMeters, coverage, material, elevationRange, colorDomain, elevationDomain } = this.props;
200
+ const { weights, numRow, numCol, gridOrigin, gridOffset } = this.state;
201
+ const { color, elevation } = weights;
202
+ const colorRange = colorRangeToFlatArray(this.props.colorRange);
203
+ const SubLayerClass = this.getSubLayerClass('gpu-grid-cell', GPUGridCellLayer);
204
+ return new SubLayerClass({
205
+ gridSize: [numCol, numRow],
206
+ gridOrigin,
207
+ gridOffset: [gridOffset.xOffset, gridOffset.yOffset],
208
+ colorRange,
209
+ elevationRange,
210
+ colorDomain,
211
+ elevationDomain,
212
+ cellSize: cellSizeMeters,
213
+ coverage,
214
+ material,
215
+ elevationScale,
216
+ extruded
217
+ }, this.getSubLayerProps({
218
+ id: 'gpu-grid-cell'
219
+ }), {
220
+ data: {
221
+ attributes: {
222
+ colors: color.aggregationBuffer,
223
+ elevations: elevation.aggregationBuffer
224
+ }
225
+ },
226
+ colorMaxMinBuffer: color.maxMinBuffer,
227
+ elevationMaxMinBuffer: elevation.maxMinBuffer,
228
+ numInstances: numCol * numRow
229
+ });
230
+ }
231
+ finalizeState(context) {
232
+ const { color, elevation } = this.state.weights;
233
+ [color, elevation].forEach(weight => {
234
+ const { aggregationBuffer, maxMinBuffer } = weight;
235
+ maxMinBuffer.delete();
236
+ aggregationBuffer?.delete();
237
+ });
238
+ super.finalizeState(context);
239
+ }
240
+ // Aggregation Overrides
241
+ updateAggregationState(opts) {
242
+ const { props, oldProps } = opts;
243
+ const { cellSize, coordinateSystem } = props;
244
+ const { viewport } = this.context;
245
+ const cellSizeChanged = oldProps.cellSize !== cellSize;
246
+ const { dimensions } = this.state;
247
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
248
+ // any attribute changed
249
+ const attributesChanged = positionsChanged || this.isAttributeChanged();
250
+ let { boundingBox } = this.state;
251
+ if (positionsChanged) {
252
+ boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
253
+ this.setState({ boundingBox });
254
+ }
255
+ if (positionsChanged || cellSizeChanged) {
256
+ const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
257
+ this.allocateResources(numRow, numCol);
258
+ this.setState({
259
+ gridOffset,
260
+ translation,
261
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
262
+ width,
263
+ height,
264
+ numCol,
265
+ numRow
266
+ });
267
+ }
268
+ const aggregationDataDirty = attributesChanged ||
269
+ this.isAggregationDirty(opts, {
270
+ dimension: dimensions.data,
271
+ compareAll: true
272
+ });
273
+ if (aggregationDataDirty) {
274
+ this._updateAccessors(opts);
275
+ }
276
+ this.setState({
277
+ aggregationDataDirty
278
+ });
279
+ }
280
+ // Private
281
+ _updateAccessors(opts) {
282
+ const { colorAggregation, elevationAggregation } = opts.props;
283
+ const { color, elevation } = this.state.weights;
284
+ color.operation = AGGREGATION_OPERATION[colorAggregation];
285
+ elevation.operation = AGGREGATION_OPERATION[elevationAggregation];
286
+ }
287
+ }
288
+ GPUGridLayer.layerName = 'GPUGridLayer';
289
+ GPUGridLayer.defaultProps = defaultProps;
@@ -0,0 +1,32 @@
1
+ import AggregationLayer, { AggregationLayerProps } from './aggregation-layer';
2
+ import { LayerContext, UpdateParameters } from '@deck.gl/core/typed';
3
+ import BinSorter from './utils/bin-sorter';
4
+ export declare type GridAggregationLayerProps<DataT = any> = AggregationLayerProps<DataT>;
5
+ export default abstract class GridAggregationLayer<ExtraPropsT = {}> extends AggregationLayer<ExtraPropsT> {
6
+ static layerName: string;
7
+ state: AggregationLayer['state'] & {
8
+ aggregationDataDirty?: any;
9
+ aggregationWeightsDirty?: any;
10
+ gpuAggregation?: any;
11
+ getValue?: () => any;
12
+ sortedBins?: BinSorter;
13
+ };
14
+ initializeAggregationLayer({ dimensions }: {
15
+ dimensions: any;
16
+ }): void;
17
+ updateState(opts: UpdateParameters<this>): void;
18
+ finalizeState(context: LayerContext): void;
19
+ updateShaders(shaders: any): void;
20
+ updateAggregationState(opts: any): void;
21
+ allocateResources(numRow: any, numCol: any): void;
22
+ updateResults({ aggregationData, maxMinData, maxData, minData }: {
23
+ aggregationData: any;
24
+ maxMinData: any;
25
+ maxData: any;
26
+ minData: any;
27
+ }): void;
28
+ _updateAggregation(opts: any): void;
29
+ _updateWeightBins(): void;
30
+ _uploadAggregationResults(): void;
31
+ }
32
+ //# sourceMappingURL=grid-aggregation-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-aggregation-layer.d.ts","sourceRoot":"","sources":["../src/grid-aggregation-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,gBAAgB,EAAE,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAC,YAAY,EAAO,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAElE,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,oBAAY,yBAAyB,CAAC,KAAK,GAAG,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAElF,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,oBAAoB,CAChD,WAAW,GAAG,EAAE,CAChB,SAAQ,gBAAgB,CAAC,WAAW,CAAC;IACrC,MAAM,CAAC,SAAS,SAA0B;IAE1C,KAAK,EAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG;QAClC,oBAAoB,CAAC,EAAE,GAAG,CAAC;QAC3B,uBAAuB,CAAC,EAAE,GAAG,CAAC;QAC9B,cAAc,CAAC,EAAE,GAAG,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC;QACrB,UAAU,CAAC,EAAE,SAAS,CAAC;KACxB,CAAC;IAEF,0BAA0B,CAAC,EAAC,UAAU,EAAC;;KAAA;IAWvC,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IA8BxC,aAAa,CAAC,OAAO,EAAE,YAAY;IASnC,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAQjC,sBAAsB,CAAC,IAAI,KAAA;IAK3B,iBAAiB,CAAC,MAAM,KAAA,EAAE,MAAM,KAAA;IAsBhC,aAAa,CAAC,EAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAC;;;;;KAAA;IAY7D,kBAAkB,CAAC,IAAI,KAAA;IAgDvB,iBAAiB;IAOjB,yBAAyB,IAAI,IAAI;CAoBlC"}