@deck.gl/aggregation-layers 9.0.40 → 9.1.0-beta.3

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 (372) 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 +70 -0
  4. package/dist/common/aggregation-layer.js.map +1 -0
  5. package/dist/common/aggregator/aggregator.d.ts +76 -0
  6. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  7. package/dist/common/aggregator/aggregator.js +5 -0
  8. package/dist/common/aggregator/aggregator.js.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  10. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  11. package/dist/common/aggregator/cpu-aggregator/aggregate.js +67 -0
  12. package/dist/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
  13. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  14. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +140 -0
  16. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
  17. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  18. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  19. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
  20. package/dist/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
  21. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  22. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  23. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
  24. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
  25. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  26. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +21 -0
  28. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
  29. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  30. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  31. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
  32. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  34. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  35. package/dist/common/aggregator/gpu-aggregator/utils.js +25 -0
  36. package/dist/common/aggregator/gpu-aggregator/utils.js.map +1 -0
  37. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  38. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  39. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +216 -0
  40. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
  41. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  42. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  43. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +202 -0
  44. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
  45. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  46. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  47. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +224 -0
  48. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
  49. package/dist/common/aggregator/index.d.ts +6 -0
  50. package/dist/common/aggregator/index.d.ts.map +1 -0
  51. package/dist/common/aggregator/index.js +6 -0
  52. package/dist/common/aggregator/index.js.map +1 -0
  53. package/dist/common/types.d.ts +11 -0
  54. package/dist/common/types.d.ts.map +1 -0
  55. package/dist/common/types.js +5 -0
  56. package/dist/common/types.js.map +1 -0
  57. package/dist/common/utils/bounds-utils.d.ts +10 -0
  58. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  59. package/dist/common/utils/bounds-utils.js +21 -0
  60. package/dist/common/utils/bounds-utils.js.map +1 -0
  61. package/dist/common/utils/color-utils.d.ts +10 -0
  62. package/dist/common/utils/color-utils.d.ts.map +1 -0
  63. package/dist/common/utils/color-utils.js +66 -0
  64. package/dist/common/utils/color-utils.js.map +1 -0
  65. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  66. package/dist/common/utils/prop-utils.js +13 -0
  67. package/dist/common/utils/prop-utils.js.map +1 -0
  68. package/dist/common/utils/scale-utils.d.ts +46 -0
  69. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  70. package/dist/common/utils/scale-utils.js +181 -0
  71. package/dist/common/utils/scale-utils.js.map +1 -0
  72. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/contour-layer/bin-options-uniforms.js +18 -0
  75. package/dist/contour-layer/bin-options-uniforms.js.map +1 -0
  76. package/dist/contour-layer/contour-layer.d.ts +42 -50
  77. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  78. package/dist/contour-layer/contour-layer.js +233 -192
  79. package/dist/contour-layer/contour-layer.js.map +1 -0
  80. package/dist/contour-layer/contour-utils.d.ts +36 -15
  81. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  82. package/dist/contour-layer/contour-utils.js +25 -29
  83. package/dist/contour-layer/contour-utils.js.map +1 -0
  84. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  85. package/dist/contour-layer/marching-squares-codes.js +4 -0
  86. package/dist/contour-layer/marching-squares-codes.js.map +1 -0
  87. package/dist/contour-layer/marching-squares.d.ts +22 -6
  88. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  89. package/dist/contour-layer/marching-squares.js +72 -68
  90. package/dist/contour-layer/marching-squares.js.map +1 -0
  91. package/dist/contour-layer/value-reader.d.ts +10 -0
  92. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  93. package/dist/contour-layer/value-reader.js +47 -0
  94. package/dist/contour-layer/value-reader.js.map +1 -0
  95. package/dist/dist.dev.js +4844 -4083
  96. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  97. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  98. package/dist/grid-layer/bin-options-uniforms.js +18 -0
  99. package/dist/grid-layer/bin-options-uniforms.js.map +1 -0
  100. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  101. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  102. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +52 -0
  103. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
  104. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  105. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  106. package/dist/grid-layer/grid-cell-layer.js +94 -0
  107. package/dist/grid-layer/grid-cell-layer.js.map +1 -0
  108. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  109. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  110. package/dist/grid-layer/grid-layer-uniforms.js +24 -0
  111. package/dist/grid-layer/grid-layer-uniforms.js.map +1 -0
  112. package/dist/grid-layer/grid-layer.d.ts +176 -14
  113. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  114. package/dist/grid-layer/grid-layer.js +343 -46
  115. package/dist/grid-layer/grid-layer.js.map +1 -0
  116. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  117. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  118. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +7 -21
  119. package/dist/heatmap-layer/aggregation-layer.js.map +1 -0
  120. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  121. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  122. package/dist/heatmap-layer/heatmap-layer-uniforms.js +33 -0
  123. package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
  124. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  125. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  126. package/dist/heatmap-layer/heatmap-layer-utils.js +4 -0
  127. package/dist/heatmap-layer/heatmap-layer-utils.js.map +1 -0
  128. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  129. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  130. package/dist/heatmap-layer/heatmap-layer.js +44 -33
  131. package/dist/heatmap-layer/heatmap-layer.js.map +1 -0
  132. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  133. package/dist/heatmap-layer/max-fs.glsl.js +4 -0
  134. package/dist/heatmap-layer/max-fs.glsl.js.map +1 -0
  135. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  136. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  137. package/dist/heatmap-layer/max-vs.glsl.js +7 -4
  138. package/dist/heatmap-layer/max-vs.glsl.js.map +1 -0
  139. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  140. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  141. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +6 -23
  142. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
  143. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  144. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  145. package/dist/heatmap-layer/triangle-layer-uniforms.js +23 -0
  146. package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
  147. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  148. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  149. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +11 -30
  150. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
  151. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  152. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  153. package/dist/heatmap-layer/triangle-layer.js +18 -30
  154. package/dist/heatmap-layer/triangle-layer.js.map +1 -0
  155. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  156. package/dist/heatmap-layer/weights-fs.glsl.js +4 -0
  157. package/dist/heatmap-layer/weights-fs.glsl.js.map +1 -0
  158. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  159. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  160. package/dist/heatmap-layer/weights-vs.glsl.js +7 -7
  161. package/dist/heatmap-layer/weights-vs.glsl.js.map +1 -0
  162. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  163. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  164. package/dist/hexagon-layer/bin-options-uniforms.js +18 -0
  165. package/dist/hexagon-layer/bin-options-uniforms.js.map +1 -0
  166. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  167. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  168. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +56 -0
  169. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
  170. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  171. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  172. package/dist/hexagon-layer/hexagon-cell-layer.js +95 -0
  173. package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -0
  174. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  175. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  176. package/dist/hexagon-layer/hexagon-layer-uniforms.js +22 -0
  177. package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
  178. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  179. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  180. package/dist/hexagon-layer/hexagon-layer.js +308 -123
  181. package/dist/hexagon-layer/hexagon-layer.js.map +1 -0
  182. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  183. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  184. package/dist/hexagon-layer/hexbin.js +70 -0
  185. package/dist/hexagon-layer/hexbin.js.map +1 -0
  186. package/dist/index.cjs +3026 -2947
  187. package/dist/index.cjs.map +4 -4
  188. package/dist/index.d.ts +7 -13
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +6 -27
  191. package/dist/index.js.map +1 -0
  192. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  193. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  194. package/dist/screen-grid-layer/bin-options-uniforms.js +16 -0
  195. package/dist/screen-grid-layer/bin-options-uniforms.js.map +1 -0
  196. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  197. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  198. package/dist/screen-grid-layer/screen-grid-cell-layer.js +53 -134
  199. package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
  200. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  201. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  202. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +5 -24
  203. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
  204. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  205. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  206. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +20 -0
  207. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
  208. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  209. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  210. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +22 -62
  211. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
  212. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  213. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  214. package/dist/screen-grid-layer/screen-grid-layer.js +158 -174
  215. package/dist/screen-grid-layer/screen-grid-layer.js.map +1 -0
  216. package/dist.min.js +401 -382
  217. package/package.json +10 -9
  218. package/src/common/aggregation-layer.ts +107 -0
  219. package/src/common/aggregator/aggregator.ts +88 -0
  220. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  221. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  222. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  223. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  224. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  225. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  226. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  227. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  228. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  229. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  230. package/src/common/aggregator/index.ts +10 -0
  231. package/src/{types.ts → common/types.ts} +10 -4
  232. package/src/common/utils/bounds-utils.ts +34 -0
  233. package/src/common/utils/color-utils.ts +86 -0
  234. package/src/common/utils/prop-utils.ts +13 -0
  235. package/src/common/utils/scale-utils.ts +236 -0
  236. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  237. package/src/contour-layer/contour-layer.ts +300 -265
  238. package/src/contour-layer/contour-utils.ts +68 -39
  239. package/src/contour-layer/marching-squares-codes.ts +4 -0
  240. package/src/contour-layer/marching-squares.ts +93 -82
  241. package/src/contour-layer/value-reader.ts +65 -0
  242. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  243. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  244. package/src/grid-layer/grid-cell-layer.ts +141 -0
  245. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  246. package/src/grid-layer/grid-layer.ts +614 -73
  247. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  248. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  249. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  250. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  251. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  252. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  253. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  254. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  255. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  256. package/src/heatmap-layer/triangle-layer.ts +26 -31
  257. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  258. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  259. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  260. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  261. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  262. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  263. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  264. package/src/hexagon-layer/hexbin.ts +79 -0
  265. package/src/index.ts +21 -34
  266. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  267. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  268. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  269. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  270. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  271. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  272. package/dist/aggregation-layer.d.ts.map +0 -1
  273. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  274. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  275. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  276. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  277. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  278. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  279. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  280. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  281. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  282. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  283. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  284. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  285. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  286. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  287. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  288. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  289. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  290. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  291. package/dist/grid-aggregation-layer.d.ts +0 -67
  292. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  293. package/dist/grid-aggregation-layer.js +0 -173
  294. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  295. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  296. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  297. package/dist/types.d.ts +0 -12
  298. package/dist/types.d.ts.map +0 -1
  299. package/dist/types.js +0 -1
  300. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  301. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  302. package/dist/utils/aggregation-operation-utils.js +0 -94
  303. package/dist/utils/bin-sorter.d.ts +0 -52
  304. package/dist/utils/bin-sorter.d.ts.map +0 -1
  305. package/dist/utils/bin-sorter.js +0 -167
  306. package/dist/utils/color-utils.d.ts +0 -3
  307. package/dist/utils/color-utils.d.ts.map +0 -1
  308. package/dist/utils/color-utils.js +0 -53
  309. package/dist/utils/cpu-aggregator.d.ts +0 -169
  310. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  311. package/dist/utils/cpu-aggregator.js +0 -421
  312. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  313. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  314. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  315. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  316. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  317. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  318. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  319. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  320. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  321. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  322. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  323. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  324. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  325. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  326. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  327. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  328. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  329. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  330. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  331. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  332. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  333. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  334. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  335. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  336. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  337. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  338. package/dist/utils/grid-aggregation-utils.js +0 -114
  339. package/dist/utils/prop-utils.d.ts.map +0 -1
  340. package/dist/utils/prop-utils.js +0 -28
  341. package/dist/utils/resource-utils.d.ts +0 -14
  342. package/dist/utils/resource-utils.d.ts.map +0 -1
  343. package/dist/utils/resource-utils.js +0 -38
  344. package/dist/utils/scale-utils.d.ts +0 -15
  345. package/dist/utils/scale-utils.d.ts.map +0 -1
  346. package/dist/utils/scale-utils.js +0 -184
  347. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  348. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  349. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  350. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  351. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  352. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  353. package/src/grid-aggregation-layer.ts +0 -243
  354. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  355. package/src/utils/aggregation-operation-utils.ts +0 -118
  356. package/src/utils/bin-sorter.ts +0 -218
  357. package/src/utils/color-utils.ts +0 -57
  358. package/src/utils/cpu-aggregator.ts +0 -503
  359. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  360. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  361. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  362. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  363. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  364. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  365. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  366. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  367. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  368. package/src/utils/grid-aggregation-utils.ts +0 -147
  369. package/src/utils/prop-utils.ts +0 -29
  370. package/src/utils/resource-utils.ts +0 -53
  371. package/src/utils/scale-utils.js +0 -219
  372. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
