@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.cjs
ADDED
|
@@ -0,0 +1,4494 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// dist/index.js
|
|
21
|
+
var dist_exports = {};
|
|
22
|
+
__export(dist_exports, {
|
|
23
|
+
AGGREGATION_OPERATION: () => AGGREGATION_OPERATION,
|
|
24
|
+
CPUGridLayer: () => CPUGridLayer,
|
|
25
|
+
ContourLayer: () => ContourLayer,
|
|
26
|
+
GPUGridLayer: () => GPUGridLayer,
|
|
27
|
+
GridLayer: () => GridLayer,
|
|
28
|
+
HeatmapLayer: () => HeatmapLayer,
|
|
29
|
+
HexagonLayer: () => HexagonLayer,
|
|
30
|
+
ScreenGridLayer: () => ScreenGridLayer,
|
|
31
|
+
_AggregationLayer: () => AggregationLayer,
|
|
32
|
+
_BinSorter: () => BinSorter,
|
|
33
|
+
_CPUAggregator: () => CPUAggregator,
|
|
34
|
+
_GPUGridAggregator: () => GPUGridAggregator
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(dist_exports);
|
|
37
|
+
|
|
38
|
+
// dist/screen-grid-layer/screen-grid-layer.js
|
|
39
|
+
var import_core8 = require("@deck.gl/core");
|
|
40
|
+
var import_constants4 = require("@luma.gl/constants");
|
|
41
|
+
|
|
42
|
+
// dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js
|
|
43
|
+
var import_engine = require("@luma.gl/engine");
|
|
44
|
+
var import_shadertools = require("@luma.gl/shadertools");
|
|
45
|
+
var import_constants2 = require("@luma.gl/constants");
|
|
46
|
+
var import_core = require("@deck.gl/core");
|
|
47
|
+
|
|
48
|
+
// dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js
|
|
49
|
+
var import_constants = require("@luma.gl/constants");
|
|
50
|
+
|
|
51
|
+
// dist/utils/aggregation-operation-utils.js
|
|
52
|
+
var AGGREGATION_OPERATION = {
|
|
53
|
+
SUM: 1,
|
|
54
|
+
MEAN: 2,
|
|
55
|
+
MIN: 3,
|
|
56
|
+
MAX: 4
|
|
57
|
+
};
|
|
58
|
+
function sumReducer(accu, cur) {
|
|
59
|
+
return accu + cur;
|
|
60
|
+
}
|
|
61
|
+
function maxReducer(accu, cur) {
|
|
62
|
+
return cur > accu ? cur : accu;
|
|
63
|
+
}
|
|
64
|
+
function minReducer(accu, cur) {
|
|
65
|
+
return cur < accu ? cur : accu;
|
|
66
|
+
}
|
|
67
|
+
function getMean(pts, accessor) {
|
|
68
|
+
if (Number.isFinite(accessor)) {
|
|
69
|
+
return pts.length ? accessor : null;
|
|
70
|
+
}
|
|
71
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
72
|
+
return filtered.length ? filtered.reduce(sumReducer, 0) / filtered.length : null;
|
|
73
|
+
}
|
|
74
|
+
function getSum(pts, accessor) {
|
|
75
|
+
if (Number.isFinite(accessor)) {
|
|
76
|
+
return pts.length ? pts.length * accessor : null;
|
|
77
|
+
}
|
|
78
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
79
|
+
return filtered.length ? filtered.reduce(sumReducer, 0) : null;
|
|
80
|
+
}
|
|
81
|
+
function getMax(pts, accessor) {
|
|
82
|
+
if (Number.isFinite(accessor)) {
|
|
83
|
+
return pts.length ? accessor : null;
|
|
84
|
+
}
|
|
85
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
86
|
+
return filtered.length ? filtered.reduce(maxReducer, -Infinity) : null;
|
|
87
|
+
}
|
|
88
|
+
function getMin(pts, accessor) {
|
|
89
|
+
if (Number.isFinite(accessor)) {
|
|
90
|
+
return pts.length ? accessor : null;
|
|
91
|
+
}
|
|
92
|
+
const filtered = pts.map(accessor).filter(Number.isFinite);
|
|
93
|
+
return filtered.length ? filtered.reduce(minReducer, Infinity) : null;
|
|
94
|
+
}
|
|
95
|
+
function getValueFunc(aggregation, accessor, context) {
|
|
96
|
+
const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
|
|
97
|
+
accessor = wrapAccessor(accessor, context);
|
|
98
|
+
switch (op) {
|
|
99
|
+
case AGGREGATION_OPERATION.MIN:
|
|
100
|
+
return (pts) => getMin(pts, accessor);
|
|
101
|
+
case AGGREGATION_OPERATION.SUM:
|
|
102
|
+
return (pts) => getSum(pts, accessor);
|
|
103
|
+
case AGGREGATION_OPERATION.MEAN:
|
|
104
|
+
return (pts) => getMean(pts, accessor);
|
|
105
|
+
case AGGREGATION_OPERATION.MAX:
|
|
106
|
+
return (pts) => getMax(pts, accessor);
|
|
107
|
+
default:
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function wrapAccessor(accessor, context = {}) {
|
|
112
|
+
if (Number.isFinite(accessor)) {
|
|
113
|
+
return accessor;
|
|
114
|
+
}
|
|
115
|
+
return (pt) => {
|
|
116
|
+
context.index = pt.index;
|
|
117
|
+
return accessor(pt.source, context);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function wrapGetValueFunc(getValue, context = {}) {
|
|
121
|
+
return (pts) => {
|
|
122
|
+
context.indices = pts.map((pt) => pt.index);
|
|
123
|
+
return getValue(pts.map((pt) => pt.source), context);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js
|
|
128
|
+
var DEFAULT_RUN_PARAMS = {
|
|
129
|
+
projectPoints: false,
|
|
130
|
+
viewport: null,
|
|
131
|
+
createBufferObjects: true,
|
|
132
|
+
moduleSettings: {}
|
|
133
|
+
};
|
|
134
|
+
var MAX_32_BIT_FLOAT = 3402823466e29;
|
|
135
|
+
var MIN_BLEND_EQUATION = [import_constants.GL.MIN, import_constants.GL.FUNC_ADD];
|
|
136
|
+
var MAX_BLEND_EQUATION = [import_constants.GL.MAX, import_constants.GL.FUNC_ADD];
|
|
137
|
+
var MAX_MIN_BLEND_EQUATION = [import_constants.GL.MAX, import_constants.GL.MIN];
|
|
138
|
+
var EQUATION_MAP = {
|
|
139
|
+
[AGGREGATION_OPERATION.SUM]: import_constants.GL.FUNC_ADD,
|
|
140
|
+
[AGGREGATION_OPERATION.MEAN]: import_constants.GL.FUNC_ADD,
|
|
141
|
+
[AGGREGATION_OPERATION.MIN]: MIN_BLEND_EQUATION,
|
|
142
|
+
[AGGREGATION_OPERATION.MAX]: MAX_BLEND_EQUATION
|
|
143
|
+
};
|
|
144
|
+
var DEFAULT_WEIGHT_PARAMS = {
|
|
145
|
+
size: 1,
|
|
146
|
+
operation: AGGREGATION_OPERATION.SUM,
|
|
147
|
+
needMin: false,
|
|
148
|
+
needMax: false,
|
|
149
|
+
combineMaxMin: false
|
|
150
|
+
};
|
|
151
|
+
var PIXEL_SIZE = 4;
|
|
152
|
+
var MAX_MIN_TEXTURE_OPTS = {
|
|
153
|
+
format: import_constants.GL.RGBA32F,
|
|
154
|
+
type: import_constants.GL.FLOAT,
|
|
155
|
+
border: 0,
|
|
156
|
+
mipmaps: false,
|
|
157
|
+
sampler: {
|
|
158
|
+
minFilter: "nearest",
|
|
159
|
+
magFilter: "nearest"
|
|
160
|
+
},
|
|
161
|
+
dataFormat: import_constants.GL.RGBA,
|
|
162
|
+
width: 1,
|
|
163
|
+
height: 1
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js
|
|
167
|
+
var aggregate_to_grid_vs_glsl_default = `#version 300 es
|
|
168
|
+
#define SHADER_NAME gpu-aggregation-to-grid-vs
|
|
169
|
+
|
|
170
|
+
in vec3 positions;
|
|
171
|
+
in vec3 positions64Low;
|
|
172
|
+
in vec3 weights;
|
|
173
|
+
uniform vec2 cellSize;
|
|
174
|
+
uniform vec2 gridSize;
|
|
175
|
+
uniform bool projectPoints;
|
|
176
|
+
uniform vec2 translation;
|
|
177
|
+
uniform vec3 scaling;
|
|
178
|
+
|
|
179
|
+
out vec3 vWeights;
|
|
180
|
+
|
|
181
|
+
vec2 project_to_pixel(vec4 pos) {
|
|
182
|
+
vec4 result;
|
|
183
|
+
pos.xy = pos.xy/pos.w;
|
|
184
|
+
result = pos + vec4(translation, 0., 0.);
|
|
185
|
+
result.xy = scaling.z > 0. ? result.xy * scaling.xy : result.xy;
|
|
186
|
+
return result.xy;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void main(void) {
|
|
190
|
+
|
|
191
|
+
vWeights = weights;
|
|
192
|
+
|
|
193
|
+
vec4 windowPos = vec4(positions, 1.);
|
|
194
|
+
if (projectPoints) {
|
|
195
|
+
windowPos = project_position_to_clipspace(positions, positions64Low, vec3(0));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
vec2 pos = project_to_pixel(windowPos);
|
|
199
|
+
|
|
200
|
+
vec2 pixelXY64[2];
|
|
201
|
+
pixelXY64[0] = vec2(pos.x, 0.);
|
|
202
|
+
pixelXY64[1] = vec2(pos.y, 0.);
|
|
203
|
+
|
|
204
|
+
// Transform (0,0):windowSize -> (0, 0): gridSize
|
|
205
|
+
vec2 gridXY64[2];
|
|
206
|
+
gridXY64[0] = div_fp64(pixelXY64[0], vec2(cellSize.x, 0));
|
|
207
|
+
gridXY64[1] = div_fp64(pixelXY64[1], vec2(cellSize.y, 0));
|
|
208
|
+
float x = floor(gridXY64[0].x);
|
|
209
|
+
float y = floor(gridXY64[1].x);
|
|
210
|
+
pos = vec2(x, y);
|
|
211
|
+
|
|
212
|
+
// Transform (0,0):gridSize -> (-1, -1):(1,1)
|
|
213
|
+
pos = (pos * (2., 2.) / (gridSize)) - (1., 1.);
|
|
214
|
+
|
|
215
|
+
// Move to pixel center, pixel-size in screen sapce (2/gridSize) * 0.5 => 1/gridSize
|
|
216
|
+
vec2 offset = 1.0 / gridSize;
|
|
217
|
+
pos = pos + offset;
|
|
218
|
+
|
|
219
|
+
gl_Position = vec4(pos, 0.0, 1.0);
|
|
220
|
+
|
|
221
|
+
// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)
|
|
222
|
+
gl_PointSize = 1.0;
|
|
223
|
+
}
|
|
224
|
+
`;
|
|
225
|
+
|
|
226
|
+
// dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js
|
|
227
|
+
var aggregate_to_grid_fs_glsl_default = `#version 300 es
|
|
228
|
+
#define SHADER_NAME gpu-aggregation-to-grid-fs
|
|
229
|
+
|
|
230
|
+
precision highp float;
|
|
231
|
+
|
|
232
|
+
in vec3 vWeights;
|
|
233
|
+
|
|
234
|
+
out vec4 fragColor;
|
|
235
|
+
|
|
236
|
+
void main(void) {
|
|
237
|
+
fragColor = vec4(vWeights, 1.0);
|
|
238
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
239
|
+
}
|
|
240
|
+
`;
|
|
241
|
+
|
|
242
|
+
// dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js
|
|
243
|
+
var aggregate_all_vs_glsl_default = `#version 300 es
|
|
244
|
+
#define SHADER_NAME gpu-aggregation-all-vs-64
|
|
245
|
+
|
|
246
|
+
in vec2 position;
|
|
247
|
+
uniform ivec2 gridSize;
|
|
248
|
+
out vec2 vTextureCoord;
|
|
249
|
+
|
|
250
|
+
void main(void) {
|
|
251
|
+
// Map each position to single pixel
|
|
252
|
+
vec2 pos = vec2(-1.0, -1.0);
|
|
253
|
+
|
|
254
|
+
// Move to pixel center, pixel-size in screen sapce (2/gridSize) * 0.5 => 1/gridSize
|
|
255
|
+
vec2 offset = 1.0 / vec2(gridSize);
|
|
256
|
+
pos = pos + offset;
|
|
257
|
+
|
|
258
|
+
gl_Position = vec4(pos, 0.0, 1.0);
|
|
259
|
+
|
|
260
|
+
int yIndex = gl_InstanceID / gridSize[0];
|
|
261
|
+
int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
|
|
262
|
+
|
|
263
|
+
vec2 yIndexFP64 = vec2(float(yIndex), 0.);
|
|
264
|
+
vec2 xIndexFP64 = vec2(float(xIndex), 0.);
|
|
265
|
+
vec2 gridSizeYFP64 = vec2(gridSize[1], 0.);
|
|
266
|
+
vec2 gridSizeXFP64 = vec2(gridSize[0], 0.);
|
|
267
|
+
|
|
268
|
+
vec2 texCoordXFP64 = div_fp64(yIndexFP64, gridSizeYFP64);
|
|
269
|
+
vec2 texCoordYFP64 = div_fp64(xIndexFP64, gridSizeXFP64);
|
|
270
|
+
|
|
271
|
+
vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x);
|
|
272
|
+
// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)
|
|
273
|
+
gl_PointSize = 1.0;
|
|
274
|
+
}
|
|
275
|
+
`;
|
|
276
|
+
|
|
277
|
+
// dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js
|
|
278
|
+
var aggregate_all_fs_glsl_default = `#version 300 es
|
|
279
|
+
#define SHADER_NAME gpu-aggregation-all-fs
|
|
280
|
+
|
|
281
|
+
precision highp float;
|
|
282
|
+
|
|
283
|
+
in vec2 vTextureCoord;
|
|
284
|
+
uniform sampler2D uSampler;
|
|
285
|
+
uniform bool combineMaxMin;
|
|
286
|
+
out vec4 fragColor;
|
|
287
|
+
void main(void) {
|
|
288
|
+
vec4 textureColor = texture(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
|
|
289
|
+
if (textureColor.a == 0.) {
|
|
290
|
+
discard;
|
|
291
|
+
}
|
|
292
|
+
fragColor.rgb = textureColor.rgb;
|
|
293
|
+
// if combineMinMax is true, use Alpha channel for first weights min value.
|
|
294
|
+
fragColor.a = combineMaxMin ? textureColor.r : textureColor.a;
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
|
|
298
|
+
// dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js
|
|
299
|
+
var transform_mean_vs_glsl_default = `#version 300 es
|
|
300
|
+
#define SHADER_NAME gpu-aggregation-transform-mean-vs
|
|
301
|
+
in vec4 aggregationValues;
|
|
302
|
+
out vec4 meanValues;
|
|
303
|
+
|
|
304
|
+
void main()
|
|
305
|
+
{
|
|
306
|
+
// TODO: Use 64-bit division ?? not needed given this is aggregation ??
|
|
307
|
+
bool isCellValid = bool(aggregationValues.w > 0.);
|
|
308
|
+
// aggregationValues: XYZ contain aggregated values, W contains count
|
|
309
|
+
meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0);
|
|
310
|
+
meanValues.w = aggregationValues.w;
|
|
311
|
+
|
|
312
|
+
// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)
|
|
313
|
+
gl_PointSize = 1.0;
|
|
314
|
+
}
|
|
315
|
+
`;
|
|
316
|
+
|
|
317
|
+
// dist/utils/resource-utils.js
|
|
318
|
+
var DEFAULT_PARAMETERS = {
|
|
319
|
+
minFilter: "nearest",
|
|
320
|
+
magFilter: "nearest"
|
|
321
|
+
};
|
|
322
|
+
function getFloatTexture(device, opts) {
|
|
323
|
+
const { width = 1, height = 1, data = null, parameters = DEFAULT_PARAMETERS } = opts;
|
|
324
|
+
const texture = device.createTexture({
|
|
325
|
+
data,
|
|
326
|
+
format: "rgba32float",
|
|
327
|
+
mipmaps: false,
|
|
328
|
+
sampler: parameters,
|
|
329
|
+
width,
|
|
330
|
+
height
|
|
331
|
+
});
|
|
332
|
+
return texture;
|
|
333
|
+
}
|
|
334
|
+
function getFramebuffer(device, opts) {
|
|
335
|
+
const { id, width = 1, height = 1, texture } = opts;
|
|
336
|
+
const fb = device.createFramebuffer({
|
|
337
|
+
id,
|
|
338
|
+
width,
|
|
339
|
+
height,
|
|
340
|
+
colorAttachments: [texture]
|
|
341
|
+
});
|
|
342
|
+
return fb;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js
|
|
346
|
+
var BUFFER_NAMES = ["aggregationBuffer", "maxMinBuffer", "minBuffer", "maxBuffer"];
|
|
347
|
+
var ARRAY_BUFFER_MAP = {
|
|
348
|
+
maxData: "maxBuffer",
|
|
349
|
+
minData: "minBuffer",
|
|
350
|
+
maxMinData: "maxMinBuffer"
|
|
351
|
+
};
|
|
352
|
+
var REQUIRED_FEATURES = [
|
|
353
|
+
"webgl2",
|
|
354
|
+
"blend-minmax-webgl1",
|
|
355
|
+
"texture-renderable-float32-webgl",
|
|
356
|
+
"texture-blend-float-webgl1",
|
|
357
|
+
"texture-formats-float32-webgl1"
|
|
358
|
+
];
|
|
359
|
+
var GPUGridAggregator = class {
|
|
360
|
+
static getAggregationData({ aggregationData, maxData, minData, maxMinData, pixelIndex }) {
|
|
361
|
+
const index = pixelIndex * PIXEL_SIZE;
|
|
362
|
+
const results = {};
|
|
363
|
+
if (aggregationData) {
|
|
364
|
+
results.cellCount = aggregationData[index + 3];
|
|
365
|
+
results.cellWeight = aggregationData[index];
|
|
366
|
+
}
|
|
367
|
+
if (maxMinData) {
|
|
368
|
+
results.maxCellWieght = maxMinData[0];
|
|
369
|
+
results.minCellWeight = maxMinData[3];
|
|
370
|
+
} else {
|
|
371
|
+
if (maxData) {
|
|
372
|
+
results.maxCellWieght = maxData[0];
|
|
373
|
+
results.totalCount = maxData[3];
|
|
374
|
+
}
|
|
375
|
+
if (minData) {
|
|
376
|
+
results.minCellWeight = minData[0];
|
|
377
|
+
results.totalCount = minData[3];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return results;
|
|
381
|
+
}
|
|
382
|
+
static getCellData({ countsData, size = 1 }) {
|
|
383
|
+
const numCells = countsData.length / 4;
|
|
384
|
+
const cellWeights = new Float32Array(numCells * size);
|
|
385
|
+
const cellCounts = new Uint32Array(numCells);
|
|
386
|
+
for (let i = 0; i < numCells; i++) {
|
|
387
|
+
for (let sizeIndex = 0; sizeIndex < size; sizeIndex++) {
|
|
388
|
+
cellWeights[i * size + sizeIndex] = countsData[i * 4 + sizeIndex];
|
|
389
|
+
}
|
|
390
|
+
cellCounts[i] = countsData[i * 4 + 3];
|
|
391
|
+
}
|
|
392
|
+
return { cellCounts, cellWeights };
|
|
393
|
+
}
|
|
394
|
+
static isSupported(device) {
|
|
395
|
+
return REQUIRED_FEATURES.every((feature) => device.features.has(feature));
|
|
396
|
+
}
|
|
397
|
+
constructor(device, props = {}) {
|
|
398
|
+
this.state = {
|
|
399
|
+
weightAttributes: {},
|
|
400
|
+
textures: {},
|
|
401
|
+
meanTextures: {},
|
|
402
|
+
buffers: {},
|
|
403
|
+
framebuffers: {},
|
|
404
|
+
maxMinFramebuffers: {},
|
|
405
|
+
minFramebuffers: {},
|
|
406
|
+
maxFramebuffers: {},
|
|
407
|
+
equations: {},
|
|
408
|
+
shaderOptions: {},
|
|
409
|
+
modelDirty: false,
|
|
410
|
+
resources: {},
|
|
411
|
+
results: {}
|
|
412
|
+
};
|
|
413
|
+
this.id = props.id || "gpu-grid-aggregator";
|
|
414
|
+
this.device = device;
|
|
415
|
+
const REQUIRED_FEATURES3 = [
|
|
416
|
+
"blend-minmax-webgl1",
|
|
417
|
+
"texture-renderable-float32-webgl",
|
|
418
|
+
"texture-formats-float32-webgl1"
|
|
419
|
+
];
|
|
420
|
+
this._hasGPUSupport = this.device.info.type === "webgl2" && REQUIRED_FEATURES3.every((feature) => device.features.has(feature));
|
|
421
|
+
if (this._hasGPUSupport) {
|
|
422
|
+
this._setupModels();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
delete() {
|
|
426
|
+
const { gridAggregationModel, allAggregationModel, meanTransform } = this;
|
|
427
|
+
const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, resources } = this.state;
|
|
428
|
+
gridAggregationModel == null ? void 0 : gridAggregationModel.destroy();
|
|
429
|
+
allAggregationModel == null ? void 0 : allAggregationModel.destroy();
|
|
430
|
+
meanTransform == null ? void 0 : meanTransform.destroy();
|
|
431
|
+
deleteResources([
|
|
432
|
+
framebuffers,
|
|
433
|
+
textures,
|
|
434
|
+
maxMinFramebuffers,
|
|
435
|
+
minFramebuffers,
|
|
436
|
+
maxFramebuffers,
|
|
437
|
+
meanTextures,
|
|
438
|
+
resources
|
|
439
|
+
]);
|
|
440
|
+
}
|
|
441
|
+
run(opts = {}) {
|
|
442
|
+
this.setState({ results: {} });
|
|
443
|
+
const aggregationParams = this._normalizeAggregationParams(opts);
|
|
444
|
+
if (!this._hasGPUSupport) {
|
|
445
|
+
import_core.log.log(1, "GPUGridAggregator: not supported")();
|
|
446
|
+
}
|
|
447
|
+
return this._runAggregation(aggregationParams);
|
|
448
|
+
}
|
|
449
|
+
getData(weightId) {
|
|
450
|
+
const data = {};
|
|
451
|
+
const results = this.state.results;
|
|
452
|
+
if (!results[weightId].aggregationData) {
|
|
453
|
+
results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
|
|
454
|
+
}
|
|
455
|
+
data.aggregationData = results[weightId].aggregationData;
|
|
456
|
+
for (const arrayName in ARRAY_BUFFER_MAP) {
|
|
457
|
+
const bufferName = ARRAY_BUFFER_MAP[arrayName];
|
|
458
|
+
if (results[weightId][arrayName] || results[weightId][bufferName]) {
|
|
459
|
+
results[weightId][arrayName] = results[weightId][arrayName] || results[weightId][bufferName].getData();
|
|
460
|
+
data[arrayName] = results[weightId][arrayName];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return data;
|
|
464
|
+
}
|
|
465
|
+
updateShaders(shaderOptions = {}) {
|
|
466
|
+
this.setState({ shaderOptions, modelDirty: true });
|
|
467
|
+
}
|
|
468
|
+
_normalizeAggregationParams(opts) {
|
|
469
|
+
const aggregationParams = { ...DEFAULT_RUN_PARAMS, ...opts };
|
|
470
|
+
const { weights } = aggregationParams;
|
|
471
|
+
if (weights) {
|
|
472
|
+
aggregationParams.weights = normalizeWeightParams(weights);
|
|
473
|
+
}
|
|
474
|
+
return aggregationParams;
|
|
475
|
+
}
|
|
476
|
+
setState(updateObject) {
|
|
477
|
+
Object.assign(this.state, updateObject);
|
|
478
|
+
}
|
|
479
|
+
_getAggregateData(opts) {
|
|
480
|
+
const results = {};
|
|
481
|
+
const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, resources } = this.state;
|
|
482
|
+
const { weights } = opts;
|
|
483
|
+
for (const id in weights) {
|
|
484
|
+
results[id] = {};
|
|
485
|
+
const { needMin, needMax, combineMaxMin } = weights[id];
|
|
486
|
+
results[id].aggregationTexture = textures[id];
|
|
487
|
+
results[id].aggregationBuffer = this.device.readPixelsToBufferWebGL(framebuffers[id], {
|
|
488
|
+
target: weights[id].aggregationBuffer,
|
|
489
|
+
sourceType: import_constants2.GL.FLOAT
|
|
490
|
+
});
|
|
491
|
+
if (needMin && needMax && combineMaxMin) {
|
|
492
|
+
results[id].maxMinBuffer = this.device.readPixelsToBufferWebGL(maxMinFramebuffers[id], {
|
|
493
|
+
target: weights[id].maxMinBuffer,
|
|
494
|
+
sourceType: import_constants2.GL.FLOAT
|
|
495
|
+
});
|
|
496
|
+
results[id].maxMinTexture = resources[`${id}-maxMinTexture`];
|
|
497
|
+
} else {
|
|
498
|
+
if (needMin) {
|
|
499
|
+
results[id].minBuffer = this.device.readPixelsToBufferWebGL(minFramebuffers[id], {
|
|
500
|
+
target: weights[id].minBuffer,
|
|
501
|
+
sourceType: import_constants2.GL.FLOAT
|
|
502
|
+
});
|
|
503
|
+
results[id].minTexture = resources[`${id}-minTexture`];
|
|
504
|
+
}
|
|
505
|
+
if (needMax) {
|
|
506
|
+
results[id].maxBuffer = this.device.readPixelsToBufferWebGL(maxFramebuffers[id], {
|
|
507
|
+
target: weights[id].maxBuffer,
|
|
508
|
+
sourceType: import_constants2.GL.FLOAT
|
|
509
|
+
});
|
|
510
|
+
results[id].maxTexture = resources[`${id}-maxTexture`];
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
this._trackGPUResultBuffers(results, weights);
|
|
515
|
+
return results;
|
|
516
|
+
}
|
|
517
|
+
_renderAggregateData(opts) {
|
|
518
|
+
const { cellSize, projectPoints, attributes, moduleSettings, numCol, numRow, weights, translation, scaling } = opts;
|
|
519
|
+
const { maxMinFramebuffers, minFramebuffers, maxFramebuffers } = this.state;
|
|
520
|
+
const gridSize = [numCol, numRow];
|
|
521
|
+
const parameters = {
|
|
522
|
+
blend: true,
|
|
523
|
+
depthTest: false,
|
|
524
|
+
blendFunc: [import_constants2.GL.ONE, import_constants2.GL.ONE]
|
|
525
|
+
};
|
|
526
|
+
const uniforms = {
|
|
527
|
+
cellSize,
|
|
528
|
+
gridSize,
|
|
529
|
+
projectPoints,
|
|
530
|
+
translation,
|
|
531
|
+
scaling
|
|
532
|
+
};
|
|
533
|
+
for (const id in weights) {
|
|
534
|
+
const { needMin, needMax } = weights[id];
|
|
535
|
+
const combineMaxMin = needMin && needMax && weights[id].combineMaxMin;
|
|
536
|
+
this._renderToWeightsTexture({
|
|
537
|
+
id,
|
|
538
|
+
parameters,
|
|
539
|
+
moduleSettings,
|
|
540
|
+
uniforms,
|
|
541
|
+
gridSize,
|
|
542
|
+
attributes,
|
|
543
|
+
weights
|
|
544
|
+
});
|
|
545
|
+
if (combineMaxMin) {
|
|
546
|
+
this._renderToMaxMinTexture({
|
|
547
|
+
id,
|
|
548
|
+
parameters: { ...parameters, blendEquation: MAX_MIN_BLEND_EQUATION },
|
|
549
|
+
gridSize,
|
|
550
|
+
minOrMaxFb: maxMinFramebuffers[id],
|
|
551
|
+
clearParams: { clearColor: [0, 0, 0, MAX_32_BIT_FLOAT] },
|
|
552
|
+
combineMaxMin
|
|
553
|
+
});
|
|
554
|
+
} else {
|
|
555
|
+
if (needMin) {
|
|
556
|
+
this._renderToMaxMinTexture({
|
|
557
|
+
id,
|
|
558
|
+
parameters: { ...parameters, blendEquation: MIN_BLEND_EQUATION },
|
|
559
|
+
gridSize,
|
|
560
|
+
minOrMaxFb: minFramebuffers[id],
|
|
561
|
+
clearParams: { clearColor: [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0] },
|
|
562
|
+
combineMaxMin
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (needMax) {
|
|
566
|
+
this._renderToMaxMinTexture({
|
|
567
|
+
id,
|
|
568
|
+
parameters: { ...parameters, blendEquation: MAX_BLEND_EQUATION },
|
|
569
|
+
gridSize,
|
|
570
|
+
minOrMaxFb: maxFramebuffers[id],
|
|
571
|
+
clearParams: { clearColor: [0, 0, 0, 0] },
|
|
572
|
+
combineMaxMin
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
_renderToMaxMinTexture(opts) {
|
|
579
|
+
const { id, parameters, gridSize, minOrMaxFb, combineMaxMin, clearParams = {} } = opts;
|
|
580
|
+
const { framebuffers } = this.state;
|
|
581
|
+
const { allAggregationModel } = this;
|
|
582
|
+
this.device.withParametersWebGL({
|
|
583
|
+
...clearParams,
|
|
584
|
+
framebuffer: minOrMaxFb,
|
|
585
|
+
viewport: [0, 0, gridSize[0], gridSize[1]]
|
|
586
|
+
}, () => {
|
|
587
|
+
this.device.clearWebGL({ color: true });
|
|
588
|
+
allAggregationModel.setUniforms({ gridSize, combineMaxMin });
|
|
589
|
+
allAggregationModel.setBindings({ uSampler: framebuffers[id].texture });
|
|
590
|
+
allAggregationModel.draw();
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
_renderToWeightsTexture(opts) {
|
|
594
|
+
const { id, parameters, moduleSettings, uniforms, gridSize, weights } = opts;
|
|
595
|
+
const { framebuffers, equations, weightAttributes } = this.state;
|
|
596
|
+
const { gridAggregationModel } = this;
|
|
597
|
+
const { operation } = weights[id];
|
|
598
|
+
const clearColor = operation === AGGREGATION_OPERATION.MIN ? [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0] : [0, 0, 0, 0];
|
|
599
|
+
this.device.withParametersWebGL({
|
|
600
|
+
framebuffer: framebuffers[id],
|
|
601
|
+
viewport: [0, 0, gridSize[0], gridSize[1]],
|
|
602
|
+
clearColor
|
|
603
|
+
}, () => {
|
|
604
|
+
this.device.clearWebGL({ color: true });
|
|
605
|
+
const attributes = { weights: weightAttributes[id] };
|
|
606
|
+
gridAggregationModel.draw({
|
|
607
|
+
parameters: { ...parameters, blendEquation: equations[id] },
|
|
608
|
+
moduleSettings,
|
|
609
|
+
uniforms,
|
|
610
|
+
attributes
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
if (operation === AGGREGATION_OPERATION.MEAN) {
|
|
614
|
+
const { meanTextures, textures } = this.state;
|
|
615
|
+
const transformOptions = {
|
|
616
|
+
_sourceTextures: { aggregationValues: meanTextures[id] },
|
|
617
|
+
_targetTexture: textures[id],
|
|
618
|
+
elementCount: textures[id].width * textures[id].height
|
|
619
|
+
};
|
|
620
|
+
if (this.meanTransform) {
|
|
621
|
+
this.meanTransform.update(transformOptions);
|
|
622
|
+
} else {
|
|
623
|
+
this.meanTransform = getMeanTransform(this.device, transformOptions);
|
|
624
|
+
}
|
|
625
|
+
this.meanTransform.run({
|
|
626
|
+
parameters: {
|
|
627
|
+
blend: false,
|
|
628
|
+
depthTest: false
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
framebuffers[id].attach({ [import_constants2.GL.COLOR_ATTACHMENT0]: textures[id] });
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
_runAggregation(opts) {
|
|
635
|
+
this._updateModels(opts);
|
|
636
|
+
this._setupFramebuffers(opts);
|
|
637
|
+
this._renderAggregateData(opts);
|
|
638
|
+
const results = this._getAggregateData(opts);
|
|
639
|
+
this.setState({ results });
|
|
640
|
+
return results;
|
|
641
|
+
}
|
|
642
|
+
_setupFramebuffers(opts) {
|
|
643
|
+
const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, equations } = this.state;
|
|
644
|
+
const { weights } = opts;
|
|
645
|
+
const { numCol, numRow } = opts;
|
|
646
|
+
const framebufferSize = { width: numCol, height: numRow };
|
|
647
|
+
for (const id in weights) {
|
|
648
|
+
const { needMin, needMax, combineMaxMin, operation } = weights[id];
|
|
649
|
+
textures[id] = weights[id].aggregationTexture || textures[id] || getFloatTexture(this.device, { id: `${id}-texture`, width: numCol, height: numRow });
|
|
650
|
+
textures[id].resize(framebufferSize);
|
|
651
|
+
let texture = textures[id];
|
|
652
|
+
if (operation === AGGREGATION_OPERATION.MEAN) {
|
|
653
|
+
meanTextures[id] = meanTextures[id] || getFloatTexture(this.device, { id: `${id}-mean-texture`, width: numCol, height: numRow });
|
|
654
|
+
meanTextures[id].resize(framebufferSize);
|
|
655
|
+
texture = meanTextures[id];
|
|
656
|
+
}
|
|
657
|
+
if (framebuffers[id]) {
|
|
658
|
+
framebuffers[id].attach({ [import_constants2.GL.COLOR_ATTACHMENT0]: texture });
|
|
659
|
+
} else {
|
|
660
|
+
framebuffers[id] = getFramebuffer(this.device, {
|
|
661
|
+
id: `${id}-fb`,
|
|
662
|
+
width: numCol,
|
|
663
|
+
height: numRow,
|
|
664
|
+
texture
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
framebuffers[id].resize(framebufferSize);
|
|
668
|
+
equations[id] = EQUATION_MAP[operation] || EQUATION_MAP[AGGREGATION_OPERATION.SUM];
|
|
669
|
+
if (needMin || needMax) {
|
|
670
|
+
if (needMin && needMax && combineMaxMin) {
|
|
671
|
+
if (!maxMinFramebuffers[id]) {
|
|
672
|
+
texture = weights[id].maxMinTexture || this._getMinMaxTexture(`${id}-maxMinTexture`);
|
|
673
|
+
maxMinFramebuffers[id] = getFramebuffer(this.device, { id: `${id}-maxMinFb`, texture });
|
|
674
|
+
}
|
|
675
|
+
} else {
|
|
676
|
+
if (needMin) {
|
|
677
|
+
if (!minFramebuffers[id]) {
|
|
678
|
+
texture = weights[id].minTexture || this._getMinMaxTexture(`${id}-minTexture`);
|
|
679
|
+
minFramebuffers[id] = getFramebuffer(this.device, {
|
|
680
|
+
id: `${id}-minFb`,
|
|
681
|
+
texture
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (needMax) {
|
|
686
|
+
if (!maxFramebuffers[id]) {
|
|
687
|
+
texture = weights[id].maxTexture || this._getMinMaxTexture(`${id}-maxTexture`);
|
|
688
|
+
maxFramebuffers[id] = getFramebuffer(this.device, {
|
|
689
|
+
id: `${id}-maxFb`,
|
|
690
|
+
texture
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
_getMinMaxTexture(name) {
|
|
699
|
+
const { resources } = this.state;
|
|
700
|
+
if (!resources[name]) {
|
|
701
|
+
resources[name] = getFloatTexture(this.device, { id: "resourceName" });
|
|
702
|
+
}
|
|
703
|
+
return resources[name];
|
|
704
|
+
}
|
|
705
|
+
_setupModels({ numCol = 0, numRow = 0 } = {}) {
|
|
706
|
+
var _a;
|
|
707
|
+
const { shaderOptions } = this.state;
|
|
708
|
+
(_a = this.gridAggregationModel) == null ? void 0 : _a.destroy();
|
|
709
|
+
this.gridAggregationModel = getAggregationModel(this.device, shaderOptions);
|
|
710
|
+
if (!this.allAggregationModel) {
|
|
711
|
+
const instanceCount = numCol * numRow;
|
|
712
|
+
this.allAggregationModel = getAllAggregationModel(this.device, instanceCount);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
_setupWeightAttributes(opts) {
|
|
716
|
+
const { weightAttributes } = this.state;
|
|
717
|
+
const { weights } = opts;
|
|
718
|
+
for (const id in weights) {
|
|
719
|
+
weightAttributes[id] = opts.attributes[id];
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
_trackGPUResultBuffers(results, weights) {
|
|
723
|
+
const { resources } = this.state;
|
|
724
|
+
for (const id in results) {
|
|
725
|
+
if (results[id]) {
|
|
726
|
+
for (const bufferName of BUFFER_NAMES) {
|
|
727
|
+
if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
|
|
728
|
+
const name = `gpu-result-${id}-${bufferName}`;
|
|
729
|
+
if (resources[name]) {
|
|
730
|
+
resources[name].delete();
|
|
731
|
+
}
|
|
732
|
+
resources[name] = results[id][bufferName];
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
_updateModels(opts) {
|
|
739
|
+
const { vertexCount, attributes, numCol, numRow } = opts;
|
|
740
|
+
const { modelDirty } = this.state;
|
|
741
|
+
if (modelDirty) {
|
|
742
|
+
this._setupModels(opts);
|
|
743
|
+
this.setState({ modelDirty: false });
|
|
744
|
+
}
|
|
745
|
+
this._setupWeightAttributes(opts);
|
|
746
|
+
this.gridAggregationModel.setVertexCount(vertexCount);
|
|
747
|
+
this.gridAggregationModel.setAttributes(attributes);
|
|
748
|
+
this.allAggregationModel.setInstanceCount(numCol * numRow);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
function normalizeWeightParams(weights) {
|
|
752
|
+
const result = {};
|
|
753
|
+
for (const id in weights) {
|
|
754
|
+
result[id] = { ...DEFAULT_WEIGHT_PARAMS, ...weights[id] };
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
function deleteResources(resources) {
|
|
759
|
+
resources = Array.isArray(resources) ? resources : [resources];
|
|
760
|
+
resources.forEach((obj) => {
|
|
761
|
+
for (const name in obj) {
|
|
762
|
+
obj[name].delete();
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
function getAggregationModel(device, shaderOptions) {
|
|
767
|
+
const shaders = (0, import_core._mergeShaders)({
|
|
768
|
+
vs: aggregate_to_grid_vs_glsl_default,
|
|
769
|
+
fs: aggregate_to_grid_fs_glsl_default,
|
|
770
|
+
modules: [import_shadertools.fp64arithmetic, import_core.project32]
|
|
771
|
+
}, shaderOptions);
|
|
772
|
+
return new import_engine.Model(device, {
|
|
773
|
+
id: "Grid-Aggregation-Model",
|
|
774
|
+
vertexCount: 1,
|
|
775
|
+
drawMode: import_constants2.GL.POINTS,
|
|
776
|
+
shaderAssembler: (0, import_core.getShaderAssembler)(),
|
|
777
|
+
...shaders
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function getAllAggregationModel(device, instanceCount) {
|
|
781
|
+
return new import_engine.Model(device, {
|
|
782
|
+
id: "All-Aggregation-Model",
|
|
783
|
+
vs: aggregate_all_vs_glsl_default,
|
|
784
|
+
fs: aggregate_all_fs_glsl_default,
|
|
785
|
+
modules: [import_shadertools.fp64arithmetic],
|
|
786
|
+
vertexCount: 1,
|
|
787
|
+
topology: "point-list",
|
|
788
|
+
isInstanced: true,
|
|
789
|
+
instanceCount,
|
|
790
|
+
attributes: {
|
|
791
|
+
position: [0, 0]
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
function getMeanTransform(device, opts) {
|
|
796
|
+
return new import_engine.TextureTransform(device, {
|
|
797
|
+
vs: transform_mean_vs_glsl_default,
|
|
798
|
+
_targetTextureVarying: "meanValues",
|
|
799
|
+
...opts
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// dist/screen-grid-layer/screen-grid-cell-layer.js
|
|
804
|
+
var import_engine2 = require("@luma.gl/engine");
|
|
805
|
+
var import_core2 = require("@deck.gl/core");
|
|
806
|
+
|
|
807
|
+
// dist/utils/color-utils.js
|
|
808
|
+
var defaultColorRange = [
|
|
809
|
+
[255, 255, 178],
|
|
810
|
+
[254, 217, 118],
|
|
811
|
+
[254, 178, 76],
|
|
812
|
+
[253, 141, 60],
|
|
813
|
+
[240, 59, 32],
|
|
814
|
+
[189, 0, 38]
|
|
815
|
+
];
|
|
816
|
+
function colorRangeToFlatArray(colorRange, normalize = false, ArrayType = Float32Array) {
|
|
817
|
+
let flatArray;
|
|
818
|
+
if (Number.isFinite(colorRange[0])) {
|
|
819
|
+
flatArray = new ArrayType(colorRange);
|
|
820
|
+
} else {
|
|
821
|
+
flatArray = new ArrayType(colorRange.length * 4);
|
|
822
|
+
let index = 0;
|
|
823
|
+
for (let i = 0; i < colorRange.length; i++) {
|
|
824
|
+
const color = colorRange[i];
|
|
825
|
+
flatArray[index++] = color[0];
|
|
826
|
+
flatArray[index++] = color[1];
|
|
827
|
+
flatArray[index++] = color[2];
|
|
828
|
+
flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
if (normalize) {
|
|
832
|
+
for (let i = 0; i < flatArray.length; i++) {
|
|
833
|
+
flatArray[i] /= 255;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return flatArray;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js
|
|
840
|
+
var screen_grid_layer_vertex_glsl_default = `#version 300 es
|
|
841
|
+
#define SHADER_NAME screen-grid-layer-vertex-shader
|
|
842
|
+
#define RANGE_COUNT 6
|
|
843
|
+
|
|
844
|
+
in vec3 positions;
|
|
845
|
+
in vec3 instancePositions;
|
|
846
|
+
in vec4 instanceCounts;
|
|
847
|
+
in vec3 instancePickingColors;
|
|
848
|
+
|
|
849
|
+
uniform float opacity;
|
|
850
|
+
uniform vec3 cellScale;
|
|
851
|
+
uniform vec4 minColor;
|
|
852
|
+
uniform vec4 maxColor;
|
|
853
|
+
uniform vec4 colorRange[RANGE_COUNT];
|
|
854
|
+
uniform vec2 colorDomain;
|
|
855
|
+
uniform bool shouldUseMinMax;
|
|
856
|
+
uniform sampler2D maxTexture;
|
|
857
|
+
|
|
858
|
+
out vec4 vColor;
|
|
859
|
+
out float vSampleCount;
|
|
860
|
+
|
|
861
|
+
vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
|
|
862
|
+
vec4 outColor = vec4(0., 0., 0., 0.);
|
|
863
|
+
if (value >= domain.x && value <= domain.y) {
|
|
864
|
+
float domainRange = domain.y - domain.x;
|
|
865
|
+
if (domainRange <= 0.) {
|
|
866
|
+
outColor = colorRange[0];
|
|
867
|
+
} else {
|
|
868
|
+
float rangeCount = float(RANGE_COUNT);
|
|
869
|
+
float rangeStep = domainRange / rangeCount;
|
|
870
|
+
float idx = floor((value - domain.x) / rangeStep);
|
|
871
|
+
idx = clamp(idx, 0., rangeCount - 1.);
|
|
872
|
+
int intIdx = int(idx);
|
|
873
|
+
outColor = colorRange[intIdx];
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
outColor = outColor / 255.;
|
|
877
|
+
return outColor;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
void main(void) {
|
|
881
|
+
vSampleCount = instanceCounts.a;
|
|
882
|
+
|
|
883
|
+
float weight = instanceCounts.r;
|
|
884
|
+
float maxWeight = texture(maxTexture, vec2(0.5)).r;
|
|
885
|
+
|
|
886
|
+
float step = weight / maxWeight;
|
|
887
|
+
vec4 minMaxColor = mix(minColor, maxColor, step) / 255.;
|
|
888
|
+
|
|
889
|
+
vec2 domain = colorDomain;
|
|
890
|
+
float domainMaxValid = float(colorDomain.y != 0.);
|
|
891
|
+
domain.y = mix(maxWeight, colorDomain.y, domainMaxValid);
|
|
892
|
+
vec4 rangeColor = quantizeScale(domain, colorRange, weight);
|
|
893
|
+
|
|
894
|
+
float rangeMinMax = float(shouldUseMinMax);
|
|
895
|
+
vec4 color = mix(rangeColor, minMaxColor, rangeMinMax);
|
|
896
|
+
vColor = vec4(color.rgb, color.a * opacity);
|
|
897
|
+
|
|
898
|
+
// Set color to be rendered to picking fbo (also used to check for selection highlight).
|
|
899
|
+
picking_setPickingColor(instancePickingColors);
|
|
900
|
+
|
|
901
|
+
gl_Position = vec4(instancePositions + positions * cellScale, 1.);
|
|
902
|
+
}
|
|
903
|
+
`;
|
|
904
|
+
|
|
905
|
+
// dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js
|
|
906
|
+
var screen_grid_layer_fragment_glsl_default = `#version 300 es
|
|
907
|
+
#define SHADER_NAME screen-grid-layer-fragment-shader
|
|
908
|
+
|
|
909
|
+
precision highp float;
|
|
910
|
+
|
|
911
|
+
in vec4 vColor;
|
|
912
|
+
in float vSampleCount;
|
|
913
|
+
|
|
914
|
+
out vec4 fragColor;
|
|
915
|
+
|
|
916
|
+
void main(void) {
|
|
917
|
+
if (vSampleCount <= 0.0) {
|
|
918
|
+
discard;
|
|
919
|
+
}
|
|
920
|
+
fragColor = vColor;
|
|
921
|
+
|
|
922
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
923
|
+
}
|
|
924
|
+
`;
|
|
925
|
+
|
|
926
|
+
// dist/screen-grid-layer/screen-grid-cell-layer.js
|
|
927
|
+
var DEFAULT_MINCOLOR = [0, 0, 0, 0];
|
|
928
|
+
var DEFAULT_MAXCOLOR = [0, 255, 0, 255];
|
|
929
|
+
var COLOR_PROPS = ["minColor", "maxColor", "colorRange", "colorDomain"];
|
|
930
|
+
var defaultProps = {
|
|
931
|
+
cellSizePixels: { type: "number", value: 100, min: 1 },
|
|
932
|
+
cellMarginPixels: { type: "number", value: 2, min: 0, max: 5 },
|
|
933
|
+
colorDomain: null,
|
|
934
|
+
colorRange: defaultColorRange
|
|
935
|
+
};
|
|
936
|
+
var _ScreenGridCellLayer = class extends import_core2.Layer {
|
|
937
|
+
static isSupported(device) {
|
|
938
|
+
return device.features.has("texture-formats-float32-webgl1");
|
|
939
|
+
}
|
|
940
|
+
getShaders() {
|
|
941
|
+
return { vs: screen_grid_layer_vertex_glsl_default, fs: screen_grid_layer_fragment_glsl_default, modules: [import_core2.picking] };
|
|
942
|
+
}
|
|
943
|
+
initializeState() {
|
|
944
|
+
const attributeManager = this.getAttributeManager();
|
|
945
|
+
attributeManager.addInstanced({
|
|
946
|
+
instancePositions: { size: 3, update: this.calculateInstancePositions },
|
|
947
|
+
instanceCounts: { size: 4, noAlloc: true }
|
|
948
|
+
});
|
|
949
|
+
this.setState({
|
|
950
|
+
model: this._getModel()
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
shouldUpdateState({ changeFlags }) {
|
|
954
|
+
return changeFlags.somethingChanged;
|
|
955
|
+
}
|
|
956
|
+
updateState(params) {
|
|
957
|
+
super.updateState(params);
|
|
958
|
+
const { oldProps, props, changeFlags } = params;
|
|
959
|
+
const attributeManager = this.getAttributeManager();
|
|
960
|
+
if (props.numInstances !== oldProps.numInstances) {
|
|
961
|
+
attributeManager.invalidateAll();
|
|
962
|
+
} else if (oldProps.cellSizePixels !== props.cellSizePixels) {
|
|
963
|
+
attributeManager.invalidate("instancePositions");
|
|
964
|
+
}
|
|
965
|
+
this._updateUniforms(oldProps, props, changeFlags);
|
|
966
|
+
}
|
|
967
|
+
draw({ uniforms }) {
|
|
968
|
+
const { parameters, maxTexture } = this.props;
|
|
969
|
+
const minColor = this.props.minColor || DEFAULT_MINCOLOR;
|
|
970
|
+
const maxColor = this.props.maxColor || DEFAULT_MAXCOLOR;
|
|
971
|
+
const colorDomain = this.props.colorDomain || [1, 0];
|
|
972
|
+
const model = this.state.model;
|
|
973
|
+
model.setUniforms(uniforms);
|
|
974
|
+
model.setBindings({
|
|
975
|
+
maxTexture
|
|
976
|
+
});
|
|
977
|
+
model.setUniforms({
|
|
978
|
+
minColor,
|
|
979
|
+
maxColor,
|
|
980
|
+
colorDomain
|
|
981
|
+
});
|
|
982
|
+
model.setParameters({
|
|
983
|
+
depthWriteEnabled: false,
|
|
984
|
+
...parameters
|
|
985
|
+
});
|
|
986
|
+
model.draw(this.context.renderPass);
|
|
987
|
+
}
|
|
988
|
+
calculateInstancePositions(attribute, { numInstances }) {
|
|
989
|
+
const { width, height } = this.context.viewport;
|
|
990
|
+
const { cellSizePixels } = this.props;
|
|
991
|
+
const numCol = Math.ceil(width / cellSizePixels);
|
|
992
|
+
const { value, size } = attribute;
|
|
993
|
+
for (let i = 0; i < numInstances; i++) {
|
|
994
|
+
const x = i % numCol;
|
|
995
|
+
const y = Math.floor(i / numCol);
|
|
996
|
+
value[i * size + 0] = x * cellSizePixels / width * 2 - 1;
|
|
997
|
+
value[i * size + 1] = 1 - y * cellSizePixels / height * 2;
|
|
998
|
+
value[i * size + 2] = 0;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
_getModel() {
|
|
1002
|
+
return new import_engine2.Model(this.context.device, {
|
|
1003
|
+
...this.getShaders(),
|
|
1004
|
+
id: this.props.id,
|
|
1005
|
+
bufferLayout: this.getAttributeManager().getBufferLayouts(),
|
|
1006
|
+
geometry: new import_engine2.Geometry({
|
|
1007
|
+
topology: "triangle-list",
|
|
1008
|
+
attributes: {
|
|
1009
|
+
positions: new Float32Array([
|
|
1010
|
+
0,
|
|
1011
|
+
0,
|
|
1012
|
+
0,
|
|
1013
|
+
1,
|
|
1014
|
+
0,
|
|
1015
|
+
0,
|
|
1016
|
+
1,
|
|
1017
|
+
1,
|
|
1018
|
+
0,
|
|
1019
|
+
0,
|
|
1020
|
+
0,
|
|
1021
|
+
0,
|
|
1022
|
+
1,
|
|
1023
|
+
1,
|
|
1024
|
+
0,
|
|
1025
|
+
0,
|
|
1026
|
+
1,
|
|
1027
|
+
0
|
|
1028
|
+
])
|
|
1029
|
+
}
|
|
1030
|
+
})
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
_shouldUseMinMax() {
|
|
1034
|
+
const { minColor, maxColor, colorDomain, colorRange } = this.props;
|
|
1035
|
+
if (minColor || maxColor) {
|
|
1036
|
+
import_core2.log.deprecated("ScreenGridLayer props: minColor and maxColor", "colorRange, colorDomain")();
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
if (colorDomain || colorRange) {
|
|
1040
|
+
return false;
|
|
1041
|
+
}
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
_updateUniforms(oldProps, props, changeFlags) {
|
|
1045
|
+
const model = this.state.model;
|
|
1046
|
+
if (COLOR_PROPS.some((key) => oldProps[key] !== props[key])) {
|
|
1047
|
+
model.setUniforms({ shouldUseMinMax: this._shouldUseMinMax() });
|
|
1048
|
+
}
|
|
1049
|
+
if (oldProps.colorRange !== props.colorRange) {
|
|
1050
|
+
model.setUniforms({ colorRange: colorRangeToFlatArray(props.colorRange) });
|
|
1051
|
+
}
|
|
1052
|
+
if (oldProps.cellMarginPixels !== props.cellMarginPixels || oldProps.cellSizePixels !== props.cellSizePixels || changeFlags.viewportChanged) {
|
|
1053
|
+
const { width, height } = this.context.viewport;
|
|
1054
|
+
const { cellSizePixels, cellMarginPixels } = this.props;
|
|
1055
|
+
const margin = cellSizePixels > cellMarginPixels ? cellMarginPixels : 0;
|
|
1056
|
+
const cellScale = new Float32Array([
|
|
1057
|
+
(cellSizePixels - margin) / width * 2,
|
|
1058
|
+
-(cellSizePixels - margin) / height * 2,
|
|
1059
|
+
1
|
|
1060
|
+
]);
|
|
1061
|
+
model.setUniforms({ cellScale });
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
var ScreenGridCellLayer = _ScreenGridCellLayer;
|
|
1066
|
+
(() => {
|
|
1067
|
+
_ScreenGridCellLayer.layerName = "ScreenGridCellLayer";
|
|
1068
|
+
})();
|
|
1069
|
+
(() => {
|
|
1070
|
+
_ScreenGridCellLayer.defaultProps = defaultProps;
|
|
1071
|
+
})();
|
|
1072
|
+
|
|
1073
|
+
// dist/grid-aggregation-layer.js
|
|
1074
|
+
var import_constants3 = require("@luma.gl/constants");
|
|
1075
|
+
var import_core7 = require("@deck.gl/core");
|
|
1076
|
+
|
|
1077
|
+
// dist/aggregation-layer.js
|
|
1078
|
+
var import_core3 = require("@deck.gl/core");
|
|
1079
|
+
|
|
1080
|
+
// dist/utils/prop-utils.js
|
|
1081
|
+
function filterProps(props, filterKeys) {
|
|
1082
|
+
const filteredProps = {};
|
|
1083
|
+
for (const key in props) {
|
|
1084
|
+
if (!filterKeys.includes(key)) {
|
|
1085
|
+
filteredProps[key] = props[key];
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
return filteredProps;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// dist/aggregation-layer.js
|
|
1092
|
+
var _AggregationLayer = class extends import_core3.CompositeLayer {
|
|
1093
|
+
initializeAggregationLayer(dimensions) {
|
|
1094
|
+
super.initializeState(this.context);
|
|
1095
|
+
this.setState({
|
|
1096
|
+
ignoreProps: filterProps(this.constructor._propTypes, dimensions.data.props),
|
|
1097
|
+
dimensions
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
updateState(opts) {
|
|
1101
|
+
super.updateState(opts);
|
|
1102
|
+
const { changeFlags } = opts;
|
|
1103
|
+
if (changeFlags.extensionsChanged) {
|
|
1104
|
+
const shaders = this.getShaders({});
|
|
1105
|
+
if (shaders && shaders.defines) {
|
|
1106
|
+
shaders.defines.NON_INSTANCED_MODEL = 1;
|
|
1107
|
+
}
|
|
1108
|
+
this.updateShaders(shaders);
|
|
1109
|
+
}
|
|
1110
|
+
this._updateAttributes();
|
|
1111
|
+
}
|
|
1112
|
+
updateAttributes(changedAttributes) {
|
|
1113
|
+
this.setState({ changedAttributes });
|
|
1114
|
+
}
|
|
1115
|
+
getAttributes() {
|
|
1116
|
+
return this.getAttributeManager().getAttributes();
|
|
1117
|
+
}
|
|
1118
|
+
getModuleSettings() {
|
|
1119
|
+
const { viewport, mousePosition, device } = this.context;
|
|
1120
|
+
const moduleSettings = Object.assign(Object.create(this.props), {
|
|
1121
|
+
viewport,
|
|
1122
|
+
mousePosition,
|
|
1123
|
+
picking: {
|
|
1124
|
+
isActive: 0
|
|
1125
|
+
},
|
|
1126
|
+
devicePixelRatio: device.canvasContext.cssToDeviceRatio()
|
|
1127
|
+
});
|
|
1128
|
+
return moduleSettings;
|
|
1129
|
+
}
|
|
1130
|
+
updateShaders(shaders) {
|
|
1131
|
+
}
|
|
1132
|
+
isAggregationDirty(updateOpts, params = {}) {
|
|
1133
|
+
const { props, oldProps, changeFlags } = updateOpts;
|
|
1134
|
+
const { compareAll = false, dimension } = params;
|
|
1135
|
+
const { ignoreProps } = this.state;
|
|
1136
|
+
const { props: dataProps, accessors = [] } = dimension;
|
|
1137
|
+
const { updateTriggersChanged } = changeFlags;
|
|
1138
|
+
if (changeFlags.dataChanged) {
|
|
1139
|
+
return true;
|
|
1140
|
+
}
|
|
1141
|
+
if (updateTriggersChanged) {
|
|
1142
|
+
if (updateTriggersChanged.all) {
|
|
1143
|
+
return true;
|
|
1144
|
+
}
|
|
1145
|
+
for (const accessor of accessors) {
|
|
1146
|
+
if (updateTriggersChanged[accessor]) {
|
|
1147
|
+
return true;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
if (compareAll) {
|
|
1152
|
+
if (changeFlags.extensionsChanged) {
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
return (0, import_core3._compareProps)({
|
|
1156
|
+
oldProps,
|
|
1157
|
+
newProps: props,
|
|
1158
|
+
ignoreProps,
|
|
1159
|
+
propTypes: this.constructor._propTypes
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
for (const name of dataProps) {
|
|
1163
|
+
if (props[name] !== oldProps[name]) {
|
|
1164
|
+
return true;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
isAttributeChanged(name) {
|
|
1170
|
+
const { changedAttributes } = this.state;
|
|
1171
|
+
if (!name) {
|
|
1172
|
+
return !isObjectEmpty(changedAttributes);
|
|
1173
|
+
}
|
|
1174
|
+
return changedAttributes && changedAttributes[name] !== void 0;
|
|
1175
|
+
}
|
|
1176
|
+
_getAttributeManager() {
|
|
1177
|
+
return new import_core3.AttributeManager(this.context.device, {
|
|
1178
|
+
id: this.props.id,
|
|
1179
|
+
stats: this.context.stats
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
var AggregationLayer = _AggregationLayer;
|
|
1184
|
+
(() => {
|
|
1185
|
+
_AggregationLayer.layerName = "AggregationLayer";
|
|
1186
|
+
})();
|
|
1187
|
+
function isObjectEmpty(obj) {
|
|
1188
|
+
let isEmpty = true;
|
|
1189
|
+
for (const key in obj) {
|
|
1190
|
+
isEmpty = false;
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
return isEmpty;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// dist/utils/scale-utils.js
|
|
1197
|
+
var import_core4 = require("@deck.gl/core");
|
|
1198
|
+
function getScale(domain, range, scaleFunction) {
|
|
1199
|
+
const scale = scaleFunction;
|
|
1200
|
+
scale.domain = () => domain;
|
|
1201
|
+
scale.range = () => range;
|
|
1202
|
+
return scale;
|
|
1203
|
+
}
|
|
1204
|
+
function getQuantizeScale(domain, range) {
|
|
1205
|
+
const scaleFunction = (value) => quantizeScale(domain, range, value);
|
|
1206
|
+
return getScale(domain, range, scaleFunction);
|
|
1207
|
+
}
|
|
1208
|
+
function getLinearScale(domain, range) {
|
|
1209
|
+
const scaleFunction = (value) => linearScale(domain, range, value);
|
|
1210
|
+
return getScale(domain, range, scaleFunction);
|
|
1211
|
+
}
|
|
1212
|
+
function getQuantileScale(domain, range) {
|
|
1213
|
+
const sortedDomain = domain.sort(ascending);
|
|
1214
|
+
let i = 0;
|
|
1215
|
+
const n = Math.max(1, range.length);
|
|
1216
|
+
const thresholds = new Array(n - 1);
|
|
1217
|
+
while (++i < n) {
|
|
1218
|
+
thresholds[i - 1] = threshold(sortedDomain, i / n);
|
|
1219
|
+
}
|
|
1220
|
+
const scaleFunction = (value) => thresholdsScale(thresholds, range, value);
|
|
1221
|
+
scaleFunction.thresholds = () => thresholds;
|
|
1222
|
+
return getScale(domain, range, scaleFunction);
|
|
1223
|
+
}
|
|
1224
|
+
function ascending(a, b) {
|
|
1225
|
+
return a - b;
|
|
1226
|
+
}
|
|
1227
|
+
function threshold(domain, fraction) {
|
|
1228
|
+
const domainLength = domain.length;
|
|
1229
|
+
if (fraction <= 0 || domainLength < 2) {
|
|
1230
|
+
return domain[0];
|
|
1231
|
+
}
|
|
1232
|
+
if (fraction >= 1) {
|
|
1233
|
+
return domain[domainLength - 1];
|
|
1234
|
+
}
|
|
1235
|
+
const domainFraction = (domainLength - 1) * fraction;
|
|
1236
|
+
const lowIndex = Math.floor(domainFraction);
|
|
1237
|
+
const low = domain[lowIndex];
|
|
1238
|
+
const high = domain[lowIndex + 1];
|
|
1239
|
+
return low + (high - low) * (domainFraction - lowIndex);
|
|
1240
|
+
}
|
|
1241
|
+
function bisectRight(a, x) {
|
|
1242
|
+
let lo = 0;
|
|
1243
|
+
let hi = a.length;
|
|
1244
|
+
while (lo < hi) {
|
|
1245
|
+
const mid = lo + hi >>> 1;
|
|
1246
|
+
if (ascending(a[mid], x) > 0) {
|
|
1247
|
+
hi = mid;
|
|
1248
|
+
} else {
|
|
1249
|
+
lo = mid + 1;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
return lo;
|
|
1253
|
+
}
|
|
1254
|
+
function thresholdsScale(thresholds, range, value) {
|
|
1255
|
+
return range[bisectRight(thresholds, value)];
|
|
1256
|
+
}
|
|
1257
|
+
function ordinalScale(domain, domainMap, range, value) {
|
|
1258
|
+
const key = `${value}`;
|
|
1259
|
+
let d = domainMap.get(key);
|
|
1260
|
+
if (d === void 0) {
|
|
1261
|
+
d = domain.push(value);
|
|
1262
|
+
domainMap.set(key, d);
|
|
1263
|
+
}
|
|
1264
|
+
return range[(d - 1) % range.length];
|
|
1265
|
+
}
|
|
1266
|
+
function getOrdinalScale(domain, range) {
|
|
1267
|
+
const domainMap = /* @__PURE__ */ new Map();
|
|
1268
|
+
const uniqueDomain = [];
|
|
1269
|
+
for (const d of domain) {
|
|
1270
|
+
const key = `${d}`;
|
|
1271
|
+
if (!domainMap.has(key)) {
|
|
1272
|
+
domainMap.set(key, uniqueDomain.push(d));
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
const scaleFunction = (value) => ordinalScale(uniqueDomain, domainMap, range, value);
|
|
1276
|
+
return getScale(domain, range, scaleFunction);
|
|
1277
|
+
}
|
|
1278
|
+
function quantizeScale(domain, range, value) {
|
|
1279
|
+
const domainRange = domain[1] - domain[0];
|
|
1280
|
+
if (domainRange <= 0) {
|
|
1281
|
+
import_core4.log.warn("quantizeScale: invalid domain, returning range[0]")();
|
|
1282
|
+
return range[0];
|
|
1283
|
+
}
|
|
1284
|
+
const step = domainRange / range.length;
|
|
1285
|
+
const idx = Math.floor((value - domain[0]) / step);
|
|
1286
|
+
const clampIdx = Math.max(Math.min(idx, range.length - 1), 0);
|
|
1287
|
+
return range[clampIdx];
|
|
1288
|
+
}
|
|
1289
|
+
function linearScale(domain, range, value) {
|
|
1290
|
+
return (value - domain[0]) / (domain[1] - domain[0]) * (range[1] - range[0]) + range[0];
|
|
1291
|
+
}
|
|
1292
|
+
function notNullOrUndefined(d) {
|
|
1293
|
+
return d !== void 0 && d !== null;
|
|
1294
|
+
}
|
|
1295
|
+
function unique(values) {
|
|
1296
|
+
const results = [];
|
|
1297
|
+
values.forEach((v) => {
|
|
1298
|
+
if (!results.includes(v) && notNullOrUndefined(v)) {
|
|
1299
|
+
results.push(v);
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
return results;
|
|
1303
|
+
}
|
|
1304
|
+
function getTruthyValues(data, valueAccessor) {
|
|
1305
|
+
const values = typeof valueAccessor === "function" ? data.map(valueAccessor) : data;
|
|
1306
|
+
return values.filter(notNullOrUndefined);
|
|
1307
|
+
}
|
|
1308
|
+
function getQuantileDomain(data, valueAccessor) {
|
|
1309
|
+
return getTruthyValues(data, valueAccessor);
|
|
1310
|
+
}
|
|
1311
|
+
function getOrdinalDomain(data, valueAccessor) {
|
|
1312
|
+
return unique(getTruthyValues(data, valueAccessor));
|
|
1313
|
+
}
|
|
1314
|
+
function clamp(value, min, max) {
|
|
1315
|
+
return Math.max(min, Math.min(max, value));
|
|
1316
|
+
}
|
|
1317
|
+
function getScaleFunctionByScaleType(scaleType) {
|
|
1318
|
+
switch (scaleType) {
|
|
1319
|
+
case "quantize":
|
|
1320
|
+
return getQuantizeScale;
|
|
1321
|
+
case "linear":
|
|
1322
|
+
return getLinearScale;
|
|
1323
|
+
case "quantile":
|
|
1324
|
+
return getQuantileScale;
|
|
1325
|
+
case "ordinal":
|
|
1326
|
+
return getOrdinalScale;
|
|
1327
|
+
default:
|
|
1328
|
+
return getQuantizeScale;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// dist/utils/bin-sorter.js
|
|
1333
|
+
var defaultGetValue = (points) => points.length;
|
|
1334
|
+
var MAX_32_BIT_FLOAT2 = 3402823466e29;
|
|
1335
|
+
var defaultGetPoints = (bin) => bin.points;
|
|
1336
|
+
var defaultGetIndex = (bin) => bin.index;
|
|
1337
|
+
var ascending2 = (a, b) => a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
1338
|
+
var defaultProps2 = {
|
|
1339
|
+
getValue: defaultGetValue,
|
|
1340
|
+
getPoints: defaultGetPoints,
|
|
1341
|
+
getIndex: defaultGetIndex,
|
|
1342
|
+
filterData: null
|
|
1343
|
+
};
|
|
1344
|
+
var BinSorter = class {
|
|
1345
|
+
constructor(bins = [], props = defaultProps2) {
|
|
1346
|
+
this.aggregatedBins = this.getAggregatedBins(bins, props);
|
|
1347
|
+
this._updateMinMaxValues();
|
|
1348
|
+
this.binMap = this.getBinMap();
|
|
1349
|
+
}
|
|
1350
|
+
getAggregatedBins(bins, props) {
|
|
1351
|
+
const { getValue = defaultGetValue, getPoints = defaultGetPoints, getIndex = defaultGetIndex, filterData } = props;
|
|
1352
|
+
const hasFilter = typeof filterData === "function";
|
|
1353
|
+
const binCount = bins.length;
|
|
1354
|
+
const aggregatedBins = [];
|
|
1355
|
+
let index = 0;
|
|
1356
|
+
for (let binIndex = 0; binIndex < binCount; binIndex++) {
|
|
1357
|
+
const bin = bins[binIndex];
|
|
1358
|
+
const points = getPoints(bin);
|
|
1359
|
+
const i = getIndex(bin);
|
|
1360
|
+
const filteredPoints = hasFilter ? points.filter(filterData) : points;
|
|
1361
|
+
bin.filteredPoints = hasFilter ? filteredPoints : null;
|
|
1362
|
+
const value = filteredPoints.length ? getValue(filteredPoints) : null;
|
|
1363
|
+
if (value !== null && value !== void 0) {
|
|
1364
|
+
aggregatedBins[index] = {
|
|
1365
|
+
i: Number.isFinite(i) ? i : binIndex,
|
|
1366
|
+
value,
|
|
1367
|
+
counts: filteredPoints.length
|
|
1368
|
+
};
|
|
1369
|
+
index++;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
return aggregatedBins;
|
|
1373
|
+
}
|
|
1374
|
+
_percentileToIndex(percentileRange) {
|
|
1375
|
+
const len = this.sortedBins.length;
|
|
1376
|
+
if (len < 2) {
|
|
1377
|
+
return [0, 0];
|
|
1378
|
+
}
|
|
1379
|
+
const [lower, upper] = percentileRange.map((n) => clamp(n, 0, 100));
|
|
1380
|
+
const lowerIdx = Math.ceil(lower / 100 * (len - 1));
|
|
1381
|
+
const upperIdx = Math.floor(upper / 100 * (len - 1));
|
|
1382
|
+
return [lowerIdx, upperIdx];
|
|
1383
|
+
}
|
|
1384
|
+
getBinMap() {
|
|
1385
|
+
const binMap = {};
|
|
1386
|
+
for (const bin of this.aggregatedBins) {
|
|
1387
|
+
binMap[bin.i] = bin;
|
|
1388
|
+
}
|
|
1389
|
+
return binMap;
|
|
1390
|
+
}
|
|
1391
|
+
_updateMinMaxValues() {
|
|
1392
|
+
let maxCount = 0;
|
|
1393
|
+
let maxValue = 0;
|
|
1394
|
+
let minValue = MAX_32_BIT_FLOAT2;
|
|
1395
|
+
let totalCount = 0;
|
|
1396
|
+
for (const x of this.aggregatedBins) {
|
|
1397
|
+
maxCount = maxCount > x.counts ? maxCount : x.counts;
|
|
1398
|
+
maxValue = maxValue > x.value ? maxValue : x.value;
|
|
1399
|
+
minValue = minValue < x.value ? minValue : x.value;
|
|
1400
|
+
totalCount += x.counts;
|
|
1401
|
+
}
|
|
1402
|
+
this.maxCount = maxCount;
|
|
1403
|
+
this.maxValue = maxValue;
|
|
1404
|
+
this.minValue = minValue;
|
|
1405
|
+
this.totalCount = totalCount;
|
|
1406
|
+
}
|
|
1407
|
+
getValueRange(percentileRange) {
|
|
1408
|
+
if (!this.sortedBins) {
|
|
1409
|
+
this.sortedBins = this.aggregatedBins.sort((a, b) => ascending2(a.value, b.value));
|
|
1410
|
+
}
|
|
1411
|
+
if (!this.sortedBins.length) {
|
|
1412
|
+
return [];
|
|
1413
|
+
}
|
|
1414
|
+
let lowerIdx = 0;
|
|
1415
|
+
let upperIdx = this.sortedBins.length - 1;
|
|
1416
|
+
if (Array.isArray(percentileRange)) {
|
|
1417
|
+
const idxRange = this._percentileToIndex(percentileRange);
|
|
1418
|
+
lowerIdx = idxRange[0];
|
|
1419
|
+
upperIdx = idxRange[1];
|
|
1420
|
+
}
|
|
1421
|
+
return [this.sortedBins[lowerIdx].value, this.sortedBins[upperIdx].value];
|
|
1422
|
+
}
|
|
1423
|
+
getValueDomainByScale(scale, [lower = 0, upper = 100] = []) {
|
|
1424
|
+
if (!this.sortedBins) {
|
|
1425
|
+
this.sortedBins = this.aggregatedBins.sort((a, b) => ascending2(a.value, b.value));
|
|
1426
|
+
}
|
|
1427
|
+
if (!this.sortedBins.length) {
|
|
1428
|
+
return [];
|
|
1429
|
+
}
|
|
1430
|
+
const indexEdge = this._percentileToIndex([lower, upper]);
|
|
1431
|
+
return this._getScaleDomain(scale, indexEdge);
|
|
1432
|
+
}
|
|
1433
|
+
_getScaleDomain(scaleType, [lowerIdx, upperIdx]) {
|
|
1434
|
+
const bins = this.sortedBins;
|
|
1435
|
+
switch (scaleType) {
|
|
1436
|
+
case "quantize":
|
|
1437
|
+
case "linear":
|
|
1438
|
+
return [bins[lowerIdx].value, bins[upperIdx].value];
|
|
1439
|
+
case "quantile":
|
|
1440
|
+
return getQuantileDomain(bins.slice(lowerIdx, upperIdx + 1), (d) => d.value);
|
|
1441
|
+
case "ordinal":
|
|
1442
|
+
return getOrdinalDomain(bins, (d) => d.value);
|
|
1443
|
+
default:
|
|
1444
|
+
return [bins[lowerIdx].value, bins[upperIdx].value];
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
|
|
1449
|
+
// dist/cpu-grid-layer/grid-aggregator.js
|
|
1450
|
+
var import_core6 = require("@deck.gl/core");
|
|
1451
|
+
|
|
1452
|
+
// dist/utils/grid-aggregation-utils.js
|
|
1453
|
+
var import_core5 = require("@deck.gl/core");
|
|
1454
|
+
var R_EARTH = 6378e3;
|
|
1455
|
+
function toFinite(n) {
|
|
1456
|
+
return Number.isFinite(n) ? n : 0;
|
|
1457
|
+
}
|
|
1458
|
+
function getBoundingBox(attributes, vertexCount) {
|
|
1459
|
+
const positions = attributes.positions.value;
|
|
1460
|
+
let yMin = Infinity;
|
|
1461
|
+
let yMax = -Infinity;
|
|
1462
|
+
let xMin = Infinity;
|
|
1463
|
+
let xMax = -Infinity;
|
|
1464
|
+
let y;
|
|
1465
|
+
let x;
|
|
1466
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
1467
|
+
x = positions[i * 3];
|
|
1468
|
+
y = positions[i * 3 + 1];
|
|
1469
|
+
yMin = y < yMin ? y : yMin;
|
|
1470
|
+
yMax = y > yMax ? y : yMax;
|
|
1471
|
+
xMin = x < xMin ? x : xMin;
|
|
1472
|
+
xMax = x > xMax ? x : xMax;
|
|
1473
|
+
}
|
|
1474
|
+
const boundingBox = {
|
|
1475
|
+
xMin: toFinite(xMin),
|
|
1476
|
+
xMax: toFinite(xMax),
|
|
1477
|
+
yMin: toFinite(yMin),
|
|
1478
|
+
yMax: toFinite(yMax)
|
|
1479
|
+
};
|
|
1480
|
+
return boundingBox;
|
|
1481
|
+
}
|
|
1482
|
+
function getTranslation(boundingBox, gridOffset, coordinateSystem, viewport) {
|
|
1483
|
+
const { width, height } = viewport;
|
|
1484
|
+
const worldOrigin = coordinateSystem === import_core5.COORDINATE_SYSTEM.CARTESIAN ? [-width / 2, -height / 2] : [-180, -90];
|
|
1485
|
+
import_core5.log.assert(coordinateSystem === import_core5.COORDINATE_SYSTEM.CARTESIAN || coordinateSystem === import_core5.COORDINATE_SYSTEM.LNGLAT || coordinateSystem === import_core5.COORDINATE_SYSTEM.DEFAULT);
|
|
1486
|
+
const { xMin, yMin } = boundingBox;
|
|
1487
|
+
return [
|
|
1488
|
+
-1 * (alignToCell(xMin - worldOrigin[0], gridOffset.xOffset) + worldOrigin[0]),
|
|
1489
|
+
-1 * (alignToCell(yMin - worldOrigin[1], gridOffset.yOffset) + worldOrigin[1])
|
|
1490
|
+
];
|
|
1491
|
+
}
|
|
1492
|
+
function alignToCell(inValue, cellSize) {
|
|
1493
|
+
const sign = inValue < 0 ? -1 : 1;
|
|
1494
|
+
let value = sign < 0 ? Math.abs(inValue) + cellSize : Math.abs(inValue);
|
|
1495
|
+
value = Math.floor(value / cellSize) * cellSize;
|
|
1496
|
+
return value * sign;
|
|
1497
|
+
}
|
|
1498
|
+
function getGridOffset(boundingBox, cellSize, convertToMeters = true) {
|
|
1499
|
+
if (!convertToMeters) {
|
|
1500
|
+
return { xOffset: cellSize, yOffset: cellSize };
|
|
1501
|
+
}
|
|
1502
|
+
const { yMin, yMax } = boundingBox;
|
|
1503
|
+
const centerLat = (yMin + yMax) / 2;
|
|
1504
|
+
return calculateGridLatLonOffset(cellSize, centerLat);
|
|
1505
|
+
}
|
|
1506
|
+
function getGridParams(boundingBox, cellSize, viewport, coordinateSystem) {
|
|
1507
|
+
const gridOffset = getGridOffset(boundingBox, cellSize, coordinateSystem !== import_core5.COORDINATE_SYSTEM.CARTESIAN);
|
|
1508
|
+
const translation = getTranslation(boundingBox, gridOffset, coordinateSystem, viewport);
|
|
1509
|
+
const { xMin, yMin, xMax, yMax } = boundingBox;
|
|
1510
|
+
const width = xMax - xMin + gridOffset.xOffset;
|
|
1511
|
+
const height = yMax - yMin + gridOffset.yOffset;
|
|
1512
|
+
const numCol = Math.ceil(width / gridOffset.xOffset);
|
|
1513
|
+
const numRow = Math.ceil(height / gridOffset.yOffset);
|
|
1514
|
+
return { gridOffset, translation, width, height, numCol, numRow };
|
|
1515
|
+
}
|
|
1516
|
+
function calculateGridLatLonOffset(cellSize, latitude) {
|
|
1517
|
+
const yOffset = calculateLatOffset(cellSize);
|
|
1518
|
+
const xOffset = calculateLonOffset(latitude, cellSize);
|
|
1519
|
+
return { yOffset, xOffset };
|
|
1520
|
+
}
|
|
1521
|
+
function calculateLatOffset(dy) {
|
|
1522
|
+
return dy / R_EARTH * (180 / Math.PI);
|
|
1523
|
+
}
|
|
1524
|
+
function calculateLonOffset(lat, dx) {
|
|
1525
|
+
return dx / R_EARTH * (180 / Math.PI) / Math.cos(lat * Math.PI / 180);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
// dist/cpu-grid-layer/grid-aggregator.js
|
|
1529
|
+
function pointToDensityGridDataCPU(props, aggregationParams) {
|
|
1530
|
+
const hashInfo = pointsToGridHashing(props, aggregationParams);
|
|
1531
|
+
const result = getGridLayerDataFromGridHash(hashInfo);
|
|
1532
|
+
return {
|
|
1533
|
+
gridHash: hashInfo.gridHash,
|
|
1534
|
+
gridOffset: hashInfo.gridOffset,
|
|
1535
|
+
data: result
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
function pointsToGridHashing(props, aggregationParams) {
|
|
1539
|
+
const { data = [], cellSize } = props;
|
|
1540
|
+
const { attributes, viewport, projectPoints, numInstances } = aggregationParams;
|
|
1541
|
+
const positions = attributes.positions.value;
|
|
1542
|
+
const { size } = attributes.positions.getAccessor();
|
|
1543
|
+
const boundingBox = aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);
|
|
1544
|
+
const offsets = aggregationParams.posOffset || [180, 90];
|
|
1545
|
+
const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);
|
|
1546
|
+
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
|
|
1547
|
+
return { gridHash: {}, gridOffset, offsets: [0, 0] };
|
|
1548
|
+
}
|
|
1549
|
+
const { width, height } = viewport;
|
|
1550
|
+
const numCol = Math.ceil(width / gridOffset.xOffset);
|
|
1551
|
+
const numRow = Math.ceil(height / gridOffset.yOffset);
|
|
1552
|
+
const gridHash = {};
|
|
1553
|
+
const { iterable, objectInfo } = (0, import_core6.createIterable)(data);
|
|
1554
|
+
const position = new Array(3);
|
|
1555
|
+
for (const pt of iterable) {
|
|
1556
|
+
objectInfo.index++;
|
|
1557
|
+
position[0] = positions[objectInfo.index * size];
|
|
1558
|
+
position[1] = positions[objectInfo.index * size + 1];
|
|
1559
|
+
position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;
|
|
1560
|
+
const [x, y] = projectPoints ? viewport.project(position) : position;
|
|
1561
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
1562
|
+
const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);
|
|
1563
|
+
const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);
|
|
1564
|
+
if (!projectPoints || xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow) {
|
|
1565
|
+
const key = `${yIndex}-${xIndex}`;
|
|
1566
|
+
gridHash[key] = gridHash[key] || { count: 0, points: [], lonIdx: xIndex, latIdx: yIndex };
|
|
1567
|
+
gridHash[key].count += 1;
|
|
1568
|
+
gridHash[key].points.push({
|
|
1569
|
+
source: pt,
|
|
1570
|
+
index: objectInfo.index
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return { gridHash, gridOffset, offsets: [offsets[0] * -1, offsets[1] * -1] };
|
|
1576
|
+
}
|
|
1577
|
+
function getGridLayerDataFromGridHash({ gridHash, gridOffset, offsets }) {
|
|
1578
|
+
const data = new Array(Object.keys(gridHash).length);
|
|
1579
|
+
let i = 0;
|
|
1580
|
+
for (const key in gridHash) {
|
|
1581
|
+
const idxs = key.split("-");
|
|
1582
|
+
const latIdx = parseInt(idxs[0], 10);
|
|
1583
|
+
const lonIdx = parseInt(idxs[1], 10);
|
|
1584
|
+
const index = i++;
|
|
1585
|
+
data[index] = {
|
|
1586
|
+
index,
|
|
1587
|
+
position: [
|
|
1588
|
+
offsets[0] + gridOffset.xOffset * lonIdx,
|
|
1589
|
+
offsets[1] + gridOffset.yOffset * latIdx
|
|
1590
|
+
],
|
|
1591
|
+
...gridHash[key]
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
return data;
|
|
1595
|
+
}
|
|
1596
|
+
function getPositionBoundingBox(positionAttribute, numInstance) {
|
|
1597
|
+
const positions = positionAttribute.value;
|
|
1598
|
+
const { size } = positionAttribute.getAccessor();
|
|
1599
|
+
let yMin = Infinity;
|
|
1600
|
+
let yMax = -Infinity;
|
|
1601
|
+
let xMin = Infinity;
|
|
1602
|
+
let xMax = -Infinity;
|
|
1603
|
+
let y;
|
|
1604
|
+
let x;
|
|
1605
|
+
for (let i = 0; i < numInstance; i++) {
|
|
1606
|
+
x = positions[i * size];
|
|
1607
|
+
y = positions[i * size + 1];
|
|
1608
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
1609
|
+
yMin = y < yMin ? y : yMin;
|
|
1610
|
+
yMax = y > yMax ? y : yMax;
|
|
1611
|
+
xMin = x < xMin ? x : xMin;
|
|
1612
|
+
xMax = x > xMax ? x : xMax;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
return { xMin, xMax, yMin, yMax };
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
// dist/grid-aggregation-layer.js
|
|
1619
|
+
var _GridAggregationLayer = class extends AggregationLayer {
|
|
1620
|
+
initializeAggregationLayer({ dimensions }) {
|
|
1621
|
+
super.initializeAggregationLayer(dimensions);
|
|
1622
|
+
this.setState({
|
|
1623
|
+
layerData: {},
|
|
1624
|
+
gpuGridAggregator: new GPUGridAggregator(this.context.device, {
|
|
1625
|
+
id: `${this.id}-gpu-aggregator`
|
|
1626
|
+
}),
|
|
1627
|
+
cpuGridAggregator: pointToDensityGridDataCPU
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
updateState(opts) {
|
|
1631
|
+
super.updateState(opts);
|
|
1632
|
+
this.updateAggregationState(opts);
|
|
1633
|
+
const { aggregationDataDirty, aggregationWeightsDirty, gpuAggregation } = this.state;
|
|
1634
|
+
if (this.getNumInstances() <= 0) {
|
|
1635
|
+
return;
|
|
1636
|
+
}
|
|
1637
|
+
let aggregationDirty = false;
|
|
1638
|
+
if (aggregationDataDirty || gpuAggregation && aggregationWeightsDirty) {
|
|
1639
|
+
this._updateAggregation(opts);
|
|
1640
|
+
aggregationDirty = true;
|
|
1641
|
+
}
|
|
1642
|
+
if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {
|
|
1643
|
+
this._updateWeightBins();
|
|
1644
|
+
this._uploadAggregationResults();
|
|
1645
|
+
aggregationDirty = true;
|
|
1646
|
+
}
|
|
1647
|
+
this.setState({ aggregationDirty });
|
|
1648
|
+
}
|
|
1649
|
+
finalizeState(context) {
|
|
1650
|
+
var _a;
|
|
1651
|
+
const { count } = this.state.weights;
|
|
1652
|
+
if (count && count.aggregationBuffer) {
|
|
1653
|
+
count.aggregationBuffer.delete();
|
|
1654
|
+
}
|
|
1655
|
+
(_a = this.state.gpuGridAggregator) == null ? void 0 : _a.delete();
|
|
1656
|
+
super.finalizeState(context);
|
|
1657
|
+
}
|
|
1658
|
+
updateShaders(shaders) {
|
|
1659
|
+
if (this.state.gpuAggregation) {
|
|
1660
|
+
this.state.gpuGridAggregator.updateShaders(shaders);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
updateAggregationState(opts) {
|
|
1664
|
+
import_core7.log.assert(false);
|
|
1665
|
+
}
|
|
1666
|
+
allocateResources(numRow, numCol) {
|
|
1667
|
+
if (this.state.numRow !== numRow || this.state.numCol !== numCol) {
|
|
1668
|
+
const dataBytes = numCol * numRow * 4 * 4;
|
|
1669
|
+
const { weights } = this.state;
|
|
1670
|
+
for (const name in weights) {
|
|
1671
|
+
const weight = weights[name];
|
|
1672
|
+
if (weight.aggregationBuffer) {
|
|
1673
|
+
weight.aggregationBuffer.delete();
|
|
1674
|
+
}
|
|
1675
|
+
weight.aggregationBuffer = this.context.device.createBuffer({
|
|
1676
|
+
byteLength: dataBytes,
|
|
1677
|
+
accessor: {
|
|
1678
|
+
size: 4,
|
|
1679
|
+
type: import_constants3.GL.FLOAT,
|
|
1680
|
+
divisor: 1
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
updateResults({ aggregationData, maxMinData, maxData, minData }) {
|
|
1687
|
+
const { count } = this.state.weights;
|
|
1688
|
+
if (count) {
|
|
1689
|
+
count.aggregationData = aggregationData;
|
|
1690
|
+
count.maxMinData = maxMinData;
|
|
1691
|
+
count.maxData = maxData;
|
|
1692
|
+
count.minData = minData;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
_updateAggregation(opts) {
|
|
1696
|
+
const { cpuGridAggregator, gpuGridAggregator, gridOffset, posOffset, translation = [0, 0], scaling = [0, 0, 0], boundingBox, projectPoints, gpuAggregation, numCol, numRow } = this.state;
|
|
1697
|
+
const { props } = opts;
|
|
1698
|
+
const { viewport } = this.context;
|
|
1699
|
+
const attributes = this.getAttributes();
|
|
1700
|
+
const vertexCount = this.getNumInstances();
|
|
1701
|
+
if (!gpuAggregation) {
|
|
1702
|
+
const result = cpuGridAggregator(props, {
|
|
1703
|
+
gridOffset,
|
|
1704
|
+
projectPoints,
|
|
1705
|
+
attributes,
|
|
1706
|
+
viewport,
|
|
1707
|
+
posOffset,
|
|
1708
|
+
boundingBox
|
|
1709
|
+
});
|
|
1710
|
+
this.setState({
|
|
1711
|
+
layerData: result
|
|
1712
|
+
});
|
|
1713
|
+
} else {
|
|
1714
|
+
const { weights } = this.state;
|
|
1715
|
+
gpuGridAggregator.run({
|
|
1716
|
+
weights,
|
|
1717
|
+
cellSize: [gridOffset.xOffset, gridOffset.yOffset],
|
|
1718
|
+
numCol,
|
|
1719
|
+
numRow,
|
|
1720
|
+
translation,
|
|
1721
|
+
scaling,
|
|
1722
|
+
vertexCount,
|
|
1723
|
+
projectPoints,
|
|
1724
|
+
attributes,
|
|
1725
|
+
moduleSettings: this.getModuleSettings()
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
_updateWeightBins() {
|
|
1730
|
+
const { getValue } = this.state;
|
|
1731
|
+
const sortedBins = new BinSorter(this.state.layerData.data || [], { getValue });
|
|
1732
|
+
this.setState({ sortedBins });
|
|
1733
|
+
}
|
|
1734
|
+
_uploadAggregationResults() {
|
|
1735
|
+
const { numCol, numRow } = this.state;
|
|
1736
|
+
const { data } = this.state.layerData;
|
|
1737
|
+
const { aggregatedBins, minValue, maxValue, totalCount } = this.state.sortedBins;
|
|
1738
|
+
const ELEMENTCOUNT = 4;
|
|
1739
|
+
const aggregationSize = numCol * numRow * ELEMENTCOUNT;
|
|
1740
|
+
const aggregationData = new Float32Array(aggregationSize).fill(0);
|
|
1741
|
+
for (const bin of aggregatedBins) {
|
|
1742
|
+
const { lonIdx, latIdx } = data[bin.i];
|
|
1743
|
+
const { value, counts } = bin;
|
|
1744
|
+
const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;
|
|
1745
|
+
aggregationData[cellIndex] = value;
|
|
1746
|
+
aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;
|
|
1747
|
+
}
|
|
1748
|
+
const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);
|
|
1749
|
+
const maxData = new Float32Array([maxValue, 0, 0, totalCount]);
|
|
1750
|
+
const minData = new Float32Array([minValue, 0, 0, totalCount]);
|
|
1751
|
+
this.updateResults({ aggregationData, maxMinData, maxData, minData });
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
var GridAggregationLayer = _GridAggregationLayer;
|
|
1755
|
+
(() => {
|
|
1756
|
+
_GridAggregationLayer.layerName = "GridAggregationLayer";
|
|
1757
|
+
})();
|
|
1758
|
+
|
|
1759
|
+
// dist/screen-grid-layer/screen-grid-layer.js
|
|
1760
|
+
var defaultProps3 = {
|
|
1761
|
+
...ScreenGridCellLayer.defaultProps,
|
|
1762
|
+
getPosition: { type: "accessor", value: (d) => d.position },
|
|
1763
|
+
getWeight: { type: "accessor", value: 1 },
|
|
1764
|
+
gpuAggregation: false,
|
|
1765
|
+
aggregation: "SUM"
|
|
1766
|
+
};
|
|
1767
|
+
var POSITION_ATTRIBUTE_NAME = "positions";
|
|
1768
|
+
var DIMENSIONS = {
|
|
1769
|
+
data: {
|
|
1770
|
+
props: ["cellSizePixels"]
|
|
1771
|
+
},
|
|
1772
|
+
weights: {
|
|
1773
|
+
props: ["aggregation"],
|
|
1774
|
+
accessors: ["getWeight"]
|
|
1775
|
+
}
|
|
1776
|
+
};
|
|
1777
|
+
var _ScreenGridLayer = class extends GridAggregationLayer {
|
|
1778
|
+
initializeState() {
|
|
1779
|
+
if (!ScreenGridCellLayer.isSupported(this.context.device)) {
|
|
1780
|
+
this.setState({ supported: false });
|
|
1781
|
+
import_core8.log.error(`ScreenGridLayer: ${this.id} is not supported on this browser`)();
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
super.initializeAggregationLayer({
|
|
1785
|
+
dimensions: DIMENSIONS,
|
|
1786
|
+
getCellSize: (props) => props.cellSizePixels
|
|
1787
|
+
});
|
|
1788
|
+
const weights = {
|
|
1789
|
+
count: {
|
|
1790
|
+
size: 1,
|
|
1791
|
+
operation: AGGREGATION_OPERATION.SUM,
|
|
1792
|
+
needMax: true,
|
|
1793
|
+
maxTexture: getFloatTexture(this.context.device, { id: `${this.id}-max-texture` })
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
this.setState({
|
|
1797
|
+
supported: true,
|
|
1798
|
+
projectPoints: true,
|
|
1799
|
+
weights,
|
|
1800
|
+
subLayerData: { attributes: {} },
|
|
1801
|
+
maxTexture: weights.count.maxTexture,
|
|
1802
|
+
positionAttributeName: "positions",
|
|
1803
|
+
posOffset: [0, 0],
|
|
1804
|
+
translation: [1, -1]
|
|
1805
|
+
});
|
|
1806
|
+
const attributeManager = this.getAttributeManager();
|
|
1807
|
+
attributeManager.add({
|
|
1808
|
+
[POSITION_ATTRIBUTE_NAME]: {
|
|
1809
|
+
size: 3,
|
|
1810
|
+
accessor: "getPosition",
|
|
1811
|
+
type: import_constants4.GL.DOUBLE,
|
|
1812
|
+
fp64: this.use64bitPositions()
|
|
1813
|
+
},
|
|
1814
|
+
count: { size: 3, accessor: "getWeight" }
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
shouldUpdateState({ changeFlags }) {
|
|
1818
|
+
return this.state.supported && changeFlags.somethingChanged;
|
|
1819
|
+
}
|
|
1820
|
+
updateState(opts) {
|
|
1821
|
+
super.updateState(opts);
|
|
1822
|
+
}
|
|
1823
|
+
renderLayers() {
|
|
1824
|
+
if (!this.state.supported) {
|
|
1825
|
+
return [];
|
|
1826
|
+
}
|
|
1827
|
+
const { maxTexture, numRow, numCol, weights } = this.state;
|
|
1828
|
+
const { updateTriggers } = this.props;
|
|
1829
|
+
const { aggregationBuffer } = weights.count;
|
|
1830
|
+
const CellLayerClass = this.getSubLayerClass("cells", ScreenGridCellLayer);
|
|
1831
|
+
return new CellLayerClass(this.props, this.getSubLayerProps({
|
|
1832
|
+
id: "cell-layer",
|
|
1833
|
+
updateTriggers
|
|
1834
|
+
}), {
|
|
1835
|
+
data: { attributes: { instanceCounts: aggregationBuffer } },
|
|
1836
|
+
maxTexture,
|
|
1837
|
+
numInstances: numRow * numCol
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
finalizeState(context) {
|
|
1841
|
+
super.finalizeState(context);
|
|
1842
|
+
const { aggregationBuffer, maxBuffer, maxTexture } = this.state;
|
|
1843
|
+
aggregationBuffer == null ? void 0 : aggregationBuffer.delete();
|
|
1844
|
+
maxBuffer == null ? void 0 : maxBuffer.delete();
|
|
1845
|
+
maxTexture == null ? void 0 : maxTexture.delete();
|
|
1846
|
+
}
|
|
1847
|
+
getPickingInfo({ info }) {
|
|
1848
|
+
const { index } = info;
|
|
1849
|
+
if (index >= 0) {
|
|
1850
|
+
const { gpuGridAggregator, gpuAggregation, weights } = this.state;
|
|
1851
|
+
const aggregationResults = gpuAggregation ? gpuGridAggregator.getData("count") : weights.count;
|
|
1852
|
+
info.object = GPUGridAggregator.getAggregationData({
|
|
1853
|
+
pixelIndex: index,
|
|
1854
|
+
...aggregationResults
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
return info;
|
|
1858
|
+
}
|
|
1859
|
+
updateResults({ aggregationData, maxData }) {
|
|
1860
|
+
const { count } = this.state.weights;
|
|
1861
|
+
count.aggregationData = aggregationData;
|
|
1862
|
+
count.aggregationBuffer.write(aggregationData);
|
|
1863
|
+
count.maxData = maxData;
|
|
1864
|
+
count.maxTexture.setImageData({ data: maxData });
|
|
1865
|
+
}
|
|
1866
|
+
updateAggregationState(opts) {
|
|
1867
|
+
const cellSize = opts.props.cellSizePixels;
|
|
1868
|
+
const cellSizeChanged = opts.oldProps.cellSizePixels !== cellSize;
|
|
1869
|
+
const { viewportChanged } = opts.changeFlags;
|
|
1870
|
+
let gpuAggregation = opts.props.gpuAggregation;
|
|
1871
|
+
if (this.state.gpuAggregation !== opts.props.gpuAggregation) {
|
|
1872
|
+
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
|
|
1873
|
+
import_core8.log.warn("GPU Grid Aggregation not supported, falling back to CPU")();
|
|
1874
|
+
gpuAggregation = false;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
|
|
1878
|
+
this.setState({
|
|
1879
|
+
gpuAggregation
|
|
1880
|
+
});
|
|
1881
|
+
const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
|
|
1882
|
+
const { dimensions } = this.state;
|
|
1883
|
+
const { data, weights } = dimensions;
|
|
1884
|
+
const aggregationDataDirty = positionsChanged || gpuAggregationChanged || viewportChanged || this.isAggregationDirty(opts, {
|
|
1885
|
+
compareAll: gpuAggregation,
|
|
1886
|
+
dimension: data
|
|
1887
|
+
});
|
|
1888
|
+
const aggregationWeightsDirty = this.isAggregationDirty(opts, { dimension: weights });
|
|
1889
|
+
this.setState({
|
|
1890
|
+
aggregationDataDirty,
|
|
1891
|
+
aggregationWeightsDirty
|
|
1892
|
+
});
|
|
1893
|
+
const { viewport } = this.context;
|
|
1894
|
+
if (viewportChanged || cellSizeChanged) {
|
|
1895
|
+
const { width, height } = viewport;
|
|
1896
|
+
const numCol = Math.ceil(width / cellSize);
|
|
1897
|
+
const numRow = Math.ceil(height / cellSize);
|
|
1898
|
+
this.allocateResources(numRow, numCol);
|
|
1899
|
+
this.setState({
|
|
1900
|
+
scaling: [width / 2, -height / 2, 1],
|
|
1901
|
+
gridOffset: { xOffset: cellSize, yOffset: cellSize },
|
|
1902
|
+
width,
|
|
1903
|
+
height,
|
|
1904
|
+
numCol,
|
|
1905
|
+
numRow
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
if (aggregationWeightsDirty) {
|
|
1909
|
+
this._updateAccessors(opts);
|
|
1910
|
+
}
|
|
1911
|
+
if (aggregationDataDirty || aggregationWeightsDirty) {
|
|
1912
|
+
this._resetResults();
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
_updateAccessors(opts) {
|
|
1916
|
+
const { getWeight, aggregation, data } = opts.props;
|
|
1917
|
+
const { count } = this.state.weights;
|
|
1918
|
+
if (count) {
|
|
1919
|
+
count.getWeight = getWeight;
|
|
1920
|
+
count.operation = AGGREGATION_OPERATION[aggregation];
|
|
1921
|
+
}
|
|
1922
|
+
this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
|
|
1923
|
+
}
|
|
1924
|
+
_resetResults() {
|
|
1925
|
+
const { count } = this.state.weights;
|
|
1926
|
+
if (count) {
|
|
1927
|
+
count.aggregationData = null;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
var ScreenGridLayer = _ScreenGridLayer;
|
|
1932
|
+
(() => {
|
|
1933
|
+
_ScreenGridLayer.layerName = "ScreenGridLayer";
|
|
1934
|
+
})();
|
|
1935
|
+
(() => {
|
|
1936
|
+
_ScreenGridLayer.defaultProps = defaultProps3;
|
|
1937
|
+
})();
|
|
1938
|
+
|
|
1939
|
+
// dist/cpu-grid-layer/cpu-grid-layer.js
|
|
1940
|
+
var import_constants5 = require("@luma.gl/constants");
|
|
1941
|
+
var import_layers = require("@deck.gl/layers");
|
|
1942
|
+
|
|
1943
|
+
// dist/utils/cpu-aggregator.js
|
|
1944
|
+
function noop() {
|
|
1945
|
+
}
|
|
1946
|
+
var dimensionSteps = ["getBins", "getDomain", "getScaleFunc"];
|
|
1947
|
+
var defaultDimensions = [
|
|
1948
|
+
{
|
|
1949
|
+
key: "fillColor",
|
|
1950
|
+
accessor: "getFillColor",
|
|
1951
|
+
pickingInfo: "colorValue",
|
|
1952
|
+
getBins: {
|
|
1953
|
+
triggers: {
|
|
1954
|
+
value: {
|
|
1955
|
+
prop: "getColorValue",
|
|
1956
|
+
updateTrigger: "getColorValue"
|
|
1957
|
+
},
|
|
1958
|
+
weight: {
|
|
1959
|
+
prop: "getColorWeight",
|
|
1960
|
+
updateTrigger: "getColorWeight"
|
|
1961
|
+
},
|
|
1962
|
+
aggregation: {
|
|
1963
|
+
prop: "colorAggregation"
|
|
1964
|
+
},
|
|
1965
|
+
filterData: {
|
|
1966
|
+
prop: "_filterData",
|
|
1967
|
+
updateTrigger: "_filterData"
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
},
|
|
1971
|
+
getDomain: {
|
|
1972
|
+
triggers: {
|
|
1973
|
+
lowerPercentile: {
|
|
1974
|
+
prop: "lowerPercentile"
|
|
1975
|
+
},
|
|
1976
|
+
upperPercentile: {
|
|
1977
|
+
prop: "upperPercentile"
|
|
1978
|
+
},
|
|
1979
|
+
scaleType: {
|
|
1980
|
+
prop: "colorScaleType"
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
},
|
|
1984
|
+
getScaleFunc: {
|
|
1985
|
+
triggers: {
|
|
1986
|
+
domain: { prop: "colorDomain" },
|
|
1987
|
+
range: { prop: "colorRange" }
|
|
1988
|
+
},
|
|
1989
|
+
onSet: {
|
|
1990
|
+
props: "onSetColorDomain"
|
|
1991
|
+
}
|
|
1992
|
+
},
|
|
1993
|
+
nullValue: [0, 0, 0, 0]
|
|
1994
|
+
},
|
|
1995
|
+
{
|
|
1996
|
+
key: "elevation",
|
|
1997
|
+
accessor: "getElevation",
|
|
1998
|
+
pickingInfo: "elevationValue",
|
|
1999
|
+
getBins: {
|
|
2000
|
+
triggers: {
|
|
2001
|
+
value: {
|
|
2002
|
+
prop: "getElevationValue",
|
|
2003
|
+
updateTrigger: "getElevationValue"
|
|
2004
|
+
},
|
|
2005
|
+
weight: {
|
|
2006
|
+
prop: "getElevationWeight",
|
|
2007
|
+
updateTrigger: "getElevationWeight"
|
|
2008
|
+
},
|
|
2009
|
+
aggregation: {
|
|
2010
|
+
prop: "elevationAggregation"
|
|
2011
|
+
},
|
|
2012
|
+
filterData: {
|
|
2013
|
+
prop: "_filterData",
|
|
2014
|
+
updateTrigger: "_filterData"
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
},
|
|
2018
|
+
getDomain: {
|
|
2019
|
+
triggers: {
|
|
2020
|
+
lowerPercentile: {
|
|
2021
|
+
prop: "elevationLowerPercentile"
|
|
2022
|
+
},
|
|
2023
|
+
upperPercentile: {
|
|
2024
|
+
prop: "elevationUpperPercentile"
|
|
2025
|
+
},
|
|
2026
|
+
scaleType: {
|
|
2027
|
+
prop: "elevationScaleType"
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
getScaleFunc: {
|
|
2032
|
+
triggers: {
|
|
2033
|
+
domain: { prop: "elevationDomain" },
|
|
2034
|
+
range: { prop: "elevationRange" }
|
|
2035
|
+
},
|
|
2036
|
+
onSet: {
|
|
2037
|
+
props: "onSetElevationDomain"
|
|
2038
|
+
}
|
|
2039
|
+
},
|
|
2040
|
+
nullValue: -1
|
|
2041
|
+
}
|
|
2042
|
+
];
|
|
2043
|
+
var defaultGetCellSize = (props) => props.cellSize;
|
|
2044
|
+
var CPUAggregator = class {
|
|
2045
|
+
constructor(opts) {
|
|
2046
|
+
this.state = {
|
|
2047
|
+
layerData: {
|
|
2048
|
+
data: void 0
|
|
2049
|
+
},
|
|
2050
|
+
dimensions: {}
|
|
2051
|
+
};
|
|
2052
|
+
this.changeFlags = {};
|
|
2053
|
+
this.dimensionUpdaters = {};
|
|
2054
|
+
this._getCellSize = opts.getCellSize || defaultGetCellSize;
|
|
2055
|
+
this._getAggregator = opts.getAggregator;
|
|
2056
|
+
this._addDimension(opts.dimensions || defaultDimensions);
|
|
2057
|
+
}
|
|
2058
|
+
static defaultDimensions() {
|
|
2059
|
+
return defaultDimensions;
|
|
2060
|
+
}
|
|
2061
|
+
updateState(opts, aggregationParams) {
|
|
2062
|
+
const { oldProps, props, changeFlags } = opts;
|
|
2063
|
+
this.updateGetValueFuncs(oldProps, props, changeFlags);
|
|
2064
|
+
const reprojectNeeded = this.needsReProjectPoints(oldProps, props, changeFlags);
|
|
2065
|
+
let aggregationDirty = false;
|
|
2066
|
+
if (changeFlags.dataChanged || reprojectNeeded) {
|
|
2067
|
+
this.getAggregatedData(props, aggregationParams);
|
|
2068
|
+
aggregationDirty = true;
|
|
2069
|
+
} else {
|
|
2070
|
+
const dimensionChanges = this.getDimensionChanges(oldProps, props, changeFlags) || [];
|
|
2071
|
+
dimensionChanges.forEach((f) => typeof f === "function" && f());
|
|
2072
|
+
aggregationDirty = true;
|
|
2073
|
+
}
|
|
2074
|
+
this.setState({ aggregationDirty });
|
|
2075
|
+
return this.state;
|
|
2076
|
+
}
|
|
2077
|
+
setState(updateObject) {
|
|
2078
|
+
this.state = { ...this.state, ...updateObject };
|
|
2079
|
+
}
|
|
2080
|
+
setDimensionState(key, updateObject) {
|
|
2081
|
+
this.setState({
|
|
2082
|
+
dimensions: {
|
|
2083
|
+
...this.state.dimensions,
|
|
2084
|
+
[key]: { ...this.state.dimensions[key], ...updateObject }
|
|
2085
|
+
}
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
normalizeResult(result = {}) {
|
|
2089
|
+
if (result.hexagons) {
|
|
2090
|
+
return { data: result.hexagons, ...result };
|
|
2091
|
+
} else if (result.layerData) {
|
|
2092
|
+
return { data: result.layerData, ...result };
|
|
2093
|
+
}
|
|
2094
|
+
return result;
|
|
2095
|
+
}
|
|
2096
|
+
getAggregatedData(props, aggregationParams) {
|
|
2097
|
+
const aggregator = this._getAggregator(props);
|
|
2098
|
+
const result = aggregator(props, aggregationParams);
|
|
2099
|
+
this.setState({
|
|
2100
|
+
layerData: this.normalizeResult(result)
|
|
2101
|
+
});
|
|
2102
|
+
this.changeFlags = {
|
|
2103
|
+
layerData: true
|
|
2104
|
+
};
|
|
2105
|
+
this.getSortedBins(props);
|
|
2106
|
+
}
|
|
2107
|
+
updateGetValueFuncs(oldProps, props, changeFlags) {
|
|
2108
|
+
for (const key in this.dimensionUpdaters) {
|
|
2109
|
+
const { value, weight, aggregation } = this.dimensionUpdaters[key].getBins.triggers;
|
|
2110
|
+
let getValue = props[value.prop];
|
|
2111
|
+
const getValueChanged = this.needUpdateDimensionStep(this.dimensionUpdaters[key].getBins, oldProps, props, changeFlags);
|
|
2112
|
+
if (getValueChanged) {
|
|
2113
|
+
if (getValue) {
|
|
2114
|
+
getValue = wrapGetValueFunc(getValue, { data: props.data });
|
|
2115
|
+
} else {
|
|
2116
|
+
getValue = getValueFunc(props[aggregation.prop], props[weight.prop], { data: props.data });
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
if (getValue) {
|
|
2120
|
+
this.setDimensionState(key, { getValue });
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
needsReProjectPoints(oldProps, props, changeFlags) {
|
|
2125
|
+
return this._getCellSize(oldProps) !== this._getCellSize(props) || this._getAggregator(oldProps) !== this._getAggregator(props) || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPosition);
|
|
2126
|
+
}
|
|
2127
|
+
addDimension(dimensions) {
|
|
2128
|
+
this._addDimension(dimensions);
|
|
2129
|
+
}
|
|
2130
|
+
_addDimension(dimensions = []) {
|
|
2131
|
+
dimensions.forEach((dimension) => {
|
|
2132
|
+
const { key } = dimension;
|
|
2133
|
+
this.dimensionUpdaters[key] = this.getDimensionUpdaters(dimension);
|
|
2134
|
+
this.state.dimensions[key] = {
|
|
2135
|
+
getValue: null,
|
|
2136
|
+
domain: null,
|
|
2137
|
+
sortedBins: null,
|
|
2138
|
+
scaleFunc: noop
|
|
2139
|
+
};
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
getDimensionUpdaters({ key, accessor, pickingInfo, getBins, getDomain, getScaleFunc, nullValue }) {
|
|
2143
|
+
return {
|
|
2144
|
+
key,
|
|
2145
|
+
accessor,
|
|
2146
|
+
pickingInfo,
|
|
2147
|
+
getBins: { updater: this.getDimensionSortedBins.bind(this), ...getBins },
|
|
2148
|
+
getDomain: { updater: this.getDimensionValueDomain.bind(this), ...getDomain },
|
|
2149
|
+
getScaleFunc: { updater: this.getDimensionScale.bind(this), ...getScaleFunc },
|
|
2150
|
+
attributeAccessor: this.getSubLayerDimensionAttribute(key, nullValue)
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
needUpdateDimensionStep(dimensionStep, oldProps, props, changeFlags) {
|
|
2154
|
+
return Object.values(dimensionStep.triggers).some((item) => {
|
|
2155
|
+
if (item.updateTrigger) {
|
|
2156
|
+
return changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged[item.updateTrigger]);
|
|
2157
|
+
}
|
|
2158
|
+
return oldProps[item.prop] !== props[item.prop];
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
getDimensionChanges(oldProps, props, changeFlags) {
|
|
2162
|
+
const updaters = [];
|
|
2163
|
+
for (const key in this.dimensionUpdaters) {
|
|
2164
|
+
const needUpdate = dimensionSteps.find((step) => this.needUpdateDimensionStep(this.dimensionUpdaters[key][step], oldProps, props, changeFlags));
|
|
2165
|
+
if (needUpdate) {
|
|
2166
|
+
updaters.push(this.dimensionUpdaters[key][needUpdate].updater.bind(this, props, this.dimensionUpdaters[key]));
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
return updaters.length ? updaters : null;
|
|
2170
|
+
}
|
|
2171
|
+
getUpdateTriggers(props) {
|
|
2172
|
+
const _updateTriggers = props.updateTriggers || {};
|
|
2173
|
+
const updateTriggers = {};
|
|
2174
|
+
for (const key in this.dimensionUpdaters) {
|
|
2175
|
+
const { accessor } = this.dimensionUpdaters[key];
|
|
2176
|
+
updateTriggers[accessor] = {};
|
|
2177
|
+
dimensionSteps.forEach((step) => {
|
|
2178
|
+
Object.values(this.dimensionUpdaters[key][step].triggers).forEach(({ prop, updateTrigger }) => {
|
|
2179
|
+
if (updateTrigger) {
|
|
2180
|
+
const fromProp = _updateTriggers[updateTrigger];
|
|
2181
|
+
if (typeof fromProp === "object" && !Array.isArray(fromProp)) {
|
|
2182
|
+
Object.assign(updateTriggers[accessor], fromProp);
|
|
2183
|
+
} else if (fromProp !== void 0) {
|
|
2184
|
+
updateTriggers[accessor][prop] = fromProp;
|
|
2185
|
+
}
|
|
2186
|
+
} else {
|
|
2187
|
+
updateTriggers[accessor][prop] = props[prop];
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
return updateTriggers;
|
|
2193
|
+
}
|
|
2194
|
+
getSortedBins(props) {
|
|
2195
|
+
for (const key in this.dimensionUpdaters) {
|
|
2196
|
+
this.getDimensionSortedBins(props, this.dimensionUpdaters[key]);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
getDimensionSortedBins(props, dimensionUpdater) {
|
|
2200
|
+
const { key } = dimensionUpdater;
|
|
2201
|
+
const { getValue } = this.state.dimensions[key];
|
|
2202
|
+
const sortedBins = new BinSorter(this.state.layerData.data || [], {
|
|
2203
|
+
getValue,
|
|
2204
|
+
filterData: props._filterData
|
|
2205
|
+
});
|
|
2206
|
+
this.setDimensionState(key, { sortedBins });
|
|
2207
|
+
this.getDimensionValueDomain(props, dimensionUpdater);
|
|
2208
|
+
}
|
|
2209
|
+
getDimensionValueDomain(props, dimensionUpdater) {
|
|
2210
|
+
const { getDomain, key } = dimensionUpdater;
|
|
2211
|
+
const { triggers: { lowerPercentile, upperPercentile, scaleType } } = getDomain;
|
|
2212
|
+
const valueDomain = this.state.dimensions[key].sortedBins.getValueDomainByScale(props[scaleType.prop], [props[lowerPercentile.prop], props[upperPercentile.prop]]);
|
|
2213
|
+
this.setDimensionState(key, { valueDomain });
|
|
2214
|
+
this.getDimensionScale(props, dimensionUpdater);
|
|
2215
|
+
}
|
|
2216
|
+
getDimensionScale(props, dimensionUpdater) {
|
|
2217
|
+
const { key, getScaleFunc, getDomain } = dimensionUpdater;
|
|
2218
|
+
const { domain, range } = getScaleFunc.triggers;
|
|
2219
|
+
const { scaleType } = getDomain.triggers;
|
|
2220
|
+
const { onSet } = getScaleFunc;
|
|
2221
|
+
const dimensionRange = props[range.prop];
|
|
2222
|
+
const dimensionDomain = props[domain.prop] || this.state.dimensions[key].valueDomain;
|
|
2223
|
+
const getScaleFunction = getScaleFunctionByScaleType(scaleType && props[scaleType.prop]);
|
|
2224
|
+
const scaleFunc = getScaleFunction(dimensionDomain, dimensionRange);
|
|
2225
|
+
if (typeof onSet === "object" && typeof props[onSet.props] === "function") {
|
|
2226
|
+
props[onSet.props](scaleFunc.domain());
|
|
2227
|
+
}
|
|
2228
|
+
this.setDimensionState(key, { scaleFunc });
|
|
2229
|
+
}
|
|
2230
|
+
getSubLayerDimensionAttribute(key, nullValue) {
|
|
2231
|
+
return (cell) => {
|
|
2232
|
+
const { sortedBins, scaleFunc } = this.state.dimensions[key];
|
|
2233
|
+
const bin = sortedBins.binMap[cell.index];
|
|
2234
|
+
if (bin && bin.counts === 0) {
|
|
2235
|
+
return nullValue;
|
|
2236
|
+
}
|
|
2237
|
+
const cv = bin && bin.value;
|
|
2238
|
+
const domain = scaleFunc.domain();
|
|
2239
|
+
const isValueInDomain = cv >= domain[0] && cv <= domain[domain.length - 1];
|
|
2240
|
+
return isValueInDomain ? scaleFunc(cv) : nullValue;
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
getSubLayerAccessors(props) {
|
|
2244
|
+
const accessors = {};
|
|
2245
|
+
for (const key in this.dimensionUpdaters) {
|
|
2246
|
+
const { accessor } = this.dimensionUpdaters[key];
|
|
2247
|
+
accessors[accessor] = this.getSubLayerDimensionAttribute(props, key);
|
|
2248
|
+
}
|
|
2249
|
+
return accessors;
|
|
2250
|
+
}
|
|
2251
|
+
getPickingInfo({ info }) {
|
|
2252
|
+
const isPicked = info.picked && info.index > -1;
|
|
2253
|
+
let object = null;
|
|
2254
|
+
if (isPicked) {
|
|
2255
|
+
const cell = this.state.layerData.data[info.index];
|
|
2256
|
+
const binInfo = {};
|
|
2257
|
+
for (const key in this.dimensionUpdaters) {
|
|
2258
|
+
const { pickingInfo } = this.dimensionUpdaters[key];
|
|
2259
|
+
const { sortedBins } = this.state.dimensions[key];
|
|
2260
|
+
const value = sortedBins.binMap[cell.index] && sortedBins.binMap[cell.index].value;
|
|
2261
|
+
binInfo[pickingInfo] = value;
|
|
2262
|
+
}
|
|
2263
|
+
object = Object.assign(binInfo, cell, {
|
|
2264
|
+
points: cell.filteredPoints || cell.points
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
info.picked = Boolean(object);
|
|
2268
|
+
info.object = object;
|
|
2269
|
+
return info;
|
|
2270
|
+
}
|
|
2271
|
+
getAccessor(dimensionKey) {
|
|
2272
|
+
if (!this.dimensionUpdaters.hasOwnProperty(dimensionKey)) {
|
|
2273
|
+
return noop;
|
|
2274
|
+
}
|
|
2275
|
+
return this.dimensionUpdaters[dimensionKey].attributeAccessor;
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
|
|
2279
|
+
// dist/cpu-grid-layer/cpu-grid-layer.js
|
|
2280
|
+
function nop() {
|
|
2281
|
+
}
|
|
2282
|
+
var defaultProps4 = {
|
|
2283
|
+
colorDomain: null,
|
|
2284
|
+
colorRange: defaultColorRange,
|
|
2285
|
+
getColorValue: { type: "accessor", value: null },
|
|
2286
|
+
getColorWeight: { type: "accessor", value: 1 },
|
|
2287
|
+
colorAggregation: "SUM",
|
|
2288
|
+
lowerPercentile: { type: "number", min: 0, max: 100, value: 0 },
|
|
2289
|
+
upperPercentile: { type: "number", min: 0, max: 100, value: 100 },
|
|
2290
|
+
colorScaleType: "quantize",
|
|
2291
|
+
onSetColorDomain: nop,
|
|
2292
|
+
elevationDomain: null,
|
|
2293
|
+
elevationRange: [0, 1e3],
|
|
2294
|
+
getElevationValue: { type: "accessor", value: null },
|
|
2295
|
+
getElevationWeight: { type: "accessor", value: 1 },
|
|
2296
|
+
elevationAggregation: "SUM",
|
|
2297
|
+
elevationLowerPercentile: { type: "number", min: 0, max: 100, value: 0 },
|
|
2298
|
+
elevationUpperPercentile: { type: "number", min: 0, max: 100, value: 100 },
|
|
2299
|
+
elevationScale: { type: "number", min: 0, value: 1 },
|
|
2300
|
+
elevationScaleType: "linear",
|
|
2301
|
+
onSetElevationDomain: nop,
|
|
2302
|
+
gridAggregator: pointToDensityGridDataCPU,
|
|
2303
|
+
cellSize: { type: "number", min: 0, max: 1e3, value: 1e3 },
|
|
2304
|
+
coverage: { type: "number", min: 0, max: 1, value: 1 },
|
|
2305
|
+
getPosition: { type: "accessor", value: (x) => x.position },
|
|
2306
|
+
extruded: false,
|
|
2307
|
+
material: true,
|
|
2308
|
+
_filterData: { type: "function", value: null, optional: true }
|
|
2309
|
+
};
|
|
2310
|
+
var _CPUGridLayer = class extends AggregationLayer {
|
|
2311
|
+
initializeState() {
|
|
2312
|
+
const cpuAggregator = new CPUAggregator({
|
|
2313
|
+
getAggregator: (props) => props.gridAggregator,
|
|
2314
|
+
getCellSize: (props) => props.cellSize
|
|
2315
|
+
});
|
|
2316
|
+
this.state = {
|
|
2317
|
+
cpuAggregator,
|
|
2318
|
+
aggregatorState: cpuAggregator.state
|
|
2319
|
+
};
|
|
2320
|
+
const attributeManager = this.getAttributeManager();
|
|
2321
|
+
attributeManager.add({
|
|
2322
|
+
positions: { size: 3, type: import_constants5.GL.DOUBLE, accessor: "getPosition" }
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
updateState(opts) {
|
|
2326
|
+
super.updateState(opts);
|
|
2327
|
+
this.setState({
|
|
2328
|
+
aggregatorState: this.state.cpuAggregator.updateState(opts, {
|
|
2329
|
+
viewport: this.context.viewport,
|
|
2330
|
+
attributes: this.getAttributes(),
|
|
2331
|
+
numInstances: this.getNumInstances()
|
|
2332
|
+
})
|
|
2333
|
+
});
|
|
2334
|
+
}
|
|
2335
|
+
getPickingInfo({ info }) {
|
|
2336
|
+
return this.state.cpuAggregator.getPickingInfo({ info });
|
|
2337
|
+
}
|
|
2338
|
+
_onGetSublayerColor(cell) {
|
|
2339
|
+
return this.state.cpuAggregator.getAccessor("fillColor")(cell);
|
|
2340
|
+
}
|
|
2341
|
+
_onGetSublayerElevation(cell) {
|
|
2342
|
+
return this.state.cpuAggregator.getAccessor("elevation")(cell);
|
|
2343
|
+
}
|
|
2344
|
+
_getSublayerUpdateTriggers() {
|
|
2345
|
+
return this.state.cpuAggregator.getUpdateTriggers(this.props);
|
|
2346
|
+
}
|
|
2347
|
+
renderLayers() {
|
|
2348
|
+
const { elevationScale, extruded, cellSize, coverage, material, transitions } = this.props;
|
|
2349
|
+
const { cpuAggregator } = this.state;
|
|
2350
|
+
const SubLayerClass = this.getSubLayerClass("grid-cell", import_layers.GridCellLayer);
|
|
2351
|
+
const updateTriggers = this._getSublayerUpdateTriggers();
|
|
2352
|
+
return new SubLayerClass({
|
|
2353
|
+
cellSize,
|
|
2354
|
+
coverage,
|
|
2355
|
+
material,
|
|
2356
|
+
elevationScale,
|
|
2357
|
+
extruded,
|
|
2358
|
+
getFillColor: this._onGetSublayerColor.bind(this),
|
|
2359
|
+
getElevation: this._onGetSublayerElevation.bind(this),
|
|
2360
|
+
transitions: transitions && {
|
|
2361
|
+
getFillColor: transitions.getColorValue || transitions.getColorWeight,
|
|
2362
|
+
getElevation: transitions.getElevationValue || transitions.getElevationWeight
|
|
2363
|
+
}
|
|
2364
|
+
}, this.getSubLayerProps({
|
|
2365
|
+
id: "grid-cell",
|
|
2366
|
+
updateTriggers
|
|
2367
|
+
}), {
|
|
2368
|
+
data: cpuAggregator.state.layerData.data
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
var CPUGridLayer = _CPUGridLayer;
|
|
2373
|
+
(() => {
|
|
2374
|
+
_CPUGridLayer.layerName = "CPUGridLayer";
|
|
2375
|
+
})();
|
|
2376
|
+
(() => {
|
|
2377
|
+
_CPUGridLayer.defaultProps = defaultProps4;
|
|
2378
|
+
})();
|
|
2379
|
+
|
|
2380
|
+
// dist/hexagon-layer/hexagon-layer.js
|
|
2381
|
+
var import_core10 = require("@deck.gl/core");
|
|
2382
|
+
var import_layers2 = require("@deck.gl/layers");
|
|
2383
|
+
var import_constants6 = require("@luma.gl/constants");
|
|
2384
|
+
|
|
2385
|
+
// dist/hexagon-layer/hexagon-aggregator.js
|
|
2386
|
+
var import_d3_hexbin = require("d3-hexbin");
|
|
2387
|
+
var import_core9 = require("@deck.gl/core");
|
|
2388
|
+
function pointToHexbin(props, aggregationParams) {
|
|
2389
|
+
const { data, radius } = props;
|
|
2390
|
+
const { viewport, attributes } = aggregationParams;
|
|
2391
|
+
const centerLngLat = data.length ? getPointsCenter(data, aggregationParams) : null;
|
|
2392
|
+
const radiusCommon = getRadiusInCommon(radius, viewport, centerLngLat);
|
|
2393
|
+
const screenPoints = [];
|
|
2394
|
+
const { iterable, objectInfo } = (0, import_core9.createIterable)(data);
|
|
2395
|
+
const positions = attributes.positions.value;
|
|
2396
|
+
const { size } = attributes.positions.getAccessor();
|
|
2397
|
+
for (const object of iterable) {
|
|
2398
|
+
objectInfo.index++;
|
|
2399
|
+
const posIndex = objectInfo.index * size;
|
|
2400
|
+
const position = [positions[posIndex], positions[posIndex + 1]];
|
|
2401
|
+
const arrayIsFinite = Number.isFinite(position[0]) && Number.isFinite(position[1]);
|
|
2402
|
+
if (arrayIsFinite) {
|
|
2403
|
+
screenPoints.push({
|
|
2404
|
+
screenCoord: viewport.projectFlat(position),
|
|
2405
|
+
source: object,
|
|
2406
|
+
index: objectInfo.index
|
|
2407
|
+
});
|
|
2408
|
+
} else {
|
|
2409
|
+
import_core9.log.warn("HexagonLayer: invalid position")();
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
const newHexbin = (0, import_d3_hexbin.hexbin)().radius(radiusCommon).x((d) => d.screenCoord[0]).y((d) => d.screenCoord[1]);
|
|
2413
|
+
const hexagonBins = newHexbin(screenPoints);
|
|
2414
|
+
return {
|
|
2415
|
+
hexagons: hexagonBins.map((hex, index) => ({
|
|
2416
|
+
position: viewport.unprojectFlat([hex.x, hex.y]),
|
|
2417
|
+
points: hex,
|
|
2418
|
+
index
|
|
2419
|
+
})),
|
|
2420
|
+
radiusCommon
|
|
2421
|
+
};
|
|
2422
|
+
}
|
|
2423
|
+
function getPointsCenter(data, aggregationParams) {
|
|
2424
|
+
const { attributes } = aggregationParams;
|
|
2425
|
+
const positions = attributes.positions.value;
|
|
2426
|
+
const { size } = attributes.positions.getAccessor();
|
|
2427
|
+
let minX = Infinity;
|
|
2428
|
+
let minY = Infinity;
|
|
2429
|
+
let maxX = -Infinity;
|
|
2430
|
+
let maxY = -Infinity;
|
|
2431
|
+
let i;
|
|
2432
|
+
for (i = 0; i < size * data.length; i += size) {
|
|
2433
|
+
const x = positions[i];
|
|
2434
|
+
const y = positions[i + 1];
|
|
2435
|
+
const arrayIsFinite = Number.isFinite(x) && Number.isFinite(y);
|
|
2436
|
+
if (arrayIsFinite) {
|
|
2437
|
+
minX = Math.min(x, minX);
|
|
2438
|
+
maxX = Math.max(x, maxX);
|
|
2439
|
+
minY = Math.min(y, minY);
|
|
2440
|
+
maxY = Math.max(y, maxY);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
return [minX, minY, maxX, maxY].every(Number.isFinite) ? [(minX + maxX) / 2, (minY + maxY) / 2] : null;
|
|
2444
|
+
}
|
|
2445
|
+
function getRadiusInCommon(radius, viewport, center) {
|
|
2446
|
+
const { unitsPerMeter } = viewport.getDistanceScales(center);
|
|
2447
|
+
return radius * unitsPerMeter[0];
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
// dist/hexagon-layer/hexagon-layer.js
|
|
2451
|
+
function nop2() {
|
|
2452
|
+
}
|
|
2453
|
+
var defaultProps5 = {
|
|
2454
|
+
colorDomain: null,
|
|
2455
|
+
colorRange: defaultColorRange,
|
|
2456
|
+
getColorValue: { type: "accessor", value: null },
|
|
2457
|
+
getColorWeight: { type: "accessor", value: 1 },
|
|
2458
|
+
colorAggregation: "SUM",
|
|
2459
|
+
lowerPercentile: { type: "number", value: 0, min: 0, max: 100 },
|
|
2460
|
+
upperPercentile: { type: "number", value: 100, min: 0, max: 100 },
|
|
2461
|
+
colorScaleType: "quantize",
|
|
2462
|
+
onSetColorDomain: nop2,
|
|
2463
|
+
elevationDomain: null,
|
|
2464
|
+
elevationRange: [0, 1e3],
|
|
2465
|
+
getElevationValue: { type: "accessor", value: null },
|
|
2466
|
+
getElevationWeight: { type: "accessor", value: 1 },
|
|
2467
|
+
elevationAggregation: "SUM",
|
|
2468
|
+
elevationLowerPercentile: { type: "number", value: 0, min: 0, max: 100 },
|
|
2469
|
+
elevationUpperPercentile: { type: "number", value: 100, min: 0, max: 100 },
|
|
2470
|
+
elevationScale: { type: "number", min: 0, value: 1 },
|
|
2471
|
+
elevationScaleType: "linear",
|
|
2472
|
+
onSetElevationDomain: nop2,
|
|
2473
|
+
radius: { type: "number", value: 1e3, min: 1 },
|
|
2474
|
+
coverage: { type: "number", min: 0, max: 1, value: 1 },
|
|
2475
|
+
extruded: false,
|
|
2476
|
+
hexagonAggregator: pointToHexbin,
|
|
2477
|
+
getPosition: { type: "accessor", value: (x) => x.position },
|
|
2478
|
+
material: true,
|
|
2479
|
+
_filterData: { type: "function", value: null, optional: true }
|
|
2480
|
+
};
|
|
2481
|
+
var _HexagonLayer = class extends AggregationLayer {
|
|
2482
|
+
initializeState() {
|
|
2483
|
+
const cpuAggregator = new CPUAggregator({
|
|
2484
|
+
getAggregator: (props) => props.hexagonAggregator,
|
|
2485
|
+
getCellSize: (props) => props.radius
|
|
2486
|
+
});
|
|
2487
|
+
this.state = {
|
|
2488
|
+
cpuAggregator,
|
|
2489
|
+
aggregatorState: cpuAggregator.state,
|
|
2490
|
+
vertices: null
|
|
2491
|
+
};
|
|
2492
|
+
const attributeManager = this.getAttributeManager();
|
|
2493
|
+
attributeManager.add({
|
|
2494
|
+
positions: { size: 3, type: import_constants6.GL.DOUBLE, accessor: "getPosition" }
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
updateState(opts) {
|
|
2498
|
+
super.updateState(opts);
|
|
2499
|
+
if (opts.changeFlags.propsOrDataChanged) {
|
|
2500
|
+
const aggregatorState = this.state.cpuAggregator.updateState(opts, {
|
|
2501
|
+
viewport: this.context.viewport,
|
|
2502
|
+
attributes: this.getAttributes()
|
|
2503
|
+
});
|
|
2504
|
+
if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
|
|
2505
|
+
const { hexagonVertices } = aggregatorState.layerData || {};
|
|
2506
|
+
this.setState({
|
|
2507
|
+
vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
|
|
2508
|
+
});
|
|
2509
|
+
}
|
|
2510
|
+
this.setState({
|
|
2511
|
+
aggregatorState
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
convertLatLngToMeterOffset(hexagonVertices) {
|
|
2516
|
+
const { viewport } = this.context;
|
|
2517
|
+
if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {
|
|
2518
|
+
const vertex0 = hexagonVertices[0];
|
|
2519
|
+
const vertex3 = hexagonVertices[3];
|
|
2520
|
+
const centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];
|
|
2521
|
+
const centroidFlat = viewport.projectFlat(centroid);
|
|
2522
|
+
const { metersPerUnit } = viewport.getDistanceScales(centroid);
|
|
2523
|
+
const vertices = hexagonVertices.map((vt) => {
|
|
2524
|
+
const vtFlat = viewport.projectFlat(vt);
|
|
2525
|
+
return [
|
|
2526
|
+
(vtFlat[0] - centroidFlat[0]) * metersPerUnit[0],
|
|
2527
|
+
(vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]
|
|
2528
|
+
];
|
|
2529
|
+
});
|
|
2530
|
+
return vertices;
|
|
2531
|
+
}
|
|
2532
|
+
import_core10.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")();
|
|
2533
|
+
return null;
|
|
2534
|
+
}
|
|
2535
|
+
getPickingInfo({ info }) {
|
|
2536
|
+
return this.state.cpuAggregator.getPickingInfo({ info });
|
|
2537
|
+
}
|
|
2538
|
+
_onGetSublayerColor(cell) {
|
|
2539
|
+
return this.state.cpuAggregator.getAccessor("fillColor")(cell);
|
|
2540
|
+
}
|
|
2541
|
+
_onGetSublayerElevation(cell) {
|
|
2542
|
+
return this.state.cpuAggregator.getAccessor("elevation")(cell);
|
|
2543
|
+
}
|
|
2544
|
+
_getSublayerUpdateTriggers() {
|
|
2545
|
+
return this.state.cpuAggregator.getUpdateTriggers(this.props);
|
|
2546
|
+
}
|
|
2547
|
+
renderLayers() {
|
|
2548
|
+
const { elevationScale, extruded, coverage, material, transitions } = this.props;
|
|
2549
|
+
const { aggregatorState, vertices } = this.state;
|
|
2550
|
+
const SubLayerClass = this.getSubLayerClass("hexagon-cell", import_layers2.ColumnLayer);
|
|
2551
|
+
const updateTriggers = this._getSublayerUpdateTriggers();
|
|
2552
|
+
const geometry = vertices ? { vertices, radius: 1 } : {
|
|
2553
|
+
radius: aggregatorState.layerData.radiusCommon || 1,
|
|
2554
|
+
radiusUnits: "common",
|
|
2555
|
+
angle: 90
|
|
2556
|
+
};
|
|
2557
|
+
return new SubLayerClass({
|
|
2558
|
+
...geometry,
|
|
2559
|
+
diskResolution: 6,
|
|
2560
|
+
elevationScale,
|
|
2561
|
+
extruded,
|
|
2562
|
+
coverage,
|
|
2563
|
+
material,
|
|
2564
|
+
getFillColor: this._onGetSublayerColor.bind(this),
|
|
2565
|
+
getElevation: this._onGetSublayerElevation.bind(this),
|
|
2566
|
+
transitions: transitions && {
|
|
2567
|
+
getFillColor: transitions.getColorValue || transitions.getColorWeight,
|
|
2568
|
+
getElevation: transitions.getElevationValue || transitions.getElevationWeight
|
|
2569
|
+
}
|
|
2570
|
+
}, this.getSubLayerProps({
|
|
2571
|
+
id: "hexagon-cell",
|
|
2572
|
+
updateTriggers
|
|
2573
|
+
}), {
|
|
2574
|
+
data: aggregatorState.layerData.data
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
var HexagonLayer = _HexagonLayer;
|
|
2579
|
+
(() => {
|
|
2580
|
+
_HexagonLayer.layerName = "HexagonLayer";
|
|
2581
|
+
})();
|
|
2582
|
+
(() => {
|
|
2583
|
+
_HexagonLayer.defaultProps = defaultProps5;
|
|
2584
|
+
})();
|
|
2585
|
+
|
|
2586
|
+
// dist/contour-layer/contour-layer.js
|
|
2587
|
+
var import_constants7 = require("@luma.gl/constants");
|
|
2588
|
+
var import_layers3 = require("@deck.gl/layers");
|
|
2589
|
+
|
|
2590
|
+
// dist/contour-layer/marching-squares.js
|
|
2591
|
+
var import_core11 = require("@deck.gl/core");
|
|
2592
|
+
|
|
2593
|
+
// dist/contour-layer/marching-squares-codes.js
|
|
2594
|
+
var HALF = 0.5;
|
|
2595
|
+
var ONE6TH = 1 / 6;
|
|
2596
|
+
var OFFSET = {
|
|
2597
|
+
N: [0, HALF],
|
|
2598
|
+
E: [HALF, 0],
|
|
2599
|
+
S: [0, -HALF],
|
|
2600
|
+
W: [-HALF, 0],
|
|
2601
|
+
NE: [HALF, HALF],
|
|
2602
|
+
NW: [-HALF, HALF],
|
|
2603
|
+
SE: [HALF, -HALF],
|
|
2604
|
+
SW: [-HALF, -HALF]
|
|
2605
|
+
};
|
|
2606
|
+
var SW_TRIANGLE = [OFFSET.W, OFFSET.SW, OFFSET.S];
|
|
2607
|
+
var SE_TRIANGLE = [OFFSET.S, OFFSET.SE, OFFSET.E];
|
|
2608
|
+
var NE_TRIANGLE = [OFFSET.E, OFFSET.NE, OFFSET.N];
|
|
2609
|
+
var NW_TRIANGLE = [OFFSET.NW, OFFSET.W, OFFSET.N];
|
|
2610
|
+
var SW_TRAPEZOID = [
|
|
2611
|
+
[-HALF, ONE6TH],
|
|
2612
|
+
[-HALF, -ONE6TH],
|
|
2613
|
+
[-ONE6TH, -HALF],
|
|
2614
|
+
[ONE6TH, -HALF]
|
|
2615
|
+
];
|
|
2616
|
+
var SE_TRAPEZOID = [
|
|
2617
|
+
[-ONE6TH, -HALF],
|
|
2618
|
+
[ONE6TH, -HALF],
|
|
2619
|
+
[HALF, -ONE6TH],
|
|
2620
|
+
[HALF, ONE6TH]
|
|
2621
|
+
];
|
|
2622
|
+
var NE_TRAPEZOID = [
|
|
2623
|
+
[HALF, -ONE6TH],
|
|
2624
|
+
[HALF, ONE6TH],
|
|
2625
|
+
[ONE6TH, HALF],
|
|
2626
|
+
[-ONE6TH, HALF]
|
|
2627
|
+
];
|
|
2628
|
+
var NW_TRAPEZOID = [
|
|
2629
|
+
[-HALF, ONE6TH],
|
|
2630
|
+
[-HALF, -ONE6TH],
|
|
2631
|
+
[ONE6TH, HALF],
|
|
2632
|
+
[-ONE6TH, HALF]
|
|
2633
|
+
];
|
|
2634
|
+
var S_RECTANGLE = [OFFSET.W, OFFSET.SW, OFFSET.SE, OFFSET.E];
|
|
2635
|
+
var E_RECTANGLE = [OFFSET.S, OFFSET.SE, OFFSET.NE, OFFSET.N];
|
|
2636
|
+
var N_RECTANGLE = [OFFSET.NW, OFFSET.W, OFFSET.E, OFFSET.NE];
|
|
2637
|
+
var W_RECTANGLE = [OFFSET.NW, OFFSET.SW, OFFSET.S, OFFSET.N];
|
|
2638
|
+
var EW_RECTANGEL = [
|
|
2639
|
+
[-HALF, ONE6TH],
|
|
2640
|
+
[-HALF, -ONE6TH],
|
|
2641
|
+
[HALF, -ONE6TH],
|
|
2642
|
+
[HALF, ONE6TH]
|
|
2643
|
+
];
|
|
2644
|
+
var SN_RECTANGEL = [
|
|
2645
|
+
[-ONE6TH, -HALF],
|
|
2646
|
+
[ONE6TH, -HALF],
|
|
2647
|
+
[ONE6TH, HALF],
|
|
2648
|
+
[-ONE6TH, HALF]
|
|
2649
|
+
];
|
|
2650
|
+
var SQUARE = [OFFSET.NW, OFFSET.SW, OFFSET.SE, OFFSET.NE];
|
|
2651
|
+
var SW_PENTAGON = [OFFSET.NW, OFFSET.SW, OFFSET.SE, OFFSET.E, OFFSET.N];
|
|
2652
|
+
var SE_PENTAGON = [OFFSET.W, OFFSET.SW, OFFSET.SE, OFFSET.NE, OFFSET.N];
|
|
2653
|
+
var NE_PENTAGON = [OFFSET.NW, OFFSET.W, OFFSET.S, OFFSET.SE, OFFSET.NE];
|
|
2654
|
+
var NW_PENTAGON = [OFFSET.NW, OFFSET.SW, OFFSET.S, OFFSET.E, OFFSET.NE];
|
|
2655
|
+
var NW_N_PENTAGON = [OFFSET.NW, OFFSET.W, [HALF, -ONE6TH], [HALF, ONE6TH], OFFSET.N];
|
|
2656
|
+
var NE_E_PENTAGON = [[-ONE6TH, -HALF], [ONE6TH, -HALF], OFFSET.E, OFFSET.NE, OFFSET.N];
|
|
2657
|
+
var SE_S_PENTAGON = [[-HALF, ONE6TH], [-HALF, -ONE6TH], OFFSET.S, OFFSET.SE, OFFSET.E];
|
|
2658
|
+
var SW_W_PENTAGON = [OFFSET.W, OFFSET.SW, OFFSET.S, [ONE6TH, HALF], [-ONE6TH, HALF]];
|
|
2659
|
+
var NW_W_PENTAGON = [OFFSET.NW, OFFSET.W, [-ONE6TH, -HALF], [ONE6TH, -HALF], OFFSET.N];
|
|
2660
|
+
var NE_N_PENTAGON = [[-HALF, ONE6TH], [-HALF, -ONE6TH], OFFSET.E, OFFSET.NE, OFFSET.N];
|
|
2661
|
+
var SE_E_PENTAGON = [OFFSET.S, OFFSET.SE, OFFSET.E, [ONE6TH, HALF], [-ONE6TH, HALF]];
|
|
2662
|
+
var SW_S_PENTAGON = [OFFSET.W, OFFSET.SW, OFFSET.S, [HALF, -ONE6TH], [HALF, ONE6TH]];
|
|
2663
|
+
var S_HEXAGON = [OFFSET.W, OFFSET.SW, OFFSET.SE, OFFSET.E, [ONE6TH, HALF], [-ONE6TH, HALF]];
|
|
2664
|
+
var E_HEXAGON = [[-HALF, ONE6TH], [-HALF, -ONE6TH], OFFSET.S, OFFSET.SE, OFFSET.NE, OFFSET.N];
|
|
2665
|
+
var N_HEXAGON = [OFFSET.NW, OFFSET.W, [-ONE6TH, -HALF], [ONE6TH, -HALF], OFFSET.E, OFFSET.NE];
|
|
2666
|
+
var W_HEXAGON = [OFFSET.NW, OFFSET.SW, OFFSET.S, [HALF, -ONE6TH], [HALF, ONE6TH], OFFSET.N];
|
|
2667
|
+
var SW_NE_HEXAGON = [OFFSET.W, OFFSET.SW, OFFSET.S, OFFSET.E, OFFSET.NE, OFFSET.N];
|
|
2668
|
+
var NW_SE_HEXAGON = [OFFSET.NW, OFFSET.W, OFFSET.S, OFFSET.SE, OFFSET.E, OFFSET.N];
|
|
2669
|
+
var NE_HEPTAGON = [
|
|
2670
|
+
[-HALF, ONE6TH],
|
|
2671
|
+
[-HALF, -ONE6TH],
|
|
2672
|
+
[-ONE6TH, -HALF],
|
|
2673
|
+
[ONE6TH, -HALF],
|
|
2674
|
+
OFFSET.E,
|
|
2675
|
+
OFFSET.NE,
|
|
2676
|
+
OFFSET.N
|
|
2677
|
+
];
|
|
2678
|
+
var SW_HEPTAGON = [
|
|
2679
|
+
OFFSET.W,
|
|
2680
|
+
OFFSET.SW,
|
|
2681
|
+
OFFSET.S,
|
|
2682
|
+
[HALF, -ONE6TH],
|
|
2683
|
+
[HALF, ONE6TH],
|
|
2684
|
+
[ONE6TH, HALF],
|
|
2685
|
+
[-ONE6TH, HALF]
|
|
2686
|
+
];
|
|
2687
|
+
var NW_HEPTAGON = [
|
|
2688
|
+
OFFSET.NW,
|
|
2689
|
+
OFFSET.W,
|
|
2690
|
+
[-ONE6TH, -HALF],
|
|
2691
|
+
[ONE6TH, -HALF],
|
|
2692
|
+
[HALF, -ONE6TH],
|
|
2693
|
+
[HALF, ONE6TH],
|
|
2694
|
+
OFFSET.N
|
|
2695
|
+
];
|
|
2696
|
+
var SE_HEPTAGON = [
|
|
2697
|
+
[-HALF, ONE6TH],
|
|
2698
|
+
[-HALF, -ONE6TH],
|
|
2699
|
+
OFFSET.S,
|
|
2700
|
+
OFFSET.SE,
|
|
2701
|
+
OFFSET.E,
|
|
2702
|
+
[ONE6TH, HALF],
|
|
2703
|
+
[-ONE6TH, HALF]
|
|
2704
|
+
];
|
|
2705
|
+
var OCTAGON = [
|
|
2706
|
+
[-HALF, ONE6TH],
|
|
2707
|
+
[-HALF, -ONE6TH],
|
|
2708
|
+
[-ONE6TH, -HALF],
|
|
2709
|
+
[ONE6TH, -HALF],
|
|
2710
|
+
[HALF, -ONE6TH],
|
|
2711
|
+
[HALF, ONE6TH],
|
|
2712
|
+
[ONE6TH, HALF],
|
|
2713
|
+
[-ONE6TH, HALF]
|
|
2714
|
+
];
|
|
2715
|
+
var ISOLINES_CODE_OFFSET_MAP = {
|
|
2716
|
+
0: [],
|
|
2717
|
+
1: [[OFFSET.W, OFFSET.S]],
|
|
2718
|
+
2: [[OFFSET.S, OFFSET.E]],
|
|
2719
|
+
3: [[OFFSET.W, OFFSET.E]],
|
|
2720
|
+
4: [[OFFSET.N, OFFSET.E]],
|
|
2721
|
+
5: {
|
|
2722
|
+
0: [
|
|
2723
|
+
[OFFSET.W, OFFSET.S],
|
|
2724
|
+
[OFFSET.N, OFFSET.E]
|
|
2725
|
+
],
|
|
2726
|
+
1: [
|
|
2727
|
+
[OFFSET.W, OFFSET.N],
|
|
2728
|
+
[OFFSET.S, OFFSET.E]
|
|
2729
|
+
]
|
|
2730
|
+
},
|
|
2731
|
+
6: [[OFFSET.N, OFFSET.S]],
|
|
2732
|
+
7: [[OFFSET.W, OFFSET.N]],
|
|
2733
|
+
8: [[OFFSET.W, OFFSET.N]],
|
|
2734
|
+
9: [[OFFSET.N, OFFSET.S]],
|
|
2735
|
+
10: {
|
|
2736
|
+
0: [
|
|
2737
|
+
[OFFSET.W, OFFSET.N],
|
|
2738
|
+
[OFFSET.S, OFFSET.E]
|
|
2739
|
+
],
|
|
2740
|
+
1: [
|
|
2741
|
+
[OFFSET.W, OFFSET.S],
|
|
2742
|
+
[OFFSET.N, OFFSET.E]
|
|
2743
|
+
]
|
|
2744
|
+
},
|
|
2745
|
+
11: [[OFFSET.N, OFFSET.E]],
|
|
2746
|
+
12: [[OFFSET.W, OFFSET.E]],
|
|
2747
|
+
13: [[OFFSET.S, OFFSET.E]],
|
|
2748
|
+
14: [[OFFSET.W, OFFSET.S]],
|
|
2749
|
+
15: []
|
|
2750
|
+
};
|
|
2751
|
+
function ternaryToIndex(ternary) {
|
|
2752
|
+
return parseInt(ternary, 4);
|
|
2753
|
+
}
|
|
2754
|
+
var ISOBANDS_CODE_OFFSET_MAP = {
|
|
2755
|
+
[ternaryToIndex("0000")]: [],
|
|
2756
|
+
[ternaryToIndex("2222")]: [],
|
|
2757
|
+
[ternaryToIndex("2221")]: [SW_TRIANGLE],
|
|
2758
|
+
[ternaryToIndex("2212")]: [SE_TRIANGLE],
|
|
2759
|
+
[ternaryToIndex("2122")]: [NE_TRIANGLE],
|
|
2760
|
+
[ternaryToIndex("1222")]: [NW_TRIANGLE],
|
|
2761
|
+
[ternaryToIndex("0001")]: [SW_TRIANGLE],
|
|
2762
|
+
[ternaryToIndex("0010")]: [SE_TRIANGLE],
|
|
2763
|
+
[ternaryToIndex("0100")]: [NE_TRIANGLE],
|
|
2764
|
+
[ternaryToIndex("1000")]: [NW_TRIANGLE],
|
|
2765
|
+
[ternaryToIndex("2220")]: [SW_TRAPEZOID],
|
|
2766
|
+
[ternaryToIndex("2202")]: [SE_TRAPEZOID],
|
|
2767
|
+
[ternaryToIndex("2022")]: [NE_TRAPEZOID],
|
|
2768
|
+
[ternaryToIndex("0222")]: [NW_TRAPEZOID],
|
|
2769
|
+
[ternaryToIndex("0002")]: [SW_TRAPEZOID],
|
|
2770
|
+
[ternaryToIndex("0020")]: [SE_TRAPEZOID],
|
|
2771
|
+
[ternaryToIndex("0200")]: [NE_TRAPEZOID],
|
|
2772
|
+
[ternaryToIndex("2000")]: [NW_TRAPEZOID],
|
|
2773
|
+
[ternaryToIndex("0011")]: [S_RECTANGLE],
|
|
2774
|
+
[ternaryToIndex("0110")]: [E_RECTANGLE],
|
|
2775
|
+
[ternaryToIndex("1100")]: [N_RECTANGLE],
|
|
2776
|
+
[ternaryToIndex("1001")]: [W_RECTANGLE],
|
|
2777
|
+
[ternaryToIndex("2211")]: [S_RECTANGLE],
|
|
2778
|
+
[ternaryToIndex("2112")]: [E_RECTANGLE],
|
|
2779
|
+
[ternaryToIndex("1122")]: [N_RECTANGLE],
|
|
2780
|
+
[ternaryToIndex("1221")]: [W_RECTANGLE],
|
|
2781
|
+
[ternaryToIndex("2200")]: [EW_RECTANGEL],
|
|
2782
|
+
[ternaryToIndex("2002")]: [SN_RECTANGEL],
|
|
2783
|
+
[ternaryToIndex("0022")]: [EW_RECTANGEL],
|
|
2784
|
+
[ternaryToIndex("0220")]: [SN_RECTANGEL],
|
|
2785
|
+
[ternaryToIndex("1111")]: [SQUARE],
|
|
2786
|
+
[ternaryToIndex("1211")]: [SW_PENTAGON],
|
|
2787
|
+
[ternaryToIndex("2111")]: [SE_PENTAGON],
|
|
2788
|
+
[ternaryToIndex("1112")]: [NE_PENTAGON],
|
|
2789
|
+
[ternaryToIndex("1121")]: [NW_PENTAGON],
|
|
2790
|
+
[ternaryToIndex("1011")]: [SW_PENTAGON],
|
|
2791
|
+
[ternaryToIndex("0111")]: [SE_PENTAGON],
|
|
2792
|
+
[ternaryToIndex("1110")]: [NE_PENTAGON],
|
|
2793
|
+
[ternaryToIndex("1101")]: [NW_PENTAGON],
|
|
2794
|
+
[ternaryToIndex("1200")]: [NW_N_PENTAGON],
|
|
2795
|
+
[ternaryToIndex("0120")]: [NE_E_PENTAGON],
|
|
2796
|
+
[ternaryToIndex("0012")]: [SE_S_PENTAGON],
|
|
2797
|
+
[ternaryToIndex("2001")]: [SW_W_PENTAGON],
|
|
2798
|
+
[ternaryToIndex("1022")]: [NW_N_PENTAGON],
|
|
2799
|
+
[ternaryToIndex("2102")]: [NE_E_PENTAGON],
|
|
2800
|
+
[ternaryToIndex("2210")]: [SE_S_PENTAGON],
|
|
2801
|
+
[ternaryToIndex("0221")]: [SW_W_PENTAGON],
|
|
2802
|
+
[ternaryToIndex("1002")]: [NW_W_PENTAGON],
|
|
2803
|
+
[ternaryToIndex("2100")]: [NE_N_PENTAGON],
|
|
2804
|
+
[ternaryToIndex("0210")]: [SE_E_PENTAGON],
|
|
2805
|
+
[ternaryToIndex("0021")]: [SW_S_PENTAGON],
|
|
2806
|
+
[ternaryToIndex("1220")]: [NW_W_PENTAGON],
|
|
2807
|
+
[ternaryToIndex("0122")]: [NE_N_PENTAGON],
|
|
2808
|
+
[ternaryToIndex("2012")]: [SE_E_PENTAGON],
|
|
2809
|
+
[ternaryToIndex("2201")]: [SW_S_PENTAGON],
|
|
2810
|
+
[ternaryToIndex("0211")]: [S_HEXAGON],
|
|
2811
|
+
[ternaryToIndex("2110")]: [E_HEXAGON],
|
|
2812
|
+
[ternaryToIndex("1102")]: [N_HEXAGON],
|
|
2813
|
+
[ternaryToIndex("1021")]: [W_HEXAGON],
|
|
2814
|
+
[ternaryToIndex("2011")]: [S_HEXAGON],
|
|
2815
|
+
[ternaryToIndex("0112")]: [E_HEXAGON],
|
|
2816
|
+
[ternaryToIndex("1120")]: [N_HEXAGON],
|
|
2817
|
+
[ternaryToIndex("1201")]: [W_HEXAGON],
|
|
2818
|
+
[ternaryToIndex("2101")]: [SW_NE_HEXAGON],
|
|
2819
|
+
[ternaryToIndex("0121")]: [SW_NE_HEXAGON],
|
|
2820
|
+
[ternaryToIndex("1012")]: [NW_SE_HEXAGON],
|
|
2821
|
+
[ternaryToIndex("1210")]: [NW_SE_HEXAGON],
|
|
2822
|
+
[ternaryToIndex("0101")]: {
|
|
2823
|
+
0: [SW_TRIANGLE, NE_TRIANGLE],
|
|
2824
|
+
1: [SW_NE_HEXAGON],
|
|
2825
|
+
2: [SW_NE_HEXAGON]
|
|
2826
|
+
},
|
|
2827
|
+
[ternaryToIndex("1010")]: {
|
|
2828
|
+
0: [NW_TRIANGLE, SE_TRIANGLE],
|
|
2829
|
+
1: [NW_SE_HEXAGON],
|
|
2830
|
+
2: [NW_SE_HEXAGON]
|
|
2831
|
+
},
|
|
2832
|
+
[ternaryToIndex("2121")]: {
|
|
2833
|
+
0: [SW_NE_HEXAGON],
|
|
2834
|
+
1: [SW_NE_HEXAGON],
|
|
2835
|
+
2: [SW_TRIANGLE, NE_TRIANGLE]
|
|
2836
|
+
},
|
|
2837
|
+
[ternaryToIndex("1212")]: {
|
|
2838
|
+
0: [NW_SE_HEXAGON],
|
|
2839
|
+
1: [NW_SE_HEXAGON],
|
|
2840
|
+
2: [NW_TRIANGLE, SE_TRIANGLE]
|
|
2841
|
+
},
|
|
2842
|
+
[ternaryToIndex("2120")]: {
|
|
2843
|
+
0: [NE_HEPTAGON],
|
|
2844
|
+
1: [NE_HEPTAGON],
|
|
2845
|
+
2: [SW_TRAPEZOID, NE_TRIANGLE]
|
|
2846
|
+
},
|
|
2847
|
+
[ternaryToIndex("2021")]: {
|
|
2848
|
+
0: [SW_HEPTAGON],
|
|
2849
|
+
1: [SW_HEPTAGON],
|
|
2850
|
+
2: [SW_TRIANGLE, NE_TRAPEZOID]
|
|
2851
|
+
},
|
|
2852
|
+
[ternaryToIndex("1202")]: {
|
|
2853
|
+
0: [NW_HEPTAGON],
|
|
2854
|
+
1: [NW_HEPTAGON],
|
|
2855
|
+
2: [NW_TRIANGLE, SE_TRAPEZOID]
|
|
2856
|
+
},
|
|
2857
|
+
[ternaryToIndex("0212")]: {
|
|
2858
|
+
0: [SE_HEPTAGON],
|
|
2859
|
+
1: [SE_HEPTAGON],
|
|
2860
|
+
2: [SE_TRIANGLE, NW_TRAPEZOID]
|
|
2861
|
+
},
|
|
2862
|
+
[ternaryToIndex("0102")]: {
|
|
2863
|
+
0: [SW_TRAPEZOID, NE_TRIANGLE],
|
|
2864
|
+
1: [NE_HEPTAGON],
|
|
2865
|
+
2: [NE_HEPTAGON]
|
|
2866
|
+
},
|
|
2867
|
+
[ternaryToIndex("0201")]: {
|
|
2868
|
+
0: [SW_TRIANGLE, NE_TRAPEZOID],
|
|
2869
|
+
1: [SW_HEPTAGON],
|
|
2870
|
+
2: [SW_HEPTAGON]
|
|
2871
|
+
},
|
|
2872
|
+
[ternaryToIndex("1020")]: {
|
|
2873
|
+
0: [NW_TRIANGLE, SE_TRAPEZOID],
|
|
2874
|
+
1: [NW_HEPTAGON],
|
|
2875
|
+
2: [NW_HEPTAGON]
|
|
2876
|
+
},
|
|
2877
|
+
[ternaryToIndex("2010")]: {
|
|
2878
|
+
0: [SE_TRIANGLE, NW_TRAPEZOID],
|
|
2879
|
+
1: [SE_HEPTAGON],
|
|
2880
|
+
2: [SE_HEPTAGON]
|
|
2881
|
+
},
|
|
2882
|
+
[ternaryToIndex("2020")]: {
|
|
2883
|
+
0: [NW_TRAPEZOID, SE_TRAPEZOID],
|
|
2884
|
+
1: [OCTAGON],
|
|
2885
|
+
2: [SW_TRAPEZOID, NE_TRAPEZOID]
|
|
2886
|
+
},
|
|
2887
|
+
[ternaryToIndex("0202")]: {
|
|
2888
|
+
0: [NE_TRAPEZOID, SW_TRAPEZOID],
|
|
2889
|
+
1: [OCTAGON],
|
|
2890
|
+
2: [NW_TRAPEZOID, SE_TRAPEZOID]
|
|
2891
|
+
}
|
|
2892
|
+
};
|
|
2893
|
+
|
|
2894
|
+
// dist/contour-layer/marching-squares.js
|
|
2895
|
+
var CONTOUR_TYPE = {
|
|
2896
|
+
ISO_LINES: 1,
|
|
2897
|
+
ISO_BANDS: 2
|
|
2898
|
+
};
|
|
2899
|
+
var DEFAULT_THRESHOLD_DATA = {
|
|
2900
|
+
zIndex: 0,
|
|
2901
|
+
zOffset: 5e-3
|
|
2902
|
+
};
|
|
2903
|
+
function getVertexCode(weight, threshold2) {
|
|
2904
|
+
if (Array.isArray(threshold2)) {
|
|
2905
|
+
if (weight < threshold2[0]) {
|
|
2906
|
+
return 0;
|
|
2907
|
+
}
|
|
2908
|
+
return weight < threshold2[1] ? 1 : 2;
|
|
2909
|
+
}
|
|
2910
|
+
return weight >= threshold2 ? 1 : 0;
|
|
2911
|
+
}
|
|
2912
|
+
function getCode(opts) {
|
|
2913
|
+
const { cellWeights, x, y, width, height } = opts;
|
|
2914
|
+
let threshold2 = opts.threshold;
|
|
2915
|
+
if (opts.thresholdValue) {
|
|
2916
|
+
import_core11.log.deprecated("thresholdValue", "threshold")();
|
|
2917
|
+
threshold2 = opts.thresholdValue;
|
|
2918
|
+
}
|
|
2919
|
+
const isLeftBoundary = x < 0;
|
|
2920
|
+
const isRightBoundary = x >= width - 1;
|
|
2921
|
+
const isBottomBoundary = y < 0;
|
|
2922
|
+
const isTopBoundary = y >= height - 1;
|
|
2923
|
+
const isBoundary = isLeftBoundary || isRightBoundary || isBottomBoundary || isTopBoundary;
|
|
2924
|
+
const weights = {};
|
|
2925
|
+
const codes = {};
|
|
2926
|
+
if (isLeftBoundary || isTopBoundary) {
|
|
2927
|
+
codes.top = 0;
|
|
2928
|
+
} else {
|
|
2929
|
+
weights.top = cellWeights[(y + 1) * width + x];
|
|
2930
|
+
codes.top = getVertexCode(weights.top, threshold2);
|
|
2931
|
+
}
|
|
2932
|
+
if (isRightBoundary || isTopBoundary) {
|
|
2933
|
+
codes.topRight = 0;
|
|
2934
|
+
} else {
|
|
2935
|
+
weights.topRight = cellWeights[(y + 1) * width + x + 1];
|
|
2936
|
+
codes.topRight = getVertexCode(weights.topRight, threshold2);
|
|
2937
|
+
}
|
|
2938
|
+
if (isRightBoundary || isBottomBoundary) {
|
|
2939
|
+
codes.right = 0;
|
|
2940
|
+
} else {
|
|
2941
|
+
weights.right = cellWeights[y * width + x + 1];
|
|
2942
|
+
codes.right = getVertexCode(weights.right, threshold2);
|
|
2943
|
+
}
|
|
2944
|
+
if (isLeftBoundary || isBottomBoundary) {
|
|
2945
|
+
codes.current = 0;
|
|
2946
|
+
} else {
|
|
2947
|
+
weights.current = cellWeights[y * width + x];
|
|
2948
|
+
codes.current = getVertexCode(weights.current, threshold2);
|
|
2949
|
+
}
|
|
2950
|
+
const { top, topRight, right, current } = codes;
|
|
2951
|
+
let code = -1;
|
|
2952
|
+
if (Number.isFinite(threshold2)) {
|
|
2953
|
+
code = top << 3 | topRight << 2 | right << 1 | current;
|
|
2954
|
+
}
|
|
2955
|
+
if (Array.isArray(threshold2)) {
|
|
2956
|
+
code = top << 6 | topRight << 4 | right << 2 | current;
|
|
2957
|
+
}
|
|
2958
|
+
let meanCode = 0;
|
|
2959
|
+
if (!isBoundary) {
|
|
2960
|
+
meanCode = getVertexCode((weights.top + weights.topRight + weights.right + weights.current) / 4, threshold2);
|
|
2961
|
+
}
|
|
2962
|
+
return { code, meanCode };
|
|
2963
|
+
}
|
|
2964
|
+
function getVertices(opts) {
|
|
2965
|
+
const { gridOrigin, cellSize, x, y, code, meanCode, type = CONTOUR_TYPE.ISO_LINES } = opts;
|
|
2966
|
+
const thresholdData = { ...DEFAULT_THRESHOLD_DATA, ...opts.thresholdData };
|
|
2967
|
+
let offsets = type === CONTOUR_TYPE.ISO_BANDS ? ISOBANDS_CODE_OFFSET_MAP[code] : ISOLINES_CODE_OFFSET_MAP[code];
|
|
2968
|
+
if (!Array.isArray(offsets)) {
|
|
2969
|
+
offsets = offsets[meanCode];
|
|
2970
|
+
}
|
|
2971
|
+
const vZ = thresholdData.zIndex * thresholdData.zOffset;
|
|
2972
|
+
const rX = (x + 1) * cellSize[0];
|
|
2973
|
+
const rY = (y + 1) * cellSize[1];
|
|
2974
|
+
const refVertexX = gridOrigin[0] + rX;
|
|
2975
|
+
const refVertexY = gridOrigin[1] + rY;
|
|
2976
|
+
if (type === CONTOUR_TYPE.ISO_BANDS) {
|
|
2977
|
+
const polygons = [];
|
|
2978
|
+
offsets.forEach((polygonOffsets) => {
|
|
2979
|
+
const polygon = [];
|
|
2980
|
+
polygonOffsets.forEach((xyOffset) => {
|
|
2981
|
+
const vX = refVertexX + xyOffset[0] * cellSize[0];
|
|
2982
|
+
const vY = refVertexY + xyOffset[1] * cellSize[1];
|
|
2983
|
+
polygon.push([vX, vY, vZ]);
|
|
2984
|
+
});
|
|
2985
|
+
polygons.push(polygon);
|
|
2986
|
+
});
|
|
2987
|
+
return polygons;
|
|
2988
|
+
}
|
|
2989
|
+
const lines = [];
|
|
2990
|
+
offsets.forEach((xyOffsets) => {
|
|
2991
|
+
xyOffsets.forEach((offset) => {
|
|
2992
|
+
const vX = refVertexX + offset[0] * cellSize[0];
|
|
2993
|
+
const vY = refVertexY + offset[1] * cellSize[1];
|
|
2994
|
+
lines.push([vX, vY, vZ]);
|
|
2995
|
+
});
|
|
2996
|
+
});
|
|
2997
|
+
return lines;
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
// dist/contour-layer/contour-utils.js
|
|
3001
|
+
function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }) {
|
|
3002
|
+
const contourSegments = [];
|
|
3003
|
+
const contourPolygons = [];
|
|
3004
|
+
const width = gridSize[0];
|
|
3005
|
+
const height = gridSize[1];
|
|
3006
|
+
let segmentIndex = 0;
|
|
3007
|
+
let polygonIndex = 0;
|
|
3008
|
+
for (const data of thresholdData) {
|
|
3009
|
+
const { contour } = data;
|
|
3010
|
+
const { threshold: threshold2 } = contour;
|
|
3011
|
+
for (let x = -1; x < width; x++) {
|
|
3012
|
+
for (let y = -1; y < height; y++) {
|
|
3013
|
+
const { code, meanCode } = getCode({
|
|
3014
|
+
cellWeights,
|
|
3015
|
+
threshold: threshold2,
|
|
3016
|
+
x,
|
|
3017
|
+
y,
|
|
3018
|
+
width,
|
|
3019
|
+
height
|
|
3020
|
+
});
|
|
3021
|
+
const opts = {
|
|
3022
|
+
type: CONTOUR_TYPE.ISO_BANDS,
|
|
3023
|
+
gridOrigin,
|
|
3024
|
+
cellSize,
|
|
3025
|
+
x,
|
|
3026
|
+
y,
|
|
3027
|
+
width,
|
|
3028
|
+
height,
|
|
3029
|
+
code,
|
|
3030
|
+
meanCode,
|
|
3031
|
+
thresholdData: data
|
|
3032
|
+
};
|
|
3033
|
+
if (Array.isArray(threshold2)) {
|
|
3034
|
+
opts.type = CONTOUR_TYPE.ISO_BANDS;
|
|
3035
|
+
const polygons = getVertices(opts);
|
|
3036
|
+
for (const polygon of polygons) {
|
|
3037
|
+
contourPolygons[polygonIndex++] = {
|
|
3038
|
+
vertices: polygon,
|
|
3039
|
+
contour
|
|
3040
|
+
};
|
|
3041
|
+
}
|
|
3042
|
+
} else {
|
|
3043
|
+
opts.type = CONTOUR_TYPE.ISO_LINES;
|
|
3044
|
+
const vertices = getVertices(opts);
|
|
3045
|
+
for (let i = 0; i < vertices.length; i += 2) {
|
|
3046
|
+
contourSegments[segmentIndex++] = {
|
|
3047
|
+
start: vertices[i],
|
|
3048
|
+
end: vertices[i + 1],
|
|
3049
|
+
contour
|
|
3050
|
+
};
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
return { contourSegments, contourPolygons };
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
// dist/contour-layer/contour-layer.js
|
|
3060
|
+
var import_core12 = require("@deck.gl/core");
|
|
3061
|
+
var DEFAULT_COLOR = [255, 255, 255, 255];
|
|
3062
|
+
var DEFAULT_STROKE_WIDTH = 1;
|
|
3063
|
+
var DEFAULT_THRESHOLD = 1;
|
|
3064
|
+
var defaultProps6 = {
|
|
3065
|
+
cellSize: { type: "number", min: 1, max: 1e3, value: 1e3 },
|
|
3066
|
+
getPosition: { type: "accessor", value: (x) => x.position },
|
|
3067
|
+
getWeight: { type: "accessor", value: 1 },
|
|
3068
|
+
gpuAggregation: false,
|
|
3069
|
+
aggregation: "SUM",
|
|
3070
|
+
contours: {
|
|
3071
|
+
type: "object",
|
|
3072
|
+
value: [{ threshold: DEFAULT_THRESHOLD }],
|
|
3073
|
+
optional: true,
|
|
3074
|
+
compare: 3
|
|
3075
|
+
},
|
|
3076
|
+
zOffset: 5e-3
|
|
3077
|
+
};
|
|
3078
|
+
var POSITION_ATTRIBUTE_NAME2 = "positions";
|
|
3079
|
+
var DIMENSIONS2 = {
|
|
3080
|
+
data: {
|
|
3081
|
+
props: ["cellSize"]
|
|
3082
|
+
},
|
|
3083
|
+
weights: {
|
|
3084
|
+
props: ["aggregation"],
|
|
3085
|
+
accessors: ["getWeight"]
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
var _ContourLayer = class extends GridAggregationLayer {
|
|
3089
|
+
initializeState() {
|
|
3090
|
+
super.initializeAggregationLayer({
|
|
3091
|
+
dimensions: DIMENSIONS2
|
|
3092
|
+
});
|
|
3093
|
+
this.setState({
|
|
3094
|
+
contourData: {},
|
|
3095
|
+
projectPoints: false,
|
|
3096
|
+
weights: {
|
|
3097
|
+
count: {
|
|
3098
|
+
size: 1,
|
|
3099
|
+
operation: AGGREGATION_OPERATION.SUM
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
});
|
|
3103
|
+
const attributeManager = this.getAttributeManager();
|
|
3104
|
+
attributeManager.add({
|
|
3105
|
+
[POSITION_ATTRIBUTE_NAME2]: {
|
|
3106
|
+
size: 3,
|
|
3107
|
+
accessor: "getPosition",
|
|
3108
|
+
type: import_constants7.GL.DOUBLE,
|
|
3109
|
+
fp64: this.use64bitPositions()
|
|
3110
|
+
},
|
|
3111
|
+
count: { size: 3, accessor: "getWeight" }
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3114
|
+
updateState(opts) {
|
|
3115
|
+
super.updateState(opts);
|
|
3116
|
+
let contoursChanged = false;
|
|
3117
|
+
const { oldProps, props } = opts;
|
|
3118
|
+
const { aggregationDirty } = this.state;
|
|
3119
|
+
if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
|
|
3120
|
+
contoursChanged = true;
|
|
3121
|
+
this._updateThresholdData(opts.props);
|
|
3122
|
+
}
|
|
3123
|
+
if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
|
|
3124
|
+
this._generateContours();
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
renderLayers() {
|
|
3128
|
+
const { contourSegments, contourPolygons } = this.state.contourData;
|
|
3129
|
+
const LinesSubLayerClass = this.getSubLayerClass("lines", import_layers3.LineLayer);
|
|
3130
|
+
const BandsSubLayerClass = this.getSubLayerClass("bands", import_layers3.SolidPolygonLayer);
|
|
3131
|
+
const lineLayer = contourSegments && contourSegments.length > 0 && new LinesSubLayerClass(this.getSubLayerProps({
|
|
3132
|
+
id: "lines"
|
|
3133
|
+
}), {
|
|
3134
|
+
data: this.state.contourData.contourSegments,
|
|
3135
|
+
getSourcePosition: (d) => d.start,
|
|
3136
|
+
getTargetPosition: (d) => d.end,
|
|
3137
|
+
getColor: (d) => d.contour.color || DEFAULT_COLOR,
|
|
3138
|
+
getWidth: (d) => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH
|
|
3139
|
+
});
|
|
3140
|
+
const bandsLayer = contourPolygons && contourPolygons.length > 0 && new BandsSubLayerClass(this.getSubLayerProps({
|
|
3141
|
+
id: "bands"
|
|
3142
|
+
}), {
|
|
3143
|
+
data: this.state.contourData.contourPolygons,
|
|
3144
|
+
getPolygon: (d) => d.vertices,
|
|
3145
|
+
getFillColor: (d) => d.contour.color || DEFAULT_COLOR
|
|
3146
|
+
});
|
|
3147
|
+
return [lineLayer, bandsLayer];
|
|
3148
|
+
}
|
|
3149
|
+
updateAggregationState(opts) {
|
|
3150
|
+
const { props, oldProps } = opts;
|
|
3151
|
+
const { cellSize, coordinateSystem } = props;
|
|
3152
|
+
const { viewport } = this.context;
|
|
3153
|
+
const cellSizeChanged = oldProps.cellSize !== cellSize;
|
|
3154
|
+
let gpuAggregation = props.gpuAggregation;
|
|
3155
|
+
if (this.state.gpuAggregation !== props.gpuAggregation) {
|
|
3156
|
+
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
|
|
3157
|
+
import_core12.log.warn("GPU Grid Aggregation not supported, falling back to CPU")();
|
|
3158
|
+
gpuAggregation = false;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
|
|
3162
|
+
this.setState({
|
|
3163
|
+
gpuAggregation
|
|
3164
|
+
});
|
|
3165
|
+
const { dimensions } = this.state;
|
|
3166
|
+
const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME2);
|
|
3167
|
+
const { data, weights } = dimensions;
|
|
3168
|
+
let { boundingBox } = this.state;
|
|
3169
|
+
if (positionsChanged) {
|
|
3170
|
+
boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
|
|
3171
|
+
this.setState({ boundingBox });
|
|
3172
|
+
}
|
|
3173
|
+
if (positionsChanged || cellSizeChanged) {
|
|
3174
|
+
const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
|
|
3175
|
+
this.allocateResources(numRow, numCol);
|
|
3176
|
+
this.setState({
|
|
3177
|
+
gridOffset,
|
|
3178
|
+
boundingBox,
|
|
3179
|
+
translation,
|
|
3180
|
+
posOffset: translation.slice(),
|
|
3181
|
+
gridOrigin: [-1 * translation[0], -1 * translation[1]],
|
|
3182
|
+
width,
|
|
3183
|
+
height,
|
|
3184
|
+
numCol,
|
|
3185
|
+
numRow
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
const aggregationDataDirty = positionsChanged || gpuAggregationChanged || this.isAggregationDirty(opts, {
|
|
3189
|
+
dimension: data,
|
|
3190
|
+
compareAll: gpuAggregation
|
|
3191
|
+
});
|
|
3192
|
+
const aggregationWeightsDirty = this.isAggregationDirty(opts, {
|
|
3193
|
+
dimension: weights
|
|
3194
|
+
});
|
|
3195
|
+
if (aggregationWeightsDirty) {
|
|
3196
|
+
this._updateAccessors(opts);
|
|
3197
|
+
}
|
|
3198
|
+
if (aggregationDataDirty || aggregationWeightsDirty) {
|
|
3199
|
+
this._resetResults();
|
|
3200
|
+
}
|
|
3201
|
+
this.setState({
|
|
3202
|
+
aggregationDataDirty,
|
|
3203
|
+
aggregationWeightsDirty
|
|
3204
|
+
});
|
|
3205
|
+
}
|
|
3206
|
+
_updateAccessors(opts) {
|
|
3207
|
+
const { getWeight, aggregation, data } = opts.props;
|
|
3208
|
+
const { count } = this.state.weights;
|
|
3209
|
+
if (count) {
|
|
3210
|
+
count.getWeight = getWeight;
|
|
3211
|
+
count.operation = AGGREGATION_OPERATION[aggregation];
|
|
3212
|
+
}
|
|
3213
|
+
this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
|
|
3214
|
+
}
|
|
3215
|
+
_resetResults() {
|
|
3216
|
+
const { count } = this.state.weights;
|
|
3217
|
+
if (count) {
|
|
3218
|
+
count.aggregationData = null;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
_generateContours() {
|
|
3222
|
+
const { numCol, numRow, gridOrigin, gridOffset, thresholdData } = this.state;
|
|
3223
|
+
const { count } = this.state.weights;
|
|
3224
|
+
let { aggregationData } = count;
|
|
3225
|
+
if (!aggregationData) {
|
|
3226
|
+
aggregationData = count.aggregationBuffer.readSyncWebGL2();
|
|
3227
|
+
count.aggregationData = aggregationData;
|
|
3228
|
+
}
|
|
3229
|
+
const { cellWeights } = GPUGridAggregator.getCellData({ countsData: aggregationData });
|
|
3230
|
+
const contourData = generateContours({
|
|
3231
|
+
thresholdData,
|
|
3232
|
+
cellWeights,
|
|
3233
|
+
gridSize: [numCol, numRow],
|
|
3234
|
+
gridOrigin,
|
|
3235
|
+
cellSize: [gridOffset.xOffset, gridOffset.yOffset]
|
|
3236
|
+
});
|
|
3237
|
+
this.setState({ contourData });
|
|
3238
|
+
}
|
|
3239
|
+
_updateThresholdData(props) {
|
|
3240
|
+
const { contours, zOffset } = props;
|
|
3241
|
+
const count = contours.length;
|
|
3242
|
+
const thresholdData = new Array(count);
|
|
3243
|
+
for (let i = 0; i < count; i++) {
|
|
3244
|
+
const contour = contours[i];
|
|
3245
|
+
thresholdData[i] = {
|
|
3246
|
+
contour,
|
|
3247
|
+
zIndex: contour.zIndex || i,
|
|
3248
|
+
zOffset
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3251
|
+
this.setState({ thresholdData });
|
|
3252
|
+
}
|
|
3253
|
+
};
|
|
3254
|
+
var ContourLayer = _ContourLayer;
|
|
3255
|
+
(() => {
|
|
3256
|
+
_ContourLayer.layerName = "ContourLayer";
|
|
3257
|
+
})();
|
|
3258
|
+
(() => {
|
|
3259
|
+
_ContourLayer.defaultProps = defaultProps6;
|
|
3260
|
+
})();
|
|
3261
|
+
|
|
3262
|
+
// dist/grid-layer/grid-layer.js
|
|
3263
|
+
var import_core15 = require("@deck.gl/core");
|
|
3264
|
+
|
|
3265
|
+
// dist/gpu-grid-layer/gpu-grid-layer.js
|
|
3266
|
+
var import_constants9 = require("@luma.gl/constants");
|
|
3267
|
+
var import_core14 = require("@deck.gl/core");
|
|
3268
|
+
|
|
3269
|
+
// dist/gpu-grid-layer/gpu-grid-cell-layer.js
|
|
3270
|
+
var import_core13 = require("@deck.gl/core");
|
|
3271
|
+
var import_engine3 = require("@luma.gl/engine");
|
|
3272
|
+
var import_shadertools2 = require("@luma.gl/shadertools");
|
|
3273
|
+
var import_engine4 = require("@luma.gl/engine");
|
|
3274
|
+
var import_constants8 = require("@luma.gl/constants");
|
|
3275
|
+
|
|
3276
|
+
// dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js
|
|
3277
|
+
var gpu_grid_cell_layer_vertex_glsl_default = `#version 300 es
|
|
3278
|
+
#define SHADER_NAME gpu-grid-cell-layer-vertex-shader
|
|
3279
|
+
#define RANGE_COUNT 6
|
|
3280
|
+
|
|
3281
|
+
in vec3 positions;
|
|
3282
|
+
in vec3 normals;
|
|
3283
|
+
|
|
3284
|
+
in vec4 colors;
|
|
3285
|
+
in vec4 elevations;
|
|
3286
|
+
in vec3 instancePickingColors;
|
|
3287
|
+
|
|
3288
|
+
// Custom uniforms
|
|
3289
|
+
uniform vec2 offset;
|
|
3290
|
+
uniform bool extruded;
|
|
3291
|
+
uniform float cellSize;
|
|
3292
|
+
uniform float coverage;
|
|
3293
|
+
uniform float opacity;
|
|
3294
|
+
uniform float elevationScale;
|
|
3295
|
+
|
|
3296
|
+
uniform ivec2 gridSize;
|
|
3297
|
+
uniform vec2 gridOrigin;
|
|
3298
|
+
uniform vec2 gridOriginLow;
|
|
3299
|
+
uniform vec2 gridOffset;
|
|
3300
|
+
uniform vec2 gridOffsetLow;
|
|
3301
|
+
uniform vec4 colorRange[RANGE_COUNT];
|
|
3302
|
+
uniform vec2 elevationRange;
|
|
3303
|
+
|
|
3304
|
+
// Domain uniforms
|
|
3305
|
+
uniform vec2 colorDomain;
|
|
3306
|
+
uniform bool colorDomainValid;
|
|
3307
|
+
uniform vec2 elevationDomain;
|
|
3308
|
+
uniform bool elevationDomainValid;
|
|
3309
|
+
|
|
3310
|
+
layout(std140) uniform;
|
|
3311
|
+
uniform ColorData
|
|
3312
|
+
{
|
|
3313
|
+
vec4 maxMinCount;
|
|
3314
|
+
} colorData;
|
|
3315
|
+
uniform ElevationData
|
|
3316
|
+
{
|
|
3317
|
+
vec4 maxMinCount;
|
|
3318
|
+
} elevationData;
|
|
3319
|
+
|
|
3320
|
+
#define EPSILON 0.00001
|
|
3321
|
+
|
|
3322
|
+
// Result
|
|
3323
|
+
out vec4 vColor;
|
|
3324
|
+
|
|
3325
|
+
vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
|
|
3326
|
+
vec4 outColor = vec4(0., 0., 0., 0.);
|
|
3327
|
+
if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
|
|
3328
|
+
float domainRange = domain.y - domain.x;
|
|
3329
|
+
if (domainRange <= 0.) {
|
|
3330
|
+
outColor = colorRange[0];
|
|
3331
|
+
} else {
|
|
3332
|
+
float rangeCount = float(RANGE_COUNT);
|
|
3333
|
+
float rangeStep = domainRange / rangeCount;
|
|
3334
|
+
float idx = floor((value - domain.x) / rangeStep);
|
|
3335
|
+
idx = clamp(idx, 0., rangeCount - 1.);
|
|
3336
|
+
int intIdx = int(idx);
|
|
3337
|
+
outColor = colorRange[intIdx];
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
return outColor;
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
float linearScale(vec2 domain, vec2 range, float value) {
|
|
3344
|
+
if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
|
|
3345
|
+
return ((value - domain.x) / (domain.y - domain.x)) * (range.y - range.x) + range.x;
|
|
3346
|
+
}
|
|
3347
|
+
return -1.;
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
void main(void) {
|
|
3351
|
+
vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r);
|
|
3352
|
+
vec4 color = quantizeScale(clrDomain, colorRange, colors.r);
|
|
3353
|
+
|
|
3354
|
+
float elevation = 0.0;
|
|
3355
|
+
|
|
3356
|
+
if (extruded) {
|
|
3357
|
+
vec2 elvDomain = elevationDomainValid ? elevationDomain : vec2(elevationData.maxMinCount.a, elevationData.maxMinCount.r);
|
|
3358
|
+
elevation = linearScale(elvDomain, elevationRange, elevations.r);
|
|
3359
|
+
elevation = elevation * (positions.z + 1.0) / 2.0 * elevationScale;
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
// if aggregated color or elevation is 0 do not render
|
|
3363
|
+
float shouldRender = float(color.r > 0.0 && elevations.r >= 0.0);
|
|
3364
|
+
float dotRadius = cellSize / 2. * coverage * shouldRender;
|
|
3365
|
+
|
|
3366
|
+
int yIndex = (gl_InstanceID / gridSize[0]);
|
|
3367
|
+
int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
|
|
3368
|
+
|
|
3369
|
+
vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(float(xIndex), 0.));
|
|
3370
|
+
instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0]));
|
|
3371
|
+
vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(float(yIndex), 0.));
|
|
3372
|
+
instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1]));
|
|
3373
|
+
|
|
3374
|
+
vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation);
|
|
3375
|
+
vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0);
|
|
3376
|
+
geometry.worldPosition = centroidPosition;
|
|
3377
|
+
vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.);
|
|
3378
|
+
|
|
3379
|
+
// Set color to be rendered to picking fbo (also used to check for selection highlight).
|
|
3380
|
+
picking_setPickingColor(instancePickingColors);
|
|
3381
|
+
|
|
3382
|
+
gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
|
|
3383
|
+
|
|
3384
|
+
// Light calculations
|
|
3385
|
+
// Worldspace is the linear space after Mercator projection
|
|
3386
|
+
|
|
3387
|
+
vec3 normals_commonspace = project_normal(normals);
|
|
3388
|
+
|
|
3389
|
+
if (extruded) {
|
|
3390
|
+
vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, normals_commonspace);
|
|
3391
|
+
vColor = vec4(lightColor, color.a * opacity) / 255.;
|
|
3392
|
+
} else {
|
|
3393
|
+
vColor = vec4(color.rgb, color.a * opacity) / 255.;
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
`;
|
|
3397
|
+
|
|
3398
|
+
// dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js
|
|
3399
|
+
var gpu_grid_cell_layer_fragment_glsl_default = `#version 300 es
|
|
3400
|
+
#define SHADER_NAME gpu-grid-cell-layer-fragment-shader
|
|
3401
|
+
|
|
3402
|
+
precision highp float;
|
|
3403
|
+
|
|
3404
|
+
in vec4 vColor;
|
|
3405
|
+
|
|
3406
|
+
out vec4 fragColor;
|
|
3407
|
+
|
|
3408
|
+
void main(void) {
|
|
3409
|
+
fragColor = vColor;
|
|
3410
|
+
fragColor = picking_filterColor(fragColor);
|
|
3411
|
+
}
|
|
3412
|
+
`;
|
|
3413
|
+
|
|
3414
|
+
// dist/gpu-grid-layer/gpu-grid-cell-layer.js
|
|
3415
|
+
var COLOR_DATA_UBO_INDEX = 0;
|
|
3416
|
+
var ELEVATION_DATA_UBO_INDEX = 1;
|
|
3417
|
+
var defaultProps7 = {
|
|
3418
|
+
colorDomain: null,
|
|
3419
|
+
colorRange: defaultColorRange,
|
|
3420
|
+
elevationDomain: null,
|
|
3421
|
+
elevationRange: [0, 1e3],
|
|
3422
|
+
elevationScale: { type: "number", min: 0, value: 1 },
|
|
3423
|
+
gridSize: { type: "array", value: [1, 1] },
|
|
3424
|
+
gridOrigin: { type: "array", value: [0, 0] },
|
|
3425
|
+
gridOffset: { type: "array", value: [0, 0] },
|
|
3426
|
+
cellSize: { type: "number", min: 0, max: 1e3, value: 1e3 },
|
|
3427
|
+
offset: { type: "array", value: [1, 1] },
|
|
3428
|
+
coverage: { type: "number", min: 0, max: 1, value: 1 },
|
|
3429
|
+
extruded: true,
|
|
3430
|
+
material: true
|
|
3431
|
+
};
|
|
3432
|
+
var _GPUGridCellLayer = class extends import_core13.Layer {
|
|
3433
|
+
getShaders() {
|
|
3434
|
+
return super.getShaders({
|
|
3435
|
+
vs: gpu_grid_cell_layer_vertex_glsl_default,
|
|
3436
|
+
fs: gpu_grid_cell_layer_fragment_glsl_default,
|
|
3437
|
+
modules: [import_core13.project32, import_core13.gouraudLighting, import_core13.picking, import_shadertools2.fp64arithmetic]
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
initializeState() {
|
|
3441
|
+
const attributeManager = this.getAttributeManager();
|
|
3442
|
+
attributeManager.addInstanced({
|
|
3443
|
+
colors: {
|
|
3444
|
+
size: 4,
|
|
3445
|
+
noAlloc: true
|
|
3446
|
+
},
|
|
3447
|
+
elevations: {
|
|
3448
|
+
size: 4,
|
|
3449
|
+
noAlloc: true
|
|
3450
|
+
}
|
|
3451
|
+
});
|
|
3452
|
+
const model = this._getModel();
|
|
3453
|
+
this._setupUniformBuffer(model);
|
|
3454
|
+
this.setState({ model });
|
|
3455
|
+
}
|
|
3456
|
+
_getModel() {
|
|
3457
|
+
return new import_engine4.Model(this.context.device, {
|
|
3458
|
+
...this.getShaders(),
|
|
3459
|
+
id: this.props.id,
|
|
3460
|
+
geometry: new import_engine3.CubeGeometry(),
|
|
3461
|
+
isInstanced: true
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
draw({ uniforms }) {
|
|
3465
|
+
const { cellSize, offset, extruded, elevationScale, coverage, gridSize, gridOrigin, gridOffset, elevationRange, colorMaxMinBuffer, elevationMaxMinBuffer } = this.props;
|
|
3466
|
+
const model = this.state.model;
|
|
3467
|
+
const gridOriginLow = [(0, import_core13.fp64LowPart)(gridOrigin[0]), (0, import_core13.fp64LowPart)(gridOrigin[1])];
|
|
3468
|
+
const gridOffsetLow = [(0, import_core13.fp64LowPart)(gridOffset[0]), (0, import_core13.fp64LowPart)(gridOffset[1])];
|
|
3469
|
+
const domainUniforms = this.getDomainUniforms();
|
|
3470
|
+
const colorRange = colorRangeToFlatArray(this.props.colorRange);
|
|
3471
|
+
this.bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
|
|
3472
|
+
model.setUniforms(uniforms);
|
|
3473
|
+
model.setUniforms(domainUniforms);
|
|
3474
|
+
model.setUniforms({
|
|
3475
|
+
cellSize,
|
|
3476
|
+
offset,
|
|
3477
|
+
extruded,
|
|
3478
|
+
elevationScale,
|
|
3479
|
+
coverage,
|
|
3480
|
+
gridSize,
|
|
3481
|
+
gridOrigin,
|
|
3482
|
+
gridOriginLow,
|
|
3483
|
+
gridOffset,
|
|
3484
|
+
gridOffsetLow,
|
|
3485
|
+
colorRange,
|
|
3486
|
+
elevationRange
|
|
3487
|
+
});
|
|
3488
|
+
model.draw(this.context.renderPass);
|
|
3489
|
+
this.unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
|
|
3490
|
+
}
|
|
3491
|
+
bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
|
|
3492
|
+
colorMaxMinBuffer.bind({ target: import_constants8.GL.UNIFORM_BUFFER, index: COLOR_DATA_UBO_INDEX });
|
|
3493
|
+
elevationMaxMinBuffer.bind({ target: import_constants8.GL.UNIFORM_BUFFER, index: ELEVATION_DATA_UBO_INDEX });
|
|
3494
|
+
}
|
|
3495
|
+
unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
|
|
3496
|
+
colorMaxMinBuffer.unbind({ target: import_constants8.GL.UNIFORM_BUFFER, index: COLOR_DATA_UBO_INDEX });
|
|
3497
|
+
elevationMaxMinBuffer.unbind({ target: import_constants8.GL.UNIFORM_BUFFER, index: ELEVATION_DATA_UBO_INDEX });
|
|
3498
|
+
}
|
|
3499
|
+
getDomainUniforms() {
|
|
3500
|
+
const { colorDomain, elevationDomain } = this.props;
|
|
3501
|
+
const domainUniforms = {};
|
|
3502
|
+
if (colorDomain !== null) {
|
|
3503
|
+
domainUniforms.colorDomainValid = true;
|
|
3504
|
+
domainUniforms.colorDomain = colorDomain;
|
|
3505
|
+
} else {
|
|
3506
|
+
domainUniforms.colorDomainValid = false;
|
|
3507
|
+
}
|
|
3508
|
+
if (elevationDomain !== null) {
|
|
3509
|
+
domainUniforms.elevationDomainValid = true;
|
|
3510
|
+
domainUniforms.elevationDomain = elevationDomain;
|
|
3511
|
+
} else {
|
|
3512
|
+
domainUniforms.elevationDomainValid = false;
|
|
3513
|
+
}
|
|
3514
|
+
return domainUniforms;
|
|
3515
|
+
}
|
|
3516
|
+
_setupUniformBuffer(model) {
|
|
3517
|
+
const programHandle = model.pipeline.handle;
|
|
3518
|
+
const gl = this.context.gl;
|
|
3519
|
+
const colorIndex = gl.getUniformBlockIndex(programHandle, "ColorData");
|
|
3520
|
+
const elevationIndex = gl.getUniformBlockIndex(programHandle, "ElevationData");
|
|
3521
|
+
gl.uniformBlockBinding(programHandle, colorIndex, COLOR_DATA_UBO_INDEX);
|
|
3522
|
+
gl.uniformBlockBinding(programHandle, elevationIndex, ELEVATION_DATA_UBO_INDEX);
|
|
3523
|
+
}
|
|
3524
|
+
};
|
|
3525
|
+
var GPUGridCellLayer = _GPUGridCellLayer;
|
|
3526
|
+
(() => {
|
|
3527
|
+
_GPUGridCellLayer.layerName = "GPUGridCellLayer";
|
|
3528
|
+
})();
|
|
3529
|
+
(() => {
|
|
3530
|
+
_GPUGridCellLayer.defaultProps = defaultProps7;
|
|
3531
|
+
})();
|
|
3532
|
+
|
|
3533
|
+
// dist/gpu-grid-layer/gpu-grid-layer.js
|
|
3534
|
+
var defaultProps8 = {
|
|
3535
|
+
colorDomain: null,
|
|
3536
|
+
colorRange: defaultColorRange,
|
|
3537
|
+
getColorWeight: { type: "accessor", value: 1 },
|
|
3538
|
+
colorAggregation: "SUM",
|
|
3539
|
+
elevationDomain: null,
|
|
3540
|
+
elevationRange: [0, 1e3],
|
|
3541
|
+
getElevationWeight: { type: "accessor", value: 1 },
|
|
3542
|
+
elevationAggregation: "SUM",
|
|
3543
|
+
elevationScale: { type: "number", min: 0, value: 1 },
|
|
3544
|
+
cellSize: { type: "number", min: 1, max: 1e3, value: 1e3 },
|
|
3545
|
+
coverage: { type: "number", min: 0, max: 1, value: 1 },
|
|
3546
|
+
getPosition: { type: "accessor", value: (x) => x.position },
|
|
3547
|
+
extruded: false,
|
|
3548
|
+
material: true
|
|
3549
|
+
};
|
|
3550
|
+
var DIMENSIONS3 = {
|
|
3551
|
+
data: {
|
|
3552
|
+
props: ["cellSize", "colorAggregation", "elevationAggregation"]
|
|
3553
|
+
}
|
|
3554
|
+
};
|
|
3555
|
+
var POSITION_ATTRIBUTE_NAME3 = "positions";
|
|
3556
|
+
var _GPUGridLayer = class extends GridAggregationLayer {
|
|
3557
|
+
initializeState({ device }) {
|
|
3558
|
+
const isSupported = GPUGridAggregator.isSupported(device);
|
|
3559
|
+
if (!isSupported) {
|
|
3560
|
+
import_core14.log.error("GPUGridLayer is not supported on this browser, use GridLayer instead")();
|
|
3561
|
+
}
|
|
3562
|
+
super.initializeAggregationLayer({
|
|
3563
|
+
dimensions: DIMENSIONS3
|
|
3564
|
+
});
|
|
3565
|
+
this.setState({
|
|
3566
|
+
gpuAggregation: false,
|
|
3567
|
+
projectPoints: false,
|
|
3568
|
+
isSupported,
|
|
3569
|
+
weights: {
|
|
3570
|
+
color: {
|
|
3571
|
+
needMin: true,
|
|
3572
|
+
needMax: true,
|
|
3573
|
+
combineMaxMin: true,
|
|
3574
|
+
maxMinBuffer: device.createBuffer({
|
|
3575
|
+
byteLength: 4 * 4,
|
|
3576
|
+
accessor: { size: 4, type: import_constants9.GL.FLOAT, divisor: 1 }
|
|
3577
|
+
})
|
|
3578
|
+
},
|
|
3579
|
+
elevation: {
|
|
3580
|
+
needMin: true,
|
|
3581
|
+
needMax: true,
|
|
3582
|
+
combineMaxMin: true,
|
|
3583
|
+
maxMinBuffer: device.createBuffer({
|
|
3584
|
+
byteLength: 4 * 4,
|
|
3585
|
+
accessor: { size: 4, type: import_constants9.GL.FLOAT, divisor: 1 }
|
|
3586
|
+
})
|
|
3587
|
+
}
|
|
3588
|
+
},
|
|
3589
|
+
positionAttributeName: "positions"
|
|
3590
|
+
});
|
|
3591
|
+
const attributeManager = this.getAttributeManager();
|
|
3592
|
+
attributeManager.add({
|
|
3593
|
+
[POSITION_ATTRIBUTE_NAME3]: {
|
|
3594
|
+
size: 3,
|
|
3595
|
+
accessor: "getPosition",
|
|
3596
|
+
type: import_constants9.GL.DOUBLE,
|
|
3597
|
+
fp64: this.use64bitPositions()
|
|
3598
|
+
},
|
|
3599
|
+
color: { size: 3, accessor: "getColorWeight" },
|
|
3600
|
+
elevation: { size: 3, accessor: "getElevationWeight" }
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3603
|
+
updateState(opts) {
|
|
3604
|
+
if (this.state.isSupported === false) {
|
|
3605
|
+
return;
|
|
3606
|
+
}
|
|
3607
|
+
super.updateState(opts);
|
|
3608
|
+
const { aggregationDirty } = this.state;
|
|
3609
|
+
if (aggregationDirty) {
|
|
3610
|
+
this.setState({
|
|
3611
|
+
gridHash: null
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
getHashKeyForIndex(index) {
|
|
3616
|
+
const { numRow, numCol, boundingBox, gridOffset } = this.state;
|
|
3617
|
+
const gridSize = [numCol, numRow];
|
|
3618
|
+
const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
|
|
3619
|
+
const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
|
|
3620
|
+
const yIndex = Math.floor(index / gridSize[0]);
|
|
3621
|
+
const xIndex = index - yIndex * gridSize[0];
|
|
3622
|
+
const latIdx = Math.floor((yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]);
|
|
3623
|
+
const lonIdx = Math.floor((xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]);
|
|
3624
|
+
return `${latIdx}-${lonIdx}`;
|
|
3625
|
+
}
|
|
3626
|
+
getPositionForIndex(index) {
|
|
3627
|
+
const { numRow, numCol, boundingBox, gridOffset } = this.state;
|
|
3628
|
+
const gridSize = [numCol, numRow];
|
|
3629
|
+
const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
|
|
3630
|
+
const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
|
|
3631
|
+
const yIndex = Math.floor(index / gridSize[0]);
|
|
3632
|
+
const xIndex = index - yIndex * gridSize[0];
|
|
3633
|
+
const yPos = yIndex * cellSize[1] + gridOrigin[1];
|
|
3634
|
+
const xPos = xIndex * cellSize[0] + gridOrigin[0];
|
|
3635
|
+
return [xPos, yPos];
|
|
3636
|
+
}
|
|
3637
|
+
getPickingInfo({ info, mode }) {
|
|
3638
|
+
const { index } = info;
|
|
3639
|
+
let object = null;
|
|
3640
|
+
if (index >= 0) {
|
|
3641
|
+
const gpuGridAggregator = this.state.gpuGridAggregator;
|
|
3642
|
+
const position = this.getPositionForIndex(index);
|
|
3643
|
+
const colorInfo = GPUGridAggregator.getAggregationData({
|
|
3644
|
+
pixelIndex: index,
|
|
3645
|
+
...gpuGridAggregator.getData("color")
|
|
3646
|
+
});
|
|
3647
|
+
const elevationInfo = GPUGridAggregator.getAggregationData({
|
|
3648
|
+
pixelIndex: index,
|
|
3649
|
+
...gpuGridAggregator.getData("elevation")
|
|
3650
|
+
});
|
|
3651
|
+
object = {
|
|
3652
|
+
colorValue: colorInfo.cellWeight,
|
|
3653
|
+
elevationValue: elevationInfo.cellWeight,
|
|
3654
|
+
count: colorInfo.cellCount || elevationInfo.cellCount,
|
|
3655
|
+
position,
|
|
3656
|
+
totalCount: colorInfo.totalCount || elevationInfo.totalCount
|
|
3657
|
+
};
|
|
3658
|
+
if (mode !== "hover") {
|
|
3659
|
+
const { props } = this;
|
|
3660
|
+
let { gridHash } = this.state;
|
|
3661
|
+
if (!gridHash) {
|
|
3662
|
+
const { gridOffset, translation, boundingBox } = this.state;
|
|
3663
|
+
const { viewport } = this.context;
|
|
3664
|
+
const attributes = this.getAttributes();
|
|
3665
|
+
const cpuAggregation = pointToDensityGridDataCPU(props, {
|
|
3666
|
+
gridOffset,
|
|
3667
|
+
attributes,
|
|
3668
|
+
viewport,
|
|
3669
|
+
translation,
|
|
3670
|
+
boundingBox
|
|
3671
|
+
});
|
|
3672
|
+
gridHash = cpuAggregation.gridHash;
|
|
3673
|
+
this.setState({ gridHash });
|
|
3674
|
+
}
|
|
3675
|
+
const key = this.getHashKeyForIndex(index);
|
|
3676
|
+
const cpuAggregationData = gridHash[key];
|
|
3677
|
+
Object.assign(object, cpuAggregationData);
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
info.picked = Boolean(object);
|
|
3681
|
+
info.object = object;
|
|
3682
|
+
return info;
|
|
3683
|
+
}
|
|
3684
|
+
renderLayers() {
|
|
3685
|
+
if (!this.state.isSupported) {
|
|
3686
|
+
return null;
|
|
3687
|
+
}
|
|
3688
|
+
const { elevationScale, extruded, cellSize: cellSizeMeters, coverage, material, elevationRange, colorDomain, elevationDomain } = this.props;
|
|
3689
|
+
const { weights, numRow, numCol, gridOrigin, gridOffset } = this.state;
|
|
3690
|
+
const { color, elevation } = weights;
|
|
3691
|
+
const colorRange = colorRangeToFlatArray(this.props.colorRange);
|
|
3692
|
+
const SubLayerClass = this.getSubLayerClass("gpu-grid-cell", GPUGridCellLayer);
|
|
3693
|
+
return new SubLayerClass({
|
|
3694
|
+
gridSize: [numCol, numRow],
|
|
3695
|
+
gridOrigin,
|
|
3696
|
+
gridOffset: [gridOffset.xOffset, gridOffset.yOffset],
|
|
3697
|
+
colorRange,
|
|
3698
|
+
elevationRange,
|
|
3699
|
+
colorDomain,
|
|
3700
|
+
elevationDomain,
|
|
3701
|
+
cellSize: cellSizeMeters,
|
|
3702
|
+
coverage,
|
|
3703
|
+
material,
|
|
3704
|
+
elevationScale,
|
|
3705
|
+
extruded
|
|
3706
|
+
}, this.getSubLayerProps({
|
|
3707
|
+
id: "gpu-grid-cell"
|
|
3708
|
+
}), {
|
|
3709
|
+
data: {
|
|
3710
|
+
attributes: {
|
|
3711
|
+
colors: color.aggregationBuffer,
|
|
3712
|
+
elevations: elevation.aggregationBuffer
|
|
3713
|
+
}
|
|
3714
|
+
},
|
|
3715
|
+
colorMaxMinBuffer: color.maxMinBuffer,
|
|
3716
|
+
elevationMaxMinBuffer: elevation.maxMinBuffer,
|
|
3717
|
+
numInstances: numCol * numRow
|
|
3718
|
+
});
|
|
3719
|
+
}
|
|
3720
|
+
finalizeState(context) {
|
|
3721
|
+
const { color, elevation } = this.state.weights;
|
|
3722
|
+
[color, elevation].forEach((weight) => {
|
|
3723
|
+
const { aggregationBuffer, maxMinBuffer } = weight;
|
|
3724
|
+
maxMinBuffer == null ? void 0 : maxMinBuffer.destroy();
|
|
3725
|
+
aggregationBuffer == null ? void 0 : aggregationBuffer.destroy();
|
|
3726
|
+
});
|
|
3727
|
+
super.finalizeState(context);
|
|
3728
|
+
}
|
|
3729
|
+
updateAggregationState(opts) {
|
|
3730
|
+
const { props, oldProps } = opts;
|
|
3731
|
+
const { cellSize, coordinateSystem } = props;
|
|
3732
|
+
const { viewport } = this.context;
|
|
3733
|
+
const cellSizeChanged = oldProps.cellSize !== cellSize;
|
|
3734
|
+
const { dimensions } = this.state;
|
|
3735
|
+
const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME3);
|
|
3736
|
+
const attributesChanged = positionsChanged || this.isAttributeChanged();
|
|
3737
|
+
let { boundingBox } = this.state;
|
|
3738
|
+
if (positionsChanged) {
|
|
3739
|
+
boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
|
|
3740
|
+
this.setState({ boundingBox });
|
|
3741
|
+
}
|
|
3742
|
+
if (positionsChanged || cellSizeChanged) {
|
|
3743
|
+
const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
|
|
3744
|
+
this.allocateResources(numRow, numCol);
|
|
3745
|
+
this.setState({
|
|
3746
|
+
gridOffset,
|
|
3747
|
+
translation,
|
|
3748
|
+
gridOrigin: [-1 * translation[0], -1 * translation[1]],
|
|
3749
|
+
width,
|
|
3750
|
+
height,
|
|
3751
|
+
numCol,
|
|
3752
|
+
numRow
|
|
3753
|
+
});
|
|
3754
|
+
}
|
|
3755
|
+
const aggregationDataDirty = attributesChanged || this.isAggregationDirty(opts, {
|
|
3756
|
+
dimension: dimensions.data,
|
|
3757
|
+
compareAll: true
|
|
3758
|
+
});
|
|
3759
|
+
if (aggregationDataDirty) {
|
|
3760
|
+
this._updateAccessors(opts);
|
|
3761
|
+
}
|
|
3762
|
+
this.setState({
|
|
3763
|
+
aggregationDataDirty
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3766
|
+
_updateAccessors(opts) {
|
|
3767
|
+
const { colorAggregation, elevationAggregation } = opts.props;
|
|
3768
|
+
const { color, elevation } = this.state.weights;
|
|
3769
|
+
color.operation = AGGREGATION_OPERATION[colorAggregation];
|
|
3770
|
+
elevation.operation = AGGREGATION_OPERATION[elevationAggregation];
|
|
3771
|
+
}
|
|
3772
|
+
};
|
|
3773
|
+
var GPUGridLayer = _GPUGridLayer;
|
|
3774
|
+
(() => {
|
|
3775
|
+
_GPUGridLayer.layerName = "GPUGridLayer";
|
|
3776
|
+
})();
|
|
3777
|
+
(() => {
|
|
3778
|
+
_GPUGridLayer.defaultProps = defaultProps8;
|
|
3779
|
+
})();
|
|
3780
|
+
|
|
3781
|
+
// dist/grid-layer/grid-layer.js
|
|
3782
|
+
var defaultProps9 = {
|
|
3783
|
+
...GPUGridLayer.defaultProps,
|
|
3784
|
+
...CPUGridLayer.defaultProps,
|
|
3785
|
+
gpuAggregation: false
|
|
3786
|
+
};
|
|
3787
|
+
var _GridLayer = class extends import_core15.CompositeLayer {
|
|
3788
|
+
initializeState() {
|
|
3789
|
+
this.state = {
|
|
3790
|
+
useGPUAggregation: false
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
updateState({ props }) {
|
|
3794
|
+
this.setState({
|
|
3795
|
+
useGPUAggregation: false
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
renderLayers() {
|
|
3799
|
+
const { data, updateTriggers } = this.props;
|
|
3800
|
+
const id = this.state.useGPUAggregation ? "GPU" : "CPU";
|
|
3801
|
+
const LayerType = this.state.useGPUAggregation ? this.getSubLayerClass("GPU", GPUGridLayer) : this.getSubLayerClass("CPU", CPUGridLayer);
|
|
3802
|
+
return new LayerType(this.props, this.getSubLayerProps({
|
|
3803
|
+
id,
|
|
3804
|
+
updateTriggers
|
|
3805
|
+
}), {
|
|
3806
|
+
data
|
|
3807
|
+
});
|
|
3808
|
+
}
|
|
3809
|
+
canUseGPUAggregation(props) {
|
|
3810
|
+
const { gpuAggregation, lowerPercentile, upperPercentile, getColorValue, getElevationValue, colorScaleType } = props;
|
|
3811
|
+
if (!gpuAggregation) {
|
|
3812
|
+
return false;
|
|
3813
|
+
}
|
|
3814
|
+
if (!GPUGridAggregator.isSupported(this.context.device)) {
|
|
3815
|
+
return false;
|
|
3816
|
+
}
|
|
3817
|
+
if (lowerPercentile !== 0 || upperPercentile !== 100) {
|
|
3818
|
+
return false;
|
|
3819
|
+
}
|
|
3820
|
+
if (getColorValue !== null || getElevationValue !== null) {
|
|
3821
|
+
return false;
|
|
3822
|
+
}
|
|
3823
|
+
if (colorScaleType === "quantile" || colorScaleType === "ordinal") {
|
|
3824
|
+
return false;
|
|
3825
|
+
}
|
|
3826
|
+
return true;
|
|
3827
|
+
}
|
|
3828
|
+
};
|
|
3829
|
+
var GridLayer = _GridLayer;
|
|
3830
|
+
(() => {
|
|
3831
|
+
_GridLayer.layerName = "GridLayer";
|
|
3832
|
+
})();
|
|
3833
|
+
(() => {
|
|
3834
|
+
_GridLayer.defaultProps = defaultProps9;
|
|
3835
|
+
})();
|
|
3836
|
+
|
|
3837
|
+
// dist/heatmap-layer/heatmap-layer-utils.js
|
|
3838
|
+
function getBounds(points) {
|
|
3839
|
+
const x = points.map((p) => p[0]);
|
|
3840
|
+
const y = points.map((p) => p[1]);
|
|
3841
|
+
const xMin = Math.min.apply(null, x);
|
|
3842
|
+
const xMax = Math.max.apply(null, x);
|
|
3843
|
+
const yMin = Math.min.apply(null, y);
|
|
3844
|
+
const yMax = Math.max.apply(null, y);
|
|
3845
|
+
return [xMin, yMin, xMax, yMax];
|
|
3846
|
+
}
|
|
3847
|
+
function boundsContain(currentBounds, targetBounds) {
|
|
3848
|
+
if (targetBounds[0] >= currentBounds[0] && targetBounds[2] <= currentBounds[2] && targetBounds[1] >= currentBounds[1] && targetBounds[3] <= currentBounds[3]) {
|
|
3849
|
+
return true;
|
|
3850
|
+
}
|
|
3851
|
+
return false;
|
|
3852
|
+
}
|
|
3853
|
+
var scratchArray = new Float32Array(12);
|
|
3854
|
+
function packVertices(points, dimensions = 2) {
|
|
3855
|
+
let index = 0;
|
|
3856
|
+
for (const point of points) {
|
|
3857
|
+
for (let i = 0; i < dimensions; i++) {
|
|
3858
|
+
scratchArray[index++] = point[i] || 0;
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
return scratchArray;
|
|
3862
|
+
}
|
|
3863
|
+
function scaleToAspectRatio(boundingBox, width, height) {
|
|
3864
|
+
const [xMin, yMin, xMax, yMax] = boundingBox;
|
|
3865
|
+
const currentWidth = xMax - xMin;
|
|
3866
|
+
const currentHeight = yMax - yMin;
|
|
3867
|
+
let newWidth = currentWidth;
|
|
3868
|
+
let newHeight = currentHeight;
|
|
3869
|
+
if (currentWidth / currentHeight < width / height) {
|
|
3870
|
+
newWidth = width / height * currentHeight;
|
|
3871
|
+
} else {
|
|
3872
|
+
newHeight = height / width * currentWidth;
|
|
3873
|
+
}
|
|
3874
|
+
if (newWidth < width) {
|
|
3875
|
+
newWidth = width;
|
|
3876
|
+
newHeight = height;
|
|
3877
|
+
}
|
|
3878
|
+
const xCenter = (xMax + xMin) / 2;
|
|
3879
|
+
const yCenter = (yMax + yMin) / 2;
|
|
3880
|
+
return [
|
|
3881
|
+
xCenter - newWidth / 2,
|
|
3882
|
+
yCenter - newHeight / 2,
|
|
3883
|
+
xCenter + newWidth / 2,
|
|
3884
|
+
yCenter + newHeight / 2
|
|
3885
|
+
];
|
|
3886
|
+
}
|
|
3887
|
+
function getTextureCoordinates(point, bounds) {
|
|
3888
|
+
const [xMin, yMin, xMax, yMax] = bounds;
|
|
3889
|
+
return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3892
|
+
// dist/heatmap-layer/heatmap-layer.js
|
|
3893
|
+
var import_constants10 = require("@luma.gl/constants");
|
|
3894
|
+
var import_engine6 = require("@luma.gl/engine");
|
|
3895
|
+
var import_core17 = require("@deck.gl/core");
|
|
3896
|
+
|
|
3897
|
+
// dist/heatmap-layer/triangle-layer.js
|
|
3898
|
+
var import_engine5 = require("@luma.gl/engine");
|
|
3899
|
+
var import_core16 = require("@deck.gl/core");
|
|
3900
|
+
|
|
3901
|
+
// dist/heatmap-layer/triangle-layer-vertex.glsl.js
|
|
3902
|
+
var triangle_layer_vertex_glsl_default = `#version 300 es
|
|
3903
|
+
#define SHADER_NAME heatp-map-layer-vertex-shader
|
|
3904
|
+
|
|
3905
|
+
uniform sampler2D maxTexture;
|
|
3906
|
+
uniform float intensity;
|
|
3907
|
+
uniform vec2 colorDomain;
|
|
3908
|
+
uniform float threshold;
|
|
3909
|
+
uniform float aggregationMode;
|
|
3910
|
+
|
|
3911
|
+
in vec3 positions;
|
|
3912
|
+
in vec2 texCoords;
|
|
3913
|
+
|
|
3914
|
+
out vec2 vTexCoords;
|
|
3915
|
+
out float vIntensityMin;
|
|
3916
|
+
out float vIntensityMax;
|
|
3917
|
+
|
|
3918
|
+
void main(void) {
|
|
3919
|
+
gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
|
|
3920
|
+
vTexCoords = texCoords;
|
|
3921
|
+
vec4 maxTexture = texture(maxTexture, vec2(0.5));
|
|
3922
|
+
float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
|
|
3923
|
+
float minValue = maxValue * threshold;
|
|
3924
|
+
if (colorDomain[1] > 0.) {
|
|
3925
|
+
// if user specified custom domain use it.
|
|
3926
|
+
maxValue = colorDomain[1];
|
|
3927
|
+
minValue = colorDomain[0];
|
|
3928
|
+
}
|
|
3929
|
+
vIntensityMax = intensity / maxValue;
|
|
3930
|
+
vIntensityMin = intensity / minValue;
|
|
3931
|
+
}
|
|
3932
|
+
`;
|
|
3933
|
+
|
|
3934
|
+
// dist/heatmap-layer/triangle-layer-fragment.glsl.js
|
|
3935
|
+
var triangle_layer_fragment_glsl_default = `#version 300 es
|
|
3936
|
+
#define SHADER_NAME triangle-layer-fragment-shader
|
|
3937
|
+
|
|
3938
|
+
precision highp float;
|
|
3939
|
+
|
|
3940
|
+
uniform float opacity;
|
|
3941
|
+
uniform sampler2D weightsTexture;
|
|
3942
|
+
uniform sampler2D colorTexture;
|
|
3943
|
+
uniform float aggregationMode;
|
|
3944
|
+
|
|
3945
|
+
in vec2 vTexCoords;
|
|
3946
|
+
in float vIntensityMin;
|
|
3947
|
+
in float vIntensityMax;
|
|
3948
|
+
|
|
3949
|
+
out vec4 fragColor;
|
|
3950
|
+
|
|
3951
|
+
vec4 getLinearColor(float value) {
|
|
3952
|
+
float factor = clamp(value * vIntensityMax, 0., 1.);
|
|
3953
|
+
vec4 color = texture(colorTexture, vec2(factor, 0.5));
|
|
3954
|
+
color.a *= min(value * vIntensityMin, 1.0);
|
|
3955
|
+
return color;
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
void main(void) {
|
|
3959
|
+
vec4 weights = texture(weightsTexture, vTexCoords);
|
|
3960
|
+
float weight = weights.r;
|
|
3961
|
+
|
|
3962
|
+
if (aggregationMode > 0.5) {
|
|
3963
|
+
weight /= max(1.0, weights.a);
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
// discard pixels with 0 weight.
|
|
3967
|
+
if (weight <= 0.) {
|
|
3968
|
+
discard;
|
|
3969
|
+
}
|
|
3970
|
+
|
|
3971
|
+
vec4 linearColor = getLinearColor(weight);
|
|
3972
|
+
linearColor.a *= opacity;
|
|
3973
|
+
fragColor = linearColor;
|
|
3974
|
+
}
|
|
3975
|
+
`;
|
|
3976
|
+
|
|
3977
|
+
// dist/heatmap-layer/triangle-layer.js
|
|
3978
|
+
var _TriangleLayer = class extends import_core16.Layer {
|
|
3979
|
+
getShaders() {
|
|
3980
|
+
return { vs: triangle_layer_vertex_glsl_default, fs: triangle_layer_fragment_glsl_default, modules: [import_core16.project32] };
|
|
3981
|
+
}
|
|
3982
|
+
initializeState({ device }) {
|
|
3983
|
+
this.setState({ model: this._getModel(device) });
|
|
3984
|
+
}
|
|
3985
|
+
_getModel(device) {
|
|
3986
|
+
const { vertexCount, data, weightsTexture, maxTexture, colorTexture } = this.props;
|
|
3987
|
+
return new import_engine5.Model(device, {
|
|
3988
|
+
...this.getShaders(),
|
|
3989
|
+
id: this.props.id,
|
|
3990
|
+
bindings: { weightsTexture, maxTexture, colorTexture },
|
|
3991
|
+
attributes: data.attributes,
|
|
3992
|
+
bufferLayout: [
|
|
3993
|
+
{ name: "positions", format: "float32x3" },
|
|
3994
|
+
{ name: "texCoords", format: "float32x2" }
|
|
3995
|
+
],
|
|
3996
|
+
topology: "triangle-fan-webgl",
|
|
3997
|
+
vertexCount
|
|
3998
|
+
});
|
|
3999
|
+
}
|
|
4000
|
+
draw({ uniforms }) {
|
|
4001
|
+
const { model } = this.state;
|
|
4002
|
+
const { intensity, threshold: threshold2, aggregationMode, colorDomain } = this.props;
|
|
4003
|
+
model.setUniforms({
|
|
4004
|
+
...uniforms,
|
|
4005
|
+
intensity,
|
|
4006
|
+
threshold: threshold2,
|
|
4007
|
+
aggregationMode,
|
|
4008
|
+
colorDomain
|
|
4009
|
+
});
|
|
4010
|
+
model.draw(this.context.renderPass);
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
4013
|
+
var TriangleLayer = _TriangleLayer;
|
|
4014
|
+
(() => {
|
|
4015
|
+
_TriangleLayer.layerName = "TriangleLayer";
|
|
4016
|
+
})();
|
|
4017
|
+
|
|
4018
|
+
// dist/heatmap-layer/weights-vs.glsl.js
|
|
4019
|
+
var weights_vs_glsl_default = `#version 300 es
|
|
4020
|
+
in vec3 positions;
|
|
4021
|
+
in vec3 positions64Low;
|
|
4022
|
+
in float weights;
|
|
4023
|
+
out vec4 weightsTexture;
|
|
4024
|
+
uniform float radiusPixels;
|
|
4025
|
+
uniform float textureWidth;
|
|
4026
|
+
uniform vec4 commonBounds;
|
|
4027
|
+
uniform float weightsScale;
|
|
4028
|
+
|
|
4029
|
+
void main()
|
|
4030
|
+
{
|
|
4031
|
+
weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);
|
|
4032
|
+
|
|
4033
|
+
float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);
|
|
4034
|
+
gl_PointSize = radiusTexels * 2.;
|
|
4035
|
+
|
|
4036
|
+
vec3 commonPosition = project_position(positions, positions64Low);
|
|
4037
|
+
|
|
4038
|
+
// // map xy from commonBounds to [-1, 1]
|
|
4039
|
+
gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;
|
|
4040
|
+
gl_Position.xy = (gl_Position.xy * 2.) - (1.);
|
|
4041
|
+
gl_Position.w = 1.0;
|
|
4042
|
+
}
|
|
4043
|
+
`;
|
|
4044
|
+
|
|
4045
|
+
// dist/heatmap-layer/weights-fs.glsl.js
|
|
4046
|
+
var weights_fs_glsl_default = `#version 300 es
|
|
4047
|
+
in vec4 weightsTexture;
|
|
4048
|
+
out vec4 fragColor;
|
|
4049
|
+
// Epanechnikov function, keeping for reference
|
|
4050
|
+
// float epanechnikovKDE(float u) {
|
|
4051
|
+
// return 0.75 * (1.0 - u * u);
|
|
4052
|
+
// }
|
|
4053
|
+
float gaussianKDE(float u){
|
|
4054
|
+
return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);
|
|
4055
|
+
}
|
|
4056
|
+
void main()
|
|
4057
|
+
{
|
|
4058
|
+
float dist = length(gl_PointCoord - vec2(0.5, 0.5));
|
|
4059
|
+
if (dist > 0.5) {
|
|
4060
|
+
discard;
|
|
4061
|
+
}
|
|
4062
|
+
fragColor = weightsTexture * gaussianKDE(2. * dist);
|
|
4063
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
4064
|
+
}
|
|
4065
|
+
`;
|
|
4066
|
+
|
|
4067
|
+
// dist/heatmap-layer/max-vs.glsl.js
|
|
4068
|
+
var max_vs_glsl_default = `#version 300 es
|
|
4069
|
+
uniform sampler2D inTexture;
|
|
4070
|
+
uniform float textureSize;
|
|
4071
|
+
out vec4 outTexture;
|
|
4072
|
+
|
|
4073
|
+
void main()
|
|
4074
|
+
{
|
|
4075
|
+
// Sample every pixel in texture
|
|
4076
|
+
int yIndex = gl_VertexID / int(textureSize);
|
|
4077
|
+
int xIndex = gl_VertexID - (yIndex * int(textureSize));
|
|
4078
|
+
vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;
|
|
4079
|
+
outTexture = texture(inTexture, uv);
|
|
4080
|
+
|
|
4081
|
+
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
|
4082
|
+
// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)
|
|
4083
|
+
gl_PointSize = 1.0;
|
|
4084
|
+
}
|
|
4085
|
+
`;
|
|
4086
|
+
|
|
4087
|
+
// dist/heatmap-layer/max-fs.glsl.js
|
|
4088
|
+
var max_fs_glsl_default = `#version 300 es
|
|
4089
|
+
in vec4 outTexture;
|
|
4090
|
+
out vec4 fragColor;
|
|
4091
|
+
void main() {
|
|
4092
|
+
fragColor = outTexture;
|
|
4093
|
+
fragColor.g = outTexture.r / max(1.0, outTexture.a);
|
|
4094
|
+
}
|
|
4095
|
+
`;
|
|
4096
|
+
|
|
4097
|
+
// dist/heatmap-layer/heatmap-layer.js
|
|
4098
|
+
var RESOLUTION = 2;
|
|
4099
|
+
var TEXTURE_PROPS = {
|
|
4100
|
+
format: "rgba8unorm",
|
|
4101
|
+
mipmaps: false,
|
|
4102
|
+
sampler: {
|
|
4103
|
+
minFilter: "linear",
|
|
4104
|
+
magFilter: "linear",
|
|
4105
|
+
addressModeU: "clamp-to-edge",
|
|
4106
|
+
addressModeV: "clamp-to-edge"
|
|
4107
|
+
}
|
|
4108
|
+
};
|
|
4109
|
+
var DEFAULT_COLOR_DOMAIN = [0, 0];
|
|
4110
|
+
var AGGREGATION_MODE = {
|
|
4111
|
+
SUM: 0,
|
|
4112
|
+
MEAN: 1
|
|
4113
|
+
};
|
|
4114
|
+
var defaultProps10 = {
|
|
4115
|
+
getPosition: { type: "accessor", value: (x) => x.position },
|
|
4116
|
+
getWeight: { type: "accessor", value: 1 },
|
|
4117
|
+
intensity: { type: "number", min: 0, value: 1 },
|
|
4118
|
+
radiusPixels: { type: "number", min: 1, max: 100, value: 50 },
|
|
4119
|
+
colorRange: defaultColorRange,
|
|
4120
|
+
threshold: { type: "number", min: 0, max: 1, value: 0.05 },
|
|
4121
|
+
colorDomain: { type: "array", value: null, optional: true },
|
|
4122
|
+
aggregation: "SUM",
|
|
4123
|
+
weightsTextureSize: { type: "number", min: 128, max: 2048, value: 2048 },
|
|
4124
|
+
debounceTimeout: { type: "number", min: 0, max: 1e3, value: 500 }
|
|
4125
|
+
};
|
|
4126
|
+
var REQUIRED_FEATURES2 = [
|
|
4127
|
+
"blend-minmax-webgl1",
|
|
4128
|
+
"texture-formats-float32-webgl1"
|
|
4129
|
+
];
|
|
4130
|
+
var FLOAT_TARGET_FEATURES = [
|
|
4131
|
+
"texture-renderable-float32-webgl",
|
|
4132
|
+
"texture-blend-float-webgl1"
|
|
4133
|
+
];
|
|
4134
|
+
var DIMENSIONS4 = {
|
|
4135
|
+
data: {
|
|
4136
|
+
props: ["radiusPixels"]
|
|
4137
|
+
}
|
|
4138
|
+
};
|
|
4139
|
+
var _HeatmapLayer = class extends AggregationLayer {
|
|
4140
|
+
initializeState() {
|
|
4141
|
+
if (!REQUIRED_FEATURES2.every((feature) => this.context.device.features.has(feature))) {
|
|
4142
|
+
this.setState({ supported: false });
|
|
4143
|
+
import_core17.log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
|
|
4144
|
+
return;
|
|
4145
|
+
}
|
|
4146
|
+
super.initializeAggregationLayer(DIMENSIONS4);
|
|
4147
|
+
this.setState({ supported: true, colorDomain: DEFAULT_COLOR_DOMAIN });
|
|
4148
|
+
this._setupTextureParams();
|
|
4149
|
+
this._setupAttributes();
|
|
4150
|
+
this._setupResources();
|
|
4151
|
+
}
|
|
4152
|
+
shouldUpdateState({ changeFlags }) {
|
|
4153
|
+
return changeFlags.somethingChanged;
|
|
4154
|
+
}
|
|
4155
|
+
updateState(opts) {
|
|
4156
|
+
if (!this.state.supported) {
|
|
4157
|
+
return;
|
|
4158
|
+
}
|
|
4159
|
+
super.updateState(opts);
|
|
4160
|
+
this._updateHeatmapState(opts);
|
|
4161
|
+
}
|
|
4162
|
+
_updateHeatmapState(opts) {
|
|
4163
|
+
const { props, oldProps } = opts;
|
|
4164
|
+
const changeFlags = this._getChangeFlags(opts);
|
|
4165
|
+
if (changeFlags.dataChanged || changeFlags.viewportChanged) {
|
|
4166
|
+
changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
|
|
4167
|
+
this._updateTextureRenderingBounds();
|
|
4168
|
+
}
|
|
4169
|
+
if (changeFlags.dataChanged || changeFlags.boundsChanged) {
|
|
4170
|
+
clearTimeout(this.state.updateTimer);
|
|
4171
|
+
this.setState({ isWeightMapDirty: true });
|
|
4172
|
+
} else if (changeFlags.viewportZoomChanged) {
|
|
4173
|
+
this._debouncedUpdateWeightmap();
|
|
4174
|
+
}
|
|
4175
|
+
if (props.colorRange !== oldProps.colorRange) {
|
|
4176
|
+
this._updateColorTexture(opts);
|
|
4177
|
+
}
|
|
4178
|
+
if (this.state.isWeightMapDirty) {
|
|
4179
|
+
this._updateWeightmap();
|
|
4180
|
+
}
|
|
4181
|
+
this.setState({ zoom: opts.context.viewport.zoom });
|
|
4182
|
+
}
|
|
4183
|
+
renderLayers() {
|
|
4184
|
+
if (!this.state.supported) {
|
|
4185
|
+
return [];
|
|
4186
|
+
}
|
|
4187
|
+
const { weightsTexture, triPositionBuffer, triTexCoordBuffer, maxWeightsTexture, colorTexture, colorDomain } = this.state;
|
|
4188
|
+
const { updateTriggers, intensity, threshold: threshold2, aggregation } = this.props;
|
|
4189
|
+
const TriangleLayerClass = this.getSubLayerClass("triangle", TriangleLayer);
|
|
4190
|
+
return new TriangleLayerClass(this.getSubLayerProps({
|
|
4191
|
+
id: "triangle-layer",
|
|
4192
|
+
updateTriggers
|
|
4193
|
+
}), {
|
|
4194
|
+
coordinateSystem: import_core17.COORDINATE_SYSTEM.DEFAULT,
|
|
4195
|
+
data: {
|
|
4196
|
+
attributes: {
|
|
4197
|
+
positions: triPositionBuffer,
|
|
4198
|
+
texCoords: triTexCoordBuffer
|
|
4199
|
+
}
|
|
4200
|
+
},
|
|
4201
|
+
vertexCount: 4,
|
|
4202
|
+
maxTexture: maxWeightsTexture,
|
|
4203
|
+
colorTexture,
|
|
4204
|
+
aggregationMode: AGGREGATION_MODE[aggregation] || 0,
|
|
4205
|
+
weightsTexture,
|
|
4206
|
+
intensity,
|
|
4207
|
+
threshold: threshold2,
|
|
4208
|
+
colorDomain
|
|
4209
|
+
});
|
|
4210
|
+
}
|
|
4211
|
+
finalizeState(context) {
|
|
4212
|
+
super.finalizeState(context);
|
|
4213
|
+
const { weightsTransform, weightsTexture, maxWeightTransform, maxWeightsTexture, triPositionBuffer, triTexCoordBuffer, colorTexture, updateTimer } = this.state;
|
|
4214
|
+
weightsTransform == null ? void 0 : weightsTransform.destroy();
|
|
4215
|
+
weightsTexture == null ? void 0 : weightsTexture.destroy();
|
|
4216
|
+
maxWeightTransform == null ? void 0 : maxWeightTransform.destroy();
|
|
4217
|
+
maxWeightsTexture == null ? void 0 : maxWeightsTexture.destroy();
|
|
4218
|
+
triPositionBuffer == null ? void 0 : triPositionBuffer.destroy();
|
|
4219
|
+
triTexCoordBuffer == null ? void 0 : triTexCoordBuffer.destroy();
|
|
4220
|
+
colorTexture == null ? void 0 : colorTexture.destroy();
|
|
4221
|
+
if (updateTimer) {
|
|
4222
|
+
clearTimeout(updateTimer);
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
_getAttributeManager() {
|
|
4226
|
+
return new import_core17.AttributeManager(this.context.device, {
|
|
4227
|
+
id: this.props.id,
|
|
4228
|
+
stats: this.context.stats
|
|
4229
|
+
});
|
|
4230
|
+
}
|
|
4231
|
+
_getChangeFlags(opts) {
|
|
4232
|
+
const changeFlags = {};
|
|
4233
|
+
const { dimensions } = this.state;
|
|
4234
|
+
changeFlags.dataChanged = this.isAttributeChanged() && "attribute changed" || this.isAggregationDirty(opts, {
|
|
4235
|
+
compareAll: true,
|
|
4236
|
+
dimension: dimensions.data
|
|
4237
|
+
}) && "aggregation is dirty";
|
|
4238
|
+
changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
|
|
4239
|
+
const { zoom } = this.state;
|
|
4240
|
+
if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
|
|
4241
|
+
changeFlags.viewportZoomChanged = true;
|
|
4242
|
+
}
|
|
4243
|
+
return changeFlags;
|
|
4244
|
+
}
|
|
4245
|
+
_createTextures() {
|
|
4246
|
+
const { textureSize, format } = this.state;
|
|
4247
|
+
this.setState({
|
|
4248
|
+
weightsTexture: this.context.device.createTexture({
|
|
4249
|
+
...TEXTURE_PROPS,
|
|
4250
|
+
width: textureSize,
|
|
4251
|
+
height: textureSize,
|
|
4252
|
+
format
|
|
4253
|
+
}),
|
|
4254
|
+
maxWeightsTexture: this.context.device.createTexture({
|
|
4255
|
+
...TEXTURE_PROPS,
|
|
4256
|
+
width: 1,
|
|
4257
|
+
height: 1,
|
|
4258
|
+
format
|
|
4259
|
+
})
|
|
4260
|
+
});
|
|
4261
|
+
}
|
|
4262
|
+
_setupAttributes() {
|
|
4263
|
+
const attributeManager = this.getAttributeManager();
|
|
4264
|
+
attributeManager.add({
|
|
4265
|
+
positions: { size: 3, type: import_constants10.GL.DOUBLE, accessor: "getPosition" },
|
|
4266
|
+
weights: { size: 1, accessor: "getWeight" }
|
|
4267
|
+
});
|
|
4268
|
+
this.setState({ positionAttributeName: "positions" });
|
|
4269
|
+
}
|
|
4270
|
+
_setupTextureParams() {
|
|
4271
|
+
const { device } = this.context;
|
|
4272
|
+
const { weightsTextureSize } = this.props;
|
|
4273
|
+
const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
|
|
4274
|
+
const floatTargetSupport = FLOAT_TARGET_FEATURES.every((feature) => device.features.has(feature));
|
|
4275
|
+
const format = floatTargetSupport ? "rgba32float" : "rgba8unorm";
|
|
4276
|
+
const weightsScale = floatTargetSupport ? 1 : 1 / 255;
|
|
4277
|
+
this.setState({ textureSize, format, weightsScale });
|
|
4278
|
+
if (!floatTargetSupport) {
|
|
4279
|
+
import_core17.log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
_createWeightsTransform(shaders) {
|
|
4283
|
+
let { weightsTransform } = this.state;
|
|
4284
|
+
const { weightsTexture } = this.state;
|
|
4285
|
+
const attributeManager = this.getAttributeManager();
|
|
4286
|
+
weightsTransform == null ? void 0 : weightsTransform.destroy();
|
|
4287
|
+
weightsTransform = new import_engine6.TextureTransform(this.context.device, {
|
|
4288
|
+
id: `${this.id}-weights-transform`,
|
|
4289
|
+
bufferLayout: attributeManager.getBufferLayouts(),
|
|
4290
|
+
vertexCount: 1,
|
|
4291
|
+
targetTexture: weightsTexture,
|
|
4292
|
+
parameters: {
|
|
4293
|
+
depthWriteEnabled: false,
|
|
4294
|
+
blendColorOperation: "add",
|
|
4295
|
+
blendColorSrcFactor: "one",
|
|
4296
|
+
blendColorDstFactor: "one",
|
|
4297
|
+
blendAlphaSrcFactor: "one",
|
|
4298
|
+
blendAlphaDstFactor: "one"
|
|
4299
|
+
},
|
|
4300
|
+
topology: "point-list",
|
|
4301
|
+
...shaders
|
|
4302
|
+
});
|
|
4303
|
+
this.setState({ weightsTransform });
|
|
4304
|
+
}
|
|
4305
|
+
_setupResources() {
|
|
4306
|
+
this._createTextures();
|
|
4307
|
+
const { device } = this.context;
|
|
4308
|
+
const { textureSize, weightsTexture, maxWeightsTexture } = this.state;
|
|
4309
|
+
const weightsTransformShaders = this.getShaders({
|
|
4310
|
+
vs: weights_vs_glsl_default,
|
|
4311
|
+
fs: weights_fs_glsl_default
|
|
4312
|
+
});
|
|
4313
|
+
this._createWeightsTransform(weightsTransformShaders);
|
|
4314
|
+
const maxWeightsTransformShaders = this.getShaders({ vs: max_vs_glsl_default, fs: max_fs_glsl_default });
|
|
4315
|
+
const maxWeightTransform = new import_engine6.TextureTransform(device, {
|
|
4316
|
+
id: `${this.id}-max-weights-transform`,
|
|
4317
|
+
bindings: { inTexture: weightsTexture },
|
|
4318
|
+
uniforms: { textureSize },
|
|
4319
|
+
targetTexture: maxWeightsTexture,
|
|
4320
|
+
...maxWeightsTransformShaders,
|
|
4321
|
+
vertexCount: textureSize * textureSize,
|
|
4322
|
+
topology: "point-list",
|
|
4323
|
+
parameters: {
|
|
4324
|
+
depthWriteEnabled: false,
|
|
4325
|
+
blendColorOperation: "max",
|
|
4326
|
+
blendAlphaOperation: "max",
|
|
4327
|
+
blendColorSrcFactor: "one",
|
|
4328
|
+
blendColorDstFactor: "one",
|
|
4329
|
+
blendAlphaSrcFactor: "one",
|
|
4330
|
+
blendAlphaDstFactor: "one"
|
|
4331
|
+
}
|
|
4332
|
+
});
|
|
4333
|
+
this.setState({
|
|
4334
|
+
weightsTexture,
|
|
4335
|
+
maxWeightsTexture,
|
|
4336
|
+
maxWeightTransform,
|
|
4337
|
+
zoom: null,
|
|
4338
|
+
triPositionBuffer: device.createBuffer({ byteLength: 48 }),
|
|
4339
|
+
triTexCoordBuffer: device.createBuffer({ byteLength: 48 })
|
|
4340
|
+
});
|
|
4341
|
+
}
|
|
4342
|
+
updateShaders(shaderOptions) {
|
|
4343
|
+
this._createWeightsTransform({
|
|
4344
|
+
vs: weights_vs_glsl_default,
|
|
4345
|
+
fs: weights_fs_glsl_default,
|
|
4346
|
+
...shaderOptions
|
|
4347
|
+
});
|
|
4348
|
+
}
|
|
4349
|
+
_updateMaxWeightValue() {
|
|
4350
|
+
const { maxWeightTransform, textureSize } = this.state;
|
|
4351
|
+
maxWeightTransform.run({
|
|
4352
|
+
parameters: { viewport: [0, 0, 1, 1] },
|
|
4353
|
+
clearColor: [0, 0, 0, 0]
|
|
4354
|
+
});
|
|
4355
|
+
}
|
|
4356
|
+
_updateBounds(forceUpdate = false) {
|
|
4357
|
+
const { viewport } = this.context;
|
|
4358
|
+
const viewportCorners = [
|
|
4359
|
+
viewport.unproject([0, 0]),
|
|
4360
|
+
viewport.unproject([viewport.width, 0]),
|
|
4361
|
+
viewport.unproject([viewport.width, viewport.height]),
|
|
4362
|
+
viewport.unproject([0, viewport.height])
|
|
4363
|
+
].map((p) => p.map(Math.fround));
|
|
4364
|
+
const visibleWorldBounds = getBounds(viewportCorners);
|
|
4365
|
+
const newState = { visibleWorldBounds, viewportCorners };
|
|
4366
|
+
let boundsChanged = false;
|
|
4367
|
+
if (forceUpdate || !this.state.worldBounds || !boundsContain(this.state.worldBounds, visibleWorldBounds)) {
|
|
4368
|
+
const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
|
|
4369
|
+
const worldBounds = this._commonToWorldBounds(scaledCommonBounds);
|
|
4370
|
+
if (this.props.coordinateSystem === import_core17.COORDINATE_SYSTEM.LNGLAT) {
|
|
4371
|
+
worldBounds[1] = Math.max(worldBounds[1], -85.051129);
|
|
4372
|
+
worldBounds[3] = Math.min(worldBounds[3], 85.051129);
|
|
4373
|
+
worldBounds[0] = Math.max(worldBounds[0], -360);
|
|
4374
|
+
worldBounds[2] = Math.min(worldBounds[2], 360);
|
|
4375
|
+
}
|
|
4376
|
+
const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
|
|
4377
|
+
newState.worldBounds = worldBounds;
|
|
4378
|
+
newState.normalizedCommonBounds = normalizedCommonBounds;
|
|
4379
|
+
boundsChanged = true;
|
|
4380
|
+
}
|
|
4381
|
+
this.setState(newState);
|
|
4382
|
+
return boundsChanged;
|
|
4383
|
+
}
|
|
4384
|
+
_updateTextureRenderingBounds() {
|
|
4385
|
+
const { triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners } = this.state;
|
|
4386
|
+
const { viewport } = this.context;
|
|
4387
|
+
triPositionBuffer.write(packVertices(viewportCorners, 3));
|
|
4388
|
+
const textureBounds = viewportCorners.map((p) => getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds));
|
|
4389
|
+
triTexCoordBuffer.write(packVertices(textureBounds, 2));
|
|
4390
|
+
}
|
|
4391
|
+
_updateColorTexture(opts) {
|
|
4392
|
+
const { colorRange } = opts.props;
|
|
4393
|
+
let { colorTexture } = this.state;
|
|
4394
|
+
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
|
|
4395
|
+
if (colorTexture && (colorTexture == null ? void 0 : colorTexture.width) === colorRange.length) {
|
|
4396
|
+
colorTexture.setSubImageData({ data: colors });
|
|
4397
|
+
} else {
|
|
4398
|
+
colorTexture == null ? void 0 : colorTexture.destroy();
|
|
4399
|
+
colorTexture = this.context.device.createTexture({
|
|
4400
|
+
...TEXTURE_PROPS,
|
|
4401
|
+
data: colors,
|
|
4402
|
+
width: colorRange.length,
|
|
4403
|
+
height: 1
|
|
4404
|
+
});
|
|
4405
|
+
}
|
|
4406
|
+
this.setState({ colorTexture });
|
|
4407
|
+
}
|
|
4408
|
+
_updateWeightmap() {
|
|
4409
|
+
const { radiusPixels, colorDomain, aggregation } = this.props;
|
|
4410
|
+
const { worldBounds, textureSize, weightsScale } = this.state;
|
|
4411
|
+
const weightsTransform = this.state.weightsTransform;
|
|
4412
|
+
this.state.isWeightMapDirty = false;
|
|
4413
|
+
const commonBounds = this._worldToCommonBounds(worldBounds, {
|
|
4414
|
+
useLayerCoordinateSystem: true
|
|
4415
|
+
});
|
|
4416
|
+
if (colorDomain && aggregation === "SUM") {
|
|
4417
|
+
const { viewport } = this.context;
|
|
4418
|
+
const metersPerPixel = viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0]) / textureSize;
|
|
4419
|
+
this.state.colorDomain = colorDomain.map((x) => x * metersPerPixel * weightsScale);
|
|
4420
|
+
} else {
|
|
4421
|
+
this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
|
|
4422
|
+
}
|
|
4423
|
+
const attributeManager = this.getAttributeManager();
|
|
4424
|
+
const attributes = attributeManager.getAttributes();
|
|
4425
|
+
const moduleSettings = this.getModuleSettings();
|
|
4426
|
+
const positions = attributes.positions.buffer;
|
|
4427
|
+
const uniforms = { radiusPixels, commonBounds, textureWidth: textureSize, weightsScale };
|
|
4428
|
+
const weights = attributes.weights.buffer;
|
|
4429
|
+
weightsTransform.model.setAttributes({ positions, weights });
|
|
4430
|
+
weightsTransform.model.setVertexCount(this.getNumInstances());
|
|
4431
|
+
weightsTransform.model.setUniforms(uniforms);
|
|
4432
|
+
weightsTransform.model.updateModuleSettings(moduleSettings);
|
|
4433
|
+
weightsTransform.run({
|
|
4434
|
+
parameters: { viewport: [0, 0, textureSize, textureSize] },
|
|
4435
|
+
clearColor: [0, 0, 0, 0]
|
|
4436
|
+
});
|
|
4437
|
+
this._updateMaxWeightValue();
|
|
4438
|
+
}
|
|
4439
|
+
_debouncedUpdateWeightmap(fromTimer = false) {
|
|
4440
|
+
let { updateTimer } = this.state;
|
|
4441
|
+
const { debounceTimeout } = this.props;
|
|
4442
|
+
if (fromTimer) {
|
|
4443
|
+
updateTimer = null;
|
|
4444
|
+
this._updateBounds(true);
|
|
4445
|
+
this._updateTextureRenderingBounds();
|
|
4446
|
+
this.setState({ isWeightMapDirty: true });
|
|
4447
|
+
} else {
|
|
4448
|
+
this.setState({ isWeightMapDirty: false });
|
|
4449
|
+
clearTimeout(updateTimer);
|
|
4450
|
+
updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
|
|
4451
|
+
}
|
|
4452
|
+
this.setState({ updateTimer });
|
|
4453
|
+
}
|
|
4454
|
+
_worldToCommonBounds(worldBounds, opts = {}) {
|
|
4455
|
+
const { useLayerCoordinateSystem = false } = opts;
|
|
4456
|
+
const [minLong, minLat, maxLong, maxLat] = worldBounds;
|
|
4457
|
+
const { viewport } = this.context;
|
|
4458
|
+
const { textureSize } = this.state;
|
|
4459
|
+
const { coordinateSystem } = this.props;
|
|
4460
|
+
const offsetMode = useLayerCoordinateSystem && (coordinateSystem === import_core17.COORDINATE_SYSTEM.LNGLAT_OFFSETS || coordinateSystem === import_core17.COORDINATE_SYSTEM.METER_OFFSETS);
|
|
4461
|
+
const offsetOriginCommon = offsetMode ? viewport.projectPosition(this.props.coordinateOrigin) : [0, 0];
|
|
4462
|
+
const size = textureSize * RESOLUTION / viewport.scale;
|
|
4463
|
+
let bottomLeftCommon;
|
|
4464
|
+
let topRightCommon;
|
|
4465
|
+
if (useLayerCoordinateSystem && !offsetMode) {
|
|
4466
|
+
bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
|
|
4467
|
+
topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
|
|
4468
|
+
} else {
|
|
4469
|
+
bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
|
|
4470
|
+
topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
|
|
4471
|
+
}
|
|
4472
|
+
return scaleToAspectRatio([
|
|
4473
|
+
bottomLeftCommon[0] - offsetOriginCommon[0],
|
|
4474
|
+
bottomLeftCommon[1] - offsetOriginCommon[1],
|
|
4475
|
+
topRightCommon[0] - offsetOriginCommon[0],
|
|
4476
|
+
topRightCommon[1] - offsetOriginCommon[1]
|
|
4477
|
+
], size, size);
|
|
4478
|
+
}
|
|
4479
|
+
_commonToWorldBounds(commonBounds) {
|
|
4480
|
+
const [xMin, yMin, xMax, yMax] = commonBounds;
|
|
4481
|
+
const { viewport } = this.context;
|
|
4482
|
+
const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
|
|
4483
|
+
const topRightWorld = viewport.unprojectPosition([xMax, yMax]);
|
|
4484
|
+
return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
|
|
4485
|
+
}
|
|
4486
|
+
};
|
|
4487
|
+
var HeatmapLayer = _HeatmapLayer;
|
|
4488
|
+
(() => {
|
|
4489
|
+
_HeatmapLayer.layerName = "HeatmapLayer";
|
|
4490
|
+
})();
|
|
4491
|
+
(() => {
|
|
4492
|
+
_HeatmapLayer.defaultProps = defaultProps10;
|
|
4493
|
+
})();
|
|
4494
|
+
//# sourceMappingURL=index.cjs.map
|