@deck.gl/aggregation-layers 8.8.0-alpha.6 → 8.8.0-beta.1
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/dist.dev.js +757 -645
- package/dist/es5/aggregation-layer.js +19 -7
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +5 -5
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-utils.js +1 -1
- package/dist/es5/contour-layer/contour-utils.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +5 -3
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +8 -8
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +12 -12
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-aggregation-layer.js +25 -12
- package/dist/es5/grid-aggregation-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +18 -9
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +17 -6
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +7 -7
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/weights-fs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +16 -5
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +26 -19
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +18 -8
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/utils/bin-sorter.js +9 -0
- package/dist/es5/utils/bin-sorter.js.map +1 -1
- package/dist/esm/aggregation-layer.js +12 -5
- package/dist/esm/aggregation-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js +6 -3
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-utils.js +1 -1
- package/dist/esm/contour-layer/contour-utils.js.map +1 -1
- package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/esm/contour-layer/marching-squares.js.map +1 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -3
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +8 -6
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +11 -9
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-aggregation-layer.js +13 -5
- package/dist/esm/grid-aggregation-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js +15 -8
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +22 -13
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +6 -5
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +11 -2
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +16 -10
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +15 -7
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/bin-sorter.js +16 -0
- package/dist/esm/utils/bin-sorter.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +6 -4
- package/src/{aggregation-layer.js → aggregation-layer.ts} +32 -15
- package/src/contour-layer/{contour-layer.js → contour-layer.ts} +95 -15
- package/src/contour-layer/{contour-utils.js → contour-utils.ts} +11 -5
- package/src/contour-layer/{marching-squares-codes.js → marching-squares-codes.ts} +0 -0
- package/src/contour-layer/{marching-squares.js → marching-squares.ts} +6 -6
- package/src/cpu-grid-layer/cpu-grid-layer.ts +310 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer-fragment.glsl.js → gpu-grid-cell-layer-fragment.glsl.ts} +0 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts} +0 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer.js → gpu-grid-cell-layer.ts} +22 -14
- package/src/gpu-grid-layer/{gpu-grid-layer.js → gpu-grid-layer.ts} +122 -17
- package/src/{grid-aggregation-layer.js → grid-aggregation-layer.ts} +25 -13
- package/src/grid-layer/{grid-layer.js → grid-layer.ts} +38 -13
- package/src/heatmap-layer/{heatmap-layer-utils.js → heatmap-layer-utils.ts} +5 -5
- package/src/heatmap-layer/{heatmap-layer.js → heatmap-layer.ts} +138 -29
- package/src/heatmap-layer/{max-fs.glsl.js → max-fs.glsl.ts} +0 -0
- package/src/heatmap-layer/{max-vs.glsl.js → max-vs.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer-vertex.glsl.js → triangle-layer-vertex.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer.js → triangle-layer.ts} +20 -10
- package/src/heatmap-layer/{weights-fs.glsl.js → weights-fs.glsl.ts} +0 -0
- package/src/heatmap-layer/{weights-vs.glsl.js → weights-vs.glsl.ts} +0 -0
- package/src/hexagon-layer/{hexagon-layer.js → hexagon-layer.ts} +174 -9
- package/src/index.ts +9 -0
- package/src/screen-grid-layer/{screen-grid-cell-layer.js → screen-grid-cell-layer.ts} +31 -14
- package/src/screen-grid-layer/{screen-grid-layer-fragment.glsl.js → screen-grid-layer-fragment.glsl.ts} +0 -0
- package/src/screen-grid-layer/{screen-grid-layer-vertex.glsl.js → screen-grid-layer-vertex.glsl.ts} +0 -0
- package/src/screen-grid-layer/{screen-grid-layer.js → screen-grid-layer.ts} +117 -15
- package/src/types.ts +10 -0
- package/src/utils/{bin-sorter.js → bin-sorter.ts} +26 -11
- package/typed/aggregation-layer.d.ts +16 -11
- package/typed/aggregation-layer.d.ts.map +1 -1
- package/typed/aggregation-layer.js +151 -0
- package/typed/contour-layer/contour-layer.d.ts +92 -36
- package/typed/contour-layer/contour-layer.d.ts.map +1 -1
- package/typed/contour-layer/contour-layer.js +234 -0
- package/typed/contour-layer/contour-utils.d.ts +8 -9
- package/typed/contour-layer/contour-utils.d.ts.map +1 -1
- package/typed/contour-layer/contour-utils.js +64 -0
- package/typed/contour-layer/marching-squares-codes.d.ts +2 -2
- package/typed/contour-layer/marching-squares-codes.d.ts.map +1 -1
- package/typed/contour-layer/marching-squares-codes.js +337 -0
- package/typed/contour-layer/marching-squares.d.ts +6 -6
- package/typed/contour-layer/marching-squares.d.ts.map +1 -1
- package/typed/contour-layer/marching-squares.js +147 -0
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +221 -126
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/cpu-grid-layer.js +129 -0
- package/typed/cpu-grid-layer/grid-aggregator.js +141 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +141 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +67 -81
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +143 -0
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +131 -62
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-layer.js +289 -0
- package/typed/grid-aggregation-layer.d.ts +19 -6
- package/typed/grid-aggregation-layer.d.ts.map +1 -1
- package/typed/grid-aggregation-layer.js +172 -0
- package/typed/grid-layer/grid-layer.d.ts +109 -90
- package/typed/grid-layer/grid-layer.d.ts.map +1 -1
- package/typed/grid-layer/grid-layer.js +60 -0
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +6 -6
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer-utils.js +78 -0
- package/typed/heatmap-layer/heatmap-layer.d.ts +147 -82
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.js +478 -0
- package/typed/heatmap-layer/max-fs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/max-fs.glsl.js +7 -0
- package/typed/heatmap-layer/max-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/max-vs.glsl.js +12 -0
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +58 -0
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +51 -0
- package/typed/heatmap-layer/triangle-layer.d.ts +25 -8
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer.js +67 -0
- package/typed/heatmap-layer/weights-fs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/weights-fs.glsl.js +19 -0
- package/typed/heatmap-layer/weights-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.js +23 -0
- package/typed/hexagon-layer/hexagon-aggregator.js +112 -0
- package/typed/hexagon-layer/hexagon-layer.d.ts +232 -125
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-layer.js +171 -0
- package/typed/index.d.ts +7 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/index.js +33 -0
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +46 -25
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-cell-layer.js +159 -0
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +37 -0
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +83 -0
- package/typed/screen-grid-layer/screen-grid-layer.d.ts +113 -30
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer.js +216 -0
- package/typed/types.d.ts +11 -0
- package/typed/types.d.ts.map +1 -0
- package/typed/types.js +1 -0
- package/typed/utils/aggregation-operation-utils.js +94 -0
- package/typed/utils/bin-sorter.d.ts +27 -21
- package/typed/utils/bin-sorter.d.ts.map +1 -1
- package/typed/utils/bin-sorter.js +167 -0
- package/typed/utils/color-utils.js +53 -0
- package/typed/utils/cpu-aggregator.js +417 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +31 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +77 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +562 -0
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +36 -0
- package/typed/utils/grid-aggregation-utils.js +114 -0
- package/typed/utils/prop-utils.js +28 -0
- package/typed/utils/resource-utils.js +40 -0
- package/typed/utils/scale-utils.js +184 -0
- package/src/cpu-grid-layer/cpu-grid-layer.js +0 -153
|
@@ -1,131 +1,226 @@
|
|
|
1
|
-
|
|
1
|
+
import { _MaterialProps as MaterialProps } from '@deck.gl/layers/typed';
|
|
2
|
+
import { Accessor, AccessorFunction, Color, Position } from '@deck.gl/core/typed';
|
|
3
|
+
import { pointToDensityGridDataCPU } from './grid-aggregator';
|
|
4
|
+
import AggregationLayer, { AggregationLayerProps } from '../aggregation-layer';
|
|
5
|
+
import Layer, { UpdateParameters } from 'modules/core/src/lib/layer';
|
|
6
|
+
import { GetPickingInfoParams, PickingInfo } from 'modules/core/src/lib/picking/pick-info';
|
|
7
|
+
import { AggregateAccessor } from '../types';
|
|
8
|
+
declare function nop(): void;
|
|
9
|
+
/** All properties supported by CPUGridLayer. */
|
|
10
|
+
export declare type CPUGridLayerProps<DataT = any> = _CPUGridLayerProps<DataT> & AggregationLayerProps<DataT>;
|
|
11
|
+
/** Properties added by CPUGridLayer. */
|
|
12
|
+
export declare type _CPUGridLayerProps<DataT> = {
|
|
13
|
+
/**
|
|
14
|
+
* Size of each cell in meters.
|
|
15
|
+
* @default 1000
|
|
16
|
+
*/
|
|
17
|
+
cellSize?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Color scale domain, default is set to the extent of aggregated weights in each cell.
|
|
20
|
+
* @default [min(colorWeight), max(colorWeight)]
|
|
21
|
+
*/
|
|
22
|
+
colorDomain?: [number, number] | null;
|
|
23
|
+
/**
|
|
24
|
+
* Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
|
|
25
|
+
*/
|
|
26
|
+
colorRange?: Color[];
|
|
27
|
+
/**
|
|
28
|
+
* Cell size multiplier, clamped between 0 - 1.
|
|
29
|
+
* @default 1
|
|
30
|
+
*/
|
|
31
|
+
coverage?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
|
|
34
|
+
* @default [0, max(elevationWeight)]
|
|
35
|
+
*/
|
|
36
|
+
elevationDomain?: [number, number] | null;
|
|
37
|
+
/**
|
|
38
|
+
* Elevation scale output range.
|
|
39
|
+
* @default [0, 1000]
|
|
40
|
+
*/
|
|
41
|
+
elevationRange?: [number, number];
|
|
42
|
+
/**
|
|
43
|
+
* Cell elevation multiplier.
|
|
44
|
+
* @default 1
|
|
45
|
+
*/
|
|
46
|
+
elevationScale?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to enable cell elevation. If set to false, all cell will be flat.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
extruded?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Filter cells and re-calculate color by `upperPercentile`.
|
|
54
|
+
* Cells with value arger than the upperPercentile will be hidden.
|
|
55
|
+
* @default 100
|
|
56
|
+
*/
|
|
57
|
+
upperPercentile?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Filter cells and re-calculate color by `lowerPercentile`.
|
|
60
|
+
* Cells with value smaller than the lowerPercentile will be hidden.
|
|
61
|
+
* @default 0
|
|
62
|
+
*/
|
|
63
|
+
lowerPercentile?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Filter cells and re-calculate elevation by `elevationUpperPercentile`.
|
|
66
|
+
* Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.
|
|
67
|
+
* @default 100
|
|
68
|
+
*/
|
|
69
|
+
elevationUpperPercentile?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Filter cells and re-calculate elevation by `elevationLowerPercentile`.
|
|
72
|
+
* Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.
|
|
73
|
+
* @default 0
|
|
74
|
+
*/
|
|
75
|
+
elevationLowerPercentile?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Scaling function used to determine the color of the grid cell, default value is 'quantize'.
|
|
78
|
+
* Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.
|
|
79
|
+
* @default 'quantize'
|
|
80
|
+
*/
|
|
81
|
+
colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';
|
|
82
|
+
/**
|
|
83
|
+
* This is an object that contains material props
|
|
84
|
+
* for [lighting effect](/docs/api-reference/core/lighting-effect.md) applied on extruded polygons.
|
|
85
|
+
* @default true
|
|
86
|
+
*/
|
|
87
|
+
material?: MaterialProps | null;
|
|
88
|
+
/**
|
|
89
|
+
* Defines the operation used to aggregate all data object weights to calculate a cell's color value.
|
|
90
|
+
* @default 'SUM'
|
|
91
|
+
*/
|
|
92
|
+
colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
93
|
+
/**
|
|
94
|
+
* Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
|
|
95
|
+
* @default 'SUM'
|
|
96
|
+
*/
|
|
97
|
+
elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
98
|
+
/**
|
|
99
|
+
* Method called to retrieve the position of each object.
|
|
100
|
+
* @default object => object.position
|
|
101
|
+
*/
|
|
102
|
+
getPosition?: AccessorFunction<DataT, Position>;
|
|
103
|
+
/**
|
|
104
|
+
* The weight of a data object used to calculate the color value for a cell.
|
|
105
|
+
* @default 1
|
|
106
|
+
*/
|
|
107
|
+
getColorWeight?: Accessor<DataT, number>;
|
|
108
|
+
/**
|
|
109
|
+
* After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.
|
|
110
|
+
* @default null
|
|
111
|
+
*/
|
|
112
|
+
getColorValue?: AggregateAccessor<DataT> | null;
|
|
113
|
+
/**
|
|
114
|
+
* The weight of a data object used to calculate the elevation value for a cell.
|
|
115
|
+
* @default 1
|
|
116
|
+
*/
|
|
117
|
+
getElevationWeight?: Accessor<DataT, number>;
|
|
118
|
+
/**
|
|
119
|
+
* After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.
|
|
120
|
+
* @default null
|
|
121
|
+
*/
|
|
122
|
+
getElevationValue?: AggregateAccessor<DataT> | null;
|
|
123
|
+
/**
|
|
124
|
+
* This callback will be called when bin color domain has been calculated.
|
|
125
|
+
* @default () => {}
|
|
126
|
+
*/
|
|
127
|
+
onSetColorDomain?: (minMax: [number, number]) => void;
|
|
128
|
+
/**
|
|
129
|
+
* This callback will be called when bin elevation domain has been calculated.
|
|
130
|
+
* @default () => {}
|
|
131
|
+
*/
|
|
132
|
+
onSetElevationDomain?: (minMax: [number, number]) => void;
|
|
133
|
+
};
|
|
134
|
+
export default class CPUGridLayer<DataT = any, ExtraPropsT = {}> extends AggregationLayer<ExtraPropsT & Required<_CPUGridLayerProps<DataT>>> {
|
|
135
|
+
static layerName: string;
|
|
136
|
+
static defaultProps: {
|
|
137
|
+
colorDomain: null;
|
|
138
|
+
colorRange: number[][];
|
|
139
|
+
getColorValue: {
|
|
140
|
+
type: string;
|
|
141
|
+
value: null;
|
|
142
|
+
};
|
|
143
|
+
getColorWeight: {
|
|
144
|
+
type: string;
|
|
145
|
+
value: number;
|
|
146
|
+
};
|
|
147
|
+
colorAggregation: string;
|
|
148
|
+
lowerPercentile: {
|
|
149
|
+
type: string;
|
|
150
|
+
min: number;
|
|
151
|
+
max: number;
|
|
152
|
+
value: number;
|
|
153
|
+
};
|
|
154
|
+
upperPercentile: {
|
|
155
|
+
type: string;
|
|
156
|
+
min: number;
|
|
157
|
+
max: number;
|
|
158
|
+
value: number;
|
|
159
|
+
};
|
|
160
|
+
colorScaleType: string;
|
|
161
|
+
onSetColorDomain: typeof nop;
|
|
162
|
+
elevationDomain: null;
|
|
163
|
+
elevationRange: number[];
|
|
164
|
+
getElevationValue: {
|
|
165
|
+
type: string;
|
|
166
|
+
value: null;
|
|
167
|
+
};
|
|
168
|
+
getElevationWeight: {
|
|
169
|
+
type: string;
|
|
170
|
+
value: number;
|
|
171
|
+
};
|
|
172
|
+
elevationAggregation: string;
|
|
173
|
+
elevationLowerPercentile: {
|
|
174
|
+
type: string;
|
|
175
|
+
min: number;
|
|
176
|
+
max: number;
|
|
177
|
+
value: number;
|
|
178
|
+
};
|
|
179
|
+
elevationUpperPercentile: {
|
|
180
|
+
type: string;
|
|
181
|
+
min: number;
|
|
182
|
+
max: number;
|
|
183
|
+
value: number;
|
|
184
|
+
};
|
|
185
|
+
elevationScale: {
|
|
186
|
+
type: string;
|
|
187
|
+
min: number;
|
|
188
|
+
value: number;
|
|
189
|
+
};
|
|
190
|
+
elevationScaleType: string;
|
|
191
|
+
onSetElevationDomain: typeof nop;
|
|
192
|
+
gridAggregator: typeof pointToDensityGridDataCPU;
|
|
193
|
+
cellSize: {
|
|
194
|
+
type: string;
|
|
195
|
+
min: number;
|
|
196
|
+
max: number;
|
|
197
|
+
value: number;
|
|
198
|
+
};
|
|
199
|
+
coverage: {
|
|
200
|
+
type: string;
|
|
201
|
+
min: number;
|
|
202
|
+
max: number;
|
|
203
|
+
value: number;
|
|
204
|
+
};
|
|
205
|
+
getPosition: {
|
|
206
|
+
type: string;
|
|
207
|
+
value: (x: any) => any;
|
|
208
|
+
};
|
|
209
|
+
extruded: boolean;
|
|
210
|
+
material: boolean;
|
|
211
|
+
_filterData: {
|
|
212
|
+
type: string;
|
|
213
|
+
value: null;
|
|
214
|
+
optional: boolean;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
initializeState(): void;
|
|
218
|
+
updateState(opts: UpdateParameters<this>): void;
|
|
219
|
+
getPickingInfo({ info }: GetPickingInfoParams): PickingInfo;
|
|
2
220
|
_onGetSublayerColor(cell: any): any;
|
|
3
221
|
_onGetSublayerElevation(cell: any): any;
|
|
4
222
|
_getSublayerUpdateTriggers(): any;
|
|
223
|
+
renderLayers(): Layer;
|
|
5
224
|
}
|
|
6
|
-
|
|
7
|
-
export const layerName: string;
|
|
8
|
-
export { defaultProps };
|
|
9
|
-
}
|
|
10
|
-
export default CPUGridLayer;
|
|
11
|
-
import AggregationLayer from "../aggregation-layer";
|
|
12
|
-
declare namespace defaultProps {
|
|
13
|
-
export const colorDomain: null;
|
|
14
|
-
export { defaultColorRange as colorRange };
|
|
15
|
-
export namespace getColorValue {
|
|
16
|
-
const type: string;
|
|
17
|
-
const value: null;
|
|
18
|
-
}
|
|
19
|
-
export namespace getColorWeight {
|
|
20
|
-
const type_1: string;
|
|
21
|
-
export { type_1 as type };
|
|
22
|
-
const value_1: number;
|
|
23
|
-
export { value_1 as value };
|
|
24
|
-
}
|
|
25
|
-
export const colorAggregation: string;
|
|
26
|
-
export namespace lowerPercentile {
|
|
27
|
-
const type_2: string;
|
|
28
|
-
export { type_2 as type };
|
|
29
|
-
export const min: number;
|
|
30
|
-
export const max: number;
|
|
31
|
-
const value_2: number;
|
|
32
|
-
export { value_2 as value };
|
|
33
|
-
}
|
|
34
|
-
export namespace upperPercentile {
|
|
35
|
-
const type_3: string;
|
|
36
|
-
export { type_3 as type };
|
|
37
|
-
const min_1: number;
|
|
38
|
-
export { min_1 as min };
|
|
39
|
-
const max_1: number;
|
|
40
|
-
export { max_1 as max };
|
|
41
|
-
const value_3: number;
|
|
42
|
-
export { value_3 as value };
|
|
43
|
-
}
|
|
44
|
-
export const colorScaleType: string;
|
|
45
|
-
export { nop as onSetColorDomain };
|
|
46
|
-
export const elevationDomain: null;
|
|
47
|
-
export const elevationRange: number[];
|
|
48
|
-
export namespace getElevationValue {
|
|
49
|
-
const type_4: string;
|
|
50
|
-
export { type_4 as type };
|
|
51
|
-
const value_4: null;
|
|
52
|
-
export { value_4 as value };
|
|
53
|
-
}
|
|
54
|
-
export namespace getElevationWeight {
|
|
55
|
-
const type_5: string;
|
|
56
|
-
export { type_5 as type };
|
|
57
|
-
const value_5: number;
|
|
58
|
-
export { value_5 as value };
|
|
59
|
-
}
|
|
60
|
-
export const elevationAggregation: string;
|
|
61
|
-
export namespace elevationLowerPercentile {
|
|
62
|
-
const type_6: string;
|
|
63
|
-
export { type_6 as type };
|
|
64
|
-
const min_2: number;
|
|
65
|
-
export { min_2 as min };
|
|
66
|
-
const max_2: number;
|
|
67
|
-
export { max_2 as max };
|
|
68
|
-
const value_6: number;
|
|
69
|
-
export { value_6 as value };
|
|
70
|
-
}
|
|
71
|
-
export namespace elevationUpperPercentile {
|
|
72
|
-
const type_7: string;
|
|
73
|
-
export { type_7 as type };
|
|
74
|
-
const min_3: number;
|
|
75
|
-
export { min_3 as min };
|
|
76
|
-
const max_3: number;
|
|
77
|
-
export { max_3 as max };
|
|
78
|
-
const value_7: number;
|
|
79
|
-
export { value_7 as value };
|
|
80
|
-
}
|
|
81
|
-
export namespace elevationScale {
|
|
82
|
-
const type_8: string;
|
|
83
|
-
export { type_8 as type };
|
|
84
|
-
const min_4: number;
|
|
85
|
-
export { min_4 as min };
|
|
86
|
-
const value_8: number;
|
|
87
|
-
export { value_8 as value };
|
|
88
|
-
}
|
|
89
|
-
export const elevationScaleType: string;
|
|
90
|
-
export { nop as onSetElevationDomain };
|
|
91
|
-
export { pointToDensityGridDataCPU as gridAggregator };
|
|
92
|
-
export namespace cellSize {
|
|
93
|
-
const type_9: string;
|
|
94
|
-
export { type_9 as type };
|
|
95
|
-
const min_5: number;
|
|
96
|
-
export { min_5 as min };
|
|
97
|
-
const max_4: number;
|
|
98
|
-
export { max_4 as max };
|
|
99
|
-
const value_9: number;
|
|
100
|
-
export { value_9 as value };
|
|
101
|
-
}
|
|
102
|
-
export namespace coverage {
|
|
103
|
-
const type_10: string;
|
|
104
|
-
export { type_10 as type };
|
|
105
|
-
const min_6: number;
|
|
106
|
-
export { min_6 as min };
|
|
107
|
-
const max_5: number;
|
|
108
|
-
export { max_5 as max };
|
|
109
|
-
const value_10: number;
|
|
110
|
-
export { value_10 as value };
|
|
111
|
-
}
|
|
112
|
-
export namespace getPosition {
|
|
113
|
-
const type_11: string;
|
|
114
|
-
export { type_11 as type };
|
|
115
|
-
export function value_11(x: any): any;
|
|
116
|
-
export { value_11 as value };
|
|
117
|
-
}
|
|
118
|
-
export const extruded: boolean;
|
|
119
|
-
export const material: boolean;
|
|
120
|
-
export namespace _filterData {
|
|
121
|
-
const type_12: string;
|
|
122
|
-
export { type_12 as type };
|
|
123
|
-
const value_12: null;
|
|
124
|
-
export { value_12 as value };
|
|
125
|
-
export const optional: boolean;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
import { defaultColorRange } from "../utils/color-utils";
|
|
129
|
-
declare function nop(): void;
|
|
130
|
-
import { pointToDensityGridDataCPU } from "./grid-aggregator";
|
|
225
|
+
export {};
|
|
131
226
|
//# sourceMappingURL=cpu-grid-layer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpu-grid-layer.d.ts","sourceRoot":"","sources":["../../src/cpu-grid-layer/cpu-grid-layer.
|
|
1
|
+
{"version":3,"file":"cpu-grid-layer.d.ts","sourceRoot":"","sources":["../../src/cpu-grid-layer/cpu-grid-layer.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAgB,cAAc,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAG1E,OAAO,EAAC,yBAAyB,EAAC,MAAM,mBAAmB,CAAC;AAE5D,OAAO,gBAAgB,EAAE,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAE7E,OAAO,KAAK,EAAE,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAC,oBAAoB,EAAE,WAAW,EAAC,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAG3C,iBAAS,GAAG,SAAK;AAyCjB,gDAAgD;AAChD,oBAAY,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,GACpE,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAE/B,wCAAwC;AACxC,oBAAY,kBAAkB,CAAC,KAAK,IAAI;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEtC;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE1C;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;;;OAIG;IACH,cAAc,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAEhE;;;;OAIG;IACH,QAAQ,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAEhC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAElD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAEtD;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEhD;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEzC;;;OAGG;IACH,aAAa,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEhD;;;OAGG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE7C;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEpD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAEtD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,GAAG,EAAE,CAAE,SAAQ,gBAAgB,CACvF,WAAW,GAAG,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAClD;IACC,MAAM,CAAC,SAAS,SAAkB;IAClC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAgB;IAEnC,eAAe,IAAI,IAAI;IAkBvB,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAYxC,cAAc,CAAC,EAAC,IAAI,EAAC,EAAE,oBAAoB,GAAG,WAAW;IAKzD,mBAAmB,CAAC,IAAI,KAAA;IAKxB,uBAAuB,CAAC,IAAI,KAAA;IAI5B,0BAA0B;IAI1B,YAAY,IAAI,KAAK;CA8BtB"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import GL from '@luma.gl/constants';
|
|
21
|
+
import { GridCellLayer } from '@deck.gl/layers';
|
|
22
|
+
import { defaultColorRange } from '../utils/color-utils';
|
|
23
|
+
import { pointToDensityGridDataCPU } from './grid-aggregator';
|
|
24
|
+
import CPUAggregator from '../utils/cpu-aggregator';
|
|
25
|
+
import AggregationLayer from '../aggregation-layer';
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
27
|
+
function nop() { }
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
// color
|
|
30
|
+
colorDomain: null,
|
|
31
|
+
colorRange: defaultColorRange,
|
|
32
|
+
getColorValue: { type: 'accessor', value: null },
|
|
33
|
+
getColorWeight: { type: 'accessor', value: 1 },
|
|
34
|
+
colorAggregation: 'SUM',
|
|
35
|
+
lowerPercentile: { type: 'number', min: 0, max: 100, value: 0 },
|
|
36
|
+
upperPercentile: { type: 'number', min: 0, max: 100, value: 100 },
|
|
37
|
+
colorScaleType: 'quantize',
|
|
38
|
+
onSetColorDomain: nop,
|
|
39
|
+
// elevation
|
|
40
|
+
elevationDomain: null,
|
|
41
|
+
elevationRange: [0, 1000],
|
|
42
|
+
getElevationValue: { type: 'accessor', value: null },
|
|
43
|
+
getElevationWeight: { type: 'accessor', value: 1 },
|
|
44
|
+
elevationAggregation: 'SUM',
|
|
45
|
+
elevationLowerPercentile: { type: 'number', min: 0, max: 100, value: 0 },
|
|
46
|
+
elevationUpperPercentile: { type: 'number', min: 0, max: 100, value: 100 },
|
|
47
|
+
elevationScale: { type: 'number', min: 0, value: 1 },
|
|
48
|
+
elevationScaleType: 'linear',
|
|
49
|
+
onSetElevationDomain: nop,
|
|
50
|
+
gridAggregator: pointToDensityGridDataCPU,
|
|
51
|
+
// grid
|
|
52
|
+
cellSize: { type: 'number', min: 0, max: 1000, value: 1000 },
|
|
53
|
+
coverage: { type: 'number', min: 0, max: 1, value: 1 },
|
|
54
|
+
getPosition: { type: 'accessor', value: x => x.position },
|
|
55
|
+
extruded: false,
|
|
56
|
+
// Optional material for 'lighting' shader module
|
|
57
|
+
material: true,
|
|
58
|
+
// data filter
|
|
59
|
+
_filterData: { type: 'function', value: null, optional: true }
|
|
60
|
+
};
|
|
61
|
+
export default class CPUGridLayer extends AggregationLayer {
|
|
62
|
+
initializeState() {
|
|
63
|
+
const cpuAggregator = new CPUAggregator({
|
|
64
|
+
getAggregator: props => props.gridAggregator,
|
|
65
|
+
getCellSize: props => props.cellSize
|
|
66
|
+
});
|
|
67
|
+
this.state = {
|
|
68
|
+
cpuAggregator,
|
|
69
|
+
aggregatorState: cpuAggregator.state
|
|
70
|
+
};
|
|
71
|
+
const attributeManager = this.getAttributeManager();
|
|
72
|
+
attributeManager.add({
|
|
73
|
+
positions: { size: 3, type: GL.DOUBLE, accessor: 'getPosition' }
|
|
74
|
+
});
|
|
75
|
+
// color and elevation attributes can't be added as attributes
|
|
76
|
+
// they are calcualted using 'getValue' accessor that takes an array of pints.
|
|
77
|
+
}
|
|
78
|
+
updateState(opts) {
|
|
79
|
+
super.updateState(opts);
|
|
80
|
+
this.setState({
|
|
81
|
+
// make a copy of the internal state of cpuAggregator for testing
|
|
82
|
+
aggregatorState: this.state.cpuAggregator.updateState(opts, {
|
|
83
|
+
viewport: this.context.viewport,
|
|
84
|
+
attributes: this.getAttributes(),
|
|
85
|
+
numInstances: this.getNumInstances()
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getPickingInfo({ info }) {
|
|
90
|
+
return this.state.cpuAggregator.getPickingInfo({ info });
|
|
91
|
+
}
|
|
92
|
+
// create a method for testing
|
|
93
|
+
_onGetSublayerColor(cell) {
|
|
94
|
+
return this.state.cpuAggregator.getAccessor('fillColor')(cell);
|
|
95
|
+
}
|
|
96
|
+
// create a method for testing
|
|
97
|
+
_onGetSublayerElevation(cell) {
|
|
98
|
+
return this.state.cpuAggregator.getAccessor('elevation')(cell);
|
|
99
|
+
}
|
|
100
|
+
_getSublayerUpdateTriggers() {
|
|
101
|
+
return this.state.cpuAggregator.getUpdateTriggers(this.props);
|
|
102
|
+
}
|
|
103
|
+
renderLayers() {
|
|
104
|
+
const { elevationScale, extruded, cellSize, coverage, material, transitions } = this.props;
|
|
105
|
+
const { cpuAggregator } = this.state;
|
|
106
|
+
const SubLayerClass = this.getSubLayerClass('grid-cell', GridCellLayer);
|
|
107
|
+
const updateTriggers = this._getSublayerUpdateTriggers();
|
|
108
|
+
return new SubLayerClass({
|
|
109
|
+
cellSize,
|
|
110
|
+
coverage,
|
|
111
|
+
material,
|
|
112
|
+
elevationScale,
|
|
113
|
+
extruded,
|
|
114
|
+
getFillColor: this._onGetSublayerColor.bind(this),
|
|
115
|
+
getElevation: this._onGetSublayerElevation.bind(this),
|
|
116
|
+
transitions: transitions && {
|
|
117
|
+
getFillColor: transitions.getColorValue || transitions.getColorWeight,
|
|
118
|
+
getElevation: transitions.getElevationValue || transitions.getElevationWeight
|
|
119
|
+
}
|
|
120
|
+
}, this.getSubLayerProps({
|
|
121
|
+
id: 'grid-cell',
|
|
122
|
+
updateTriggers
|
|
123
|
+
}), {
|
|
124
|
+
data: cpuAggregator.state.layerData.data
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
CPUGridLayer.layerName = 'CPUGridLayer';
|
|
129
|
+
CPUGridLayer.defaultProps = defaultProps;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import { createIterable } from '@deck.gl/core';
|
|
21
|
+
import { getGridOffset } from '../utils/grid-aggregation-utils';
|
|
22
|
+
/**
|
|
23
|
+
* Calculate density grid from an array of points
|
|
24
|
+
* @param {Object} props - object containing :
|
|
25
|
+
* @param {Iterable} [props.data] - data objects to be aggregated
|
|
26
|
+
* @param {Integer} [props.cellSize] - size of the grid cell
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} aggregationParams - object containing :
|
|
29
|
+
* @param {Object} gridOffset - {xOffset, yOffset} cell size in meters
|
|
30
|
+
* @param {Integer} width - width of the grid
|
|
31
|
+
* @param {Integer} height - height of the grid
|
|
32
|
+
* @param {Boolean} projectPoints - `true` if doing screen space projection, `false` otherwise
|
|
33
|
+
* @param {Array} attributes - attributes array containing position values
|
|
34
|
+
* @param {Viewport} viewport - viewport to be used for projection
|
|
35
|
+
* @param {Array} posOffset - [xOffset, yOffset] offset to be applied to positions to get cell index
|
|
36
|
+
* @param {Object} boundingBox - {xMin, yMin, xMax, yMax} bounding box of input data
|
|
37
|
+
*
|
|
38
|
+
* @returns {object} - grid data, cell dimension
|
|
39
|
+
*/
|
|
40
|
+
export function pointToDensityGridDataCPU(props, aggregationParams) {
|
|
41
|
+
const hashInfo = pointsToGridHashing(props, aggregationParams);
|
|
42
|
+
const result = getGridLayerDataFromGridHash(hashInfo);
|
|
43
|
+
return {
|
|
44
|
+
gridHash: hashInfo.gridHash,
|
|
45
|
+
gridOffset: hashInfo.gridOffset,
|
|
46
|
+
data: result
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Project points into each cell, return a hash table of cells
|
|
51
|
+
* @param {Iterable} points
|
|
52
|
+
* @param {number} cellSize - unit size in meters
|
|
53
|
+
* @param {function} getPosition - position accessor
|
|
54
|
+
* @returns {object} - grid hash and cell dimension
|
|
55
|
+
*/
|
|
56
|
+
/* eslint-disable max-statements, complexity */
|
|
57
|
+
function pointsToGridHashing(props, aggregationParams) {
|
|
58
|
+
const { data = [], cellSize } = props;
|
|
59
|
+
const { attributes, viewport, projectPoints, numInstances } = aggregationParams;
|
|
60
|
+
const positions = attributes.positions.value;
|
|
61
|
+
const { size } = attributes.positions.getAccessor();
|
|
62
|
+
const boundingBox = aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);
|
|
63
|
+
const offsets = aggregationParams.posOffset || [180, 90];
|
|
64
|
+
const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);
|
|
65
|
+
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
|
|
66
|
+
return { gridHash: {}, gridOffset };
|
|
67
|
+
}
|
|
68
|
+
const { width, height } = viewport;
|
|
69
|
+
const numCol = Math.ceil(width / gridOffset.xOffset);
|
|
70
|
+
const numRow = Math.ceil(height / gridOffset.yOffset);
|
|
71
|
+
// calculate count per cell
|
|
72
|
+
const gridHash = {};
|
|
73
|
+
const { iterable, objectInfo } = createIterable(data);
|
|
74
|
+
const position = new Array(3);
|
|
75
|
+
for (const pt of iterable) {
|
|
76
|
+
objectInfo.index++;
|
|
77
|
+
position[0] = positions[objectInfo.index * size];
|
|
78
|
+
position[1] = positions[objectInfo.index * size + 1];
|
|
79
|
+
position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;
|
|
80
|
+
const [x, y] = projectPoints ? viewport.project(position) : position;
|
|
81
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
82
|
+
const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);
|
|
83
|
+
const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);
|
|
84
|
+
if (!projectPoints ||
|
|
85
|
+
// when doing screen space agggregation (projectPoints = true), filter points outside of the viewport range.
|
|
86
|
+
(xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow)) {
|
|
87
|
+
const key = `${yIndex}-${xIndex}`;
|
|
88
|
+
gridHash[key] = gridHash[key] || { count: 0, points: [], lonIdx: xIndex, latIdx: yIndex };
|
|
89
|
+
gridHash[key].count += 1;
|
|
90
|
+
gridHash[key].points.push({
|
|
91
|
+
source: pt,
|
|
92
|
+
index: objectInfo.index
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { gridHash, gridOffset, offsets: [offsets[0] * -1, offsets[1] * -1] };
|
|
98
|
+
}
|
|
99
|
+
/* eslint-enable max-statements, complexity */
|
|
100
|
+
function getGridLayerDataFromGridHash({ gridHash, gridOffset, offsets }) {
|
|
101
|
+
const data = new Array(Object.keys(gridHash).length);
|
|
102
|
+
let i = 0;
|
|
103
|
+
for (const key in gridHash) {
|
|
104
|
+
const idxs = key.split('-');
|
|
105
|
+
const latIdx = parseInt(idxs[0], 10);
|
|
106
|
+
const lonIdx = parseInt(idxs[1], 10);
|
|
107
|
+
const index = i++;
|
|
108
|
+
data[index] = {
|
|
109
|
+
index,
|
|
110
|
+
position: [
|
|
111
|
+
offsets[0] + gridOffset.xOffset * lonIdx,
|
|
112
|
+
offsets[1] + gridOffset.yOffset * latIdx
|
|
113
|
+
],
|
|
114
|
+
...gridHash[key]
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
// Calculate bounding box of position attribute
|
|
120
|
+
function getPositionBoundingBox(positionAttribute, numInstance) {
|
|
121
|
+
// TODO - value might not exist (e.g. attribute transition)
|
|
122
|
+
const positions = positionAttribute.value;
|
|
123
|
+
const { size } = positionAttribute.getAccessor();
|
|
124
|
+
let yMin = Infinity;
|
|
125
|
+
let yMax = -Infinity;
|
|
126
|
+
let xMin = Infinity;
|
|
127
|
+
let xMax = -Infinity;
|
|
128
|
+
let y;
|
|
129
|
+
let x;
|
|
130
|
+
for (let i = 0; i < numInstance; i++) {
|
|
131
|
+
x = positions[i * size];
|
|
132
|
+
y = positions[i * size + 1];
|
|
133
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
134
|
+
yMin = y < yMin ? y : yMin;
|
|
135
|
+
yMax = y > yMax ? y : yMax;
|
|
136
|
+
xMin = x < xMin ? x : xMin;
|
|
137
|
+
xMax = x > xMax ? x : xMax;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { xMin, xMax, yMin, yMax };
|
|
141
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare const _default: "#version 300 es\n#define SHADER_NAME gpu-grid-cell-layer-fragment-shader\n\nprecision highp float;\n\nin vec4 vColor;\n\nout vec4 fragColor;\n\nvoid main(void) {\n fragColor = vColor;\n fragColor = picking_filterColor(fragColor);\n}\n";
|
|
2
2
|
export default _default;
|
|
3
3
|
//# sourceMappingURL=gpu-grid-cell-layer-fragment.glsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpu-grid-cell-layer-fragment.glsl.d.ts","sourceRoot":"","sources":["../../src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.
|
|
1
|
+
{"version":3,"file":"gpu-grid-cell-layer-fragment.glsl.d.ts","sourceRoot":"","sources":["../../src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts"],"names":[],"mappings":";AAoBA,wBAcE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
export default `\
|
|
21
|
+
#version 300 es
|
|
22
|
+
#define SHADER_NAME gpu-grid-cell-layer-fragment-shader
|
|
23
|
+
|
|
24
|
+
precision highp float;
|
|
25
|
+
|
|
26
|
+
in vec4 vColor;
|
|
27
|
+
|
|
28
|
+
out vec4 fragColor;
|
|
29
|
+
|
|
30
|
+
void main(void) {
|
|
31
|
+
fragColor = vColor;
|
|
32
|
+
fragColor = picking_filterColor(fragColor);
|
|
33
|
+
}
|
|
34
|
+
`;
|