@@ -1,241 +1,282 @@
1
- // Copyright (c) 2015 - 2018 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 { LineLayer, SolidPolygonLayer } from '@deck.gl/layers';
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { COORDINATE_SYSTEM, project32, Viewport, _deepEqual } from '@deck.gl/core';
5
+ import { PathLayer, SolidPolygonLayer } from '@deck.gl/layers';
6
+ import { WebGLAggregator, CPUAggregator } from "../common/aggregator/index.js";
7
+ import AggregationLayer from "../common/aggregation-layer.js";
21
8
  import { generateContours } from "./contour-utils.js";
22
- import { log } from '@deck.gl/core';
23
- import GPUGridAggregator from "../utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
24
- import { AGGREGATION_OPERATION, getValueFunc } from "../utils/aggregation-operation-utils.js";
25
- import { getBoundingBox, getGridParams } from "../utils/grid-aggregation-utils.js";
26
- import GridAggregationLayer from "../grid-aggregation-layer.js";
9
+ import { getAggregatorValueReader } from "./value-reader.js";
10
+ import { getBinIdRange } from "../common/utils/bounds-utils.js";
11
+ import { Matrix4 } from '@math.gl/core';
12
+ import { binOptionsUniforms } from "./bin-options-uniforms.js";
27
13
  const DEFAULT_COLOR = [255, 255, 255, 255];
