@deck.gl/aggregation-layers 9.0.0-beta.2 → 9.0.0-beta.4
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.
- package/dist/aggregation-layer.js +153 -0
- package/{typed → dist}/contour-layer/contour-layer.d.ts +1 -1
- package/dist/contour-layer/contour-layer.d.ts.map +1 -0
- package/dist/contour-layer/contour-layer.js +241 -0
- package/dist/contour-layer/contour-utils.js +64 -0
- package/dist/contour-layer/marching-squares-codes.js +337 -0
- package/dist/contour-layer/marching-squares.js +147 -0
- package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +3 -3
- package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -0
- package/dist/cpu-grid-layer/cpu-grid-layer.js +130 -0
- package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
- package/dist/dist.dev.js +1296 -13614
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
- package/dist/{esm/gpu-grid-layer → gpu-grid-layer}/gpu-grid-cell-layer-vertex.glsl.js +20 -1
- package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +1 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -0
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
- package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +3 -3
- package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -0
- package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
- package/{typed → dist}/grid-aggregation-layer.d.ts +3 -3
- package/dist/grid-aggregation-layer.d.ts.map +1 -0
- package/dist/grid-aggregation-layer.js +172 -0
- package/{typed → dist}/grid-layer/grid-layer.d.ts +2 -2
- package/dist/grid-layer/grid-layer.d.ts.map +1 -0
- package/dist/grid-layer/grid-layer.js +63 -0
- package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
- package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +1 -1
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
- package/dist/heatmap-layer/heatmap-layer.js +471 -0
- package/dist/{esm/heatmap-layer → heatmap-layer}/max-fs.glsl.js +0 -1
- package/dist/{esm/heatmap-layer → heatmap-layer}/max-vs.glsl.js +0 -1
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +61 -0
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +52 -0
- package/dist/heatmap-layer/triangle-layer.js +59 -0
- package/dist/{esm/heatmap-layer → heatmap-layer}/weights-fs.glsl.js +0 -1
- package/dist/{esm/heatmap-layer → heatmap-layer}/weights-vs.glsl.js +0 -1
- package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
- package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +3 -3
- package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-layer.js +174 -0
- package/dist/index.cjs +4494 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +166 -0
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +40 -0
- package/dist/{esm/screen-grid-layer → screen-grid-layer}/screen-grid-layer-vertex.glsl.js +19 -1
- package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer.js +216 -0
- package/dist/types.js +1 -0
- package/dist/utils/aggregation-operation-utils.js +94 -0
- package/dist/utils/bin-sorter.js +167 -0
- package/dist/utils/color-utils.js +53 -0
- package/dist/utils/cpu-aggregator.js +421 -0
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +34 -0
- package/dist/{esm/utils → utils}/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +19 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
- package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +566 -0
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +37 -0
- package/dist/utils/grid-aggregation-utils.js +114 -0
- package/dist/utils/prop-utils.js +28 -0
- package/dist/utils/resource-utils.js +38 -0
- package/dist/utils/scale-utils.js +184 -0
- package/dist.min.js +60 -174
- package/package.json +18 -11
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +10 -13
- package/dist/es5/aggregation-layer.js +0 -215
- package/dist/es5/aggregation-layer.js.map +0 -1
- package/dist/es5/contour-layer/contour-layer.js +0 -353
- package/dist/es5/contour-layer/contour-layer.js.map +0 -1
- package/dist/es5/contour-layer/contour-utils.js +0 -110
- package/dist/es5/contour-layer/contour-utils.js.map +0 -1
- package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
- package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
- package/dist/es5/contour-layer/marching-squares.js +0 -168
- package/dist/es5/contour-layer/marching-squares.js.map +0 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
- package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
- package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
- package/dist/es5/grid-aggregation-layer.js +0 -280
- package/dist/es5/grid-aggregation-layer.js.map +0 -1
- package/dist/es5/grid-layer/grid-layer.js +0 -125
- package/dist/es5/grid-layer/grid-layer.js.map +0 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -107
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +0 -678
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
- package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
- package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
- package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
- package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
- package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
- package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +0 -121
- package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
- package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
- package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
- package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
- package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
- package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
- package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
- package/dist/es5/index.js +0 -104
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
- package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
- package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/utils/aggregation-operation-utils.js +0 -123
- package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
- package/dist/es5/utils/bin-sorter.js +0 -248
- package/dist/es5/utils/bin-sorter.js.map +0 -1
- package/dist/es5/utils/color-utils.js +0 -39
- package/dist/es5/utils/color-utils.js.map +0 -1
- package/dist/es5/utils/cpu-aggregator.js +0 -496
- package/dist/es5/utils/cpu-aggregator.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
- package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
- package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
- package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
- package/dist/es5/utils/grid-aggregation-utils.js +0 -118
- package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
- package/dist/es5/utils/prop-utils.js +0 -19
- package/dist/es5/utils/prop-utils.js.map +0 -1
- package/dist/es5/utils/resource-utils.js +0 -59
- package/dist/es5/utils/resource-utils.js.map +0 -1
- package/dist/es5/utils/scale-utils.js +0 -254
- package/dist/es5/utils/scale-utils.js.map +0 -1
- package/dist/esm/aggregation-layer.js +0 -156
- package/dist/esm/aggregation-layer.js.map +0 -1
- package/dist/esm/contour-layer/contour-layer.js +0 -316
- package/dist/esm/contour-layer/contour-layer.js.map +0 -1
- package/dist/esm/contour-layer/contour-utils.js +0 -81
- package/dist/esm/contour-layer/contour-utils.js.map +0 -1
- package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
- package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
- package/dist/esm/contour-layer/marching-squares.js +0 -151
- package/dist/esm/contour-layer/marching-squares.js.map +0 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
- package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
- package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
- package/dist/esm/grid-aggregation-layer.js +0 -240
- package/dist/esm/grid-aggregation-layer.js.map +0 -1
- package/dist/esm/grid-layer/grid-layer.js +0 -80
- package/dist/esm/grid-layer/grid-layer.js.map +0 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -55
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +0 -638
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
- package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +0 -78
- package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
- package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
- package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
- package/dist/esm/index.js +0 -13
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
- package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/aggregation-operation-utils.js +0 -91
- package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
- package/dist/esm/utils/bin-sorter.js +0 -165
- package/dist/esm/utils/bin-sorter.js.map +0 -1
- package/dist/esm/utils/color-utils.js +0 -28
- package/dist/esm/utils/color-utils.js.map +0 -1
- package/dist/esm/utils/cpu-aggregator.js +0 -487
- package/dist/esm/utils/cpu-aggregator.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
- package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
- package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
- package/dist/esm/utils/grid-aggregation-utils.js +0 -109
- package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
- package/dist/esm/utils/prop-utils.js +0 -12
- package/dist/esm/utils/prop-utils.js.map +0 -1
- package/dist/esm/utils/resource-utils.js +0 -44
- package/dist/esm/utils/resource-utils.js.map +0 -1
- package/dist/esm/utils/scale-utils.js +0 -192
- package/dist/esm/utils/scale-utils.js.map +0 -1
- package/typed/contour-layer/contour-layer.d.ts.map +0 -1
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
- package/typed/grid-aggregation-layer.d.ts.map +0 -1
- package/typed/grid-layer/grid-layer.d.ts.map +0 -1
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +0 -1
- package/typed/index.d.ts +0 -20
- package/typed/index.d.ts.map +0 -1
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -1
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +0 -1
- /package/{typed → dist}/aggregation-layer.d.ts +0 -0
- /package/{typed → dist}/aggregation-layer.d.ts.map +0 -0
- /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
- /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
- /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
- /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
- /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
- /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
- /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
- /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
- /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
- /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
- /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
- /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/triangle-layer.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts +0 -0
- /package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
- /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
- /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
- /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
- /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
- /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
- /package/{typed → dist}/types.d.ts +0 -0
- /package/{typed → dist}/types.d.ts.map +0 -0
- /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
- /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/bin-sorter.d.ts +0 -0
- /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
- /package/{typed → dist}/utils/color-utils.d.ts +0 -0
- /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
- /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
- /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
- /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
- /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
- /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
- /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
- /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { default as ScreenGridLayer } from "./screen-grid-layer/screen-grid-layer.js";
|
|
2
|
+
export { default as CPUGridLayer } from "./cpu-grid-layer/cpu-grid-layer.js";
|
|
3
|
+
export { default as HexagonLayer } from "./hexagon-layer/hexagon-layer.js";
|
|
4
|
+
export { default as ContourLayer } from "./contour-layer/contour-layer.js";
|
|
5
|
+
export { default as GridLayer } from "./grid-layer/grid-layer.js";
|
|
6
|
+
export { default as GPUGridLayer } from "./gpu-grid-layer/gpu-grid-layer.js";
|
|
7
|
+
export { AGGREGATION_OPERATION } from "./utils/aggregation-operation-utils.js";
|
|
8
|
+
export { default as HeatmapLayer } from "./heatmap-layer/heatmap-layer.js";
|
|
9
|
+
export { default as _GPUGridAggregator } from "./utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
|
|
10
|
+
export { default as _CPUAggregator } from "./utils/cpu-aggregator.js";
|
|
11
|
+
export { default as _AggregationLayer } from "./aggregation-layer.js";
|
|
12
|
+
export { default as _BinSorter } from "./utils/bin-sorter.js";
|
|
13
|
+
export type { ContourLayerProps } from "./contour-layer/contour-layer.js";
|
|
14
|
+
export type { HeatmapLayerProps } from "./heatmap-layer/heatmap-layer.js";
|
|
15
|
+
export type { HexagonLayerProps } from "./hexagon-layer/hexagon-layer.js";
|
|
16
|
+
export type { CPUGridLayerProps } from "./cpu-grid-layer/cpu-grid-layer.js";
|
|
17
|
+
export type { GridLayerProps } from "./grid-layer/grid-layer.js";
|
|
18
|
+
export type { GPUGridLayerProps } from "./gpu-grid-layer/gpu-grid-layer.js";
|
|
19
|
+
export type { ScreenGridLayerProps } from "./screen-grid-layer/screen-grid-layer.js";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,iDAA8C;AACjF,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,2CAAwC;AACxE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,yCAAsC;AACtE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,yCAAsC;AACtE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,mCAAgC;AAC7D,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,2CAAwC;AACxE,OAAO,EAAC,qBAAqB,EAAC,+CAA4C;AAG1E,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,yCAAsC;AACtE,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,4DAAyD;AAC/F,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,kCAA+B;AACjE,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,+BAA4B;AACjE,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,8BAA2B;AAGzD,YAAY,EAAC,iBAAiB,EAAC,yCAAsC;AACrE,YAAY,EAAC,iBAAiB,EAAC,yCAAsC;AACrE,YAAY,EAAC,iBAAiB,EAAC,yCAAsC;AACrE,YAAY,EAAC,iBAAiB,EAAC,2CAAwC;AACvE,YAAY,EAAC,cAAc,EAAC,mCAAgC;AAC5D,YAAY,EAAC,iBAAiB,EAAC,2CAAwC;AACvE,YAAY,EAAC,oBAAoB,EAAC,iDAA8C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
export { default as ScreenGridLayer } from "./screen-grid-layer/screen-grid-layer.js";
|
|
21
|
+
export { default as CPUGridLayer } from "./cpu-grid-layer/cpu-grid-layer.js";
|
|
22
|
+
export { default as HexagonLayer } from "./hexagon-layer/hexagon-layer.js";
|
|
23
|
+
export { default as ContourLayer } from "./contour-layer/contour-layer.js";
|
|
24
|
+
export { default as GridLayer } from "./grid-layer/grid-layer.js";
|
|
25
|
+
export { default as GPUGridLayer } from "./gpu-grid-layer/gpu-grid-layer.js";
|
|
26
|
+
export { AGGREGATION_OPERATION } from "./utils/aggregation-operation-utils.js";
|
|
27
|
+
// experimental export
|
|
28
|
+
export { default as HeatmapLayer } from "./heatmap-layer/heatmap-layer.js";
|
|
29
|
+
export { default as _GPUGridAggregator } from "./utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
|
|
30
|
+
export { default as _CPUAggregator } from "./utils/cpu-aggregator.js";
|
|
31
|
+
export { default as _AggregationLayer } from "./aggregation-layer.js";
|
|
32
|
+
export { default as _BinSorter } from "./utils/bin-sorter.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Device, Texture } from '@luma.gl/core';
|
|
2
2
|
import { Model } from '@luma.gl/engine';
|
|
3
3
|
import { Layer, LayerProps, UpdateParameters, DefaultProps } from '@deck.gl/core';
|
|
4
|
-
import type { _ScreenGridLayerProps } from
|
|
4
|
+
import type { _ScreenGridLayerProps } from "./screen-grid-layer.js";
|
|
5
5
|
import { ShaderModule } from '@luma.gl/shadertools';
|
|
6
6
|
/** All properties supported by ScreenGridCellLayer. */
|
|
7
7
|
export type ScreenGridCellLayerProps<DataT = unknown> = _ScreenGridCellLayerProps<DataT> & LayerProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-cell-layer.d.ts","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-cell-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,KAAK,EAAW,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAE,UAAU,EAAgB,gBAAgB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAI9F,OAAO,KAAK,EAAC,qBAAqB,EAAC,+BAA4B;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAclD,uDAAuD;AACvD,MAAM,MAAM,wBAAwB,CAAC,KAAK,GAAG,OAAO,IAAI,yBAAyB,CAAC,KAAK,CAAC,GACtF,UAAU,CAAC;AAEb,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,CAAC,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC5E,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,mBAAmB,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,KAAK,CAC9F,WAAW,GAAG,QAAQ,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CACzD;IACC,MAAM,CAAC,SAAS,SAAyB;IACzC,MAAM,CAAC,YAAY,kDAAgB;IAEnC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM;IAIjC,KAAK,EAAG;QACN,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,CAAC;IAEF,UAAU,IAAI;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,YAAY,EAAE,CAAA;KAAC;IAI/D,eAAe;IAYf,iBAAiB,CAAC,EAAC,WAAW,EAAC;;KAAA;IAK/B,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAe1C,IAAI,CAAC,EAAC,QAAQ,EAAC;;KAAA;IA2Bf,0BAA0B,CAAC,SAAS,KAAA,EAAE,EAAC,YAAY,EAAC;;KAAA;IAkBpD,SAAS,IAAI,KAAK;IAsBlB,gBAAgB,IAAI,OAAO;IAe3B,eAAe,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,GAAG,IAAI;CA2BpD"}
|
|
@@ -0,0 +1,166 @@
|
|
|
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 { Model, Geometry } from '@luma.gl/engine';
|
|
21
|
+
import { Layer, log, picking } from '@deck.gl/core';
|
|
22
|
+
import { defaultColorRange, colorRangeToFlatArray } from "../utils/color-utils.js";
|
|
23
|
+
import vs from "./screen-grid-layer-vertex.glsl.js";
|
|
24
|
+
import fs from "./screen-grid-layer-fragment.glsl.js";
|
|
25
|
+
const DEFAULT_MINCOLOR = [0, 0, 0, 0];
|
|
26
|
+
const DEFAULT_MAXCOLOR = [0, 255, 0, 255];
|
|
27
|
+
const COLOR_PROPS = ['minColor', 'maxColor', 'colorRange', 'colorDomain'];
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
cellSizePixels: { type: 'number', value: 100, min: 1 },
|
|
30
|
+
cellMarginPixels: { type: 'number', value: 2, min: 0, max: 5 },
|
|
31
|
+
colorDomain: null,
|
|
32
|
+
colorRange: defaultColorRange
|
|
33
|
+
};
|
|
34
|
+
export default class ScreenGridCellLayer extends Layer {
|
|
35
|
+
static { this.layerName = 'ScreenGridCellLayer'; }
|
|
36
|
+
static { this.defaultProps = defaultProps; }
|
|
37
|
+
static isSupported(device) {
|
|
38
|
+
return device.features.has('texture-formats-float32-webgl1');
|
|
39
|
+
}
|
|
40
|
+
getShaders() {
|
|
41
|
+
return { vs, fs, modules: [picking] };
|
|
42
|
+
}
|
|
43
|
+
initializeState() {
|
|
44
|
+
const attributeManager = this.getAttributeManager();
|
|
45
|
+
attributeManager.addInstanced({
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
47
|
+
instancePositions: { size: 3, update: this.calculateInstancePositions },
|
|
48
|
+
instanceCounts: { size: 4, noAlloc: true }
|
|
49
|
+
});
|
|
50
|
+
this.setState({
|
|
51
|
+
model: this._getModel()
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
shouldUpdateState({ changeFlags }) {
|
|
55
|
+
// 'instanceCounts' buffer contetns change on viewport change.
|
|
56
|
+
return changeFlags.somethingChanged;
|
|
57
|
+
}
|
|
58
|
+
updateState(params) {
|
|
59
|
+
super.updateState(params);
|
|
60
|
+
const { oldProps, props, changeFlags } = params;
|
|
61
|
+
const attributeManager = this.getAttributeManager();
|
|
62
|
+
if (props.numInstances !== oldProps.numInstances) {
|
|
63
|
+
attributeManager.invalidateAll();
|
|
64
|
+
}
|
|
65
|
+
else if (oldProps.cellSizePixels !== props.cellSizePixels) {
|
|
66
|
+
attributeManager.invalidate('instancePositions');
|
|
67
|
+
}
|
|
68
|
+
this._updateUniforms(oldProps, props, changeFlags);
|
|
69
|
+
}
|
|
70
|
+
draw({ uniforms }) {
|
|
71
|
+
const { parameters, maxTexture } = this.props;
|
|
72
|
+
const minColor = this.props.minColor || DEFAULT_MINCOLOR;
|
|
73
|
+
const maxColor = this.props.maxColor || DEFAULT_MAXCOLOR;
|
|
74
|
+
// If colorDomain not specified we use default domain [1, maxCount]
|
|
75
|
+
// maxCount value will be sampled form maxTexture in vertex shader.
|
|
76
|
+
const colorDomain = this.props.colorDomain || [1, 0];
|
|
77
|
+
const model = this.state.model;
|
|
78
|
+
model.setUniforms(uniforms);
|
|
79
|
+
model.setBindings({
|
|
80
|
+
maxTexture
|
|
81
|
+
});
|
|
82
|
+
model.setUniforms({
|
|
83
|
+
minColor,
|
|
84
|
+
maxColor,
|
|
85
|
+
colorDomain
|
|
86
|
+
});
|
|
87
|
+
model.setParameters({
|
|
88
|
+
depthWriteEnabled: false,
|
|
89
|
+
// How to specify depth mask in WebGPU?
|
|
90
|
+
// depthMask: false,
|
|
91
|
+
...parameters
|
|
92
|
+
});
|
|
93
|
+
model.draw(this.context.renderPass);
|
|
94
|
+
}
|
|
95
|
+
calculateInstancePositions(attribute, { numInstances }) {
|
|
96
|
+
const { width, height } = this.context.viewport;
|
|
97
|
+
const { cellSizePixels } = this.props;
|
|
98
|
+
const numCol = Math.ceil(width / cellSizePixels);
|
|
99
|
+
const { value, size } = attribute;
|
|
100
|
+
for (let i = 0; i < numInstances; i++) {
|
|
101
|
+
const x = i % numCol;
|
|
102
|
+
const y = Math.floor(i / numCol);
|
|
103
|
+
value[i * size + 0] = ((x * cellSizePixels) / width) * 2 - 1;
|
|
104
|
+
value[i * size + 1] = 1 - ((y * cellSizePixels) / height) * 2;
|
|
105
|
+
value[i * size + 2] = 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Private Methods
|
|
109
|
+
_getModel() {
|
|
110
|
+
return new Model(this.context.device, {
|
|
111
|
+
...this.getShaders(),
|
|
112
|
+
id: this.props.id,
|
|
113
|
+
bufferLayout: this.getAttributeManager().getBufferLayouts(),
|
|
114
|
+
geometry: new Geometry({
|
|
115
|
+
topology: 'triangle-list',
|
|
116
|
+
attributes: {
|
|
117
|
+
// prettier-ignore
|
|
118
|
+
positions: new Float32Array([
|
|
119
|
+
0, 0, 0,
|
|
120
|
+
1, 0, 0,
|
|
121
|
+
1, 1, 0,
|
|
122
|
+
0, 0, 0,
|
|
123
|
+
1, 1, 0,
|
|
124
|
+
0, 1, 0,
|
|
125
|
+
])
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
_shouldUseMinMax() {
|
|
131
|
+
const { minColor, maxColor, colorDomain, colorRange } = this.props;
|
|
132
|
+
if (minColor || maxColor) {
|
|
133
|
+
log.deprecated('ScreenGridLayer props: minColor and maxColor', 'colorRange, colorDomain')();
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
// minColor and maxColor not supplied, check if colorRange or colorDomain supplied.
|
|
137
|
+
// NOTE: colorDomain and colorRange are experimental features, use them only when supplied.
|
|
138
|
+
if (colorDomain || colorRange) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
// None specified, use default minColor and maxColor
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
_updateUniforms(oldProps, props, changeFlags) {
|
|
145
|
+
const model = this.state.model;
|
|
146
|
+
if (COLOR_PROPS.some(key => oldProps[key] !== props[key])) {
|
|
147
|
+
model.setUniforms({ shouldUseMinMax: this._shouldUseMinMax() });
|
|
148
|
+
}
|
|
149
|
+
if (oldProps.colorRange !== props.colorRange) {
|
|
150
|
+
model.setUniforms({ colorRange: colorRangeToFlatArray(props.colorRange) });
|
|
151
|
+
}
|
|
152
|
+
if (oldProps.cellMarginPixels !== props.cellMarginPixels ||
|
|
153
|
+
oldProps.cellSizePixels !== props.cellSizePixels ||
|
|
154
|
+
changeFlags.viewportChanged) {
|
|
155
|
+
const { width, height } = this.context.viewport;
|
|
156
|
+
const { cellSizePixels, cellMarginPixels } = this.props;
|
|
157
|
+
const margin = cellSizePixels > cellMarginPixels ? cellMarginPixels : 0;
|
|
158
|
+
const cellScale = new Float32Array([
|
|
159
|
+
((cellSizePixels - margin) / width) * 2,
|
|
160
|
+
(-(cellSizePixels - margin) / height) * 2,
|
|
161
|
+
1
|
|
162
|
+
]);
|
|
163
|
+
model.setUniforms({ cellScale });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
/* fragment shader for the grid-layer */
|
|
21
|
+
export default `\
|
|
22
|
+
#version 300 es
|
|
23
|
+
#define SHADER_NAME screen-grid-layer-fragment-shader
|
|
24
|
+
|
|
25
|
+
precision highp float;
|
|
26
|
+
|
|
27
|
+
in vec4 vColor;
|
|
28
|
+
in float vSampleCount;
|
|
29
|
+
|
|
30
|
+
out vec4 fragColor;
|
|
31
|
+
|
|
32
|
+
void main(void) {
|
|
33
|
+
if (vSampleCount <= 0.0) {
|
|
34
|
+
discard;
|
|
35
|
+
}
|
|
36
|
+
fragColor = vColor;
|
|
37
|
+
|
|
38
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
@@ -1,3 +1,22 @@
|
|
|
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.
|
|
1
20
|
export default `\
|
|
2
21
|
#version 300 es
|
|
3
22
|
#define SHADER_NAME screen-grid-layer-vertex-shader
|
|
@@ -63,4 +82,3 @@ void main(void) {
|
|
|
63
82
|
gl_Position = vec4(instancePositions + positions * cellScale, 1.);
|
|
64
83
|
}
|
|
65
84
|
`;
|
|
66
|
-
//# sourceMappingURL=screen-grid-layer-vertex.glsl.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Accessor, Color, GetPickingInfoParams, Layer, LayerContext, LayersList, PickingInfo, Position, UpdateParameters, DefaultProps } from '@deck.gl/core';
|
|
2
2
|
import type { Buffer, Texture } from '@luma.gl/core';
|
|
3
|
-
import GridAggregationLayer, { GridAggregationLayerProps } from
|
|
3
|
+
import GridAggregationLayer, { GridAggregationLayerProps } from "../grid-aggregation-layer.js";
|
|
4
4
|
/** All properties supported by ScreenGridLayer. */
|
|
5
5
|
export type ScreenGridLayerProps<DataT = unknown> = _ScreenGridLayerProps<DataT> & GridAggregationLayerProps<DataT>;
|
|
6
6
|
/** Properties added by ScreenGridLayer. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-layer.d.ts","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,KAAK,EACL,YAAY,EACZ,UAAU,EAEV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAKnD,OAAO,oBAAoB,EAAE,EAAC,yBAAyB,EAAC,qCAAkC;AAuB1F,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAC9E,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAEnC,2CAA2C;AAC3C,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAExB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEtC;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;IAErB;;;;OAIG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAExC;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;CAC9C,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,OAAO,OAAO,eAAe,CAClC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,EAAE,GAAG,EAAE,CAC1B,SAAQ,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxF,MAAM,CAAC,SAAS,SAAqB;IACrC,MAAM,CAAC,YAAY,8CAAgB;IAEnC,KAAK,EAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG;QAC7C,SAAS,EAAE,OAAO,CAAC;QACnB,iBAAiB,CAAC,EAAE,GAAG,CAAC;QACxB,cAAc,CAAC,EAAE,GAAG,CAAC;QACrB,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,eAAe;IA2Cf,iBAAiB,CAAC,EAAC,WAAW,EAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAIvD,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAIxC,YAAY,IAAI,UAAU,GAAG,KAAK;IAuBlC,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAU1C,cAAc,CAAC,EAAC,IAAI,EAAC,EAAE,oBAAoB,GAAG,WAAW;IAsBzD,aAAa,CAAC,EAAC,eAAe,EAAE,OAAO,EAAC;;;KAAA;IASxC,sBAAsB,CAAC,IAAI,KAAA;IAiE3B,gBAAgB,CAAC,IAAI,KAAA;IAUrB,aAAa;CAMd"}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 { GL } from '@luma.gl/constants';
|
|
22
|
+
import GPUGridAggregator from "../utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
|
|
23
|
+
import { AGGREGATION_OPERATION, getValueFunc } from "../utils/aggregation-operation-utils.js";
|
|
24
|
+
import ScreenGridCellLayer from "./screen-grid-cell-layer.js";
|
|
25
|
+
import GridAggregationLayer from "../grid-aggregation-layer.js";
|
|
26
|
+
import { getFloatTexture } from "../utils/resource-utils.js";
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
...ScreenGridCellLayer.defaultProps,
|
|
29
|
+
getPosition: { type: 'accessor', value: (d) => d.position },
|
|
30
|
+
getWeight: { type: 'accessor', value: 1 },
|
|
31
|
+
gpuAggregation: false, // TODO(v9): Re-enable GPU aggregation.
|
|
32
|
+
aggregation: 'SUM'
|
|
33
|
+
};
|
|
34
|
+
const POSITION_ATTRIBUTE_NAME = 'positions';
|
|
35
|
+
const DIMENSIONS = {
|
|
36
|
+
data: {
|
|
37
|
+
props: ['cellSizePixels']
|
|
38
|
+
},
|
|
39
|
+
weights: {
|
|
40
|
+
props: ['aggregation'],
|
|
41
|
+
accessors: ['getWeight']
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/** Aggregates data into histogram bins and renders them as a grid. */
|
|
45
|
+
export default class ScreenGridLayer extends GridAggregationLayer {
|
|
46
|
+
static { this.layerName = 'ScreenGridLayer'; }
|
|
47
|
+
static { this.defaultProps = defaultProps; }
|
|
48
|
+
initializeState() {
|
|
49
|
+
if (!ScreenGridCellLayer.isSupported(this.context.device)) {
|
|
50
|
+
// max aggregated value is sampled from a float texture
|
|
51
|
+
this.setState({ supported: false });
|
|
52
|
+
log.error(`ScreenGridLayer: ${this.id} is not supported on this browser`)();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
super.initializeAggregationLayer({
|
|
56
|
+
dimensions: DIMENSIONS,
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
getCellSize: props => props.cellSizePixels // TODO
|
|
59
|
+
});
|
|
60
|
+
const weights = {
|
|
61
|
+
count: {
|
|
62
|
+
size: 1,
|
|
63
|
+
operation: AGGREGATION_OPERATION.SUM,
|
|
64
|
+
needMax: true,
|
|
65
|
+
maxTexture: getFloatTexture(this.context.device, { id: `${this.id}-max-texture` })
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
this.setState({
|
|
69
|
+
supported: true,
|
|
70
|
+
projectPoints: true, // aggregation in screen space
|
|
71
|
+
weights,
|
|
72
|
+
subLayerData: { attributes: {} },
|
|
73
|
+
maxTexture: weights.count.maxTexture,
|
|
74
|
+
positionAttributeName: 'positions',
|
|
75
|
+
posOffset: [0, 0],
|
|
76
|
+
translation: [1, -1]
|
|
77
|
+
});
|
|
78
|
+
const attributeManager = this.getAttributeManager();
|
|
79
|
+
attributeManager.add({
|
|
80
|
+
[POSITION_ATTRIBUTE_NAME]: {
|
|
81
|
+
size: 3,
|
|
82
|
+
accessor: 'getPosition',
|
|
83
|
+
type: GL.DOUBLE,
|
|
84
|
+
fp64: this.use64bitPositions()
|
|
85
|
+
},
|
|
86
|
+
// this attribute is used in gpu aggregation path only
|
|
87
|
+
count: { size: 3, accessor: 'getWeight' }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
shouldUpdateState({ changeFlags }) {
|
|
91
|
+
return this.state.supported && changeFlags.somethingChanged;
|
|
92
|
+
}
|
|
93
|
+
updateState(opts) {
|
|
94
|
+
super.updateState(opts);
|
|
95
|
+
}
|
|
96
|
+
renderLayers() {
|
|
97
|
+
if (!this.state.supported) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const { maxTexture, numRow, numCol, weights } = this.state;
|
|
101
|
+
const { updateTriggers } = this.props;
|
|
102
|
+
const { aggregationBuffer } = weights.count;
|
|
103
|
+
const CellLayerClass = this.getSubLayerClass('cells', ScreenGridCellLayer);
|
|
104
|
+
return new CellLayerClass(this.props, this.getSubLayerProps({
|
|
105
|
+
id: 'cell-layer',
|
|
106
|
+
updateTriggers
|
|
107
|
+
}), {
|
|
108
|
+
data: { attributes: { instanceCounts: aggregationBuffer } },
|
|
109
|
+
maxTexture,
|
|
110
|
+
numInstances: numRow * numCol
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
finalizeState(context) {
|
|
114
|
+
super.finalizeState(context);
|
|
115
|
+
const { aggregationBuffer, maxBuffer, maxTexture } = this.state;
|
|
116
|
+
aggregationBuffer?.delete();
|
|
117
|
+
maxBuffer?.delete();
|
|
118
|
+
maxTexture?.delete();
|
|
119
|
+
}
|
|
120
|
+
getPickingInfo({ info }) {
|
|
121
|
+
const { index } = info;
|
|
122
|
+
if (index >= 0) {
|
|
123
|
+
const { gpuGridAggregator, gpuAggregation, weights } = this.state;
|
|
124
|
+
// Get count aggregation results
|
|
125
|
+
const aggregationResults = gpuAggregation
|
|
126
|
+
? gpuGridAggregator.getData('count')
|
|
127
|
+
: weights.count;
|
|
128
|
+
// Each instance (one cell) is aggregated into single pixel,
|
|
129
|
+
// Get current instance's aggregation details.
|
|
130
|
+
info.object = GPUGridAggregator.getAggregationData({
|
|
131
|
+
pixelIndex: index,
|
|
132
|
+
...aggregationResults
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return info;
|
|
136
|
+
}
|
|
137
|
+
// Aggregation Overrides
|
|
138
|
+
updateResults({ aggregationData, maxData }) {
|
|
139
|
+
const { count } = this.state.weights;
|
|
140
|
+
count.aggregationData = aggregationData;
|
|
141
|
+
count.aggregationBuffer.write(aggregationData);
|
|
142
|
+
count.maxData = maxData;
|
|
143
|
+
count.maxTexture.setImageData({ data: maxData });
|
|
144
|
+
}
|
|
145
|
+
/* eslint-disable complexity, max-statements */
|
|
146
|
+
updateAggregationState(opts) {
|
|
147
|
+
const cellSize = opts.props.cellSizePixels;
|
|
148
|
+
const cellSizeChanged = opts.oldProps.cellSizePixels !== cellSize;
|
|
149
|
+
const { viewportChanged } = opts.changeFlags;
|
|
150
|
+
let gpuAggregation = opts.props.gpuAggregation;
|
|
151
|
+
if (this.state.gpuAggregation !== opts.props.gpuAggregation) {
|
|
152
|
+
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
|
|
153
|
+
log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
|
|
154
|
+
gpuAggregation = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
|
|
158
|
+
this.setState({
|
|
159
|
+
gpuAggregation
|
|
160
|
+
});
|
|
161
|
+
const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
|
|
162
|
+
const { dimensions } = this.state;
|
|
163
|
+
const { data, weights } = dimensions;
|
|
164
|
+
const aggregationDataDirty = positionsChanged ||
|
|
165
|
+
gpuAggregationChanged ||
|
|
166
|
+
viewportChanged ||
|
|
167
|
+
this.isAggregationDirty(opts, {
|
|
168
|
+
compareAll: gpuAggregation, // check for all (including extentions props) when using gpu aggregation
|
|
169
|
+
dimension: data
|
|
170
|
+
});
|
|
171
|
+
const aggregationWeightsDirty = this.isAggregationDirty(opts, { dimension: weights });
|
|
172
|
+
this.setState({
|
|
173
|
+
aggregationDataDirty,
|
|
174
|
+
aggregationWeightsDirty
|
|
175
|
+
});
|
|
176
|
+
const { viewport } = this.context;
|
|
177
|
+
if (viewportChanged || cellSizeChanged) {
|
|
178
|
+
const { width, height } = viewport;
|
|
179
|
+
const numCol = Math.ceil(width / cellSize);
|
|
180
|
+
const numRow = Math.ceil(height / cellSize);
|
|
181
|
+
this.allocateResources(numRow, numCol);
|
|
182
|
+
this.setState({
|
|
183
|
+
// transformation from clipspace to screen(pixel) space
|
|
184
|
+
scaling: [width / 2, -height / 2, 1],
|
|
185
|
+
gridOffset: { xOffset: cellSize, yOffset: cellSize },
|
|
186
|
+
width,
|
|
187
|
+
height,
|
|
188
|
+
numCol,
|
|
189
|
+
numRow
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (aggregationWeightsDirty) {
|
|
193
|
+
this._updateAccessors(opts);
|
|
194
|
+
}
|
|
195
|
+
if (aggregationDataDirty || aggregationWeightsDirty) {
|
|
196
|
+
this._resetResults();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/* eslint-enable complexity, max-statements */
|
|
200
|
+
// Private
|
|
201
|
+
_updateAccessors(opts) {
|
|
202
|
+
const { getWeight, aggregation, data } = opts.props;
|
|
203
|
+
const { count } = this.state.weights;
|
|
204
|
+
if (count) {
|
|
205
|
+
count.getWeight = getWeight;
|
|
206
|
+
count.operation = AGGREGATION_OPERATION[aggregation];
|
|
207
|
+
}
|
|
208
|
+
this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
|
|
209
|
+
}
|
|
210
|
+
_resetResults() {
|
|
211
|
+
const { count } = this.state.weights;
|
|
212
|
+
if (count) {
|
|
213
|
+
count.aggregationData = null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2019 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
export const AGGREGATION_OPERATION = {
|
|
21
|
+
SUM: 1,
|
|
22
|
+
MEAN: 2,
|
|
23
|
+
MIN: 3,
|
|
24
|
+
MAX: 4
|
|
25
|
+
};
|
|
26
|
+
function sumReducer(accu, cur) {
|
|
27
|
+
return accu + cur;
|
|
28
|
+
}
|
|
29
|
+
function maxReducer(accu, cur) {
|
|
30
|
+
return cur > accu ? cur : accu;
|
|
31
|
+
}
|
|
32
|
+
function minReducer(accu, cur) {
|
|
33
|
+
return cur < accu ? cur : accu;
|
|
34
|
+
}
|
|
35
|
+
export function getMean(pts, accessor) {
|
|
36
|
+
if (Number.isFinite(accessor)) {
|
|
37
|
+
return pts.length ? accessor : null;
|
|
38
|
+
}
|
|
39
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
40
|
+
return filtered.length ? filtered.reduce(sumReducer, 0) / filtered.length : null;
|
|
41
|
+
}
|
|
42
|
+
export function getSum(pts, accessor) {
|
|
43
|
+
if (Number.isFinite(accessor)) {
|
|
44
|
+
return pts.length ? pts.length * accessor : null;
|
|
45
|
+
}
|
|
46
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
47
|
+
return filtered.length ? filtered.reduce(sumReducer, 0) : null;
|
|
48
|
+
}
|
|
49
|
+
export function getMax(pts, accessor) {
|
|
50
|
+
if (Number.isFinite(accessor)) {
|
|
51
|
+
return pts.length ? accessor : null;
|
|
52
|
+
}
|
|
53
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
54
|
+
return filtered.length ? filtered.reduce(maxReducer, -Infinity) : null;
|
|
55
|
+
}
|
|
56
|
+
export function getMin(pts, accessor) {
|
|
57
|
+
if (Number.isFinite(accessor)) {
|
|
58
|
+
return pts.length ? accessor : null;
|
|
59
|
+
}
|
|
60
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
61
|
+
return filtered.length ? filtered.reduce(minReducer, Infinity) : null;
|
|
62
|
+
}
|
|
63
|
+
// Function to convert from aggregation/accessor props (like colorAggregation and getColorWeight) to getValue prop (like getColorValue)
|
|
64
|
+
export function getValueFunc(aggregation, accessor, context) {
|
|
65
|
+
const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
|
|
66
|
+
accessor = wrapAccessor(accessor, context);
|
|
67
|
+
switch (op) {
|
|
68
|
+
case AGGREGATION_OPERATION.MIN:
|
|
69
|
+
return pts => getMin(pts, accessor);
|
|
70
|
+
case AGGREGATION_OPERATION.SUM:
|
|
71
|
+
return pts => getSum(pts, accessor);
|
|
72
|
+
case AGGREGATION_OPERATION.MEAN:
|
|
73
|
+
return pts => getMean(pts, accessor);
|
|
74
|
+
case AGGREGATION_OPERATION.MAX:
|
|
75
|
+
return pts => getMax(pts, accessor);
|
|
76
|
+
default:
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function wrapAccessor(accessor, context = {}) {
|
|
81
|
+
if (Number.isFinite(accessor)) {
|
|
82
|
+
return accessor;
|
|
83
|
+
}
|
|
84
|
+
return pt => {
|
|
85
|
+
context.index = pt.index;
|
|
86
|
+
return accessor(pt.source, context);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function wrapGetValueFunc(getValue, context = {}) {
|
|
90
|
+
return pts => {
|
|
91
|
+
context.indices = pts.map(pt => pt.index);
|
|
92
|
+
return getValue(pts.map(pt => pt.source), context);
|
|
93
|
+
};
|
|
94
|
+
}
|