@deck.gl/aggregation-layers 8.8.0-beta.4 → 8.8.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 +8 -3
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/package.json +2 -2
- package/src/contour-layer/contour-layer.ts +2 -0
- package/src/cpu-grid-layer/cpu-grid-layer.ts +1 -0
- package/src/gpu-grid-layer/gpu-grid-layer.ts +1 -3
- package/src/grid-layer/grid-layer.ts +1 -0
- package/src/heatmap-layer/heatmap-layer.ts +1 -0
- package/src/hexagon-layer/hexagon-layer.ts +1 -0
- package/src/screen-grid-layer/screen-grid-layer.ts +1 -0
- package/typed/contour-layer/contour-layer.d.ts +1 -0
- package/typed/contour-layer/contour-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +1 -0
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +1 -3
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
- package/typed/grid-layer/grid-layer.d.ts +1 -0
- package/typed/grid-layer/grid-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.d.ts +1 -0
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-layer.d.ts +1 -0
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer.d.ts +1 -0
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/dist/es5/aggregation-layer.md +0 -54
- package/dist/es5/grid-aggregation-layer.md +0 -46
- package/dist/esm/aggregation-layer.md +0 -54
- package/dist/esm/grid-aggregation-layer.md +0 -46
- package/src/aggregation-layer.md +0 -54
- package/src/grid-aggregation-layer.md +0 -46
package/dist/dist.dev.js
CHANGED
|
@@ -15875,6 +15875,7 @@ const DIMENSIONS = {
|
|
|
15875
15875
|
};
|
|
15876
15876
|
/** All properties supported by ContourLayer. */
|
|
15877
15877
|
|
|
15878
|
+
/** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */
|
|
15878
15879
|
class ContourLayer extends _grid_aggregation_layer__WEBPACK_IMPORTED_MODULE_6__["default"] {
|
|
15879
15880
|
initializeState() {
|
|
15880
15881
|
super.initializeAggregationLayer({
|
|
@@ -16867,6 +16868,7 @@ const defaultProps = {
|
|
|
16867
16868
|
};
|
|
16868
16869
|
/** All properties supported by CPUGridLayer. */
|
|
16869
16870
|
|
|
16871
|
+
/** Aggregate data into a grid-based heatmap. Aggregation is performed on CPU. */
|
|
16870
16872
|
class CPUGridLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["default"] {
|
|
16871
16873
|
initializeState() {
|
|
16872
16874
|
const cpuAggregator = new _utils_cpu_aggregator__WEBPACK_IMPORTED_MODULE_4__["default"]({
|
|
@@ -17716,9 +17718,7 @@ const DIMENSIONS = {
|
|
|
17716
17718
|
const POSITION_ATTRIBUTE_NAME = 'positions';
|
|
17717
17719
|
/** All properties supported by GPUGridLayer. */
|
|
17718
17720
|
|
|
17719
|
-
/**
|
|
17720
|
-
* The `GPUGridLayer` renders a grid heatmap based on an array of inputs.
|
|
17721
|
-
*/
|
|
17721
|
+
/** Aggregate data into a grid-based heatmap. Aggregation is performed on GPU (WebGL2 only). */
|
|
17722
17722
|
class GPUGridLayer extends _grid_aggregation_layer__WEBPACK_IMPORTED_MODULE_8__["default"] {
|
|
17723
17723
|
initializeState({
|
|
17724
17724
|
gl
|
|
@@ -18397,6 +18397,7 @@ const defaultProps = { ..._gpu_grid_layer_gpu_grid_layer__WEBPACK_IMPORTED_MODUL
|
|
|
18397
18397
|
};
|
|
18398
18398
|
/** All properties supported by GridLayer. */
|
|
18399
18399
|
|
|
18400
|
+
/** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
|
|
18400
18401
|
class GridLayer extends _deck_gl_core__WEBPACK_IMPORTED_MODULE_0__["CompositeLayer"] {
|
|
18401
18402
|
constructor(...args) {
|
|
18402
18403
|
super(...args);
|
|
@@ -18708,6 +18709,8 @@ const DIMENSIONS = {
|
|
|
18708
18709
|
props: ['radiusPixels']
|
|
18709
18710
|
}
|
|
18710
18711
|
};
|
|
18712
|
+
|
|
18713
|
+
/** Visualizes the spatial distribution of data. */
|
|
18711
18714
|
class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["default"] {
|
|
18712
18715
|
constructor(...args) {
|
|
18713
18716
|
super(...args);
|
|
@@ -19960,6 +19963,7 @@ const defaultProps = {
|
|
|
19960
19963
|
};
|
|
19961
19964
|
/** All properties supported by by HexagonLayer. */
|
|
19962
19965
|
|
|
19966
|
+
/** Aggregates data into a hexagon-based heatmap. The color and height of a hexagon are determined based on the objects it contains. */
|
|
19963
19967
|
class HexagonLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_4__["default"] {
|
|
19964
19968
|
constructor(...args) {
|
|
19965
19969
|
super(...args);
|
|
@@ -20674,6 +20678,7 @@ const DIMENSIONS = {
|
|
|
20674
20678
|
};
|
|
20675
20679
|
/** All properties supported by ScreenGridLayer. */
|
|
20676
20680
|
|
|
20681
|
+
/** Aggregates data into histogram bins and renders them as a grid. */
|
|
20677
20682
|
class ScreenGridLayer extends _grid_aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["default"] {
|
|
20678
20683
|
constructor(...args) {
|
|
20679
20684
|
super(...args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contour-layer/contour-layer.ts"],"names":["DEFAULT_COLOR","DEFAULT_STROKE_WIDTH","DEFAULT_THRESHOLD","defaultProps","cellSize","type","min","max","value","getPosition","x","position","getWeight","gpuAggregation","aggregation","contours","threshold","zOffset","POSITION_ATTRIBUTE_NAME","DIMENSIONS","data","props","weights","accessors","ContourLayer","dimensions","setState","contourData","projectPoints","count","size","operation","AGGREGATION_OPERATION","SUM","attributeManager","getAttributeManager","add","accessor","fp64","use64bitPositions","opts","contoursChanged","oldProps","aggregationDirty","state","_updateThresholdData","getNumInstances","_generateContours","contourSegments","contourPolygons","LinesSubLayerClass","getSubLayerClass","LineLayer","BandsSubLayerClass","SolidPolygonLayer","lineLayer","length","getSubLayerProps","id","getSourcePosition","d","start","getTargetPosition","end","getColor","contour","color","getWidth","strokeWidth","bandsLayer","getPolygon","vertices","getFillColor","coordinateSystem","viewport","context","cellSizeChanged","GPUGridAggregator","isSupported","gl","log","warn","gpuAggregationChanged","positionsChanged","isAttributeChanged","boundingBox","getAttributes","gridOffset","translation","width","height","numCol","numRow","allocateResources","posOffset","slice","gridOrigin","aggregationDataDirty","isAggregationDirty","dimension","compareAll","aggregationWeightsDirty","_updateAccessors","_resetResults","getValue","aggregationData","thresholdData","aggregationBuffer","getData","getCellData","countsData","cellWeights","gridSize","xOffset","yOffset","Array","i","zIndex","GridAggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AACA;;AACA;;AAWA;;AACA;;AACA;;AACA;;;;;;AAEA,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AAAA,OAAO,EAAPA,OADiB;AAEjBoD,UAAAA,MAAM,EAAEpD,OAAO,CAACoD,MAAR,IAAkBD,CAFT;AAGjBnG,UAAAA,OAAO,EAAPA;AAHiB,SAAnB;AAKD;;AACD,WAAKS,QAAL,CAAc;AAACgF,QAAAA,aAAa,EAAbA;AAAD,OAAd;AACD;;;EA5NsEY,6B;;;8BAApD9F,Y,eAGA,c;8BAHAA,Y,kBAIGrB,Y","sourcesContent":["// Copyright (c) 2015 - 2018 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport GL from '@luma.gl/constants';\nimport {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';\nimport {generateContours} from './contour-utils';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Layer,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\n\nconst DEFAULT_COLOR = [255, 255, 255, 255];\nconst DEFAULT_STROKE_WIDTH = 1;\nconst DEFAULT_THRESHOLD = 1;\n\nconst defaultProps: DefaultProps<ContourLayerProps> = {\n // grid aggregation\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n gpuAggregation: true,\n aggregation: 'SUM',\n\n // contour lines\n contours: [{threshold: DEFAULT_THRESHOLD}],\n\n zOffset: 0.005\n};\n\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize']\n },\n weights: {\n props: ['aggregation'],\n accessors: ['getWeight']\n }\n};\n\n/** All properties supported by ContourLayer. */\nexport type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by ContourLayer. */\nexport type _ContourLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default true\n */\n gpuAggregation?: boolean;\n\n /**\n * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Definition of contours to be drawn.\n * @default [{threshold: 1}]\n */\n contours: {\n /**\n * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.\n *\n * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.\n */\n threshold: number | number[];\n\n /**\n * RGBA color array to be used to render the contour.\n * @default [255, 255, 255, 255]\n */\n color?: Color;\n\n /**\n * Applicable for `Isoline`s only, width of the Isoline in pixels.\n * @default 1\n */\n strokeWidth?: number;\n\n /** Defines z order of the contour. */\n zIndex?: number;\n }[];\n\n /**\n * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).\n * @default 0.005\n */\n zOffset?: number;\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of each object.\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\nexport default class ContourLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<\n ExtraPropsT & Required<_ContourLayerProps<DataT>>\n> {\n static layerName = 'ContourLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n contourData: {},\n projectPoints: false,\n weights: {\n count: {\n size: 1,\n operation: AGGREGATION_OPERATION.SUM\n }\n }\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n // this attribute is used in gpu aggregation path only\n count: {size: 3, accessor: 'getWeight'}\n });\n }\n\n updateState(opts: UpdateParameters<this>): void {\n super.updateState(opts);\n let contoursChanged = false;\n const {oldProps, props} = opts;\n const {aggregationDirty} = this.state;\n\n if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {\n contoursChanged = true;\n this._updateThresholdData(opts.props);\n }\n\n if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {\n this._generateContours();\n }\n }\n\n renderLayers(): Layer[] {\n const {contourSegments, contourPolygons} = this.state.contourData;\n\n const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);\n const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);\n\n // Contour lines layer\n const lineLayer =\n contourSegments &&\n contourSegments.length > 0 &&\n new LinesSubLayerClass(\n this.getSubLayerProps({\n id: 'lines'\n }),\n {\n data: this.state.contourData.contourSegments,\n getSourcePosition: d => d.start,\n getTargetPosition: d => d.end,\n getColor: d => d.contour.color || DEFAULT_COLOR,\n getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH\n }\n );\n\n // Contour bands layer\n const bandsLayer =\n contourPolygons &&\n contourPolygons.length > 0 &&\n new BandsSubLayerClass(\n this.getSubLayerProps({\n id: 'bands'\n }),\n {\n data: this.state.contourData.contourPolygons,\n getPolygon: d => d.vertices,\n getFillColor: d => d.contour.color || DEFAULT_COLOR\n }\n );\n\n return [lineLayer, bandsLayer];\n }\n\n // Aggregation Overrides\n\n /* eslint-disable max-statements, complexity */\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n let gpuAggregation = props.gpuAggregation;\n if (this.state.gpuAggregation !== props.gpuAggregation) {\n if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.gl)) {\n log.warn('GPU Grid Aggregation not supported, falling back to CPU')();\n gpuAggregation = false;\n }\n }\n const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;\n this.setState({\n gpuAggregation\n });\n\n const {dimensions} = this.state;\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n const {data, weights} = dimensions;\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n boundingBox,\n translation,\n posOffset: translation.slice(), // Used for CPU aggregation, to offset points\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n positionsChanged ||\n gpuAggregationChanged ||\n this.isAggregationDirty(opts, {\n dimension: data,\n compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation\n });\n const aggregationWeightsDirty = this.isAggregationDirty(opts, {\n dimension: weights\n });\n\n if (aggregationWeightsDirty) {\n this._updateAccessors(opts);\n }\n if (aggregationDataDirty || aggregationWeightsDirty) {\n this._resetResults();\n }\n this.setState({\n aggregationDataDirty,\n aggregationWeightsDirty\n });\n }\n /* eslint-enable max-statements, complexity */\n\n // Private (Aggregation)\n\n private _updateAccessors(opts) {\n const {getWeight, aggregation, data} = opts.props;\n const {count} = this.state.weights;\n if (count) {\n count.getWeight = getWeight;\n count.operation = AGGREGATION_OPERATION[aggregation];\n }\n this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});\n }\n\n private _resetResults() {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = null;\n }\n }\n\n // Private (Contours)\n\n private _generateContours() {\n const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;\n const {count} = this.state.weights;\n let {aggregationData} = count;\n if (!aggregationData) {\n aggregationData = count.aggregationBuffer.getData();\n count.aggregationData = aggregationData;\n }\n\n const {cellWeights} = GPUGridAggregator.getCellData({countsData: aggregationData});\n const contourData = generateContours({\n thresholdData,\n cellWeights,\n gridSize: [numCol, numRow],\n gridOrigin,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset]\n });\n\n // contourData contains both iso-lines and iso-bands if requested.\n this.setState({contourData});\n }\n\n private _updateThresholdData(props) {\n const {contours, zOffset} = props;\n const count = contours.length;\n const thresholdData = new Array(count);\n for (let i = 0; i < count; i++) {\n const contour = contours[i];\n thresholdData[i] = {\n contour,\n zIndex: contour.zIndex || i,\n zOffset\n };\n }\n this.setState({thresholdData});\n }\n}\n"],"file":"contour-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/contour-layer/contour-layer.ts"],"names":["DEFAULT_COLOR","DEFAULT_STROKE_WIDTH","DEFAULT_THRESHOLD","defaultProps","cellSize","type","min","max","value","getPosition","x","position","getWeight","gpuAggregation","aggregation","contours","threshold","zOffset","POSITION_ATTRIBUTE_NAME","DIMENSIONS","data","props","weights","accessors","ContourLayer","dimensions","setState","contourData","projectPoints","count","size","operation","AGGREGATION_OPERATION","SUM","attributeManager","getAttributeManager","add","accessor","fp64","use64bitPositions","opts","contoursChanged","oldProps","aggregationDirty","state","_updateThresholdData","getNumInstances","_generateContours","contourSegments","contourPolygons","LinesSubLayerClass","getSubLayerClass","LineLayer","BandsSubLayerClass","SolidPolygonLayer","lineLayer","length","getSubLayerProps","id","getSourcePosition","d","start","getTargetPosition","end","getColor","contour","color","getWidth","strokeWidth","bandsLayer","getPolygon","vertices","getFillColor","coordinateSystem","viewport","context","cellSizeChanged","GPUGridAggregator","isSupported","gl","log","warn","gpuAggregationChanged","positionsChanged","isAttributeChanged","boundingBox","getAttributes","gridOffset","translation","width","height","numCol","numRow","allocateResources","posOffset","slice","gridOrigin","aggregationDataDirty","isAggregationDirty","dimension","compareAll","aggregationWeightsDirty","_updateAccessors","_resetResults","getValue","aggregationData","thresholdData","aggregationBuffer","getData","getCellData","countsData","cellWeights","gridSize","xOffset","yOffset","Array","i","zIndex","GridAggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AACA;;AACA;;AAWA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAAtB;AACA,IAAMC,oBAAoB,GAAG,CAA7B;AACA,IAAMC,iBAAiB,GAAG,CAA1B;AAEA,IAAMC,YAA6C,GAAG;AAEpDC,EAAAA,QAAQ,EAAE;AAACC,IAAAA,IAAI,EAAE,QAAP;AAAiBC,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,IAA9B;AAAoCC,IAAAA,KAAK,EAAE;AAA3C,GAF0C;AAGpDC,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aining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport GL from '@luma.gl/constants';\nimport {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';\nimport {generateContours} from './contour-utils';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Layer,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\n\nconst DEFAULT_COLOR = [255, 255, 255, 255];\nconst DEFAULT_STROKE_WIDTH = 1;\nconst DEFAULT_THRESHOLD = 1;\n\nconst defaultProps: DefaultProps<ContourLayerProps> = {\n // grid aggregation\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n gpuAggregation: true,\n aggregation: 'SUM',\n\n // contour lines\n contours: [{threshold: DEFAULT_THRESHOLD}],\n\n zOffset: 0.005\n};\n\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize']\n },\n weights: {\n props: ['aggregation'],\n accessors: ['getWeight']\n }\n};\n\n/** All properties supported by ContourLayer. */\nexport type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by ContourLayer. */\nexport type _ContourLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default true\n */\n gpuAggregation?: boolean;\n\n /**\n * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Definition of contours to be drawn.\n * @default [{threshold: 1}]\n */\n contours: {\n /**\n * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.\n *\n * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.\n */\n threshold: number | number[];\n\n /**\n * RGBA color array to be used to render the contour.\n * @default [255, 255, 255, 255]\n */\n color?: Color;\n\n /**\n * Applicable for `Isoline`s only, width of the Isoline in pixels.\n * @default 1\n */\n strokeWidth?: number;\n\n /** Defines z order of the contour. */\n zIndex?: number;\n }[];\n\n /**\n * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).\n * @default 0.005\n */\n zOffset?: number;\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of each object.\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */\nexport default class ContourLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<\n ExtraPropsT & Required<_ContourLayerProps<DataT>>\n> {\n static layerName = 'ContourLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n contourData: {},\n projectPoints: false,\n weights: {\n count: {\n size: 1,\n operation: AGGREGATION_OPERATION.SUM\n }\n }\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n // this attribute is used in gpu aggregation path only\n count: {size: 3, accessor: 'getWeight'}\n });\n }\n\n updateState(opts: UpdateParameters<this>): void {\n super.updateState(opts);\n let contoursChanged = false;\n const {oldProps, props} = opts;\n const {aggregationDirty} = this.state;\n\n if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {\n contoursChanged = true;\n this._updateThresholdData(opts.props);\n }\n\n if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {\n this._generateContours();\n }\n }\n\n renderLayers(): Layer[] {\n const {contourSegments, contourPolygons} = this.state.contourData;\n\n const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);\n const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);\n\n // Contour lines layer\n const lineLayer =\n contourSegments &&\n contourSegments.length > 0 &&\n new LinesSubLayerClass(\n this.getSubLayerProps({\n id: 'lines'\n }),\n {\n data: this.state.contourData.contourSegments,\n getSourcePosition: d => d.start,\n getTargetPosition: d => d.end,\n getColor: d => d.contour.color || DEFAULT_COLOR,\n getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH\n }\n );\n\n // Contour bands layer\n const bandsLayer =\n contourPolygons &&\n contourPolygons.length > 0 &&\n new BandsSubLayerClass(\n this.getSubLayerProps({\n id: 'bands'\n }),\n {\n data: this.state.contourData.contourPolygons,\n getPolygon: d => d.vertices,\n getFillColor: d => d.contour.color || DEFAULT_COLOR\n }\n );\n\n return [lineLayer, bandsLayer];\n }\n\n // Aggregation Overrides\n\n /* eslint-disable max-statements, complexity */\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n let gpuAggregation = props.gpuAggregation;\n if (this.state.gpuAggregation !== props.gpuAggregation) {\n if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.gl)) {\n log.warn('GPU Grid Aggregation not supported, falling back to CPU')();\n gpuAggregation = false;\n }\n }\n const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;\n this.setState({\n gpuAggregation\n });\n\n const {dimensions} = this.state;\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n const {data, weights} = dimensions;\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n boundingBox,\n translation,\n posOffset: translation.slice(), // Used for CPU aggregation, to offset points\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n positionsChanged ||\n gpuAggregationChanged ||\n this.isAggregationDirty(opts, {\n dimension: data,\n compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation\n });\n const aggregationWeightsDirty = this.isAggregationDirty(opts, {\n dimension: weights\n });\n\n if (aggregationWeightsDirty) {\n this._updateAccessors(opts);\n }\n if (aggregationDataDirty || aggregationWeightsDirty) {\n this._resetResults();\n }\n this.setState({\n aggregationDataDirty,\n aggregationWeightsDirty\n });\n }\n /* eslint-enable max-statements, complexity */\n\n // Private (Aggregation)\n\n private _updateAccessors(opts) {\n const {getWeight, aggregation, data} = opts.props;\n const {count} = this.state.weights;\n if (count) {\n count.getWeight = getWeight;\n count.operation = AGGREGATION_OPERATION[aggregation];\n }\n this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});\n }\n\n private _resetResults() {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = null;\n }\n }\n\n // Private (Contours)\n\n private _generateContours() {\n const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;\n const {count} = this.state.weights;\n let {aggregationData} = count;\n if (!aggregationData) {\n aggregationData = count.aggregationBuffer.getData();\n count.aggregationData = aggregationData;\n }\n\n const {cellWeights} = GPUGridAggregator.getCellData({countsData: aggregationData});\n const contourData = generateContours({\n thresholdData,\n cellWeights,\n gridSize: [numCol, numRow],\n gridOrigin,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset]\n });\n\n // contourData contains both iso-lines and iso-bands if requested.\n this.setState({contourData});\n }\n\n private _updateThresholdData(props) {\n const {contours, zOffset} = props;\n const count = contours.length;\n const thresholdData = new Array(count);\n for (let i = 0; i < count; i++) {\n const contour = contours[i];\n thresholdData[i] = {\n contour,\n zIndex: contour.zIndex || i,\n zOffset\n };\n }\n this.setState({thresholdData});\n }\n}\n"],"file":"contour-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cpu-grid-layer/cpu-grid-layer.ts"],"names":["nop","defaultProps","colorDomain","colorRange","defaultColorRange","getColorValue","type","value","getColorWeight","colorAggregation","lowerPercentile","min","max","upperPercentile","colorScaleType","onSetColorDomain","elevationDomain","elevationRange","getElevationValue","getElevationWeight","elevationAggregation","elevationLowerPercentile","elevationUpperPercentile","elevationScale","elevationScaleType","onSetElevationDomain","gridAggregator","pointToDensityGridDataCPU","cellSize","coverage","getPosition","x","position","extruded","material","_filterData","optional","CPUGridLayer","cpuAggregator","CPUAggregator","getAggregator","props","getCellSize","state","aggregatorState","attributeManager","getAttributeManager","add","positions","size","accessor","opts","setState","updateState","viewport","context","attributes","getAttributes","numInstances","getNumInstances","info","getPickingInfo","cell","getAccessor","getUpdateTriggers","transitions","SubLayerClass","getSubLayerClass","GridCellLayer","updateTriggers","_getSublayerUpdateTriggers","getFillColor","_onGetSublayerColor","bind","getElevation","_onGetSublayerElevation","getSubLayerProps","id","data","layerData","AggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AAGA;;AACA;;AACA;;AACA;;;;;;AAOA,SAASA,GAAT,GAAe,CAAE;;AAEjB,IAAMC,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEC,6BAHwC;AAIpDC,EAAAA,aAAa,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJqC;AAKpDC,EAAAA,cAAc,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GALoC;AAMpDE,EAAAA,gBAAgB,EAAE,KANkC;AAOpDC,EAAAA,eAAe,EAAE;AAACJ,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,GAA9B;AAAmCL,IAAAA,KAAK,EAAE;AAA1C,GAPmC;AAQpDM,EAAAA,eAAe,EAAE;AAACP,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,GAA9B;AAAmCL,IAAAA,KAAK,EAAE;AAA1C,GARmC;AASpDO,EAAAA,cAAc,EAAE,UAToC;AAUpDC,EAAAA,gBAAgB,EAAEf,GAVkC;AAapDgB,EAAAA,eAAe,EAAE,IAbmC;AAcpDC,EAAAA,cAAc,EAAE,CAAC,CAAD,EAAI,IAAJ,CAdoC;AAepDC,EAAA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KEU,QAAAA,QAAQ,EAARA,QALF;AAOEsC,QAAAA,YAAY,EAAE,KAAKC,mBAAL,CAAyBC,IAAzB,CAA8B,IAA9B,CAPhB;AAQEC,QAAAA,YAAY,EAAE,KAAKC,uBAAL,CAA6BF,IAA7B,CAAkC,IAAlC,CARhB;AASER,QAAAA,WAAW,EAAEA,WAAW,IAAI;AAC1BM,UAAAA,YAAY,EAAEN,WAAW,CAAC5D,aAAZ,IAA6B4D,WAAW,CAACzD,cAD7B;AAE1BkE,UAAAA,YAAY,EAAET,WAAW,CAAC/C,iBAAZ,IAAiC+C,WAAW,CAAC9C;AAFjC;AAT9B,OADK,EAeL,KAAKyD,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,EAAE,WADgB;AAEpBR,QAAAA,cAAc,EAAdA;AAFoB,OAAtB,CAfK,EAmBL;AACES,QAAAA,IAAI,EAAExC,aAAa,CAACK,KAAd,CAAoBoC,SAApB,CAA8BD;AADtC,OAnBK,CAAP;AAuBD;;;EAnFsEE,yB;;;8BAApD3C,Y,eAGA,c;8BAHAA,Y,kBAIGpC,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport GL from '@luma.gl/constants';\nimport {GridCellLayer} from '@deck.gl/layers';\nimport {Accessor, AccessorFunction, Color, Position, Material, DefaultProps} from '@deck.gl/core';\n\nimport {defaultColorRange} from '../utils/color-utils';\nimport {pointToDensityGridDataCPU} from './grid-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\n\nimport Layer, {UpdateParameters} from 'modules/core/src/lib/layer';\nimport {GetPickingInfoParams, PickingInfo} from 'modules/core/src/lib/picking/pick-info';\nimport {AggregateAccessor} from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction nop() {}\n\nconst defaultProps: DefaultProps<CPUGridLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n upperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n colorScaleType: 'quantize',\n onSetColorDomain: nop,\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n elevationScale: {type: 'number', min: 0, value: 1},\n elevationScaleType: 'linear',\n onSetElevationDomain: nop,\n\n gridAggregator: pointToDensityGridDataCPU,\n\n // grid\n cellSize: {type: 'number', min: 0, max: 1000, value: 1000},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n getPosition: {type: 'accessor', value: x => x.position},\n extruded: false,\n\n // Optional material for 'lighting' shader module\n material: true,\n\n // data filter\n _filterData: {type: 'function', value: null, optional: true}\n};\n\n/** All properties supported by CPUGridLayer. */\nexport type CPUGridLayerProps<DataT = any> = _CPUGridLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\n/** Properties added by CPUGridLayer. */\nexport type _CPUGridLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * Color scale domain, default is set to the extent of aggregated weights in each cell.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`\n */\n colorRange?: Color[];\n\n /**\n * Cell size multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Cell elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default true\n */\n extruded?: boolean;\n\n /**\n * Filter cells and re-calculate color by `upperPercentile`.\n * Cells with value arger than the upperPercentile will be hidden.\n * @default 100\n */\n upperPercentile?: number;\n\n /**\n * Filter cells and re-calculate color by `lowerPercentile`.\n * Cells with value smaller than the lowerPercentile will be hidden.\n * @default 0\n */\n lowerPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationUpperPercentile`.\n * Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.\n * @default 100\n */\n elevationUpperPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationLowerPercentile`.\n * Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.\n * @default 0\n */\n elevationLowerPercentile?: number;\n\n /**\n * Scaling function used to determine the color of the grid cell, default value is 'quantize'.\n * Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.\n * @default 'quantize'\n */\n colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';\n\n /**\n * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.\n */\n elevationScaleType?: 'linear';\n\n // TODO - document\n gridAggregator?: (props: any, params: any) => any;\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a cell.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.\n * @default null\n */\n getColorValue?: AggregateAccessor<DataT> | null;\n\n /**\n * The weight of a data object used to calculate the elevation value for a cell.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.\n * @default null\n */\n getElevationValue?: AggregateAccessor<DataT> | null;\n\n /**\n * This callback will be called when bin color domain has been calculated.\n * @default () => {}\n */\n onSetColorDomain?: (minMax: [number, number]) => void;\n\n /**\n * This callback will be called when bin elevation domain has been calculated.\n * @default () => {}\n */\n onSetElevationDomain?: (minMax: [number, number]) => void;\n\n /**\n * (Experimental) Filter data objects\n */\n _filterData: null | ((d: DataT) => boolean);\n};\n\nexport default class CPUGridLayer<DataT = any, ExtraPropsT = {}> extends AggregationLayer<\n ExtraPropsT & Required<_CPUGridLayerProps<DataT>>\n> {\n static layerName = 'CPUGridLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n const cpuAggregator = new CPUAggregator({\n getAggregator: props => props.gridAggregator,\n getCellSize: props => props.cellSize\n });\n\n this.state = {\n cpuAggregator,\n aggregatorState: cpuAggregator.state\n };\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}\n });\n // color and elevation attributes can't be added as attributes\n // they are calcualted using 'getValue' accessor that takes an array of pints.\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n this.setState({\n // make a copy of the internal state of cpuAggregator for testing\n aggregatorState: this.state.cpuAggregator.updateState(opts, {\n viewport: this.context.viewport,\n attributes: this.getAttributes(),\n numInstances: this.getNumInstances()\n })\n });\n }\n\n getPickingInfo({info}: GetPickingInfoParams): PickingInfo {\n return this.state.cpuAggregator.getPickingInfo({info});\n }\n\n // create a method for testing\n _onGetSublayerColor(cell) {\n return this.state.cpuAggregator.getAccessor('fillColor')(cell);\n }\n\n // create a method for testing\n _onGetSublayerElevation(cell) {\n return this.state.cpuAggregator.getAccessor('elevation')(cell);\n }\n\n _getSublayerUpdateTriggers() {\n return this.state.cpuAggregator.getUpdateTriggers(this.props);\n }\n\n renderLayers(): Layer {\n const {elevationScale, extruded, cellSize, coverage, material, transitions} = this.props;\n const {cpuAggregator} = this.state;\n const SubLayerClass = this.getSubLayerClass('grid-cell', GridCellLayer);\n const updateTriggers = this._getSublayerUpdateTriggers();\n\n return new SubLayerClass(\n {\n cellSize,\n coverage,\n material,\n elevationScale,\n extruded,\n\n getFillColor: this._onGetSublayerColor.bind(this),\n getElevation: this._onGetSublayerElevation.bind(this),\n transitions: transitions && {\n getFillColor: transitions.getColorValue || transitions.getColorWeight,\n getElevation: transitions.getElevationValue || transitions.getElevationWeight\n }\n },\n this.getSubLayerProps({\n id: 'grid-cell',\n updateTriggers\n }),\n {\n data: cpuAggregator.state.layerData.data\n }\n );\n }\n}\n"],"file":"cpu-grid-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cpu-grid-layer/cpu-grid-layer.ts"],"names":["nop","defaultProps","colorDomain","colorRange","defaultColorRange","getColorValue","type","value","getColorWeight","colorAggregation","lowerPercentile","min","max","upperPercentile","colorScaleType","onSetColorDomain","elevationDomain","elevationRange","getElevationValue","getElevationWeight","elevationAggregation","elevationLowerPercentile","elevationUpperPercentile","elevationScale","elevationScaleType","onSetElevationDomain","gridAggregator","pointToDensityGridDataCPU","cellSize","coverage","getPosition","x","position","extruded","material","_filterData","optional","CPUGridLayer","cpuAggregator","CPUAggregator","getAggregator","props","getCellSize","state","aggregatorState","attributeManager","getAttributeManager","add","positions","size","accessor","opts","setState","updateState","viewport","context","attributes","getAttributes","numInstances","getNumInstances","info","getPickingInfo","cell","getAccessor","getUpdateTriggers","transitions","SubLayerClass","getSubLayerClass","GridCellLayer","updateTriggers","_getSublayerUpdateTriggers","getFillColor","_onGetSublayerColor","bind","getElevation","_onGetSublayerElevation","getSubLayerProps","id","data","layerData","AggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AAGA;;AACA;;AACA;;AACA;;;;;;AAOA,SAASA,GAAT,GAAe,CAAE;;AAEjB,IAAMC,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEC,6BAHwC;AAIpDC,EAAAA,aAAa,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJqC;AAKpDC,EAAAA,cAAc,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GALoC;AAMpDE,EAAAA,gBAAgB,EAAE,KANkC;AAOpDC,EAAAA,eAAe,EAAE;AAACJ,IAAAA,IAAI,EAAE,QAAP;AAAi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,UAA2CC,QAA3C,eAA2CA,QAA3C;AAAA,UAAqDK,QAArD,eAAqDA,QAArD;AAAA,UAA+D+B,WAA/D,eAA+DA,WAA/D;AACA,UAAO3B,aAAP,GAAwB,KAAKK,KAA7B,CAAOL,aAAP;AACA,UAAM4B,aAAa,GAAG,KAAKC,gBAAL,CAAsB,WAAtB,EAAmCC,qBAAnC,CAAtB;;AACA,UAAMC,cAAc,GAAG,KAAKC,0BAAL,EAAvB;;AAEA,aAAO,IAAIJ,aAAJ,CACL;AACEtC,QAAAA,QAAQ,EAARA,QADF;AAEEC,QAAAA,QAAQ,EAARA,QAFF;AAGEK,QAAAA,QAAQ,EAARA,QAHF;AAIEX,QAAAA,cAAc,EAAdA,cAJF;AAKEU,QAAAA,QAAQ,EAARA,QALF;AAOEsC,QAAAA,YAAY,EAAE,KAAKC,mBAAL,CAAyBC,IAAzB,CAA8B,IAA9B,CAPhB;AAQEC,QAAAA,YAAY,EAAE,KAAKC,uBAAL,CAA6BF,IAA7B,CAAkC,IAAlC,CARhB;AASER,QAAAA,WAAW,EAAEA,WAAW,IAAI;AAC1BM,UAAAA,YAAY,EAAEN,WAAW,CAAC5D,aAAZ,IAA6B4D,WAAW,CAACzD,cAD7B;AAE1BkE,UAAAA,YAAY,EAAET,WAAW,CAAC/C,iBAAZ,IAAiC+C,WAAW,CAAC9C;AAFjC;AAT9B,OADK,EAeL,KAAKyD,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,EAAE,WADgB;AAEpBR,QAAAA,cAAc,EAAdA;AAFoB,OAAtB,CAfK,EAmBL;AACES,QAAAA,IAAI,EAAExC,aAAa,CAACK,KAAd,CAAoBoC,SAApB,CAA8BD;AADtC,OAnBK,CAAP;AAuBD;;;EAnFsEE,yB;;;8BAApD3C,Y,eAGA,c;8BAHAA,Y,kBAIGpC,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport GL from '@luma.gl/constants';\nimport {GridCellLayer} from '@deck.gl/layers';\nimport {Accessor, AccessorFunction, Color, Position, Material, DefaultProps} from '@deck.gl/core';\n\nimport {defaultColorRange} from '../utils/color-utils';\nimport {pointToDensityGridDataCPU} from './grid-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\n\nimport Layer, {UpdateParameters} from 'modules/core/src/lib/layer';\nimport {GetPickingInfoParams, PickingInfo} from 'modules/core/src/lib/picking/pick-info';\nimport {AggregateAccessor} from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction nop() {}\n\nconst defaultProps: DefaultProps<CPUGridLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n upperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n colorScaleType: 'quantize',\n onSetColorDomain: nop,\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n elevationScale: {type: 'number', min: 0, value: 1},\n elevationScaleType: 'linear',\n onSetElevationDomain: nop,\n\n gridAggregator: pointToDensityGridDataCPU,\n\n // grid\n cellSize: {type: 'number', min: 0, max: 1000, value: 1000},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n getPosition: {type: 'accessor', value: x => x.position},\n extruded: false,\n\n // Optional material for 'lighting' shader module\n material: true,\n\n // data filter\n _filterData: {type: 'function', value: null, optional: true}\n};\n\n/** All properties supported by CPUGridLayer. */\nexport type CPUGridLayerProps<DataT = any> = _CPUGridLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\n/** Properties added by CPUGridLayer. */\nexport type _CPUGridLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * Color scale domain, default is set to the extent of aggregated weights in each cell.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`\n */\n colorRange?: Color[];\n\n /**\n * Cell size multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Cell elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default true\n */\n extruded?: boolean;\n\n /**\n * Filter cells and re-calculate color by `upperPercentile`.\n * Cells with value arger than the upperPercentile will be hidden.\n * @default 100\n */\n upperPercentile?: number;\n\n /**\n * Filter cells and re-calculate color by `lowerPercentile`.\n * Cells with value smaller than the lowerPercentile will be hidden.\n * @default 0\n */\n lowerPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationUpperPercentile`.\n * Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.\n * @default 100\n */\n elevationUpperPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationLowerPercentile`.\n * Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.\n * @default 0\n */\n elevationLowerPercentile?: number;\n\n /**\n * Scaling function used to determine the color of the grid cell, default value is 'quantize'.\n * Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.\n * @default 'quantize'\n */\n colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';\n\n /**\n * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.\n */\n elevationScaleType?: 'linear';\n\n // TODO - document\n gridAggregator?: (props: any, params: any) => any;\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a cell.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.\n * @default null\n */\n getColorValue?: AggregateAccessor<DataT> | null;\n\n /**\n * The weight of a data object used to calculate the elevation value for a cell.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.\n * @default null\n */\n getElevationValue?: AggregateAccessor<DataT> | null;\n\n /**\n * This callback will be called when bin color domain has been calculated.\n * @default () => {}\n */\n onSetColorDomain?: (minMax: [number, number]) => void;\n\n /**\n * This callback will be called when bin elevation domain has been calculated.\n * @default () => {}\n */\n onSetElevationDomain?: (minMax: [number, number]) => void;\n\n /**\n * (Experimental) Filter data objects\n */\n _filterData: null | ((d: DataT) => boolean);\n};\n\n/** Aggregate data into a grid-based heatmap. Aggregation is performed on CPU. */\nexport default class CPUGridLayer<DataT = any, ExtraPropsT = {}> extends AggregationLayer<\n ExtraPropsT & Required<_CPUGridLayerProps<DataT>>\n> {\n static layerName = 'CPUGridLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n const cpuAggregator = new CPUAggregator({\n getAggregator: props => props.gridAggregator,\n getCellSize: props => props.cellSize\n });\n\n this.state = {\n cpuAggregator,\n aggregatorState: cpuAggregator.state\n };\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}\n });\n // color and elevation attributes can't be added as attributes\n // they are calcualted using 'getValue' accessor that takes an array of pints.\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n this.setState({\n // make a copy of the internal state of cpuAggregator for testing\n aggregatorState: this.state.cpuAggregator.updateState(opts, {\n viewport: this.context.viewport,\n attributes: this.getAttributes(),\n numInstances: this.getNumInstances()\n })\n });\n }\n\n getPickingInfo({info}: GetPickingInfoParams): PickingInfo {\n return this.state.cpuAggregator.getPickingInfo({info});\n }\n\n // create a method for testing\n _onGetSublayerColor(cell) {\n return this.state.cpuAggregator.getAccessor('fillColor')(cell);\n }\n\n // create a method for testing\n _onGetSublayerElevation(cell) {\n return this.state.cpuAggregator.getAccessor('elevation')(cell);\n }\n\n _getSublayerUpdateTriggers() {\n return this.state.cpuAggregator.getUpdateTriggers(this.props);\n }\n\n renderLayers(): Layer {\n const {elevationScale, extruded, cellSize, coverage, material, transitions} = this.props;\n const {cpuAggregator} = this.state;\n const SubLayerClass = this.getSubLayerClass('grid-cell', GridCellLayer);\n const updateTriggers = this._getSublayerUpdateTriggers();\n\n return new SubLayerClass(\n {\n cellSize,\n coverage,\n material,\n elevationScale,\n extruded,\n\n getFillColor: this._onGetSublayerColor.bind(this),\n getElevation: this._onGetSublayerElevation.bind(this),\n transitions: transitions && {\n getFillColor: transitions.getColorValue || transitions.getColorWeight,\n getElevation: transitions.getElevationValue || transitions.getElevationWeight\n }\n },\n this.getSubLayerProps({\n id: 'grid-cell',\n updateTriggers\n }),\n {\n data: cpuAggregator.state.layerData.data\n }\n );\n }\n}\n"],"file":"cpu-grid-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/gpu-grid-layer/gpu-grid-layer.ts"],"names":["defaultProps","colorDomain","colorRange","defaultColorRange","getColorWeight","type","value","colorAggregation","elevationDomain","elevationRange","getElevationWeight","elevationAggregation","elevationScale","min","cellSize","max","coverage","getPosition","x","position","extruded","material","DIMENSIONS","data","props","POSITION_ATTRIBUTE_NAME","GPUGridLayer","gl","isSupported","GPUGridAggregator","log","error","dimensions","setState","gpuAggregation","projectPoints","weights","color","needMin","needMax","combineMaxMin","maxMinBuffer","Buffer","byteLength","accessor","size","divisor","elevation","positionAttributeName","attributeManager","getAttributeManager","add","fp64","use64bitPositions","opts","state","aggregationDirty","gridHash","index","numRow","numCol","boundingBox","gridOffset","gridSize","gridOrigin","xMin","yMin","xOffset","yOffset","yIndex","Math","floor","xIndex","latIdx","lonIdx","yPos","xPos","info","mode","object","gpuGridAggregator","getPositionForIndex","colorInfo","getAggregationData","pixelIndex","getData","elevationInfo","colorValue","cellWeight","elevationValue","count","cellCount","totalCount","translation","viewport","context","attributes","getAttributes","cpuAggregation","key","getHashKeyForIndex","cpuAggregationData","Object","assign","picked","Boolean","cellSizeMeters","SubLayerClass","getSubLayerClass","GPUGridCellLayer","getSubLayerProps","id","colors","aggregationBuffer","elevations","colorMaxMinBuffer","elevationMaxMinBuffer","numInstances","forEach","weight","delete","oldProps","coordinateSystem","cellSizeChanged","positionsChanged","isAttributeChanged","attributesChanged","getNumInstances","width","height","allocateResources","aggregationDataDirty","isAggregationDirty","dimension","compareAll","_updateAccessors","operation","AGGREGATION_OPERATION","GridAggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA;;AAEA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEC,6BAHwC;AAIpDC,EAAAA,cAAc,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJoC;AAKpDC,EAAAA,gBAAgB,EAAE,KALkC;AAQpDC,EAAAA,eAAe,EAAE,IARmC;AASpDC,EAAAA,cAAc,EAAE,CAAC,CAAD,EAAI,IAAJ,CAToC;AAUpDC,EAAAA,kBAAkB,EAAE;AAACL,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAVgC;AAWpDK,EAAAA,oBAAoB,EAAE,KAX8B;AAYpDC,EAAAA,cAAc,EAAE;AAACP,IAAAA,IAAI,EAAE,QAAP;AAAiBQ,IAAAA,GAAG,EAAE,CAAtB;AAAyBP,IAAAA,KAAK,EAAE;AAAhC,GAZoC;AAepDQ,EAAAA,QAAQ,EAAE;AAACT,IAAAA,IAAI,EAAE,QAAP;AAAiBQ,IAAAA,GAAG,EAAE,CAAtB;AAAyBE,IAAAA,GAAG,EAAE,IAA9B;AAAoCT,IAAAA,KAAK,EAAE;AAA3C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B9H,oBAAtB,CAAtB;AACD;;;EAnRsE+H,6B;;;8BAApDhH,Y,eAGA,c;8BAHAA,Y,kBAIG1B,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {Buffer} from '@luma.gl/core';\nimport GL from '@luma.gl/constants';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Material,\n GetPickingInfoParams,\n LayerContext,\n log,\n PickingInfo,\n Position,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION} from '../utils/aggregation-operation-utils';\nimport {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';\nimport GPUGridCellLayer from './gpu-grid-cell-layer';\nimport {pointToDensityGridDataCPU} from './../cpu-grid-layer/grid-aggregator';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\n\nconst defaultProps: DefaultProps<GPUGridLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationScale: {type: 'number', min: 0, value: 1},\n\n // grid\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n getPosition: {type: 'accessor', value: x => x.position},\n extruded: false,\n\n // Optional material for 'lighting' shader module\n material: true\n};\n\n// This layer only perform GPU aggregation, no need to seperate data and weight props\n// aggregation will be dirty when any of the props are changed.\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize', 'colorAggregation', 'elevationAggregation']\n }\n // rest of the changes are detected by `state.attributesChanged`\n};\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\n/** All properties supported by GPUGridLayer. */\nexport type GPUGridLayerProps<DataT = any> = _GPUGridLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by GPUGridLayer. */\nexport type _GPUGridLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * Color scale domain, default is set to the extent of aggregated weights in each cell.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`\n */\n colorRange?: Color[];\n\n /**\n * Cell size multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Cell elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default true\n */\n extruded?: boolean;\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a cell.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * The weight of a data object used to calculate the elevation value for a cell.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n};\n\n/**\n * The `GPUGridLayer` renders a grid heatmap based on an array of inputs.\n */\nexport default class GPUGridLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<\n ExtraPropsT & Required<_GPUGridLayerProps<DataT>>\n> {\n static layerName = 'GPUGridLayer';\n static defaultProps = defaultProps;\n\n initializeState({gl}: LayerContext): void {\n const isSupported = GPUGridAggregator.isSupported(gl);\n if (!isSupported) {\n log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();\n }\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n gpuAggregation: true,\n projectPoints: false, // aggregation in world space\n isSupported,\n weights: {\n color: {\n needMin: true,\n needMax: true,\n combineMaxMin: true,\n maxMinBuffer: new Buffer(gl, {\n byteLength: 4 * 4,\n accessor: {size: 4, type: GL.FLOAT, divisor: 1}\n })\n },\n elevation: {\n needMin: true,\n needMax: true,\n combineMaxMin: true,\n maxMinBuffer: new Buffer(gl, {\n byteLength: 4 * 4,\n accessor: {size: 4, type: GL.FLOAT, divisor: 1}\n })\n }\n },\n positionAttributeName: 'positions'\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n color: {size: 3, accessor: 'getColorWeight'},\n elevation: {size: 3, accessor: 'getElevationWeight'}\n });\n }\n\n updateState(opts) {\n if (this.state.isSupported === false) {\n // Skip update, layer not supported\n return;\n }\n super.updateState(opts);\n const {aggregationDirty} = this.state;\n if (aggregationDirty) {\n // reset cached CPU Aggregation results (used for picking)\n this.setState({\n gridHash: null\n });\n }\n }\n\n getHashKeyForIndex(index: number): string {\n const {numRow, numCol, boundingBox, gridOffset} = this.state;\n const gridSize = [numCol, numRow];\n const gridOrigin = [boundingBox.xMin, boundingBox.yMin];\n const cellSize = [gridOffset.xOffset, gridOffset.yOffset];\n\n const yIndex = Math.floor(index / gridSize[0]);\n const xIndex = index - yIndex * gridSize[0];\n // This will match the index to the hash-key to access aggregation data from CPU aggregation results.\n const latIdx = Math.floor(\n (yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]\n );\n const lonIdx = Math.floor(\n (xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]\n );\n return `${latIdx}-${lonIdx}`;\n }\n\n getPositionForIndex(index: number): Position {\n const {numRow, numCol, boundingBox, gridOffset} = this.state;\n const gridSize = [numCol, numRow];\n const gridOrigin = [boundingBox.xMin, boundingBox.yMin];\n const cellSize = [gridOffset.xOffset, gridOffset.yOffset];\n\n const yIndex = Math.floor(index / gridSize[0]);\n const xIndex = index - yIndex * gridSize[0];\n const yPos = yIndex * cellSize[1] + gridOrigin[1];\n const xPos = xIndex * cellSize[0] + gridOrigin[0];\n return [xPos, yPos];\n }\n\n getPickingInfo({info, mode}: GetPickingInfoParams): PickingInfo {\n const {index} = info;\n let object: any = null;\n if (index >= 0) {\n const {gpuGridAggregator} = this.state;\n const position = this.getPositionForIndex(index);\n const colorInfo = GPUGridAggregator.getAggregationData({\n pixelIndex: index,\n ...gpuGridAggregator.getData('color')\n });\n const elevationInfo = GPUGridAggregator.getAggregationData({\n pixelIndex: index,\n ...gpuGridAggregator.getData('elevation')\n });\n\n object = {\n colorValue: colorInfo.cellWeight,\n elevationValue: elevationInfo.cellWeight,\n count: colorInfo.cellCount || elevationInfo.cellCount,\n position,\n totalCount: colorInfo.totalCount || elevationInfo.totalCount\n };\n if (mode !== 'hover') {\n // perform CPU aggregation for full list of points for each cell\n const {props} = this;\n let {gridHash} = this.state;\n if (!gridHash) {\n const {gridOffset, translation, boundingBox} = this.state;\n const {viewport} = this.context;\n const attributes = this.getAttributes();\n const cpuAggregation = pointToDensityGridDataCPU(props as any, {\n gridOffset,\n attributes,\n viewport,\n translation,\n boundingBox\n });\n gridHash = cpuAggregation.gridHash;\n this.setState({gridHash});\n }\n const key = this.getHashKeyForIndex(index);\n const cpuAggregationData = gridHash[key];\n Object.assign(object, cpuAggregationData);\n }\n }\n\n // override object with picked cell\n info.picked = Boolean(object);\n info.object = object;\n\n return info;\n }\n\n renderLayers() {\n if (!this.state.isSupported) {\n return null;\n }\n const {\n elevationScale,\n extruded,\n cellSize: cellSizeMeters,\n coverage,\n material,\n elevationRange,\n colorDomain,\n elevationDomain\n } = this.props;\n\n const {weights, numRow, numCol, gridOrigin, gridOffset} = this.state;\n const {color, elevation} = weights;\n const colorRange = colorRangeToFlatArray(this.props.colorRange);\n\n const SubLayerClass = this.getSubLayerClass('gpu-grid-cell', GPUGridCellLayer);\n\n return new SubLayerClass(\n {\n gridSize: [numCol, numRow],\n gridOrigin,\n gridOffset: [gridOffset.xOffset, gridOffset.yOffset],\n colorRange,\n elevationRange,\n colorDomain,\n elevationDomain,\n\n cellSize: cellSizeMeters,\n coverage,\n material,\n elevationScale,\n extruded\n },\n this.getSubLayerProps({\n id: 'gpu-grid-cell'\n }),\n {\n data: {\n attributes: {\n colors: color.aggregationBuffer,\n elevations: elevation.aggregationBuffer\n }\n },\n colorMaxMinBuffer: color.maxMinBuffer,\n elevationMaxMinBuffer: elevation.maxMinBuffer,\n numInstances: numCol * numRow\n }\n );\n }\n\n finalizeState(context: LayerContext) {\n const {color, elevation} = this.state.weights;\n [color, elevation].forEach(weight => {\n const {aggregationBuffer, maxMinBuffer} = weight;\n maxMinBuffer.delete();\n aggregationBuffer?.delete();\n });\n super.finalizeState(context);\n }\n\n // Aggregation Overrides\n\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n const {dimensions} = this.state;\n\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n // any attribute changed\n const attributesChanged = positionsChanged || this.isAttributeChanged();\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n translation,\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n attributesChanged ||\n this.isAggregationDirty(opts, {\n dimension: dimensions.data,\n compareAll: true\n });\n\n if (aggregationDataDirty) {\n this._updateAccessors(opts);\n }\n this.setState({\n aggregationDataDirty\n });\n }\n\n // Private\n\n _updateAccessors(opts) {\n const {colorAggregation, elevationAggregation} = opts.props;\n const {color, elevation} = this.state.weights;\n color.operation = AGGREGATION_OPERATION[colorAggregation];\n elevation.operation = AGGREGATION_OPERATION[elevationAggregation];\n }\n}\n"],"file":"gpu-grid-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/gpu-grid-layer/gpu-grid-layer.ts"],"names":["defaultProps","colorDomain","colorRange","defaultColorRange","getColorWeight","type","value","colorAggregation","elevationDomain","elevationRange","getElevationWeight","elevationAggregation","elevationScale","min","cellSize","max","coverage","getPosition","x","position","extruded","material","DIMENSIONS","data","props","POSITION_ATTRIBUTE_NAME","GPUGridLayer","gl","isSupported","GPUGridAggregator","log","error","dimensions","setState","gpuAggregation","projectPoints","weights","color","needMin","needMax","combineMaxMin","maxMinBuffer","Buffer","byteLength","accessor","size","divisor","elevation","positionAttributeName","attributeManager","getAttributeManager","add","fp64","use64bitPositions","opts","state","aggregationDirty","gridHash","index","numRow","numCol","boundingBox","gridOffset","gridSize","gridOrigin","xMin","yMin","xOffset","yOffset","yIndex","Math","floor","xIndex","latIdx","lonIdx","yPos","xPos","info","mode","object","gpuGridAggregator","getPositionForIndex","colorInfo","getAggregationData","pixelIndex","getData","elevationInfo","colorValue","cellWeight","elevationValue","count","cellCount","totalCount","translation","viewport","context","attributes","getAttributes","cpuAggregation","key","getHashKeyForIndex","cpuAggregationData","Object","assign","picked","Boolean","cellSizeMeters","SubLayerClass","getSubLayerClass","GPUGridCellLayer","getSubLayerProps","id","colors","aggregationBuffer","elevations","colorMaxMinBuffer","elevationMaxMinBuffer","numInstances","forEach","weight","delete","oldProps","coordinateSystem","cellSizeChanged","positionsChanged","isAttributeChanged","attributesChanged","getNumInstances","width","height","allocateResources","aggregationDataDirty","isAggregationDirty","dimension","compareAll","_updateAccessors","operation","AGGREGATION_OPERATION","GridAggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA;;AAEA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEC,6BAHwC;AAIpDC,EAAAA,cAAc,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJ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T,IADM;AAE5B+G,QAAAA,UAAU,EAAE;AAFgB,OAA9B,CAFF;;AAOA,UAAIH,oBAAJ,EAA0B;AACxB,aAAKI,gBAAL,CAAsBjF,IAAtB;AACD;;AACD,WAAKrB,QAAL,CAAc;AACZkG,QAAAA,oBAAoB,EAApBA;AADY,OAAd;AAGD;;;WAID,0BAAiB7E,IAAjB,EAAuB;AACrB,wBAAiDA,IAAI,CAAC9B,KAAtD;AAAA,UAAOjB,gBAAP,eAAOA,gBAAP;AAAA,UAAyBI,oBAAzB,eAAyBA,oBAAzB;AACA,iCAA2B,KAAK4C,KAAL,CAAWnB,OAAtC;AAAA,UAAOC,KAAP,wBAAOA,KAAP;AAAA,UAAcU,SAAd,wBAAcA,SAAd;AACAV,MAAAA,KAAK,CAACmG,SAAN,GAAkBC,iDAAsBlI,gBAAtB,CAAlB;AACAwC,MAAAA,SAAS,CAACyF,SAAV,GAAsBC,iDAAsB9H,oBAAtB,CAAtB;AACD;;;EAnRsE+H,6B;;;8BAApDhH,Y,eAGA,c;8BAHAA,Y,kBAIG1B,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {Buffer} from '@luma.gl/core';\nimport GL from '@luma.gl/constants';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Material,\n GetPickingInfoParams,\n LayerContext,\n log,\n PickingInfo,\n Position,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION} from '../utils/aggregation-operation-utils';\nimport {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';\nimport GPUGridCellLayer from './gpu-grid-cell-layer';\nimport {pointToDensityGridDataCPU} from './../cpu-grid-layer/grid-aggregator';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\n\nconst defaultProps: DefaultProps<GPUGridLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationScale: {type: 'number', min: 0, value: 1},\n\n // grid\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n getPosition: {type: 'accessor', value: x => x.position},\n extruded: false,\n\n // Optional material for 'lighting' shader module\n material: true\n};\n\n// This layer only perform GPU aggregation, no need to seperate data and weight props\n// aggregation will be dirty when any of the props are changed.\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize', 'colorAggregation', 'elevationAggregation']\n }\n // rest of the changes are detected by `state.attributesChanged`\n};\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\n/** All properties supported by GPUGridLayer. */\nexport type GPUGridLayerProps<DataT = any> = _GPUGridLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by GPUGridLayer. */\nexport type _GPUGridLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * Color scale domain, default is set to the extent of aggregated weights in each cell.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`\n */\n colorRange?: Color[];\n\n /**\n * Cell size multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Cell elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default true\n */\n extruded?: boolean;\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a cell.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * The weight of a data object used to calculate the elevation value for a cell.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n};\n\n/** Aggregate data into a grid-based heatmap. Aggregation is performed on GPU (WebGL2 only). */\nexport default class GPUGridLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<\n ExtraPropsT & Required<_GPUGridLayerProps<DataT>>\n> {\n static layerName = 'GPUGridLayer';\n static defaultProps = defaultProps;\n\n initializeState({gl}: LayerContext): void {\n const isSupported = GPUGridAggregator.isSupported(gl);\n if (!isSupported) {\n log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();\n }\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n gpuAggregation: true,\n projectPoints: false, // aggregation in world space\n isSupported,\n weights: {\n color: {\n needMin: true,\n needMax: true,\n combineMaxMin: true,\n maxMinBuffer: new Buffer(gl, {\n byteLength: 4 * 4,\n accessor: {size: 4, type: GL.FLOAT, divisor: 1}\n })\n },\n elevation: {\n needMin: true,\n needMax: true,\n combineMaxMin: true,\n maxMinBuffer: new Buffer(gl, {\n byteLength: 4 * 4,\n accessor: {size: 4, type: GL.FLOAT, divisor: 1}\n })\n }\n },\n positionAttributeName: 'positions'\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n color: {size: 3, accessor: 'getColorWeight'},\n elevation: {size: 3, accessor: 'getElevationWeight'}\n });\n }\n\n updateState(opts) {\n if (this.state.isSupported === false) {\n // Skip update, layer not supported\n return;\n }\n super.updateState(opts);\n const {aggregationDirty} = this.state;\n if (aggregationDirty) {\n // reset cached CPU Aggregation results (used for picking)\n this.setState({\n gridHash: null\n });\n }\n }\n\n getHashKeyForIndex(index: number): string {\n const {numRow, numCol, boundingBox, gridOffset} = this.state;\n const gridSize = [numCol, numRow];\n const gridOrigin = [boundingBox.xMin, boundingBox.yMin];\n const cellSize = [gridOffset.xOffset, gridOffset.yOffset];\n\n const yIndex = Math.floor(index / gridSize[0]);\n const xIndex = index - yIndex * gridSize[0];\n // This will match the index to the hash-key to access aggregation data from CPU aggregation results.\n const latIdx = Math.floor(\n (yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]\n );\n const lonIdx = Math.floor(\n (xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]\n );\n return `${latIdx}-${lonIdx}`;\n }\n\n getPositionForIndex(index: number): Position {\n const {numRow, numCol, boundingBox, gridOffset} = this.state;\n const gridSize = [numCol, numRow];\n const gridOrigin = [boundingBox.xMin, boundingBox.yMin];\n const cellSize = [gridOffset.xOffset, gridOffset.yOffset];\n\n const yIndex = Math.floor(index / gridSize[0]);\n const xIndex = index - yIndex * gridSize[0];\n const yPos = yIndex * cellSize[1] + gridOrigin[1];\n const xPos = xIndex * cellSize[0] + gridOrigin[0];\n return [xPos, yPos];\n }\n\n getPickingInfo({info, mode}: GetPickingInfoParams): PickingInfo {\n const {index} = info;\n let object: any = null;\n if (index >= 0) {\n const {gpuGridAggregator} = this.state;\n const position = this.getPositionForIndex(index);\n const colorInfo = GPUGridAggregator.getAggregationData({\n pixelIndex: index,\n ...gpuGridAggregator.getData('color')\n });\n const elevationInfo = GPUGridAggregator.getAggregationData({\n pixelIndex: index,\n ...gpuGridAggregator.getData('elevation')\n });\n\n object = {\n colorValue: colorInfo.cellWeight,\n elevationValue: elevationInfo.cellWeight,\n count: colorInfo.cellCount || elevationInfo.cellCount,\n position,\n totalCount: colorInfo.totalCount || elevationInfo.totalCount\n };\n if (mode !== 'hover') {\n // perform CPU aggregation for full list of points for each cell\n const {props} = this;\n let {gridHash} = this.state;\n if (!gridHash) {\n const {gridOffset, translation, boundingBox} = this.state;\n const {viewport} = this.context;\n const attributes = this.getAttributes();\n const cpuAggregation = pointToDensityGridDataCPU(props as any, {\n gridOffset,\n attributes,\n viewport,\n translation,\n boundingBox\n });\n gridHash = cpuAggregation.gridHash;\n this.setState({gridHash});\n }\n const key = this.getHashKeyForIndex(index);\n const cpuAggregationData = gridHash[key];\n Object.assign(object, cpuAggregationData);\n }\n }\n\n // override object with picked cell\n info.picked = Boolean(object);\n info.object = object;\n\n return info;\n }\n\n renderLayers() {\n if (!this.state.isSupported) {\n return null;\n }\n const {\n elevationScale,\n extruded,\n cellSize: cellSizeMeters,\n coverage,\n material,\n elevationRange,\n colorDomain,\n elevationDomain\n } = this.props;\n\n const {weights, numRow, numCol, gridOrigin, gridOffset} = this.state;\n const {color, elevation} = weights;\n const colorRange = colorRangeToFlatArray(this.props.colorRange);\n\n const SubLayerClass = this.getSubLayerClass('gpu-grid-cell', GPUGridCellLayer);\n\n return new SubLayerClass(\n {\n gridSize: [numCol, numRow],\n gridOrigin,\n gridOffset: [gridOffset.xOffset, gridOffset.yOffset],\n colorRange,\n elevationRange,\n colorDomain,\n elevationDomain,\n\n cellSize: cellSizeMeters,\n coverage,\n material,\n elevationScale,\n extruded\n },\n this.getSubLayerProps({\n id: 'gpu-grid-cell'\n }),\n {\n data: {\n attributes: {\n colors: color.aggregationBuffer,\n elevations: elevation.aggregationBuffer\n }\n },\n colorMaxMinBuffer: color.maxMinBuffer,\n elevationMaxMinBuffer: elevation.maxMinBuffer,\n numInstances: numCol * numRow\n }\n );\n }\n\n finalizeState(context: LayerContext) {\n const {color, elevation} = this.state.weights;\n [color, elevation].forEach(weight => {\n const {aggregationBuffer, maxMinBuffer} = weight;\n maxMinBuffer.delete();\n aggregationBuffer?.delete();\n });\n super.finalizeState(context);\n }\n\n // Aggregation Overrides\n\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n const {dimensions} = this.state;\n\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n // any attribute changed\n const attributesChanged = positionsChanged || this.isAttributeChanged();\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n translation,\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n attributesChanged ||\n this.isAggregationDirty(opts, {\n dimension: dimensions.data,\n compareAll: true\n });\n\n if (aggregationDataDirty) {\n this._updateAccessors(opts);\n }\n this.setState({\n aggregationDataDirty\n });\n }\n\n // Private\n\n _updateAccessors(opts) {\n const {colorAggregation, elevationAggregation} = opts.props;\n const {color, elevation} = this.state.weights;\n color.operation = AGGREGATION_OPERATION[colorAggregation];\n elevation.operation = AGGREGATION_OPERATION[elevationAggregation];\n }\n}\n"],"file":"gpu-grid-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/grid-layer/grid-layer.ts"],"names":["defaultProps","GPUGridLayer","CPUGridLayer","gpuAggregation","GridLayer","state","useGPUAggregation","props","setState","canUseGPUAggregation","data","updateTriggers","id","LayerType","getSubLayerClass","getSubLayerProps","lowerPercentile","upperPercentile","getColorValue","getElevationValue","colorScaleType","GPUGridAggregator","isSupported","context","gl","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,YAA0C,iDAC3CC,sBAAaD,YAD8B,GAE3CE,sBAAaF,YAF8B;AAG9CG,EAAAA,cAAc,EAAE;AAH8B,EAAhD;;
|
|
1
|
+
{"version":3,"sources":["../../../src/grid-layer/grid-layer.ts"],"names":["defaultProps","GPUGridLayer","CPUGridLayer","gpuAggregation","GridLayer","state","useGPUAggregation","props","setState","canUseGPUAggregation","data","updateTriggers","id","LayerType","getSubLayerClass","getSubLayerProps","lowerPercentile","upperPercentile","getColorValue","getElevationValue","colorScaleType","GPUGridAggregator","isSupported","context","gl","CompositeL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IEW,aAJF;AAAA,UAKEC,iBALF,GAOIZ,KAPJ,CAKEY,iBALF;AAAA,UAMEC,cANF,GAOIb,KAPJ,CAMEa,cANF;;AAQA,UAAI,CAACjB,cAAL,EAAqB;AAEnB,eAAO,KAAP;AACD;;AACD,UAAI,CAACkB,2BAAkBC,WAAlB,CAA8B,KAAKC,OAAL,CAAaC,EAA3C,CAAL,EAAqD;AACnD,eAAO,KAAP;AACD;;AACD,UAAIR,eAAe,KAAK,CAApB,IAAyBC,eAAe,KAAK,GAAjD,EAAsD;AAEpD,eAAO,KAAP;AACD;;AACD,UAAIC,aAAa,KAAK,IAAlB,IAA0BC,iBAAiB,KAAK,IAApD,EAA0D;AAExD,eAAO,KAAP;AACD;;AACD,UAAIC,cAAc,KAAK,UAAnB,IAAiCA,cAAc,KAAK,SAAxD,EAAmE;AAEjE,eAAO,KAAP;AACD;;AACD,aAAO,IAAP;AACD;;;EAvEmEK,oB;;;8BAAjDrB,S,eAGA,W;8BAHAA,S,kBAIGJ,Y","sourcesContent":["import {\n CompositeLayer,\n CompositeLayerProps,\n Layer,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport GPUGridLayer, {_GPUGridLayerProps} from '../gpu-grid-layer/gpu-grid-layer';\nimport CPUGridLayer, {_CPUGridLayerProps} from '../cpu-grid-layer/cpu-grid-layer';\n\nconst defaultProps: DefaultProps<GridLayerProps> = {\n ...GPUGridLayer.defaultProps,\n ...CPUGridLayer.defaultProps,\n gpuAggregation: false\n};\n\n/** All properties supported by GridLayer. */\nexport type GridLayerProps<DataT = any> = _GridLayerProps<DataT> & CompositeLayerProps<DataT>;\n\n/** Properties added by GridLayer. */\ntype _GridLayerProps<DataT> = _CPUGridLayerProps<DataT> &\n _GPUGridLayerProps<DataT> & {\n /**\n * Whether the aggregation should be performed in high-precision 64-bit mode.\n * @default false\n */\n fp64?: boolean;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default false\n */\n gpuAggregation?: boolean;\n };\n\n/** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */\nexport default class GridLayer<DataT = any, ExtraPropsT = {}> extends CompositeLayer<\n ExtraPropsT & Required<_GridLayerProps<DataT>>\n> {\n static layerName = 'GridLayer';\n static defaultProps = defaultProps;\n\n state!: CompositeLayer['state'] & {\n useGPUAggregation: boolean;\n };\n\n initializeState() {\n this.state = {\n useGPUAggregation: true\n };\n }\n\n updateState({props}: UpdateParameters<this>) {\n this.setState({\n useGPUAggregation: this.canUseGPUAggregation(props)\n });\n }\n\n renderLayers(): Layer {\n const {data, updateTriggers} = this.props;\n const id = this.state.useGPUAggregation ? 'GPU' : 'CPU';\n const LayerType = this.state.useGPUAggregation\n ? this.getSubLayerClass('GPU', GPUGridLayer)\n : this.getSubLayerClass('CPU', CPUGridLayer);\n return new LayerType(\n this.props,\n this.getSubLayerProps({\n id,\n updateTriggers\n }),\n {\n data\n }\n );\n }\n\n // Private methods\n\n canUseGPUAggregation(props: GridLayer['props']) {\n const {\n gpuAggregation,\n lowerPercentile,\n upperPercentile,\n getColorValue,\n getElevationValue,\n colorScaleType\n } = props;\n if (!gpuAggregation) {\n // cpu aggregation is requested\n return false;\n }\n if (!GPUGridAggregator.isSupported(this.context.gl)) {\n return false;\n }\n if (lowerPercentile !== 0 || upperPercentile !== 100) {\n // percentile calculations requires sorting not supported on GPU\n return false;\n }\n if (getColorValue !== null || getElevationValue !== null) {\n // accessor for custom color or elevation calculation is specified\n return false;\n }\n if (colorScaleType === 'quantile' || colorScaleType === 'ordinal') {\n // quantile and ordinal scales are not supported on GPU\n return false;\n }\n return true;\n }\n}\n"],"file":"grid-layer.js"}
|