@deck.gl/aggregation-layers 8.6.0 → 8.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/aggregation-layer.js +109 -163
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +240 -260
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-utils.js +65 -86
- package/dist/es5/contour-layer/contour-utils.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares-codes.js +181 -106
- package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares.js +56 -59
- package/dist/es5/contour-layer/marching-squares.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +85 -121
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/es5/cpu-grid-layer/grid-aggregator.js +93 -119
- package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -167
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +319 -322
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-aggregation-layer.js +202 -230
- package/dist/es5/grid-aggregation-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +61 -91
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +24 -59
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +515 -533
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +64 -91
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-aggregator.js +59 -77
- package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +121 -164
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/index.js +12 -12
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +168 -193
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +235 -250
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/utils/aggregation-operation-utils.js +16 -31
- package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
- package/dist/es5/utils/bin-sorter.js +118 -198
- package/dist/es5/utils/bin-sorter.js.map +1 -1
- package/dist/es5/utils/color-utils.js +8 -10
- package/dist/es5/utils/color-utils.js.map +1 -1
- package/dist/es5/utils/cpu-aggregator.js +323 -342
- package/dist/es5/utils/cpu-aggregator.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +20 -18
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +545 -545
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
- package/dist/es5/utils/grid-aggregation-utils.js +50 -44
- package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
- package/dist/es5/utils/prop-utils.js +2 -2
- package/dist/es5/utils/prop-utils.js.map +1 -1
- package/dist/es5/utils/resource-utils.js +32 -39
- package/dist/es5/utils/resource-utils.js.map +1 -1
- package/dist/es5/utils/scale-utils.js +36 -66
- package/dist/es5/utils/scale-utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cpu-grid-layer/cpu-grid-layer.js"],"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","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAEA,SAASA,GAAT,GAAe,CAAE;;AAEjB,IAAMC,YAAY,GAAG;AAEnBC,EAAAA,WAAW,EAAE,IAFM;AAGnBC,EAAAA,UAAU,EAAEC,6BAHO;AAInBC,EAAAA,aAAa,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJI;AAKnBC,EAAAA,cAAc,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GALG;AAMnBE,EAAAA,gBAAgB,EAAE,KANC;AAOnBC,EAAAA,eAAe,EAAE;AAACJ,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,GAA9B;AAAmCL,IAAAA,KAAK,EAAE;AAA1C,GAPE;AAQnBM,EAAAA,eAAe,EAAE;AAACP,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAA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,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;;;EA9EuCE,yB;;;AAiF1C3C,YAAY,CAAC4C,SAAb,GAAyB,cAAzB;AACA5C,YAAY,CAACpC,YAAb,GAA4BA,YAA5B","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 {GridCellLayer} from '@deck.gl/layers';\n\nimport {defaultColorRange} from '../utils/color-utils';\nimport {pointToDensityGridDataCPU} from './grid-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer from '../aggregation-layer';\n\nfunction nop() {}\n\nconst defaultProps = {\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\nexport default class CPUGridLayer extends AggregationLayer {\n initializeState() {\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, 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) {\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(opts.props)\n })\n });\n }\n\n getPickingInfo({info}) {\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() {\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\nCPUGridLayer.layerName = 'CPUGridLayer';\nCPUGridLayer.defaultProps = defaultProps;\n"],"file":"cpu-grid-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cpu-grid-layer/cpu-grid-layer.js"],"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","AggregationLayer","initializeState","cpuAggregator","CPUAggregator","getAggregator","props","getCellSize","state","aggregatorState","attributeManager","getAttributeManager","add","positions","size","accessor","updateState","opts","setState","viewport","context","attributes","getAttributes","numInstances","getNumInstances","getPickingInfo","info","_onGetSublayerColor","cell","getAccessor","_onGetSublayerElevation","_getSublayerUpdateTriggers","getUpdateTriggers","renderLayers","transitions","SubLayerClass","getSubLayerClass","GridCellLayer","updateTriggers","getFillColor","bind","getElevation","getSubLayerProps","id","data","layerData","layerName"],"mappings":";;;;;;;;;AAoBA;;AAEA;;AACA;;AACA;;AACA;;AAEA,SAASA,GAAT,GAAe,CAAE;;AAEjB,MAAMC,YAAY,GAAG;AAEnBC,EAAAA,WAAW,EAAE,IAFM;AAGnBC,EAAAA,UAAU,EAAEC,6BAHO;AAInBC,EAAAA,aAAa,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJI;AAKnBC,EAAAA,cAAc,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GALG;AAMnBE,EAAAA,gBAAgB,EAAE,KANC;AAOnBC,EAAAA,eAAe,EAAE;AAACJ,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,GAA9B;AAAmCL,IAA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G,KAAKC,gBAAL,CAAsB,WAAtB,EAAmCC,qBAAnC,CAAtB;;AACA,UAAMC,cAAc,GAAG,KAAKP,0BAAL,EAAvB;;AAEA,WAAO,IAAII,aAAJ,CACL;AACE5C,MAAAA,QADF;AAEEC,MAAAA,QAFF;AAGEK,MAAAA,QAHF;AAIEX,MAAAA,cAJF;AAKEU,MAAAA,QALF;AAOE2C,MAAAA,YAAY,EAAE,KAAKZ,mBAAL,CAAyBa,IAAzB,CAA8B,IAA9B,CAPhB;AAQEC,MAAAA,YAAY,EAAE,KAAKX,uBAAL,CAA6BU,IAA7B,CAAkC,IAAlC,CARhB;AASEN,MAAAA,WAAW,EAAEA,WAAW,IAAI;AAC1BK,QAAAA,YAAY,EAAEL,WAAW,CAAClE,aAAZ,IAA6BkE,WAAW,CAAC/D,cAD7B;AAE1BsE,QAAAA,YAAY,EAAEP,WAAW,CAACrD,iBAAZ,IAAiCqD,WAAW,CAACpD;AAFjC;AAT9B,KADK,EAeL,KAAK4D,gBAAL,CAAsB;AACpBC,MAAAA,EAAE,EAAE,WADgB;AAEpBL,MAAAA;AAFoB,KAAtB,CAfK,EAmBL;AACEM,MAAAA,IAAI,EAAEzC,aAAa,CAACK,KAAd,CAAoBqC,SAApB,CAA8BD;AADtC,KAnBK,CAAP;AAuBD;;AA9EwD;;;AAiF3D5C,YAAY,CAAC8C,SAAb,GAAyB,cAAzB;AACA9C,YAAY,CAACpC,YAAb,GAA4BA,YAA5B","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 {GridCellLayer} from '@deck.gl/layers';\n\nimport {defaultColorRange} from '../utils/color-utils';\nimport {pointToDensityGridDataCPU} from './grid-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer from '../aggregation-layer';\n\nfunction nop() {}\n\nconst defaultProps = {\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\nexport default class CPUGridLayer extends AggregationLayer {\n initializeState() {\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, 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) {\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(opts.props)\n })\n });\n }\n\n getPickingInfo({info}) {\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() {\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\nCPUGridLayer.layerName = 'CPUGridLayer';\nCPUGridLayer.defaultProps = defaultProps;\n"],"file":"cpu-grid-layer.js"}
|
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.pointToDensityGridDataCPU = pointToDensityGridDataCPU;
|
|
9
7
|
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
8
|
var _core = require("@deck.gl/core");
|
|
15
9
|
|
|
16
10
|
var _gridAggregationUtils = require("../utils/grid-aggregation-utils");
|
|
17
11
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
23
|
-
|
|
24
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
-
|
|
26
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
27
|
-
|
|
28
12
|
function pointToDensityGridDataCPU(props, aggregationParams) {
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
const hashInfo = pointsToGridHashing(props, aggregationParams);
|
|
14
|
+
const result = getGridLayerDataFromGridHash(hashInfo);
|
|
31
15
|
return {
|
|
32
16
|
gridHash: hashInfo.gridHash,
|
|
33
17
|
gridOffset: hashInfo.gridOffset,
|
|
@@ -36,125 +20,115 @@ function pointToDensityGridDataCPU(props, aggregationParams) {
|
|
|
36
20
|
}
|
|
37
21
|
|
|
38
22
|
function pointsToGridHashing(props, aggregationParams) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
23
|
+
const {
|
|
24
|
+
data = [],
|
|
25
|
+
cellSize
|
|
26
|
+
} = props;
|
|
27
|
+
const {
|
|
28
|
+
attributes,
|
|
29
|
+
viewport,
|
|
30
|
+
projectPoints,
|
|
31
|
+
numInstances
|
|
32
|
+
} = aggregationParams;
|
|
33
|
+
const positions = attributes.positions.value;
|
|
34
|
+
const {
|
|
35
|
+
size
|
|
36
|
+
} = attributes.positions.getAccessor();
|
|
37
|
+
const boundingBox = aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);
|
|
38
|
+
const offsets = aggregationParams.posOffset || [180, 90];
|
|
39
|
+
const gridOffset = aggregationParams.gridOffset || (0, _gridAggregationUtils.getGridOffset)(boundingBox, cellSize);
|
|
54
40
|
|
|
55
41
|
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
|
|
56
42
|
return {
|
|
57
43
|
gridHash: {},
|
|
58
|
-
gridOffset
|
|
44
|
+
gridOffset
|
|
59
45
|
};
|
|
60
46
|
}
|
|
61
47
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
lonIdx: xIndex,
|
|
100
|
-
latIdx: yIndex
|
|
101
|
-
};
|
|
102
|
-
gridHash[key].count += 1;
|
|
103
|
-
gridHash[key].points.push({
|
|
104
|
-
source: pt,
|
|
105
|
-
index: objectInfo.index
|
|
106
|
-
});
|
|
107
|
-
}
|
|
48
|
+
const {
|
|
49
|
+
width,
|
|
50
|
+
height
|
|
51
|
+
} = viewport;
|
|
52
|
+
const numCol = Math.ceil(width / gridOffset.xOffset);
|
|
53
|
+
const numRow = Math.ceil(height / gridOffset.yOffset);
|
|
54
|
+
const gridHash = {};
|
|
55
|
+
const {
|
|
56
|
+
iterable,
|
|
57
|
+
objectInfo
|
|
58
|
+
} = (0, _core.createIterable)(data);
|
|
59
|
+
const position = new Array(3);
|
|
60
|
+
|
|
61
|
+
for (const pt of iterable) {
|
|
62
|
+
objectInfo.index++;
|
|
63
|
+
position[0] = positions[objectInfo.index * size];
|
|
64
|
+
position[1] = positions[objectInfo.index * size + 1];
|
|
65
|
+
position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;
|
|
66
|
+
const [x, y] = projectPoints ? viewport.project(position) : position;
|
|
67
|
+
|
|
68
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
69
|
+
const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);
|
|
70
|
+
const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);
|
|
71
|
+
|
|
72
|
+
if (!projectPoints || xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow) {
|
|
73
|
+
const key = "".concat(yIndex, "-").concat(xIndex);
|
|
74
|
+
gridHash[key] = gridHash[key] || {
|
|
75
|
+
count: 0,
|
|
76
|
+
points: [],
|
|
77
|
+
lonIdx: xIndex,
|
|
78
|
+
latIdx: yIndex
|
|
79
|
+
};
|
|
80
|
+
gridHash[key].count += 1;
|
|
81
|
+
gridHash[key].points.push({
|
|
82
|
+
source: pt,
|
|
83
|
+
index: objectInfo.index
|
|
84
|
+
});
|
|
108
85
|
}
|
|
109
86
|
}
|
|
110
|
-
} catch (err) {
|
|
111
|
-
_iterator.e(err);
|
|
112
|
-
} finally {
|
|
113
|
-
_iterator.f();
|
|
114
87
|
}
|
|
115
88
|
|
|
116
89
|
return {
|
|
117
|
-
gridHash
|
|
118
|
-
gridOffset
|
|
90
|
+
gridHash,
|
|
91
|
+
gridOffset,
|
|
119
92
|
offsets: [offsets[0] * -1, offsets[1] * -1]
|
|
120
93
|
};
|
|
121
94
|
}
|
|
122
95
|
|
|
123
|
-
function getGridLayerDataFromGridHash(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
96
|
+
function getGridLayerDataFromGridHash({
|
|
97
|
+
gridHash,
|
|
98
|
+
gridOffset,
|
|
99
|
+
offsets
|
|
100
|
+
}) {
|
|
101
|
+
const data = new Array(Object.keys(gridHash).length);
|
|
102
|
+
let i = 0;
|
|
103
|
+
|
|
104
|
+
for (const key in gridHash) {
|
|
105
|
+
const idxs = key.split('-');
|
|
106
|
+
const latIdx = parseInt(idxs[0], 10);
|
|
107
|
+
const lonIdx = parseInt(idxs[1], 10);
|
|
108
|
+
const index = i++;
|
|
109
|
+
data[index] = {
|
|
110
|
+
index,
|
|
111
|
+
position: [offsets[0] + gridOffset.xOffset * lonIdx, offsets[1] + gridOffset.yOffset * latIdx],
|
|
112
|
+
...gridHash[key]
|
|
113
|
+
};
|
|
139
114
|
}
|
|
140
115
|
|
|
141
116
|
return data;
|
|
142
117
|
}
|
|
143
118
|
|
|
144
119
|
function getPositionBoundingBox(positionAttribute, numInstance) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
for (var i = 0; i < numInstance; i++) {
|
|
120
|
+
const positions = positionAttribute.value;
|
|
121
|
+
const {
|
|
122
|
+
size
|
|
123
|
+
} = positionAttribute.getAccessor();
|
|
124
|
+
let yMin = Infinity;
|
|
125
|
+
let yMax = -Infinity;
|
|
126
|
+
let xMin = Infinity;
|
|
127
|
+
let xMax = -Infinity;
|
|
128
|
+
let y;
|
|
129
|
+
let x;
|
|
130
|
+
|
|
131
|
+
for (let i = 0; i < numInstance; i++) {
|
|
158
132
|
x = positions[i * size];
|
|
159
133
|
y = positions[i * size + 1];
|
|
160
134
|
|
|
@@ -167,10 +141,10 @@ function getPositionBoundingBox(positionAttribute, numInstance) {
|
|
|
167
141
|
}
|
|
168
142
|
|
|
169
143
|
return {
|
|
170
|
-
xMin
|
|
171
|
-
xMax
|
|
172
|
-
yMin
|
|
173
|
-
yMax
|
|
144
|
+
xMin,
|
|
145
|
+
xMax,
|
|
146
|
+
yMin,
|
|
147
|
+
yMax
|
|
174
148
|
};
|
|
175
149
|
}
|
|
176
150
|
//# sourceMappingURL=grid-aggregator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cpu-grid-layer/grid-aggregator.js"],"names":["pointToDensityGridDataCPU","props","aggregationParams","hashInfo","pointsToGridHashing","result","getGridLayerDataFromGridHash","gridHash","gridOffset","data","cellSize","attributes","viewport","projectPoints","numInstances","positions","value","getAccessor","size","boundingBox","getPositionBoundingBox","offsets","posOffset","xOffset","yOffset","width","height","numCol","Math","ceil","numRow","iterable","objectInfo","position","Array","pt","index","project","x","y","Number","isFinite","yIndex","floor","xIndex","key","count","points","lonIdx","latIdx","push","source","Object","keys","length","i","idxs","split","parseInt","positionAttribute","numInstance","yMin","Infinity","yMax","xMin","xMax"],"mappings":";;;;;;;;;;;;;AAoBA;;AACA;;;;;;;;;;;;AAoBO,SAASA,yBAAT,CAAmCC,KAAnC,EAA0CC,iBAA1C,EAA6D;AAClE,MAAMC,QAAQ,GAAGC,mBAAmB,C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,CAACH,QAAZ;AACA,MAAIvB,CAAJ;AACA,MAAID,CAAJ;;AAEA,OAAK,IAAIiB,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGK,WAApB,EAAiCL,CAAC,EAAlC,EAAsC;AACpCjB,IAAAA,CAAC,GAAGvB,SAAS,CAACwC,CAAC,GAAGrC,IAAL,CAAb;AACAqB,IAAAA,CAAC,GAAGxB,SAAS,CAACwC,CAAC,GAAGrC,IAAJ,GAAW,CAAZ,CAAb;;AACA,QAAIsB,MAAM,CAACC,QAAP,CAAgBH,CAAhB,KAAsBE,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAA1B,EAA8C;AAC5CsB,MAAAA,IAAI,GAAGtB,CAAC,GAAGsB,IAAJ,GAAWtB,CAAX,GAAesB,IAAtB;AACAE,MAAAA,IAAI,GAAGxB,CAAC,GAAGwB,IAAJ,GAAWxB,CAAX,GAAewB,IAAtB;AACAC,MAAAA,IAAI,GAAG1B,CAAC,GAAG0B,IAAJ,GAAW1B,CAAX,GAAe0B,IAAtB;AACAC,MAAAA,IAAI,GAAG3B,CAAC,GAAG2B,IAAJ,GAAW3B,CAAX,GAAe2B,IAAtB;AACD;AACF;;AAED,SAAO;AAACD,IAAAA,IAAI,EAAJA,IAAD;AAAOC,IAAAA,IAAI,EAAJA,IAAP;AAAaJ,IAAAA,IAAI,EAAJA,IAAb;AAAmBE,IAAAA,IAAI,EAAJA;AAAnB,GAAP;AACD","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 {createIterable} from '@deck.gl/core';\nimport {getGridOffset} from '../utils/grid-aggregation-utils';\n\n/**\n * Calculate density grid from an array of points\n * @param {Object} props - object containing :\n * @param {Iterable} [props.data] - data objects to be aggregated\n * @param {Integer} [props.cellSize] - size of the grid cell\n *\n * @param {Object} aggregationParams - object containing :\n * @param {Object} gridOffset - {xOffset, yOffset} cell size in meters\n * @param {Integer} width - width of the grid\n * @param {Integer} height - height of the grid\n * @param {Boolean} projectPoints - `true` if doing screen space projection, `false` otherwise\n * @param {Array} attributes - attributes array containing position values\n * @param {Viewport} viewport - viewport to be used for projection\n * @param {Array} posOffset - [xOffset, yOffset] offset to be applied to positions to get cell index\n * @param {Object} boundingBox - {xMin, yMin, xMax, yMax} bounding box of input data\n *\n * @returns {object} - grid data, cell dimension\n */\nexport function pointToDensityGridDataCPU(props, aggregationParams) {\n const hashInfo = pointsToGridHashing(props, aggregationParams);\n const result = getGridLayerDataFromGridHash(hashInfo);\n\n return {\n gridHash: hashInfo.gridHash,\n gridOffset: hashInfo.gridOffset,\n data: result\n };\n}\n\n/**\n * Project points into each cell, return a hash table of cells\n * @param {Iterable} points\n * @param {number} cellSize - unit size in meters\n * @param {function} getPosition - position accessor\n * @returns {object} - grid hash and cell dimension\n */\n/* eslint-disable max-statements, complexity */\nfunction pointsToGridHashing(props, aggregationParams) {\n const {data = [], cellSize} = props;\n const {attributes, viewport, projectPoints, numInstances} = aggregationParams;\n const positions = attributes.positions.value;\n const {size} = attributes.positions.getAccessor();\n const boundingBox =\n aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);\n const offsets = aggregationParams.posOffset || [180, 90];\n const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);\n\n if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {\n return {gridHash: {}, gridOffset};\n }\n\n const {width, height} = viewport;\n const numCol = Math.ceil(width / gridOffset.xOffset);\n const numRow = Math.ceil(height / gridOffset.yOffset);\n\n // calculate count per cell\n const gridHash = {};\n\n const {iterable, objectInfo} = createIterable(data);\n const position = new Array(3);\n for (const pt of iterable) {\n objectInfo.index++;\n position[0] = positions[objectInfo.index * size];\n position[1] = positions[objectInfo.index * size + 1];\n position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;\n const [x, y] = projectPoints ? viewport.project(position) : position;\n if (Number.isFinite(x) && Number.isFinite(y)) {\n const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);\n const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);\n if (\n !projectPoints ||\n // when doing screen space agggregation (projectPoints = true), filter points outside of the viewport range.\n (xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow)\n ) {\n const key = `${yIndex}-${xIndex}`;\n\n gridHash[key] = gridHash[key] || {count: 0, points: [], lonIdx: xIndex, latIdx: yIndex};\n gridHash[key].count += 1;\n gridHash[key].points.push({\n source: pt,\n index: objectInfo.index\n });\n }\n }\n }\n\n return {gridHash, gridOffset, offsets: [offsets[0] * -1, offsets[1] * -1]};\n}\n/* eslint-enable max-statements, complexity */\n\nfunction getGridLayerDataFromGridHash({gridHash, gridOffset, offsets}) {\n const data = new Array(Object.keys(gridHash).length);\n let i = 0;\n for (const key in gridHash) {\n const idxs = key.split('-');\n const latIdx = parseInt(idxs[0], 10);\n const lonIdx = parseInt(idxs[1], 10);\n const index = i++;\n\n data[index] = {\n index,\n position: [\n offsets[0] + gridOffset.xOffset * lonIdx,\n offsets[1] + gridOffset.yOffset * latIdx\n ],\n ...gridHash[key]\n };\n }\n return data;\n}\n\n// Calculate bounding box of position attribute\nfunction getPositionBoundingBox(positionAttribute, numInstance) {\n // TODO - value might not exist (e.g. attribute transition)\n const positions = positionAttribute.value;\n const {size} = positionAttribute.getAccessor();\n\n let yMin = Infinity;\n let yMax = -Infinity;\n let xMin = Infinity;\n let xMax = -Infinity;\n let y;\n let x;\n\n for (let i = 0; i < numInstance; i++) {\n x = positions[i * size];\n y = positions[i * size + 1];\n if (Number.isFinite(x) && Number.isFinite(y)) {\n yMin = y < yMin ? y : yMin;\n yMax = y > yMax ? y : yMax;\n xMin = x < xMin ? x : xMin;\n xMax = x > xMax ? x : xMax;\n }\n }\n\n return {xMin, xMax, yMin, yMax};\n}\n"],"file":"grid-aggregator.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cpu-grid-layer/grid-aggregator.js"],"names":["pointToDensityGridDataCPU","props","aggregationParams","hashInfo","pointsToGridHashing","result","getGridLayerDataFromGridHash","gridHash","gridOffset","data","cellSize","attributes","viewport","projectPoints","numInstances","positions","value","size","getAccessor","boundingBox","getPositionBoundingBox","offsets","posOffset","xOffset","yOffset","width","height","numCol","Math","ceil","numRow","iterable","objectInfo","position","Array","pt","index","x","y","project","Number","isFinite","yIndex","floor","xIndex","key","count","points","lonIdx","latIdx","push","source","Object","keys","length","i","idxs","split","parseInt","positionAttribute","numInstance","yMin","Infinity","yMax","xMin","xMax"],"mappings":";;;;;;;AAoBA;;AACA;;AAoBO,SAASA,yBAAT,CAAmCC,KAAnC,EAA0CC,iBAA1C,EAA6D;AAClE,QAAMC,QAAQ,GAAGC,mBAAmB,CAACH,KAAD,EAAQC,iBAAR,CAApC;AACA,QAAMG,MAAM,GAAGC,4BAA4B,CAACH,QAAD,CAA3C;AAEA,SAAO;AACLI,IAAAA,QAAQ,EAAEJ,QAAQ,CAACI,QADd;AAELC,IAAAA,UAAU,EAAEL,QAAQ,CA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I,GAAG3B,CAAC,GAAG2B,IAAJ,GAAW3B,CAAX,GAAe2B,IAAtB;AACAC,MAAAA,IAAI,GAAG5B,CAAC,GAAG4B,IAAJ,GAAW5B,CAAX,GAAe4B,IAAtB;AACD;AACF;;AAED,SAAO;AAACD,IAAAA,IAAD;AAAOC,IAAAA,IAAP;AAAaJ,IAAAA,IAAb;AAAmBE,IAAAA;AAAnB,GAAP;AACD","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 {createIterable} from '@deck.gl/core';\nimport {getGridOffset} from '../utils/grid-aggregation-utils';\n\n/**\n * Calculate density grid from an array of points\n * @param {Object} props - object containing :\n * @param {Iterable} [props.data] - data objects to be aggregated\n * @param {Integer} [props.cellSize] - size of the grid cell\n *\n * @param {Object} aggregationParams - object containing :\n * @param {Object} gridOffset - {xOffset, yOffset} cell size in meters\n * @param {Integer} width - width of the grid\n * @param {Integer} height - height of the grid\n * @param {Boolean} projectPoints - `true` if doing screen space projection, `false` otherwise\n * @param {Array} attributes - attributes array containing position values\n * @param {Viewport} viewport - viewport to be used for projection\n * @param {Array} posOffset - [xOffset, yOffset] offset to be applied to positions to get cell index\n * @param {Object} boundingBox - {xMin, yMin, xMax, yMax} bounding box of input data\n *\n * @returns {object} - grid data, cell dimension\n */\nexport function pointToDensityGridDataCPU(props, aggregationParams) {\n const hashInfo = pointsToGridHashing(props, aggregationParams);\n const result = getGridLayerDataFromGridHash(hashInfo);\n\n return {\n gridHash: hashInfo.gridHash,\n gridOffset: hashInfo.gridOffset,\n data: result\n };\n}\n\n/**\n * Project points into each cell, return a hash table of cells\n * @param {Iterable} points\n * @param {number} cellSize - unit size in meters\n * @param {function} getPosition - position accessor\n * @returns {object} - grid hash and cell dimension\n */\n/* eslint-disable max-statements, complexity */\nfunction pointsToGridHashing(props, aggregationParams) {\n const {data = [], cellSize} = props;\n const {attributes, viewport, projectPoints, numInstances} = aggregationParams;\n const positions = attributes.positions.value;\n const {size} = attributes.positions.getAccessor();\n const boundingBox =\n aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);\n const offsets = aggregationParams.posOffset || [180, 90];\n const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);\n\n if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {\n return {gridHash: {}, gridOffset};\n }\n\n const {width, height} = viewport;\n const numCol = Math.ceil(width / gridOffset.xOffset);\n const numRow = Math.ceil(height / gridOffset.yOffset);\n\n // calculate count per cell\n const gridHash = {};\n\n const {iterable, objectInfo} = createIterable(data);\n const position = new Array(3);\n for (const pt of iterable) {\n objectInfo.index++;\n position[0] = positions[objectInfo.index * size];\n position[1] = positions[objectInfo.index * size + 1];\n position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;\n const [x, y] = projectPoints ? viewport.project(position) : position;\n if (Number.isFinite(x) && Number.isFinite(y)) {\n const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);\n const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);\n if (\n !projectPoints ||\n // when doing screen space agggregation (projectPoints = true), filter points outside of the viewport range.\n (xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow)\n ) {\n const key = `${yIndex}-${xIndex}`;\n\n gridHash[key] = gridHash[key] || {count: 0, points: [], lonIdx: xIndex, latIdx: yIndex};\n gridHash[key].count += 1;\n gridHash[key].points.push({\n source: pt,\n index: objectInfo.index\n });\n }\n }\n }\n\n return {gridHash, gridOffset, offsets: [offsets[0] * -1, offsets[1] * -1]};\n}\n/* eslint-enable max-statements, complexity */\n\nfunction getGridLayerDataFromGridHash({gridHash, gridOffset, offsets}) {\n const data = new Array(Object.keys(gridHash).length);\n let i = 0;\n for (const key in gridHash) {\n const idxs = key.split('-');\n const latIdx = parseInt(idxs[0], 10);\n const lonIdx = parseInt(idxs[1], 10);\n const index = i++;\n\n data[index] = {\n index,\n position: [\n offsets[0] + gridOffset.xOffset * lonIdx,\n offsets[1] + gridOffset.yOffset * latIdx\n ],\n ...gridHash[key]\n };\n }\n return data;\n}\n\n// Calculate bounding box of position attribute\nfunction getPositionBoundingBox(positionAttribute, numInstance) {\n // TODO - value might not exist (e.g. attribute transition)\n const positions = positionAttribute.value;\n const {size} = positionAttribute.getAccessor();\n\n let yMin = Infinity;\n let yMax = -Infinity;\n let xMin = Infinity;\n let xMax = -Infinity;\n let y;\n let x;\n\n for (let i = 0; i < numInstance; i++) {\n x = positions[i * size];\n y = positions[i * size + 1];\n if (Number.isFinite(x) && Number.isFinite(y)) {\n yMin = y < yMin ? y : yMin;\n yMax = y > yMax ? y : yMax;\n xMin = x < xMin ? x : xMin;\n xMax = x > xMax ? x : xMax;\n }\n }\n\n return {xMin, xMax, yMin, yMax};\n}\n"],"file":"grid-aggregator.js"}
|