@deck.gl/aggregation-layers 9.0.40 → 9.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/aggregation-layer.d.ts +30 -0
- package/dist/common/aggregation-layer.d.ts.map +1 -0
- package/dist/common/aggregation-layer.js +70 -0
- package/dist/common/aggregation-layer.js.map +1 -0
- package/dist/common/aggregator/aggregator.d.ts +76 -0
- package/dist/common/aggregator/aggregator.d.ts.map +1 -0
- package/dist/common/aggregator/aggregator.js +5 -0
- package/dist/common/aggregator/aggregator.js.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.js +67 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +140 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +21 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
- package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/utils.js +25 -0
- package/dist/common/aggregator/gpu-aggregator/utils.js.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +216 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +202 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +224 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
- package/dist/common/aggregator/index.d.ts +6 -0
- package/dist/common/aggregator/index.d.ts.map +1 -0
- package/dist/common/aggregator/index.js +6 -0
- package/dist/common/aggregator/index.js.map +1 -0
- package/dist/common/types.d.ts +11 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +5 -0
- package/dist/common/types.js.map +1 -0
- package/dist/common/utils/bounds-utils.d.ts +10 -0
- package/dist/common/utils/bounds-utils.d.ts.map +1 -0
- package/dist/common/utils/bounds-utils.js +21 -0
- package/dist/common/utils/bounds-utils.js.map +1 -0
- package/dist/common/utils/color-utils.d.ts +10 -0
- package/dist/common/utils/color-utils.d.ts.map +1 -0
- package/dist/common/utils/color-utils.js +66 -0
- package/dist/common/utils/color-utils.js.map +1 -0
- package/dist/common/utils/prop-utils.d.ts.map +1 -0
- package/dist/common/utils/prop-utils.js +13 -0
- package/dist/common/utils/prop-utils.js.map +1 -0
- package/dist/common/utils/scale-utils.d.ts +46 -0
- package/dist/common/utils/scale-utils.d.ts.map +1 -0
- package/dist/common/utils/scale-utils.js +181 -0
- package/dist/common/utils/scale-utils.js.map +1 -0
- package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
- package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/contour-layer/bin-options-uniforms.js +18 -0
- package/dist/contour-layer/bin-options-uniforms.js.map +1 -0
- package/dist/contour-layer/contour-layer.d.ts +42 -50
- package/dist/contour-layer/contour-layer.d.ts.map +1 -1
- package/dist/contour-layer/contour-layer.js +233 -192
- package/dist/contour-layer/contour-layer.js.map +1 -0
- package/dist/contour-layer/contour-utils.d.ts +36 -15
- package/dist/contour-layer/contour-utils.d.ts.map +1 -1
- package/dist/contour-layer/contour-utils.js +25 -29
- package/dist/contour-layer/contour-utils.js.map +1 -0
- package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
- package/dist/contour-layer/marching-squares-codes.js +4 -0
- package/dist/contour-layer/marching-squares-codes.js.map +1 -0
- package/dist/contour-layer/marching-squares.d.ts +22 -6
- package/dist/contour-layer/marching-squares.d.ts.map +1 -1
- package/dist/contour-layer/marching-squares.js +72 -68
- package/dist/contour-layer/marching-squares.js.map +1 -0
- package/dist/contour-layer/value-reader.d.ts +10 -0
- package/dist/contour-layer/value-reader.d.ts.map +1 -0
- package/dist/contour-layer/value-reader.js +47 -0
- package/dist/contour-layer/value-reader.js.map +1 -0
- package/dist/dist.dev.js +4844 -4083
- package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
- package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/grid-layer/bin-options-uniforms.js +18 -0
- package/dist/grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +52 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
- package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer.js +94 -0
- package/dist/grid-layer/grid-cell-layer.js.map +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
- package/dist/grid-layer/grid-layer-uniforms.js +24 -0
- package/dist/grid-layer/grid-layer-uniforms.js.map +1 -0
- package/dist/grid-layer/grid-layer.d.ts +176 -14
- package/dist/grid-layer/grid-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer.js +343 -46
- package/dist/grid-layer/grid-layer.js.map +1 -0
- package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
- package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
- package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +7 -21
- package/dist/heatmap-layer/aggregation-layer.js.map +1 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js +33 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
- package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
- package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-utils.js +4 -0
- package/dist/heatmap-layer/heatmap-layer-utils.js.map +1 -0
- package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +44 -33
- package/dist/heatmap-layer/heatmap-layer.js.map +1 -0
- package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/max-fs.glsl.js +4 -0
- package/dist/heatmap-layer/max-fs.glsl.js.map +1 -0
- package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
- package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/max-vs.glsl.js +7 -4
- package/dist/heatmap-layer/max-vs.glsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +6 -23
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js +23 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +11 -30
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.js +18 -30
- package/dist/heatmap-layer/triangle-layer.js.map +1 -0
- package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/weights-fs.glsl.js +4 -0
- package/dist/heatmap-layer/weights-fs.glsl.js.map +1 -0
- package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
- package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/weights-vs.glsl.js +7 -7
- package/dist/heatmap-layer/weights-vs.glsl.js.map +1 -0
- package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
- package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/hexagon-layer/bin-options-uniforms.js +18 -0
- package/dist/hexagon-layer/bin-options-uniforms.js.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +56 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.js +95 -0
- package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js +22 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
- package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
- package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer.js +308 -123
- package/dist/hexagon-layer/hexagon-layer.js.map +1 -0
- package/dist/hexagon-layer/hexbin.d.ts +17 -0
- package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
- package/dist/hexagon-layer/hexbin.js +70 -0
- package/dist/hexagon-layer/hexbin.js.map +1 -0
- package/dist/index.cjs +3026 -2947
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +7 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -27
- package/dist/index.js.map +1 -0
- package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
- package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/screen-grid-layer/bin-options-uniforms.js +16 -0
- package/dist/screen-grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +53 -134
- package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +5 -24
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +20 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +22 -62
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
- package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer.js +158 -174
- package/dist/screen-grid-layer/screen-grid-layer.js.map +1 -0
- package/dist.min.js +401 -382
- package/package.json +10 -9
- package/src/common/aggregation-layer.ts +107 -0
- package/src/common/aggregator/aggregator.ts +88 -0
- package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
- package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
- package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
- package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
- package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
- package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
- package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
- package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
- package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
- package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
- package/src/common/aggregator/index.ts +10 -0
- package/src/{types.ts → common/types.ts} +10 -4
- package/src/common/utils/bounds-utils.ts +34 -0
- package/src/common/utils/color-utils.ts +86 -0
- package/src/common/utils/prop-utils.ts +13 -0
- package/src/common/utils/scale-utils.ts +236 -0
- package/src/contour-layer/bin-options-uniforms.ts +26 -0
- package/src/contour-layer/contour-layer.ts +300 -265
- package/src/contour-layer/contour-utils.ts +68 -39
- package/src/contour-layer/marching-squares-codes.ts +4 -0
- package/src/contour-layer/marching-squares.ts +93 -82
- package/src/contour-layer/value-reader.ts +65 -0
- package/src/grid-layer/bin-options-uniforms.ts +26 -0
- package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
- package/src/grid-layer/grid-cell-layer.ts +141 -0
- package/src/grid-layer/grid-layer-uniforms.ts +37 -0
- package/src/grid-layer/grid-layer.ts +614 -73
- package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
- package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
- package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
- package/src/heatmap-layer/heatmap-layer.ts +59 -36
- package/src/heatmap-layer/max-fs.glsl.ts +4 -0
- package/src/heatmap-layer/max-vs.glsl.ts +7 -4
- package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
- package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
- package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
- package/src/heatmap-layer/triangle-layer.ts +26 -31
- package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
- package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
- package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
- package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
- package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
- package/src/hexagon-layer/hexagon-layer.ts +454 -186
- package/src/hexagon-layer/hexbin.ts +79 -0
- package/src/index.ts +21 -34
- package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
- package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
- package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
- package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
- package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
- package/dist/aggregation-layer.d.ts.map +0 -1
- package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
- package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
- package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
- package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
- package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
- package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
- package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
- package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
- package/dist/grid-aggregation-layer.d.ts +0 -67
- package/dist/grid-aggregation-layer.d.ts.map +0 -1
- package/dist/grid-aggregation-layer.js +0 -173
- package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
- package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
- package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
- package/dist/types.d.ts +0 -12
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -1
- package/dist/utils/aggregation-operation-utils.d.ts +0 -19
- package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
- package/dist/utils/aggregation-operation-utils.js +0 -94
- package/dist/utils/bin-sorter.d.ts +0 -52
- package/dist/utils/bin-sorter.d.ts.map +0 -1
- package/dist/utils/bin-sorter.js +0 -167
- package/dist/utils/color-utils.d.ts +0 -3
- package/dist/utils/color-utils.d.ts.map +0 -1
- package/dist/utils/color-utils.js +0 -53
- package/dist/utils/cpu-aggregator.d.ts +0 -169
- package/dist/utils/cpu-aggregator.d.ts.map +0 -1
- package/dist/utils/cpu-aggregator.js +0 -421
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
- package/dist/utils/grid-aggregation-utils.d.ts +0 -30
- package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
- package/dist/utils/grid-aggregation-utils.js +0 -114
- package/dist/utils/prop-utils.d.ts.map +0 -1
- package/dist/utils/prop-utils.js +0 -28
- package/dist/utils/resource-utils.d.ts +0 -14
- package/dist/utils/resource-utils.d.ts.map +0 -1
- package/dist/utils/resource-utils.js +0 -38
- package/dist/utils/scale-utils.d.ts +0 -15
- package/dist/utils/scale-utils.d.ts.map +0 -1
- package/dist/utils/scale-utils.js +0 -184
- package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
- package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
- package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
- package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
- package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
- package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
- package/src/grid-aggregation-layer.ts +0 -243
- package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
- package/src/utils/aggregation-operation-utils.ts +0 -118
- package/src/utils/bin-sorter.ts +0 -218
- package/src/utils/color-utils.ts +0 -57
- package/src/utils/cpu-aggregator.ts +0 -503
- package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
- package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
- package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
- package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
- package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
- package/src/utils/grid-aggregation-utils.ts +0 -147
- package/src/utils/prop-utils.ts +0 -29
- package/src/utils/resource-utils.ts +0 -53
- package/src/utils/scale-utils.js +0 -219
- /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
import {GL} from '@luma.gl/constants';
|
|
22
|
-
import {LayerContext, log, UpdateParameters, Accessor} from '@deck.gl/core';
|
|
23
|
-
import AggregationLayer, {AggregationLayerProps} from './aggregation-layer';
|
|
24
|
-
import GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
25
|
-
import BinSorter from './utils/bin-sorter';
|
|
26
|
-
import {pointToDensityGridDataCPU} from './cpu-grid-layer/grid-aggregator';
|
|
27
|
-
import type {Buffer} from '@luma.gl/core';
|
|
28
|
-
|
|
29
|
-
export type GridAggregationLayerProps<DataT> = AggregationLayerProps<DataT>;
|
|
30
|
-
|
|
31
|
-
export default abstract class GridAggregationLayer<
|
|
32
|
-
DataT,
|
|
33
|
-
ExtraPropsT extends {} = {}
|
|
34
|
-
> extends AggregationLayer<DataT, ExtraPropsT> {
|
|
35
|
-
static layerName = 'GridAggregationLayer';
|
|
36
|
-
|
|
37
|
-
state!: AggregationLayer<DataT>['state'] & {
|
|
38
|
-
aggregationDataDirty?: boolean;
|
|
39
|
-
aggregationWeightsDirty?: boolean;
|
|
40
|
-
aggregationDirty?: boolean;
|
|
41
|
-
gpuAggregation?: any;
|
|
42
|
-
getValue?: () => any;
|
|
43
|
-
sortedBins?: BinSorter;
|
|
44
|
-
weights: {
|
|
45
|
-
[key: string]: {
|
|
46
|
-
aggregationBuffer?: Buffer;
|
|
47
|
-
maxMinBuffer?: Buffer;
|
|
48
|
-
aggregationData: Float32Array | null;
|
|
49
|
-
maxMinData: Float32Array;
|
|
50
|
-
maxData: Float32Array;
|
|
51
|
-
minData: Float32Array;
|
|
52
|
-
getWeight: Accessor<DataT, number>;
|
|
53
|
-
operation: number;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
cpuGridAggregator?: Function;
|
|
57
|
-
gpuGridAggregator?: GPUGridAggregator;
|
|
58
|
-
layerData: any;
|
|
59
|
-
numRow: number;
|
|
60
|
-
numCol: number;
|
|
61
|
-
gridOffset: {xOffset: number; yOffset: number};
|
|
62
|
-
posOffset: number[];
|
|
63
|
-
gridOrigin: number[];
|
|
64
|
-
translation: number[];
|
|
65
|
-
scaling: number[];
|
|
66
|
-
boundingBox: {xMin: number; yMin: number; xMax: number; yMax: number};
|
|
67
|
-
projectPoints?: (p: [number, number]) => [number, number];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
initializeAggregationLayer({dimensions}) {
|
|
71
|
-
super.initializeAggregationLayer(dimensions);
|
|
72
|
-
this.setState({
|
|
73
|
-
// CPU aggregation results
|
|
74
|
-
layerData: {},
|
|
75
|
-
gpuGridAggregator: new GPUGridAggregator(this.context.device, {
|
|
76
|
-
id: `${this.id}-gpu-aggregator`
|
|
77
|
-
}),
|
|
78
|
-
cpuGridAggregator: pointToDensityGridDataCPU
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
updateState(opts: UpdateParameters<this>) {
|
|
83
|
-
// get current attributes
|
|
84
|
-
super.updateState(opts);
|
|
85
|
-
|
|
86
|
-
this.updateAggregationState(opts);
|
|
87
|
-
|
|
88
|
-
const {aggregationDataDirty, aggregationWeightsDirty, gpuAggregation} = this.state;
|
|
89
|
-
if (this.getNumInstances() <= 0) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
let aggregationDirty = false;
|
|
93
|
-
// CPU aggregation is two steps
|
|
94
|
-
// 1. Create bins (based on cellSize and position) 2. Aggregate weights for each bin
|
|
95
|
-
// For GPU aggregation both above steps are combined into one step
|
|
96
|
-
|
|
97
|
-
// step-1
|
|
98
|
-
if (aggregationDataDirty || (gpuAggregation && aggregationWeightsDirty)) {
|
|
99
|
-
this._updateAggregation(opts);
|
|
100
|
-
aggregationDirty = true;
|
|
101
|
-
}
|
|
102
|
-
// step-2 (Applicalbe for CPU aggregation only)
|
|
103
|
-
if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {
|
|
104
|
-
this._updateWeightBins();
|
|
105
|
-
this._uploadAggregationResults();
|
|
106
|
-
aggregationDirty = true;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
this.setState({aggregationDirty});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
finalizeState(context: LayerContext) {
|
|
113
|
-
const {count} = this.state.weights;
|
|
114
|
-
if (count && count.aggregationBuffer) {
|
|
115
|
-
count.aggregationBuffer.delete();
|
|
116
|
-
}
|
|
117
|
-
this.state.gpuGridAggregator?.delete();
|
|
118
|
-
super.finalizeState(context);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
updateShaders(shaders: any): void {
|
|
122
|
-
if (this.state.gpuAggregation) {
|
|
123
|
-
this.state.gpuGridAggregator!.updateShaders(shaders);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Methods that can be overriden by subclasses for customizations
|
|
128
|
-
|
|
129
|
-
updateAggregationState(opts: UpdateParameters<this>) {
|
|
130
|
-
// Sublayers should implement this method.
|
|
131
|
-
log.assert(false);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
allocateResources(numRow, numCol) {
|
|
135
|
-
if (this.state.numRow !== numRow || this.state.numCol !== numCol) {
|
|
136
|
-
const dataBytes = numCol * numRow * 4 * 4;
|
|
137
|
-
const {weights} = this.state;
|
|
138
|
-
for (const name in weights) {
|
|
139
|
-
const weight = weights[name];
|
|
140
|
-
if (weight.aggregationBuffer) {
|
|
141
|
-
weight.aggregationBuffer.delete();
|
|
142
|
-
}
|
|
143
|
-
weight.aggregationBuffer = this.context.device.createBuffer({
|
|
144
|
-
byteLength: dataBytes,
|
|
145
|
-
// @ts-expect-error legacy
|
|
146
|
-
accessor: {
|
|
147
|
-
size: 4,
|
|
148
|
-
type: GL.FLOAT,
|
|
149
|
-
divisor: 1
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
updateResults({aggregationData, maxMinData, maxData, minData}) {
|
|
157
|
-
const {count} = this.state.weights;
|
|
158
|
-
if (count) {
|
|
159
|
-
count.aggregationData = aggregationData;
|
|
160
|
-
count.maxMinData = maxMinData;
|
|
161
|
-
count.maxData = maxData;
|
|
162
|
-
count.minData = minData;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Private
|
|
167
|
-
|
|
168
|
-
_updateAggregation(opts) {
|
|
169
|
-
const {
|
|
170
|
-
cpuGridAggregator,
|
|
171
|
-
gpuGridAggregator,
|
|
172
|
-
gridOffset,
|
|
173
|
-
posOffset,
|
|
174
|
-
translation = [0, 0],
|
|
175
|
-
scaling = [0, 0, 0],
|
|
176
|
-
boundingBox,
|
|
177
|
-
projectPoints,
|
|
178
|
-
gpuAggregation,
|
|
179
|
-
numCol,
|
|
180
|
-
numRow
|
|
181
|
-
} = this.state;
|
|
182
|
-
const {props} = opts;
|
|
183
|
-
const {viewport} = this.context;
|
|
184
|
-
const attributes = this.getAttributes();
|
|
185
|
-
const vertexCount = this.getNumInstances();
|
|
186
|
-
|
|
187
|
-
if (!gpuAggregation) {
|
|
188
|
-
const result = cpuGridAggregator!(props, {
|
|
189
|
-
gridOffset,
|
|
190
|
-
projectPoints,
|
|
191
|
-
attributes,
|
|
192
|
-
viewport,
|
|
193
|
-
posOffset,
|
|
194
|
-
boundingBox
|
|
195
|
-
});
|
|
196
|
-
this.setState({
|
|
197
|
-
layerData: result
|
|
198
|
-
});
|
|
199
|
-
} else {
|
|
200
|
-
const {weights} = this.state;
|
|
201
|
-
gpuGridAggregator!.run({
|
|
202
|
-
weights,
|
|
203
|
-
cellSize: [gridOffset.xOffset, gridOffset.yOffset],
|
|
204
|
-
numCol,
|
|
205
|
-
numRow,
|
|
206
|
-
translation,
|
|
207
|
-
scaling,
|
|
208
|
-
vertexCount,
|
|
209
|
-
projectPoints,
|
|
210
|
-
attributes,
|
|
211
|
-
moduleSettings: this.getModuleSettings()
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
_updateWeightBins() {
|
|
217
|
-
const {getValue} = this.state;
|
|
218
|
-
|
|
219
|
-
const sortedBins = new BinSorter(this.state.layerData.data || [], {getValue});
|
|
220
|
-
this.setState({sortedBins});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
_uploadAggregationResults(): void {
|
|
224
|
-
const {numCol, numRow} = this.state;
|
|
225
|
-
const {data} = this.state.layerData;
|
|
226
|
-
const {aggregatedBins, minValue, maxValue, totalCount} = this.state.sortedBins!;
|
|
227
|
-
|
|
228
|
-
const ELEMENTCOUNT = 4;
|
|
229
|
-
const aggregationSize = numCol * numRow * ELEMENTCOUNT;
|
|
230
|
-
const aggregationData = new Float32Array(aggregationSize).fill(0);
|
|
231
|
-
for (const bin of aggregatedBins) {
|
|
232
|
-
const {lonIdx, latIdx} = data[bin.i];
|
|
233
|
-
const {value, counts} = bin;
|
|
234
|
-
const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;
|
|
235
|
-
aggregationData[cellIndex] = value;
|
|
236
|
-
aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;
|
|
237
|
-
}
|
|
238
|
-
const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);
|
|
239
|
-
const maxData = new Float32Array([maxValue, 0, 0, totalCount]);
|
|
240
|
-
const minData = new Float32Array([minValue, 0, 0, totalCount]);
|
|
241
|
-
this.updateResults({aggregationData, maxMinData, maxData, minData});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
import {hexbin} from 'd3-hexbin';
|
|
22
|
-
import {createIterable, log} from '@deck.gl/core';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Use d3-hexbin to performs hexagonal binning from geo points to hexagons
|
|
26
|
-
* @param {Iterable} data - array of points
|
|
27
|
-
* @param {Number} radius - hexagon radius in meter
|
|
28
|
-
* @param {function} getPosition - get points lon lat
|
|
29
|
-
* @param {Object} viewport - current viewport object
|
|
30
|
-
|
|
31
|
-
* @return {Object} - hexagons and countRange
|
|
32
|
-
*/
|
|
33
|
-
export function pointToHexbin(props, aggregationParams) {
|
|
34
|
-
const {data, radius} = props;
|
|
35
|
-
const {viewport, attributes} = aggregationParams;
|
|
36
|
-
// get hexagon radius in mercator world unit
|
|
37
|
-
const centerLngLat = data.length ? getPointsCenter(data, aggregationParams) : null;
|
|
38
|
-
const radiusCommon = getRadiusInCommon(radius, viewport, centerLngLat);
|
|
39
|
-
|
|
40
|
-
// add world space coordinates to points
|
|
41
|
-
const screenPoints: {
|
|
42
|
-
screenCoord: number[];
|
|
43
|
-
source: any;
|
|
44
|
-
index: number;
|
|
45
|
-
}[] = [];
|
|
46
|
-
const {iterable, objectInfo} = createIterable(data);
|
|
47
|
-
const positions = attributes.positions.value;
|
|
48
|
-
const {size} = attributes.positions.getAccessor();
|
|
49
|
-
for (const object of iterable) {
|
|
50
|
-
objectInfo.index++;
|
|
51
|
-
const posIndex = objectInfo.index * size;
|
|
52
|
-
const position = [positions[posIndex], positions[posIndex + 1]];
|
|
53
|
-
const arrayIsFinite = Number.isFinite(position[0]) && Number.isFinite(position[1]);
|
|
54
|
-
if (arrayIsFinite) {
|
|
55
|
-
screenPoints.push({
|
|
56
|
-
screenCoord: viewport.projectFlat(position),
|
|
57
|
-
source: object,
|
|
58
|
-
index: objectInfo.index
|
|
59
|
-
});
|
|
60
|
-
} else {
|
|
61
|
-
log.warn('HexagonLayer: invalid position')();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const newHexbin = hexbin()
|
|
66
|
-
.radius(radiusCommon)
|
|
67
|
-
.x(d => d.screenCoord[0])
|
|
68
|
-
.y(d => d.screenCoord[1]);
|
|
69
|
-
|
|
70
|
-
const hexagonBins = newHexbin(screenPoints);
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
hexagons: hexagonBins.map((hex, index) => ({
|
|
74
|
-
position: viewport.unprojectFlat([hex.x, hex.y]),
|
|
75
|
-
points: hex,
|
|
76
|
-
index
|
|
77
|
-
})),
|
|
78
|
-
radiusCommon
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get the bounding box of all data points
|
|
84
|
-
*/
|
|
85
|
-
export function getPointsCenter(data, aggregationParams) {
|
|
86
|
-
const {attributes} = aggregationParams;
|
|
87
|
-
const positions = attributes.positions.value;
|
|
88
|
-
const {size} = attributes.positions.getAccessor();
|
|
89
|
-
|
|
90
|
-
let minX = Infinity;
|
|
91
|
-
let minY = Infinity;
|
|
92
|
-
let maxX = -Infinity;
|
|
93
|
-
let maxY = -Infinity;
|
|
94
|
-
let i;
|
|
95
|
-
|
|
96
|
-
for (i = 0; i < size * data.length; i += size) {
|
|
97
|
-
const x = positions[i];
|
|
98
|
-
const y = positions[i + 1];
|
|
99
|
-
const arrayIsFinite = Number.isFinite(x) && Number.isFinite(y);
|
|
100
|
-
|
|
101
|
-
if (arrayIsFinite) {
|
|
102
|
-
minX = Math.min(x, minX);
|
|
103
|
-
maxX = Math.max(x, maxX);
|
|
104
|
-
minY = Math.min(y, minY);
|
|
105
|
-
maxY = Math.max(y, maxY);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// return center
|
|
110
|
-
return [minX, minY, maxX, maxY].every(Number.isFinite)
|
|
111
|
-
? [(minX + maxX) / 2, (minY + maxY) / 2]
|
|
112
|
-
: null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Get radius in mercator world space coordinates from meter
|
|
117
|
-
* @param {Number} radius - in meter
|
|
118
|
-
* @param {Object} viewport - current viewport object
|
|
119
|
-
* @param {Array<Number>} center - data center
|
|
120
|
-
|
|
121
|
-
* @return {Number} radius in mercator world spcae coordinates
|
|
122
|
-
*/
|
|
123
|
-
export function getRadiusInCommon(radius, viewport, center) {
|
|
124
|
-
const {unitsPerMeter} = viewport.getDistanceScales(center);
|
|
125
|
-
// x, y distance should be the same
|
|
126
|
-
return radius * unitsPerMeter[0];
|
|
127
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2015 - 2019 Uber Technologies, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
export const AGGREGATION_OPERATION = {
|
|
22
|
-
SUM: 1,
|
|
23
|
-
MEAN: 2,
|
|
24
|
-
MIN: 3,
|
|
25
|
-
MAX: 4
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
function sumReducer(accu, cur) {
|
|
29
|
-
return accu + cur;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function maxReducer(accu, cur) {
|
|
33
|
-
return cur > accu ? cur : accu;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function minReducer(accu, cur) {
|
|
37
|
-
return cur < accu ? cur : accu;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getMean(pts, accessor) {
|
|
41
|
-
if (Number.isFinite(accessor)) {
|
|
42
|
-
return pts.length ? accessor : null;
|
|
43
|
-
}
|
|
44
|
-
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
45
|
-
|
|
46
|
-
return filtered.length ? filtered.reduce(sumReducer, 0) / filtered.length : null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function getSum(pts, accessor) {
|
|
50
|
-
if (Number.isFinite(accessor)) {
|
|
51
|
-
return pts.length ? pts.length * accessor : null;
|
|
52
|
-
}
|
|
53
|
-
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
54
|
-
|
|
55
|
-
return filtered.length ? filtered.reduce(sumReducer, 0) : null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function getMax(pts, accessor) {
|
|
59
|
-
if (Number.isFinite(accessor)) {
|
|
60
|
-
return pts.length ? accessor : null;
|
|
61
|
-
}
|
|
62
|
-
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
63
|
-
|
|
64
|
-
return filtered.length ? filtered.reduce(maxReducer, -Infinity) : null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function getMin(pts, accessor) {
|
|
68
|
-
if (Number.isFinite(accessor)) {
|
|
69
|
-
return pts.length ? accessor : null;
|
|
70
|
-
}
|
|
71
|
-
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
72
|
-
|
|
73
|
-
return filtered.length ? filtered.reduce(minReducer, Infinity) : null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Function to convert from aggregation/accessor props (like colorAggregation and getColorWeight) to getValue prop (like getColorValue)
|
|
77
|
-
export function getValueFunc(aggregation, accessor, context) {
|
|
78
|
-
const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
|
|
79
|
-
accessor = wrapAccessor(accessor, context);
|
|
80
|
-
switch (op) {
|
|
81
|
-
case AGGREGATION_OPERATION.MIN:
|
|
82
|
-
return pts => getMin(pts, accessor);
|
|
83
|
-
case AGGREGATION_OPERATION.SUM:
|
|
84
|
-
return pts => getSum(pts, accessor);
|
|
85
|
-
case AGGREGATION_OPERATION.MEAN:
|
|
86
|
-
return pts => getMean(pts, accessor);
|
|
87
|
-
case AGGREGATION_OPERATION.MAX:
|
|
88
|
-
return pts => getMax(pts, accessor);
|
|
89
|
-
default:
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type AccessorContext = {
|
|
95
|
-
data?;
|
|
96
|
-
index?: number;
|
|
97
|
-
indices?: number[];
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
function wrapAccessor(accessor, context: AccessorContext = {}) {
|
|
101
|
-
if (Number.isFinite(accessor)) {
|
|
102
|
-
return accessor;
|
|
103
|
-
}
|
|
104
|
-
return pt => {
|
|
105
|
-
context.index = pt.index;
|
|
106
|
-
return accessor(pt.source, context);
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function wrapGetValueFunc(getValue, context: AccessorContext = {}) {
|
|
111
|
-
return pts => {
|
|
112
|
-
context.indices = pts.map(pt => pt.index);
|
|
113
|
-
return getValue(
|
|
114
|
-
pts.map(pt => pt.source),
|
|
115
|
-
context
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
}
|
package/src/utils/bin-sorter.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
// getValue takes an array of points returns a value to sort the bins on.
|
|
22
|
-
// by default it returns the number of points
|
|
23
|
-
// this is where to pass in a function to color the bins by
|
|
24
|
-
// avg/mean/max of specific value of the point
|
|
25
|
-
const defaultGetValue = points => points.length;
|
|
26
|
-
|
|
27
|
-
import {clamp, getQuantileDomain, getOrdinalDomain} from './scale-utils';
|
|
28
|
-
|
|
29
|
-
const MAX_32_BIT_FLOAT = 3.402823466e38;
|
|
30
|
-
|
|
31
|
-
// access array of points in each bin
|
|
32
|
-
const defaultGetPoints = bin => bin.points;
|
|
33
|
-
// access index of each bin
|
|
34
|
-
const defaultGetIndex = bin => bin.index;
|
|
35
|
-
|
|
36
|
-
// d3-scending
|
|
37
|
-
const ascending = (a, b) => (a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN);
|
|
38
|
-
|
|
39
|
-
const defaultProps = {
|
|
40
|
-
getValue: defaultGetValue,
|
|
41
|
-
getPoints: defaultGetPoints,
|
|
42
|
-
getIndex: defaultGetIndex,
|
|
43
|
-
filterData: null
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type AggregatedBin = {
|
|
47
|
-
i: number;
|
|
48
|
-
value: any;
|
|
49
|
-
counts: number;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default class BinSorter {
|
|
53
|
-
maxCount!: number;
|
|
54
|
-
maxValue!: number;
|
|
55
|
-
minValue!: number;
|
|
56
|
-
totalCount!: number;
|
|
57
|
-
|
|
58
|
-
aggregatedBins: AggregatedBin[];
|
|
59
|
-
sortedBins!: AggregatedBin[];
|
|
60
|
-
binMap: Record<number, AggregatedBin>;
|
|
61
|
-
|
|
62
|
-
constructor(bins: unknown[] = [], props: Partial<typeof defaultProps> = defaultProps) {
|
|
63
|
-
this.aggregatedBins = this.getAggregatedBins(bins, props);
|
|
64
|
-
this._updateMinMaxValues();
|
|
65
|
-
this.binMap = this.getBinMap();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get an array of object with aggregated values and index of bins
|
|
70
|
-
* Array object will be sorted by value optionally.
|
|
71
|
-
* @param {Array} bins
|
|
72
|
-
* @param {Function} getValue
|
|
73
|
-
* @return {Array} array of values and index lookup
|
|
74
|
-
*/
|
|
75
|
-
getAggregatedBins(bins, props): AggregatedBin[] {
|
|
76
|
-
const {
|
|
77
|
-
getValue = defaultGetValue,
|
|
78
|
-
getPoints = defaultGetPoints,
|
|
79
|
-
getIndex = defaultGetIndex,
|
|
80
|
-
filterData
|
|
81
|
-
} = props;
|
|
82
|
-
|
|
83
|
-
const hasFilter = typeof filterData === 'function';
|
|
84
|
-
const binCount = bins.length;
|
|
85
|
-
const aggregatedBins: AggregatedBin[] = [];
|
|
86
|
-
let index = 0;
|
|
87
|
-
|
|
88
|
-
for (let binIndex = 0; binIndex < binCount; binIndex++) {
|
|
89
|
-
const bin = bins[binIndex];
|
|
90
|
-
const points = getPoints(bin);
|
|
91
|
-
const i = getIndex(bin);
|
|
92
|
-
|
|
93
|
-
const filteredPoints = hasFilter ? points.filter(filterData) : points;
|
|
94
|
-
|
|
95
|
-
bin.filteredPoints = hasFilter ? filteredPoints : null;
|
|
96
|
-
|
|
97
|
-
const value = filteredPoints.length ? getValue(filteredPoints) : null;
|
|
98
|
-
|
|
99
|
-
if (value !== null && value !== undefined) {
|
|
100
|
-
// filter bins if value is null or undefined
|
|
101
|
-
aggregatedBins[index] = {
|
|
102
|
-
i: Number.isFinite(i) ? i : binIndex,
|
|
103
|
-
value,
|
|
104
|
-
counts: filteredPoints.length
|
|
105
|
-
};
|
|
106
|
-
index++;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return aggregatedBins;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
_percentileToIndex(percentileRange): [number, number] {
|
|
113
|
-
const len = this.sortedBins.length;
|
|
114
|
-
if (len < 2) {
|
|
115
|
-
return [0, 0];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const [lower, upper] = percentileRange.map(n => clamp(n, 0, 100));
|
|
119
|
-
|
|
120
|
-
const lowerIdx = Math.ceil((lower / 100) * (len - 1));
|
|
121
|
-
const upperIdx = Math.floor((upper / 100) * (len - 1));
|
|
122
|
-
|
|
123
|
-
return [lowerIdx, upperIdx];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Get a mapping from cell/hexagon index to sorted bin
|
|
128
|
-
* This is used to retrieve bin value for color calculation
|
|
129
|
-
* @return {Object} bin index to aggregatedBins
|
|
130
|
-
*/
|
|
131
|
-
getBinMap(): Record<number, AggregatedBin> {
|
|
132
|
-
const binMap = {};
|
|
133
|
-
for (const bin of this.aggregatedBins) {
|
|
134
|
-
binMap[bin.i] = bin;
|
|
135
|
-
}
|
|
136
|
-
return binMap;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Private
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Get ths max count of all bins
|
|
143
|
-
*/
|
|
144
|
-
_updateMinMaxValues(): void {
|
|
145
|
-
let maxCount = 0;
|
|
146
|
-
let maxValue = 0;
|
|
147
|
-
let minValue = MAX_32_BIT_FLOAT;
|
|
148
|
-
let totalCount = 0;
|
|
149
|
-
for (const x of this.aggregatedBins) {
|
|
150
|
-
maxCount = maxCount > x.counts ? maxCount : x.counts;
|
|
151
|
-
maxValue = maxValue > x.value ? maxValue : x.value;
|
|
152
|
-
minValue = minValue < x.value ? minValue : x.value;
|
|
153
|
-
totalCount += x.counts;
|
|
154
|
-
}
|
|
155
|
-
this.maxCount = maxCount;
|
|
156
|
-
this.maxValue = maxValue;
|
|
157
|
-
this.minValue = minValue;
|
|
158
|
-
this.totalCount = totalCount;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Get range of values of all bins
|
|
163
|
-
* @param {Number[]} range
|
|
164
|
-
* @param {Number} range[0] - lower bound
|
|
165
|
-
* @param {Number} range[1] - upper bound
|
|
166
|
-
* @return {Array} array of new value range
|
|
167
|
-
*/
|
|
168
|
-
getValueRange(percentileRange: [number, number]): [number, number] {
|
|
169
|
-
if (!this.sortedBins) {
|
|
170
|
-
this.sortedBins = this.aggregatedBins.sort((a, b) => ascending(a.value, b.value));
|
|
171
|
-
}
|
|
172
|
-
if (!this.sortedBins.length) {
|
|
173
|
-
// @ts-expect-error
|
|
174
|
-
return [];
|
|
175
|
-
}
|
|
176
|
-
let lowerIdx = 0;
|
|
177
|
-
let upperIdx = this.sortedBins.length - 1;
|
|
178
|
-
|
|
179
|
-
if (Array.isArray(percentileRange)) {
|
|
180
|
-
const idxRange = this._percentileToIndex(percentileRange);
|
|
181
|
-
lowerIdx = idxRange[0];
|
|
182
|
-
upperIdx = idxRange[1];
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return [this.sortedBins[lowerIdx].value, this.sortedBins[upperIdx].value];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
getValueDomainByScale(scale: string, [lower = 0, upper = 100] = []) {
|
|
189
|
-
if (!this.sortedBins) {
|
|
190
|
-
this.sortedBins = this.aggregatedBins.sort((a, b) => ascending(a.value, b.value));
|
|
191
|
-
}
|
|
192
|
-
if (!this.sortedBins.length) {
|
|
193
|
-
return [];
|
|
194
|
-
}
|
|
195
|
-
const indexEdge = this._percentileToIndex([lower, upper]);
|
|
196
|
-
|
|
197
|
-
return this._getScaleDomain(scale, indexEdge);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
_getScaleDomain(scaleType: string, [lowerIdx, upperIdx]: [number, number]): [number, number] {
|
|
201
|
-
const bins = this.sortedBins;
|
|
202
|
-
|
|
203
|
-
switch (scaleType) {
|
|
204
|
-
case 'quantize':
|
|
205
|
-
case 'linear':
|
|
206
|
-
return [bins[lowerIdx].value, bins[upperIdx].value];
|
|
207
|
-
|
|
208
|
-
case 'quantile':
|
|
209
|
-
return getQuantileDomain(bins.slice(lowerIdx, upperIdx + 1), d => d.value);
|
|
210
|
-
|
|
211
|
-
case 'ordinal':
|
|
212
|
-
return getOrdinalDomain(bins, d => d.value) as [number, number];
|
|
213
|
-
|
|
214
|
-
default:
|
|
215
|
-
return [bins[lowerIdx].value, bins[upperIdx].value];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|