@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,67 @@
1
+ // Copyright (c) 2015 - 2019 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import GL from '@luma.gl/constants';
21
+ import { Model, Geometry } from '@luma.gl/core';
22
+ import { Layer, project32 } from '@deck.gl/core';
23
+ import vs from './triangle-layer-vertex.glsl';
24
+ import fs from './triangle-layer-fragment.glsl';
25
+ export default class TriangleLayer extends Layer {
26
+ getShaders() {
27
+ return { vs, fs, modules: [project32] };
28
+ }
29
+ initializeState({ gl }) {
30
+ const attributeManager = this.getAttributeManager();
31
+ attributeManager.add({
32
+ positions: { size: 3, noAlloc: true },
33
+ texCoords: { size: 2, noAlloc: true }
34
+ });
35
+ this.setState({
36
+ model: this._getModel(gl)
37
+ });
38
+ }
39
+ _getModel(gl) {
40
+ const { vertexCount } = this.props;
41
+ return new Model(gl, {
42
+ ...this.getShaders(),
43
+ id: this.props.id,
44
+ geometry: new Geometry({
45
+ drawMode: GL.TRIANGLE_FAN,
46
+ vertexCount
47
+ })
48
+ });
49
+ }
50
+ draw({ uniforms }) {
51
+ const { model } = this.state;
52
+ const { texture, maxTexture, colorTexture, intensity, threshold, aggregationMode, colorDomain } = this.props;
53
+ model
54
+ .setUniforms({
55
+ ...uniforms,
56
+ texture,
57
+ maxTexture,
58
+ colorTexture,
59
+ intensity,
60
+ threshold,
61
+ aggregationMode,
62
+ colorDomain
63
+ })
64
+ .draw();
65
+ }
66
+ }
67
+ TriangleLayer.layerName = 'TriangleLayer';
@@ -0,0 +1,3 @@
1
+ declare const _default: "varying vec4 weightsTexture;\n// Epanechnikov function, keeping for reference\n// float epanechnikovKDE(float u) {\n// return 0.75 * (1.0 - u * u);\n// }\nfloat gaussianKDE(float u){\n return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);\n}\nvoid main()\n{\n float dist = length(gl_PointCoord - vec2(0.5, 0.5));\n if (dist > 0.5) {\n discard;\n }\n gl_FragColor = weightsTexture * gaussianKDE(2. * dist);\n DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n";
2
+ export default _default;
3
+ //# sourceMappingURL=weights-fs.glsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weights-fs.glsl.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/weights-fs.glsl.ts"],"names":[],"mappings":";AAAA,wBAkBE"}
@@ -0,0 +1,19 @@
1
+ export default `\
2
+ varying vec4 weightsTexture;
3
+ // Epanechnikov function, keeping for reference
4
+ // float epanechnikovKDE(float u) {
5
+ // return 0.75 * (1.0 - u * u);
6
+ // }
7
+ float gaussianKDE(float u){
8
+ return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);
9
+ }
10
+ void main()
11
+ {
12
+ float dist = length(gl_PointCoord - vec2(0.5, 0.5));
13
+ if (dist > 0.5) {
14
+ discard;
15
+ }
16
+ gl_FragColor = weightsTexture * gaussianKDE(2. * dist);
17
+ DECKGL_FILTER_COLOR(gl_FragColor, geometry);
18
+ }
19
+ `;
@@ -0,0 +1,3 @@
1
+ declare const _default: "attribute vec3 positions;\nattribute vec3 positions64Low;\nattribute float weights;\nvarying vec4 weightsTexture;\nuniform float radiusPixels;\nuniform float textureWidth;\nuniform vec4 commonBounds;\nuniform float weightsScale;\nvoid main()\n{\n weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);\n\n float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);\n gl_PointSize = radiusTexels * 2.;\n\n vec3 commonPosition = project_position(positions, positions64Low);\n\n // map xy from commonBounds to [-1, 1]\n gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;\n gl_Position.xy = (gl_Position.xy * 2.) - (1.);\n}\n";
2
+ export default _default;
3
+ //# sourceMappingURL=weights-vs.glsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weights-vs.glsl.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/weights-vs.glsl.ts"],"names":[],"mappings":";AAAA,wBAsBE"}
@@ -0,0 +1,23 @@
1
+ export default `\
2
+ attribute vec3 positions;
3
+ attribute vec3 positions64Low;
4
+ attribute float weights;
5
+ varying vec4 weightsTexture;
6
+ uniform float radiusPixels;
7
+ uniform float textureWidth;
8
+ uniform vec4 commonBounds;
9
+ uniform float weightsScale;
10
+ void main()
11
+ {
12
+ weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);
13
+
14
+ float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);
15
+ gl_PointSize = radiusTexels * 2.;
16
+
17
+ vec3 commonPosition = project_position(positions, positions64Low);
18
+
19
+ // map xy from commonBounds to [-1, 1]
20
+ gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;
21
+ gl_Position.xy = (gl_Position.xy * 2.) - (1.);
22
+ }
23
+ `;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Use d3-hexbin to performs hexagonal binning from geo points to hexagons
3
+ * @param {Iterable} data - array of points
4
+ * @param {Number} radius - hexagon radius in meter
5
+ * @param {function} getPosition - get points lon lat
6
+ * @param {Object} viewport - current viewport object
7
+
8
+ * @return {Object} - hexagons and countRange
9
+ */
10
+ export function pointToHexbin(props: any, aggregationParams: any): any;
11
+ /**
12
+ * Get the bounding box of all data points
13
+ */
14
+ export function getPointsCenter(data: any, aggregationParams: any): number[] | null;
15
+ /**
16
+ * Get radius in mercator world space coordinates from meter
17
+ * @param {Number} radius - in meter
18
+ * @param {Object} viewport - current viewport object
19
+ * @param {Array<Number>} center - data center
20
+
21
+ * @return {Number} radius in mercator world spcae coordinates
22
+ */
23
+ export function getRadiusInCommon(radius: number, viewport: any, center: Array<number>): number;
24
+ //# sourceMappingURL=hexagon-aggregator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexagon-aggregator.d.ts","sourceRoot":"","sources":["../../src/hexagon-layer/hexagon-aggregator.js"],"names":[],"mappings":"AAuBA;;;;;;;;GAQG;AACH,uEA2CC;AAED;;GAEG;AACH,oFA4BC;AAED;;;;;;;GAOG;AACH,yEAJW,aAAa,UAQvB"}
@@ -0,0 +1,112 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { hexbin } from 'd3-hexbin';
21
+ import { createIterable, log } from '@deck.gl/core';
22
+ /**
23
+ * Use d3-hexbin to performs hexagonal binning from geo points to hexagons
24
+ * @param {Iterable} data - array of points
25
+ * @param {Number} radius - hexagon radius in meter
26
+ * @param {function} getPosition - get points lon lat
27
+ * @param {Object} viewport - current viewport object
28
+
29
+ * @return {Object} - hexagons and countRange
30
+ */
31
+ export function pointToHexbin(props, aggregationParams) {
32
+ const { data, radius } = props;
33
+ const { viewport, attributes } = aggregationParams;
34
+ // get hexagon radius in mercator world unit
35
+ const centerLngLat = data.length ? getPointsCenter(data, aggregationParams) : null;
36
+ const radiusCommon = getRadiusInCommon(radius, viewport, centerLngLat);
37
+ // add world space coordinates to points
38
+ const screenPoints = [];
39
+ const { iterable, objectInfo } = createIterable(data);
40
+ const positions = attributes.positions.value;
41
+ const { size } = attributes.positions.getAccessor();
42
+ for (const object of iterable) {
43
+ objectInfo.index++;
44
+ const posIndex = objectInfo.index * size;
45
+ const position = [positions[posIndex], positions[posIndex + 1]];
46
+ const arrayIsFinite = Number.isFinite(position[0]) && Number.isFinite(position[1]);
47
+ if (arrayIsFinite) {
48
+ screenPoints.push({
49
+ screenCoord: viewport.projectFlat(position),
50
+ source: object,
51
+ index: objectInfo.index
52
+ });
53
+ }
54
+ else {
55
+ log.warn('HexagonLayer: invalid position')();
56
+ }
57
+ }
58
+ const newHexbin = hexbin()
59
+ .radius(radiusCommon)
60
+ .x(d => d.screenCoord[0])
61
+ .y(d => d.screenCoord[1]);
62
+ const hexagonBins = newHexbin(screenPoints);
63
+ return {
64
+ hexagons: hexagonBins.map((hex, index) => ({
65
+ position: viewport.unprojectFlat([hex.x, hex.y]),
66
+ points: hex,
67
+ index
68
+ })),
69
+ radiusCommon
70
+ };
71
+ }
72
+ /**
73
+ * Get the bounding box of all data points
74
+ */
75
+ export function getPointsCenter(data, aggregationParams) {
76
+ const { attributes } = aggregationParams;
77
+ const positions = attributes.positions.value;
78
+ const { size } = attributes.positions.getAccessor();
79
+ let minX = Infinity;
80
+ let minY = Infinity;
81
+ let maxX = -Infinity;
82
+ let maxY = -Infinity;
83
+ let i;
84
+ for (i = 0; i < size * data.length; i += size) {
85
+ const x = positions[i];
86
+ const y = positions[i + 1];
87
+ const arrayIsFinite = Number.isFinite(x) && Number.isFinite(y);
88
+ if (arrayIsFinite) {
89
+ minX = Math.min(x, minX);
90
+ maxX = Math.max(x, maxX);
91
+ minY = Math.min(y, minY);
92
+ maxY = Math.max(y, maxY);
93
+ }
94
+ }
95
+ // return center
96
+ return [minX, minY, maxX, maxY].every(Number.isFinite)
97
+ ? [(minX + maxX) / 2, (minY + maxY) / 2]
98
+ : null;
99
+ }
100
+ /**
101
+ * Get radius in mercator world space coordinates from meter
102
+ * @param {Number} radius - in meter
103
+ * @param {Object} viewport - current viewport object
104
+ * @param {Array<Number>} center - data center
105
+
106
+ * @return {Number} radius in mercator world spcae coordinates
107
+ */
108
+ export function getRadiusInCommon(radius, viewport, center) {
109
+ const { unitsPerMeter } = viewport.getDistanceScales(center);
110
+ // x, y distance should be the same
111
+ return radius * unitsPerMeter[0];
112
+ }
@@ -0,0 +1,165 @@
1
+ import { Accessor, AccessorFunction, Color, Position, Material, UpdateParameters, DefaultProps } from '@deck.gl/core/typed';
2
+ import { ColumnLayer } from '@deck.gl/layers/typed';
3
+ import CPUAggregator from '../utils/cpu-aggregator';
4
+ import AggregationLayer, { AggregationLayerProps } from '../aggregation-layer';
5
+ import { AggregateAccessor } from '../types';
6
+ /** All properties supported by by HexagonLayer. */
7
+ export declare type HexagonLayerProps<DataT = any> = _HexagonLayerProps<DataT> & AggregationLayerProps<DataT>;
8
+ /** Properties added by HexagonLayer. */
9
+ declare type _HexagonLayerProps<DataT = any> = {
10
+ /**
11
+ * Radius of hexagon bin in meters. The hexagons are pointy-topped (rather than flat-topped).
12
+ * @default 1000
13
+ */
14
+ radius?: number;
15
+ /**
16
+ * Function to aggregate data into hexagonal bins.
17
+ * @default d3-hexbin
18
+ */
19
+ hexagonAggregator?: (props: any, params: any) => any;
20
+ /**
21
+ * Color scale input domain.
22
+ * @default [min(colorWeight), max(colorWeight)]
23
+ */
24
+ colorDomain?: [number, number] | null;
25
+ /**
26
+ * Specified as an array of colors [color1, color2, ...].
27
+ * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)
28
+ */
29
+ colorRange?: Color[];
30
+ /**
31
+ * Hexagon radius multiplier, clamped between 0 - 1.
32
+ * @default 1
33
+ */
34
+ coverage?: number;
35
+ /**
36
+ * Elevation scale input domain. The elevation scale is a linear scale that maps number of counts to elevation.
37
+ * @default [0, max(elevationWeight)]
38
+ */
39
+ elevationDomain?: [number, number] | null;
40
+ /**
41
+ * Elevation scale output range.
42
+ * @default [0, 1000]
43
+ */
44
+ elevationRange?: [number, number];
45
+ /**
46
+ * Hexagon elevation multiplier.
47
+ * @default 1
48
+ */
49
+ elevationScale?: number;
50
+ /**
51
+ * Whether to enable cell elevation. If set to false, all cell will be flat.
52
+ * @default false
53
+ */
54
+ extruded?: boolean;
55
+ /**
56
+ * Filter bins and re-calculate color by `upperPercentile`.
57
+ * Hexagons with color value larger than the `upperPercentile` will be hidden.
58
+ * @default 100
59
+ */
60
+ upperPercentile?: number;
61
+ /**
62
+ * Filter bins and re-calculate color by `lowerPercentile`.
63
+ * Hexagons with color value smaller than the `lowerPercentile` will be hidden.
64
+ * @default 0
65
+ */
66
+ lowerPercentile?: number;
67
+ /**
68
+ * Filter bins and re-calculate elevation by `elevationUpperPercentile`.
69
+ * Hexagons with elevation value larger than the `elevationUpperPercentile` will be hidden.
70
+ * @default 100
71
+ */
72
+ elevationUpperPercentile?: number;
73
+ /**
74
+ * Filter bins and re-calculate elevation by `elevationLowerPercentile`.
75
+ * Hexagons with elevation value larger than the `elevationLowerPercentile` will be hidden.
76
+ * @default 0
77
+ */
78
+ elevationLowerPercentile?: number;
79
+ /**
80
+ * Scaling function used to determine the color of the grid cell, default value is 'quantize'.
81
+ * Supported Values are 'quantize', 'quantile' and 'ordinal'.
82
+ * @default 'quantize'
83
+ */
84
+ colorScaleType?: 'quantize' | 'quantile' | 'ordinal';
85
+ /**
86
+ * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.
87
+ */
88
+ elevationScaleType?: 'linear';
89
+ /**
90
+ * Material settings for lighting effect. Applies if `extruded: true`.
91
+ *
92
+ * @default true
93
+ * @see https://deck.gl/docs/developer-guide/using-lighting
94
+ */
95
+ material?: Material;
96
+ /**
97
+ * Defines the operation used to aggregate all data object weights to calculate a cell's color value.
98
+ * @default 'SUM'
99
+ */
100
+ colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
101
+ /**
102
+ * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
103
+ * @default 'SUM'
104
+ */
105
+ elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
106
+ /**
107
+ * Method called to retrieve the position of each object.
108
+ * @default object => object.position
109
+ */
110
+ getPosition?: AccessorFunction<DataT, Position>;
111
+ /**
112
+ * The weight of a data object used to calculate the color value for a bin.
113
+ * @default 1
114
+ */
115
+ getColorWeight?: Accessor<DataT, number>;
116
+ /**
117
+ * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its color is based on.
118
+ * @default null
119
+ */
120
+ getColorValue?: AggregateAccessor<DataT> | null;
121
+ /**
122
+ * The weight of a data object used to calculate the elevation value for a bin.
123
+ * @default 1
124
+ */
125
+ getElevationWeight?: Accessor<DataT, number>;
126
+ /**
127
+ * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its elevation is based on.
128
+ * @default null
129
+ */
130
+ getElevationValue?: AggregateAccessor<DataT> | null;
131
+ /**
132
+ * This callback will be called when cell color domain has been calculated.
133
+ * @default () => {}
134
+ */
135
+ onSetColorDomain?: (minMax: [number, number]) => void;
136
+ /**
137
+ * This callback will be called when cell elevation domain has been calculated.
138
+ * @default () => {}
139
+ */
140
+ onSetElevationDomain?: (minMax: [number, number]) => void;
141
+ /**
142
+ * (Experimental) Filter data objects
143
+ */
144
+ _filterData: null | ((d: DataT) => boolean);
145
+ };
146
+ export default class HexagonLayer<ExtraPropsT = {}> extends AggregationLayer<ExtraPropsT & Required<_HexagonLayerProps>> {
147
+ static layerName: string;
148
+ static defaultProps: DefaultProps<HexagonLayerProps<any>>;
149
+ state: AggregationLayer['state'] & {
150
+ cpuAggregator: CPUAggregator;
151
+ aggregatorState: any;
152
+ };
153
+ initializeState(): void;
154
+ updateState(opts: UpdateParameters<this>): void;
155
+ convertLatLngToMeterOffset(hexagonVertices: any): number[][] | null;
156
+ getPickingInfo({ info }: {
157
+ info: any;
158
+ }): any;
159
+ _onGetSublayerColor(cell: any): any;
160
+ _onGetSublayerElevation(cell: any): any;
161
+ _getSublayerUpdateTriggers(): {};
162
+ renderLayers(): ColumnLayer<any, {}>;
163
+ }
164
+ export {};
165
+ //# sourceMappingURL=hexagon-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexagon-layer.d.ts","sourceRoot":"","sources":["../../src/hexagon-layer/hexagon-layer.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,171 @@
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 { log } from '@deck.gl/core';
21
+ import { ColumnLayer } from '@deck.gl/layers';
22
+ import { defaultColorRange } from '../utils/color-utils';
23
+ import { pointToHexbin } from './hexagon-aggregator';
24
+ import CPUAggregator from '../utils/cpu-aggregator';
25
+ import AggregationLayer from '../aggregation-layer';
26
+ import GL from '@luma.gl/constants';
27
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
28
+ function nop() { }
29
+ const defaultProps = {
30
+ // color
31
+ colorDomain: null,
32
+ colorRange: defaultColorRange,
33
+ getColorValue: { type: 'accessor', value: null },
34
+ getColorWeight: { type: 'accessor', value: 1 },
35
+ colorAggregation: 'SUM',
36
+ lowerPercentile: { type: 'number', value: 0, min: 0, max: 100 },
37
+ upperPercentile: { type: 'number', value: 100, min: 0, max: 100 },
38
+ colorScaleType: 'quantize',
39
+ onSetColorDomain: nop,
40
+ // elevation
41
+ elevationDomain: null,
42
+ elevationRange: [0, 1000],
43
+ getElevationValue: { type: 'accessor', value: null },
44
+ getElevationWeight: { type: 'accessor', value: 1 },
45
+ elevationAggregation: 'SUM',
46
+ elevationLowerPercentile: { type: 'number', value: 0, min: 0, max: 100 },
47
+ elevationUpperPercentile: { type: 'number', value: 100, min: 0, max: 100 },
48
+ elevationScale: { type: 'number', min: 0, value: 1 },
49
+ elevationScaleType: 'linear',
50
+ onSetElevationDomain: nop,
51
+ radius: { type: 'number', value: 1000, min: 1 },
52
+ coverage: { type: 'number', min: 0, max: 1, value: 1 },
53
+ extruded: false,
54
+ hexagonAggregator: pointToHexbin,
55
+ getPosition: { type: 'accessor', value: x => x.position },
56
+ // Optional material for 'lighting' shader module
57
+ material: true,
58
+ // data filter
59
+ _filterData: { type: 'function', value: null, optional: true }
60
+ };
61
+ export default class HexagonLayer extends AggregationLayer {
62
+ initializeState() {
63
+ const cpuAggregator = new CPUAggregator({
64
+ getAggregator: props => props.hexagonAggregator,
65
+ getCellSize: props => props.radius
66
+ });
67
+ this.state = {
68
+ cpuAggregator,
69
+ aggregatorState: cpuAggregator.state,
70
+ vertices: null
71
+ };
72
+ const attributeManager = this.getAttributeManager();
73
+ attributeManager.add({
74
+ positions: { size: 3, type: GL.DOUBLE, accessor: 'getPosition' }
75
+ });
76
+ // color and elevation attributes can't be added as attributes
77
+ // they are calculated using 'getValue' accessor that takes an array of pints.
78
+ }
79
+ updateState(opts) {
80
+ super.updateState(opts);
81
+ if (opts.changeFlags.propsOrDataChanged) {
82
+ const aggregatorState = this.state.cpuAggregator.updateState(opts, {
83
+ viewport: this.context.viewport,
84
+ attributes: this.getAttributes()
85
+ });
86
+ if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
87
+ // if user provided custom aggregator and returns hexagonVertices,
88
+ // Need to recalculate radius and angle based on vertices
89
+ const { hexagonVertices } = aggregatorState.layerData || {};
90
+ this.setState({
91
+ vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
92
+ });
93
+ }
94
+ this.setState({
95
+ // make a copy of the internal state of cpuAggregator for testing
96
+ aggregatorState
97
+ });
98
+ }
99
+ }
100
+ convertLatLngToMeterOffset(hexagonVertices) {
101
+ const { viewport } = this.context;
102
+ if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {
103
+ // get centroid of hexagons
104
+ const vertex0 = hexagonVertices[0];
105
+ const vertex3 = hexagonVertices[3];
106
+ const centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];
107
+ const centroidFlat = viewport.projectFlat(centroid);
108
+ const { metersPerUnit } = viewport.getDistanceScales(centroid);
109
+ // offset all points by centroid to meter offset
110
+ const vertices = hexagonVertices.map(vt => {
111
+ const vtFlat = viewport.projectFlat(vt);
112
+ return [
113
+ (vtFlat[0] - centroidFlat[0]) * metersPerUnit[0],
114
+ (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]
115
+ ];
116
+ });
117
+ return vertices;
118
+ }
119
+ log.error('HexagonLayer: hexagonVertices needs to be an array of 6 points')();
120
+ return null;
121
+ }
122
+ getPickingInfo({ info }) {
123
+ return this.state.cpuAggregator.getPickingInfo({ info });
124
+ }
125
+ // create a method for testing
126
+ _onGetSublayerColor(cell) {
127
+ return this.state.cpuAggregator.getAccessor('fillColor')(cell);
128
+ }
129
+ // create a method for testing
130
+ _onGetSublayerElevation(cell) {
131
+ return this.state.cpuAggregator.getAccessor('elevation')(cell);
132
+ }
133
+ _getSublayerUpdateTriggers() {
134
+ return this.state.cpuAggregator.getUpdateTriggers(this.props);
135
+ }
136
+ renderLayers() {
137
+ const { elevationScale, extruded, coverage, material, transitions } = this.props;
138
+ const { aggregatorState, vertices } = this.state;
139
+ const SubLayerClass = this.getSubLayerClass('hexagon-cell', ColumnLayer);
140
+ const updateTriggers = this._getSublayerUpdateTriggers();
141
+ const geometry = vertices
142
+ ? { vertices, radius: 1 }
143
+ : {
144
+ // default geometry
145
+ radius: aggregatorState.layerData.radiusCommon || 1,
146
+ radiusUnits: 'common',
147
+ angle: 90
148
+ };
149
+ return new SubLayerClass({
150
+ ...geometry,
151
+ diskResolution: 6,
152
+ elevationScale,
153
+ extruded,
154
+ coverage,
155
+ material,
156
+ getFillColor: this._onGetSublayerColor.bind(this),
157
+ getElevation: this._onGetSublayerElevation.bind(this),
158
+ transitions: transitions && {
159
+ getFillColor: transitions.getColorValue || transitions.getColorWeight,
160
+ getElevation: transitions.getElevationValue || transitions.getElevationWeight
161
+ }
162
+ }, this.getSubLayerProps({
163
+ id: 'hexagon-cell',
164
+ updateTriggers
165
+ }), {
166
+ data: aggregatorState.layerData.data
167
+ });
168
+ }
169
+ }
170
+ HexagonLayer.layerName = 'HexagonLayer';
171
+ HexagonLayer.defaultProps = defaultProps;
@@ -0,0 +1,20 @@
1
+ export { default as ScreenGridLayer } from './screen-grid-layer/screen-grid-layer';
2
+ export { default as CPUGridLayer } from './cpu-grid-layer/cpu-grid-layer';
3
+ export { default as HexagonLayer } from './hexagon-layer/hexagon-layer';
4
+ export { default as ContourLayer } from './contour-layer/contour-layer';
5
+ export { default as GridLayer } from './grid-layer/grid-layer';
6
+ export { default as GPUGridLayer } from './gpu-grid-layer/gpu-grid-layer';
7
+ export { AGGREGATION_OPERATION } from './utils/aggregation-operation-utils';
8
+ export { default as HeatmapLayer } from './heatmap-layer/heatmap-layer';
9
+ export { default as _GPUGridAggregator } from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
10
+ export { default as _CPUAggregator } from './utils/cpu-aggregator';
11
+ export { default as _AggregationLayer } from './aggregation-layer';
12
+ export { default as _BinSorter } from './utils/bin-sorter';
13
+ export type { ContourLayerProps } from './contour-layer/contour-layer';
14
+ export type { HeatmapLayerProps } from './heatmap-layer/heatmap-layer';
15
+ export type { HexagonLayerProps } from './hexagon-layer/hexagon-layer';
16
+ export type { CPUGridLayerProps } from './cpu-grid-layer/cpu-grid-layer';
17
+ export type { GridLayerProps } from './grid-layer/grid-layer';
18
+ export type { GPUGridLayerProps } from './gpu-grid-layer/gpu-grid-layer';
19
+ export type { ScreenGridLayerProps } from './screen-grid-layer/screen-grid-layer';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAC,qBAAqB,EAAC,MAAM,qCAAqC,CAAC;AAG1E,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAGzD,YAAY,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AACvE,YAAY,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AACvE,YAAY,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAC"}