28
14
  const DEFAULT_STROKE_WIDTH = 1;
29
- const DEFAULT_THRESHOLD = 1;
30
15
  const defaultProps = {
31
16
  // grid aggregation
32
- cellSize: { type: 'number', min: 1, max: 1000, value: 1000 },
17
+ cellSize: { type: 'number', min: 1, value: 1000 },
18
+ gridOrigin: { type: 'array', compare: true, value: [0, 0] },
33
19
  getPosition: { type: 'accessor', value: (x) => x.position },
34
20
  getWeight: { type: 'accessor', value: 1 },
35
- gpuAggregation: false, // TODO(v9): Re-enable GPU aggregation.
21
+ gpuAggregation: true,
36
22
  aggregation: 'SUM',
37
23
  // contour lines
38
24
  contours: {
39
25
  type: 'object',
40
- value: [{ threshold: DEFAULT_THRESHOLD }],
26
+ value: [{ threshold: 1 }],
41
27
  optional: true,
42
28
  compare: 3
43
29
  },
44
30
  zOffset: 0.005
45
31
  };
46
- const POSITION_ATTRIBUTE_NAME = 'positions';
47
- const DIMENSIONS = {
48
- data: {
49
- props: ['cellSize']
50
- },
51
- weights: {
52
- props: ['aggregation'],
53
- accessors: ['getWeight']
32
+ /** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
33
+ class GridLayer extends AggregationLayer {
34
+ getAggregatorType() {
35
+ return this.props.gpuAggregation && WebGLAggregator.isSupported(this.context.device)
36
+ ? 'gpu'
37
+ : 'cpu';
54
38
  }
55
- };
56
- /** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */
57
- class ContourLayer extends GridAggregationLayer {
58
- initializeState() {
59
- super.initializeAggregationLayer({
60
- dimensions: DIMENSIONS
61
- });
62
- this.setState({
63
- contourData: {},
64
- projectPoints: false,
65
- weights: {
66
- count: {
67
- size: 1,
68
- operation: AGGREGATION_OPERATION.SUM
69
- }
70
- }
39
+ createAggregator(type) {
40
+ if (type === 'cpu') {
41
+ return new CPUAggregator({
42
+ dimensions: 2,
43
+ getBin: {
44
+ sources: ['positions'],
45
+ getValue: ({ positions }, index, opts) => {
46
+ const viewport = this.state.aggregatorViewport;
47
+ // project to common space
48
+ const p = viewport.projectPosition(positions);
49
+ const { cellSizeCommon, cellOriginCommon } = opts;
50
+ return [
51
+ Math.floor((p[0] - cellOriginCommon[0]) / cellSizeCommon[0]),
52
+ Math.floor((p[1] - cellOriginCommon[1]) / cellSizeCommon[1])
53
+ ];
54
+ }
55
+ },
56
+ getValue: [{ sources: ['counts'], getValue: ({ counts }) => counts }],
57
+ onUpdate: this._onAggregationUpdate.bind(this)
58
+ });
59
+ }
60
+ return new WebGLAggregator(this.context.device, {
61
+ dimensions: 2,
62
+ channelCount: 1,
63
+ bufferLayout: this.getAttributeManager().getBufferLayouts({ isInstanced: false }),
64
+ ...super.getShaders({
65
+ modules: [project32, binOptionsUniforms],
66
+ vs: /* glsl */ `
67
+ in vec3 positions;
68
+ in vec3 positions64Low;
69
+ in float counts;
70
+
71
+ void getBin(out ivec2 binId) {
72
+ vec3 positionCommon = project_position(positions, positions64Low);
73
+ vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
74
+ binId = ivec2(gridCoords);
75
+ }
76
+ void getValue(out float value) {
77
+ value = counts;
78
+ }
79
+ `
80
+ }),
81
+ onUpdate: this._onAggregationUpdate.bind(this)
71
82
  });
83
+ }
84
+ initializeState() {
85
+ super.initializeState();
72
86
  const attributeManager = this.getAttributeManager();
73
87
  attributeManager.add({
74
- [POSITION_ATTRIBUTE_NAME]: {
88
+ positions: {
75
89
  size: 3,
76
90
  accessor: 'getPosition',
77
91
  type: 'float64',
78
92
  fp64: this.use64bitPositions()
79
93
  },
80
- // this attribute is used in gpu aggregation path only
81
- count: { size: 3, accessor: 'getWeight' }
94
+ counts: { size: 1, accessor: 'getWeight' }
95
+ });
96
+ }
97
+ updateState(params) {
98
+ const aggregatorChanged = super.updateState(params);
99
+ const { props, oldProps, changeFlags } = params;
100
+ const { aggregator } = this.state;
101
+ if (aggregatorChanged ||
102
+ changeFlags.dataChanged ||
103
+ props.cellSize !== oldProps.cellSize ||
104
+ !_deepEqual(props.gridOrigin, oldProps.gridOrigin, 1) ||
105
+ props.aggregation !== oldProps.aggregation) {
106
+ this._updateBinOptions();
107
+ const { cellSizeCommon, cellOriginCommon, binIdRange } = this.state;
108
+ aggregator.setProps({
109
+ // @ts-expect-error only used by GPUAggregator
110
+ binIdRange,
111
+ pointCount: this.getNumInstances(),
112
+ operations: [props.aggregation],
113
+ binOptions: {
114
+ cellSizeCommon,
115
+ cellOriginCommon
116
+ }
117
+ });
118
+ }
119
+ if (!_deepEqual(oldProps.contours, props.contours, 2)) {
120
+ // Recalculate contours
121
+ this.setState({ contourData: null });
122
+ }
123
+ return aggregatorChanged;
124
+ }
125
+ _updateBinOptions() {
126
+ const bounds = this.getBounds();
127
+ const cellSizeCommon = [1, 1];
128
+ let cellOriginCommon = [0, 0];
129
+ let binIdRange = [
130
+ [0, 1],
131
+ [0, 1]
132
+ ];
133
+ let viewport = this.context.viewport;
134
+ if (bounds && Number.isFinite(bounds[0][0])) {
135
+ let centroid = [(bounds[0][0] + bounds[1][0]) / 2, (bounds[0][1] + bounds[1][1]) / 2];
136
+ const { cellSize, gridOrigin } = this.props;
137
+ const { unitsPerMeter } = viewport.getDistanceScales(centroid);
138
+ cellSizeCommon[0] = unitsPerMeter[0] * cellSize;
139
+ cellSizeCommon[1] = unitsPerMeter[1] * cellSize;
140
+ // Offset common space to center at the origin of the grid cell where the data center is in
141
+ // This improves precision without affecting the cell positions
142
+ const centroidCommon = viewport.projectFlat(centroid);
143
+ cellOriginCommon = [
144
+ Math.floor((centroidCommon[0] - gridOrigin[0]) / cellSizeCommon[0]) * cellSizeCommon[0] +
145
+ gridOrigin[0],
146
+ Math.floor((centroidCommon[1] - gridOrigin[1]) / cellSizeCommon[1]) * cellSizeCommon[1] +
147
+ gridOrigin[1]
148
+ ];
149
+ centroid = viewport.unprojectFlat(cellOriginCommon);
150
+ const ViewportType = viewport.constructor;
151
+ // We construct a viewport for the GPU aggregator's project module
152
+ // This viewport is determined by data
153
+ // removes arbitrary precision variance that depends on initial view state
154
+ viewport = viewport.isGeospatial
155
+ ? new ViewportType({ longitude: centroid[0], latitude: centroid[1], zoom: 12 })
156
+ : new Viewport({ position: [centroid[0], centroid[1], 0], zoom: 12 });
157
+ // Round to the nearest 32-bit float to match CPU and GPU results
158
+ cellOriginCommon = [Math.fround(viewport.center[0]), Math.fround(viewport.center[1])];
159
+ binIdRange = getBinIdRange({
160
+ dataBounds: bounds,
161
+ getBinId: (p) => {
162
+ const positionCommon = viewport.projectFlat(p);
163
+ return [
164
+ Math.floor((positionCommon[0] - cellOriginCommon[0]) / cellSizeCommon[0]),
165
+ Math.floor((positionCommon[1] - cellOriginCommon[1]) / cellSizeCommon[1])
166
+ ];
167
+ }
168
+ });
169
+ }
170
+ this.setState({ cellSizeCommon, cellOriginCommon, binIdRange, aggregatorViewport: viewport });
171
+ }
172
+ draw(opts) {
173
+ // Replaces render time viewport with our own
174
+ if (opts.shaderModuleProps.project) {
175
+ opts.shaderModuleProps.project.viewport = this.state.aggregatorViewport;
176
+ }
177
+ super.draw(opts);
178
+ }
179
+ _onAggregationUpdate() {
180
+ const { aggregator, binIdRange } = this.state;
181
+ this.setState({
182
+ aggregatedValueReader: getAggregatorValueReader({ aggregator, binIdRange, channel: 0 }),
183
+ contourData: null
82
184
  });
83
185
  }
84
- updateState(opts) {
85
- super.updateState(opts);
86
- let contoursChanged = false;
87
- const { oldProps, props } = opts;
88
- const { aggregationDirty } = this.state;
89
- if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
90
- contoursChanged = true;
91
- this._updateThresholdData(opts.props);
186
+ _getContours() {
187
+ const { aggregatedValueReader } = this.state;
188
+ if (!aggregatedValueReader) {
189
+ return null;
92
190
  }
93
- if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
94
- this._generateContours();
191
+ if (!this.state.contourData) {
192
+ const { binIdRange } = this.state;
193
+ const { contours } = this.props;
194
+ const contourData = generateContours({
195
+ contours,
196
+ getValue: aggregatedValueReader,
197
+ xRange: binIdRange[0],
198
+ yRange: binIdRange[1]
199
+ });
200
+ this.state.contourData = contourData;
201
+ }
202
+ return this.state.contourData;
203
+ }
204
+ onAttributeChange(id) {
205
+ const { aggregator } = this.state;
206
+ switch (id) {
207
+ case 'positions':
208
+ aggregator.setNeedsUpdate();
209
+ this._updateBinOptions();
210
+ const { cellSizeCommon, cellOriginCommon, binIdRange } = this.state;
211
+ aggregator.setProps({
212
+ // @ts-expect-error only used by GPUAggregator
213
+ binIdRange,
214
+ binOptions: {
215
+ cellSizeCommon,
216
+ cellOriginCommon
217
+ }
218
+ });
219
+ break;
220
+ case 'counts':
221
+ aggregator.setNeedsUpdate(0);
222
+ break;
223
+ default:
224
+ // This should not happen
95
225
  }
96
226
  }
97
227
  renderLayers() {
98
- const { contourSegments, contourPolygons } = this.state.contourData;
99
- const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
228
+ const contourData = this._getContours();
229
+ if (!contourData) {
230
+ return null;
231
+ }
232
+ const { lines, polygons } = contourData;
233
+ const { zOffset } = this.props;
234
+ const { cellOriginCommon, cellSizeCommon } = this.state;
235
+ const LinesSubLayerClass = this.getSubLayerClass('lines', PathLayer);
100
236
  const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);
237
+ const modelMatrix = new Matrix4()
238
+ .translate([cellOriginCommon[0], cellOriginCommon[1], 0])
239
+ .scale([cellSizeCommon[0], cellSizeCommon[1], zOffset]);
101
240
  // Contour lines layer
102
- const lineLayer = contourSegments &&
103
- contourSegments.length > 0 &&
241
+ const lineLayer = lines &&
242
+ lines.length > 0 &&
104
243
  new LinesSubLayerClass(this.getSubLayerProps({
105
244
  id: 'lines'
106
245
  }), {
107
- data: this.state.contourData.contourSegments,
108
- getSourcePosition: d => d.start,
109
- getTargetPosition: d => d.end,
110
- getColor: d => d.contour.color || DEFAULT_COLOR,
111
- getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH
246
+ data: lines,
247
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
248
+ modelMatrix,
249
+ getPath: d => d.vertices,
250
+ getColor: d => d.contour.color ?? DEFAULT_COLOR,
251
+ getWidth: d => d.contour.strokeWidth ?? DEFAULT_STROKE_WIDTH,
252
+ widthUnits: 'pixels'
112
253
  });
113
254
  // Contour bands layer
114
- const bandsLayer = contourPolygons &&
115
- contourPolygons.length > 0 &&
255
+ const bandsLayer = polygons &&
256
+ polygons.length > 0 &&
116
257
  new BandsSubLayerClass(this.getSubLayerProps({
117
258
  id: 'bands'
118
259
  }), {
119
- data: this.state.contourData.contourPolygons,
260
+ data: polygons,
261
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
262
+ modelMatrix,
120
263
  getPolygon: d => d.vertices,
121
- getFillColor: d => d.contour.color || DEFAULT_COLOR
264
+ getFillColor: d => d.contour.color ?? DEFAULT_COLOR
122
265
  });
123
266
  return [lineLayer, bandsLayer];
124
267
  }
125
- // Aggregation Overrides
126
- /* eslint-disable max-statements, complexity */
127
- updateAggregationState(opts) {
128
- const { props, oldProps } = opts;
129
- const { cellSize, coordinateSystem } = props;
130
- const { viewport } = this.context;
131
- const cellSizeChanged = oldProps.cellSize !== cellSize;
132
- let gpuAggregation = props.gpuAggregation;
133
- if (this.state.gpuAggregation !== props.gpuAggregation) {
134
- if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
135
- log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
136
- gpuAggregation = false;
137
- }
138
- }
139
- const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
140
- this.setState({
141
- gpuAggregation
142
- });
143
- const { dimensions } = this.state;
144
- const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
145
- const { data, weights } = dimensions;
146
- let { boundingBox } = this.state;
147
- if (positionsChanged) {
148
- boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
149
- this.setState({ boundingBox });
150
- }
151
- if (positionsChanged || cellSizeChanged) {
152
- const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
153
- this.allocateResources(numRow, numCol);
154
- this.setState({
155
- gridOffset,
156
- boundingBox,
157
- translation,
158
- posOffset: translation.slice(), // Used for CPU aggregation, to offset points
159
- gridOrigin: [-1 * translation[0], -1 * translation[1]],
160
- width,
161
- height,
162
- numCol,
163
- numRow
164
- });
165
- }
166
- const aggregationDataDirty = positionsChanged ||
167
- gpuAggregationChanged ||
168
- this.isAggregationDirty(opts, {
169
- dimension: data,
170
- compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation
171
- });
172
- const aggregationWeightsDirty = this.isAggregationDirty(opts, {
173
- dimension: weights
174
- });
175
- if (aggregationWeightsDirty) {
176
- this._updateAccessors(opts);
177
- }
178
- if (aggregationDataDirty || aggregationWeightsDirty) {
179
- this._resetResults();
180
- }
181
- this.setState({
182
- aggregationDataDirty,
183
- aggregationWeightsDirty
184
- });
185
- }
186
- /* eslint-enable max-statements, complexity */
187
- // Private (Aggregation)
188
- _updateAccessors(opts) {
189
- const { getWeight, aggregation, data } = opts.props;
190
- const { count } = this.state.weights;
191
- if (count) {
192
- count.getWeight = getWeight;
193
- count.operation = AGGREGATION_OPERATION[aggregation];
194
- }
195
- this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
196
- }
197
- _resetResults() {
198
- const { count } = this.state.weights;
199
- if (count) {
200
- count.aggregationData = null;
201
- }
202
- }
203
- // Private (Contours)
204
- _generateContours() {
205
- const { numCol, numRow, gridOrigin, gridOffset, thresholdData } = this.state;
206
- const { count } = this.state.weights;
207
- let { aggregationData } = count;
208
- if (!aggregationData) {
209
- // @ts-ignore
210
- aggregationData = count.aggregationBuffer.readSyncWebGL();
211
- count.aggregationData = aggregationData;
212
- }
213
- const { cellWeights } = GPUGridAggregator.getCellData({ countsData: aggregationData });
214
- const contourData = generateContours({
215
- thresholdData,
216
- cellWeights,
217
- gridSize: [numCol, numRow],
218
- gridOrigin,
219
- cellSize: [gridOffset.xOffset, gridOffset.yOffset]
220
- });
221
- // contourData contains both iso-lines and iso-bands if requested.
222
- this.setState({ contourData });
223
- }
224
- _updateThresholdData(props) {
225
- const { contours, zOffset } = props;
226
- const count = contours.length;
227
- const thresholdData = new Array(count);
228
- for (let i = 0; i < count; i++) {
229
- const contour = contours[i];
230
- thresholdData[i] = {
231
- contour,
232
- zIndex: contour.zIndex || i,
233
- zOffset
268
+ getPickingInfo(params) {
269
+ const info = params.info;
270
+ const { object } = info;
271
+ if (object) {
272
+ info.object = {
273
+ contour: object.contour
234
274
  };
235
275
  }
236
- this.setState({ thresholdData });
276
+ return info;
237
277
  }
238
278
  }
239
- ContourLayer.layerName = 'ContourLayer';
240
- ContourLayer.defaultProps = defaultProps;
241
- export default ContourLayer;
279
+ GridLayer.layerName = 'ContourLayer';
280
+ GridLayer.defaultProps = defaultProps;
281
+ export default GridLayer;
282
+ //# sourceMappingURL=contour-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contour-layer.js","sourceRoot":"","sources":["../../src/contour-layer/contour-layer.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAEL,iBAAiB,EAEjB,SAAS,EAIT,QAAQ,EACR,UAAU,EAGX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAE,aAAa,EAAuB,sCAAmC;AAChG,OAAO,gBAAgB,uCAAoC;AAE3D,OAAO,EAAC,gBAAgB,EAAuC,2BAAwB;AACvF,OAAO,EAAC,wBAAwB,EAAC,0BAAuB;AACxD,OAAO,EAAC,aAAa,EAAC,wCAAqC;AAC3D,OAAO,EAAC,OAAO,EAAC,M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,CAAC,CAAC,QAAQ;gBACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,aAAa;gBAC/C,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,oBAAoB;gBAC5D,UAAU,EAAE,QAAQ;aACrB,CACF,CAAC;QAEJ,sBAAsB;QACtB,MAAM,UAAU,GACd,QAAQ;YACR,QAAQ,CAAC,MAAM,GAAG,CAAC;YACnB,IAAI,kBAAkB,CACpB,IAAI,CAAC,gBAAgB,CAAC;gBACpB,EAAE,EAAE,OAAO;aACZ,CAAC,EACF;gBACE,IAAI,EAAE,QAAQ;gBACd,gBAAgB,EAAE,iBAAiB,CAAC,SAAS;gBAC7C,WAAW;gBACX,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;gBAC3B,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,aAAa;aACpD,CACF,CAAC;QAEJ,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,cAAc,CAAC,MAA4B;QACzC,MAAM,IAAI,GAA4B,MAAM,CAAC,IAAI,CAAC;QAClD,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;QACtB,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,GAAG;gBACZ,OAAO,EAAG,MAAuC,CAAC,OAAO;aAC1D,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;;AA/SM,mBAAS,GAAG,cAAc,CAAC;AAC3B,sBAAY,GAAG,YAAY,CAAC;eALhB,SAAS"}
@@ -1,18 +1,39 @@
1
- export declare function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }: {
2
- thresholdData: any;
3
- cellWeights: Float32Array;
4
- gridSize: number[];
5
- gridOrigin: number[];
6
- cellSize: number[];
1
+ import type { Color } from '@deck.gl/core';
2
+ export type Contour = {
3
+ /**
4
+ * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.
5
+ *
6
+ * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.
7
+ */
8
+ threshold: number | number[];
9
+ /**
10
+ * RGBA color array to be used to render the contour.
11
+ * @default [255, 255, 255, 255]
12
+ */
13
+ color?: Color;
14
+ /**
15
+ * Applicable for `Isoline`s only, width of the Isoline in pixels.
16
+ * @default 1
17
+ */
18
+ strokeWidth?: number;
19
+ /** Defines z order of the contour. */
20
+ zIndex?: number;
21
+ };
22
+ export type ContourLine = {
23
+ vertices: number[][];
24
+ contour: Contour;
25
+ };
26
+ export type ContourPolygon = {
27
+ vertices: number[][];
28
+ contour: Contour;
29
+ };
30
+ export declare function generateContours({ contours, getValue, xRange, yRange }: {
31
+ contours: Contour[];
32
+ getValue: (x: number, y: number) => number;
33
+ xRange: [number, number];
34
+ yRange: [number, number];
7
35
  }): {
8
- contourSegments: {
9
- start: number[];
10
- end: number[];
11
- contour: any;
12
- }[];
13
- contourPolygons: {
14
- vertices: number[][];
15
- contour: any;
16
- }[];
36
+ lines: ContourLine[];
37
+ polygons: ContourPolygon[];
17
38
  };
18
39
  //# sourceMappingURL=contour-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contour-utils.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,EAC/B,aAAa,EACb,WAAW,EACX,QAAQ,EACR,UAAU,EACV,QAAQ,EACT,EAAE;IACD,aAAa,EAAE,GAAG,CAAC;IACnB,WAAW,EAAE,YAAY,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;;eACgC,MAAM,EAAE;aAAO,MAAM,EAAE;iBAAW,GAAG;;;kBAClC,MAAM,EAAE,EAAE;iBAAW,GAAG;;EAyD3D"}
1
+ {"version":3,"file":"contour-utils.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAGzC,MAAM,MAAM,OAAO,GAAG;IACpB;;;;OAIG;IACH,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAIF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACP,EAAE;IACD,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1B;;;EAmDA"}
@@ -1,42 +1,39 @@
1
- import { getCode, getVertices, CONTOUR_TYPE } from "./marching-squares.js";
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { getCode, getLines, getPolygons } from "./marching-squares.js";
2
5
  // Given all the cell weights, generates contours for each threshold.
3
6
  /* eslint-disable max-depth */
4
- export function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }) {
5
- const contourSegments = [];
7
+ export function generateContours({ contours, getValue, xRange, yRange }) {
8
+ const contourLines = [];
6
9
  const contourPolygons = [];
7
- const width = gridSize[0];
8
- const height = gridSize[1];
9
10
  let segmentIndex = 0;
10
11
  let polygonIndex = 0;
11
- for (const data of thresholdData) {
12
- const { contour } = data;
12
+ for (let i = 0; i < contours.length; i++) {
13
+ const contour = contours[i];
14
+ const z = contour.zIndex ?? i;
13
15
  const { threshold } = contour;
14
- for (let x = -1; x < width; x++) {
15
- for (let y = -1; y < height; y++) {
16
+ for (let x = xRange[0] - 1; x < xRange[1]; x++) {
17
+ for (let y = yRange[0] - 1; y < yRange[1]; y++) {
16
18
  // Get the MarchingSquares code based on neighbor cell weights.
17
19
  const { code, meanCode } = getCode({
18
- cellWeights,
20
+ getValue,
19
21
  threshold,
20
22
  x,
21
23
  y,
22
- width,
23
- height
24
+ xRange,
25
+ yRange
24
26
  });
25
27
  const opts = {
26
- type: CONTOUR_TYPE.ISO_BANDS,
27
- gridOrigin,
28
- cellSize,
29
28
  x,
30
29
  y,
31
- width,
32
- height,
30
+ z,
33
31
  code,
34
- meanCode,
35
- thresholdData: data
32
+ meanCode
36
33
  };
37
34
  if (Array.isArray(threshold)) {
38
- opts.type = CONTOUR_TYPE.ISO_BANDS;
39
- const polygons = getVertices(opts);
35
+ // ISO bands
36
+ const polygons = getPolygons(opts);
40
37
  for (const polygon of polygons) {
41
38
  contourPolygons[polygonIndex++] = {
42
39
  vertices: polygon,
@@ -45,13 +42,11 @@ export function generateContours({ thresholdData, cellWeights, gridSize, gridOri
45
42
  }
46
43
  }
47
44
  else {
48
- // Get the intersection vertices based on MarchingSquares code.
49
- opts.type = CONTOUR_TYPE.ISO_LINES;
50
- const vertices = getVertices(opts);
51
- for (let i = 0; i < vertices.length; i += 2) {
52
- contourSegments[segmentIndex++] = {
53
- start: vertices[i],
54
- end: vertices[i + 1],
45
+ // ISO lines
46
+ const path = getLines(opts);
47
+ if (path.length > 0) {
48
+ contourLines[segmentIndex++] = {
49
+ vertices: path,
55
50
  contour
56
51
  };
57
52
  }
@@ -59,6 +54,7 @@ export function generateContours({ thresholdData, cellWeights, gridSize, gridOri
59
54
  }
60
55
  }
61
56
  }
62
- return { contourSegments, contourPolygons };
57
+ return { lines: contourLines, polygons: contourPolygons };
63
58
  }
64
59
  /* eslint-enable max-depth */
60
+ //# sourceMappingURL=contour-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contour-utils.js","sourceRoot":"","sources":["../../src/contour-layer/contour-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAC,8BAA2B;AAoClE,qEAAqE;AACrE,8BAA8B;AAC9B,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EAMP;IACC,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,eAAe,GAAqB,EAAE,CAAC;IAC7C,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QAC9B,MAAM,EAAC,SAAS,EAAC,GAAG,OAAO,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,G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