@deck.gl/aggregation-layers 8.7.0-alpha.2 → 8.7.0-alpha.9

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.
Files changed (70) hide show
  1. package/dist/dist.dev.js +2512 -1759
  2. package/dist/es5/aggregation-layer.js +163 -109
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +260 -240
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/contour-layer/contour-utils.js +86 -65
  7. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  8. package/dist/es5/contour-layer/marching-squares-codes.js +106 -181
  9. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  10. package/dist/es5/contour-layer/marching-squares.js +59 -56
  11. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +121 -85
  13. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js +119 -93
  15. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  17. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +167 -131
  18. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  19. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +322 -319
  20. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  21. package/dist/es5/grid-aggregation-layer.js +230 -202
  22. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  23. package/dist/es5/grid-layer/grid-layer.js +91 -61
  24. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  25. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +59 -24
  26. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  27. package/dist/es5/heatmap-layer/heatmap-layer.js +536 -515
  28. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  29. package/dist/es5/heatmap-layer/triangle-layer.js +91 -64
  30. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  31. package/dist/es5/hexagon-layer/hexagon-aggregator.js +77 -59
  32. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  33. package/dist/es5/hexagon-layer/hexagon-layer.js +164 -121
  34. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  35. package/dist/es5/index.js +12 -12
  36. package/dist/es5/index.js.map +1 -1
  37. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +193 -168
  38. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  39. package/dist/es5/screen-grid-layer/screen-grid-layer.js +250 -235
  40. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  41. package/dist/es5/utils/aggregation-operation-utils.js +31 -16
  42. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  43. package/dist/es5/utils/bin-sorter.js +198 -118
  44. package/dist/es5/utils/bin-sorter.js.map +1 -1
  45. package/dist/es5/utils/color-utils.js +10 -8
  46. package/dist/es5/utils/color-utils.js.map +1 -1
  47. package/dist/es5/utils/cpu-aggregator.js +342 -323
  48. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +18 -20
  50. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  51. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +547 -549
  52. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  53. package/dist/es5/utils/grid-aggregation-utils.js +44 -50
  54. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  55. package/dist/es5/utils/prop-utils.js +2 -2
  56. package/dist/es5/utils/prop-utils.js.map +1 -1
  57. package/dist/es5/utils/resource-utils.js +39 -32
  58. package/dist/es5/utils/resource-utils.js.map +1 -1
  59. package/dist/es5/utils/scale-utils.js +66 -36
  60. package/dist/es5/utils/scale-utils.js.map +1 -1
  61. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  62. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  63. package/dist/esm/heatmap-layer/heatmap-layer.js +4 -1
  64. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  65. package/dist/esm/index.js.map +1 -1
  66. package/dist.min.js +1 -1
  67. package/package.json +3 -3
  68. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +2 -3
  69. package/src/heatmap-layer/heatmap-layer.js +3 -1
  70. /package/src/{index.js → index.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/grid-aggregation-layer.js"],"names":["GridAggregationLayer","AggregationLayer","initializeState","dimensions","gl","context","setState","layerData","gpuGridAggregator","GPUGridAggregator","id","cpuGridAggregator","pointToDensityGridDataCPU","updateState","opts","updateAggregationState","aggregationDataDirty","aggregationWeightsDirty","gpuAggregation","state","getNumInstances","aggregationDirty","_updateAggregation","_updateWeightBins","_uploadAggregationResults","finalizeState","count","weights","aggregationBuffer","delete","updateShaders","shaders","log","assert","allocateResources","numRow","numCol","dataBytes","name","weight","Buffer","byteLength","accessor","size","type","divisor","updateResults","aggregationData","maxMinData","maxData","minData","gridOffset","posOffset","translation","scaling","boundingBox","projectPoints","props","viewport","attributes","getAttributes","vertexCount","result","run","cellSize","xOffset","yOffset","moduleSettings","getModuleSettings","getValue","sortedBins","BinSorter","data","aggregatedBins","minValue","maxValue","totalCount","ELEMENTCOUNT","aggregationSize","Float32Array","fill","bin","lonIdx","latIdx","i","value","counts","cellIndex","layerName"],"mappings":";;;;;;;;;AAoBA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEe,MAAMA,oBAAN,SAAmCC,yBAAn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MAAMC,GAAX,IAAkBR,cAAlB,EAAkC;AAChC,YAAM;AAACS,QAAAA,MAAD;AAASC,QAAAA;AAAT,UAAmBX,IAAI,CAACS,GAAG,CAACG,CAAL,CAA7B;AACA,YAAM;AAACC,QAAAA,KAAD;AAAQC,QAAAA;AAAR,UAAkBL,GAAxB;AACA,YAAMM,SAAS,GAAG,CAACL,MAAM,GAAGC,MAAM,GAAG/C,MAAnB,IAA6ByC,YAA/C;AACA9B,MAAAA,eAAe,CAACwC,SAAD,CAAf,GAA6BF,KAA7B;AACAtC,MAAAA,eAAe,CAACwC,SAAS,GAAGV,YAAZ,GAA2B,CAA5B,CAAf,GAAgDS,MAAhD;AACD;;AACD,UAAMtC,UAAU,GAAG,IAAI+B,YAAJ,CAAiB,CAACJ,QAAD,EAAW,CAAX,EAAc,CAAd,EAAiBD,QAAjB,CAAjB,CAAnB;AACA,UAAMzB,OAAO,GAAG,IAAI8B,YAAJ,CAAiB,CAACJ,QAAD,EAAW,CAAX,EAAc,CAAd,EAAiBC,UAAjB,CAAjB,CAAhB;AACA,UAAM1B,OAAO,GAAG,IAAI6B,YAAJ,CAAiB,CAACL,QAAD,EAAW,CAAX,EAAc,CAAd,EAAiBE,UAAjB,CAAjB,CAAhB;AACA,SAAK9B,aAAL,CAAmB;AAACC,MAAAA,eAAD;AAAkBC,MAAAA,UAAlB;AAA8BC,MAAAA,OAA9B;AAAuCC,MAAAA;AAAvC,KAAnB;AACD;;AA5KgE;;;AA+KnElD,oBAAoB,CAACwF,SAArB,GAAiC,sBAAjC","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 AggregationLayer from './aggregation-layer';\nimport GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {Buffer} from '@luma.gl/core';\nimport {log} from '@deck.gl/core';\nimport GL from '@luma.gl/constants';\nimport BinSorter from './utils/bin-sorter';\nimport {pointToDensityGridDataCPU} from './cpu-grid-layer/grid-aggregator';\n\nexport default class GridAggregationLayer extends AggregationLayer {\n initializeState({dimensions}) {\n const {gl} = this.context;\n super.initializeState(dimensions);\n this.setState({\n // CPU aggregation results\n layerData: {},\n gpuGridAggregator: new GPUGridAggregator(gl, {id: `${this.id}-gpu-aggregator`}),\n cpuGridAggregator: pointToDensityGridDataCPU\n });\n }\n\n updateState(opts) {\n // get current attributes\n super.updateState(opts);\n\n this.updateAggregationState(opts);\n\n const {aggregationDataDirty, aggregationWeightsDirty, gpuAggregation} = this.state;\n if (this.getNumInstances() <= 0) {\n return;\n }\n let aggregationDirty = false;\n // CPU aggregation is two steps\n // 1. Create bins (based on cellSize and position) 2. Aggregate weights for each bin\n // For GPU aggregation both above steps are combined into one step\n\n // step-1\n if (aggregationDataDirty || (gpuAggregation && aggregationWeightsDirty)) {\n this._updateAggregation(opts);\n aggregationDirty = true;\n }\n // step-2 (Applicalbe for CPU aggregation only)\n if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {\n this._updateWeightBins();\n this._uploadAggregationResults();\n aggregationDirty = true;\n }\n\n this.setState({aggregationDirty});\n }\n\n finalizeState() {\n const {count} = this.state.weights;\n if (count && count.aggregationBuffer) {\n count.aggregationBuffer.delete();\n }\n this.state.gpuGridAggregator?.delete();\n super.finalizeState();\n }\n\n updateShaders(shaders) {\n if (this.state.gpuAggregation) {\n this.state.gpuGridAggregator.updateShaders(shaders);\n }\n }\n\n // Methods that can be overriden by subclasses for customizations\n\n updateAggregationState(opts) {\n // Sublayers should implement this method.\n log.assert(false);\n }\n\n allocateResources(numRow, numCol) {\n if (this.state.numRow !== numRow || this.state.numCol !== numCol) {\n const dataBytes = numCol * numRow * 4 * 4;\n const gl = this.context.gl;\n const {weights} = this.state;\n for (const name in weights) {\n const weight = weights[name];\n if (weight.aggregationBuffer) {\n weight.aggregationBuffer.delete();\n }\n weight.aggregationBuffer = new Buffer(gl, {\n byteLength: dataBytes,\n accessor: {\n size: 4,\n type: GL.FLOAT,\n divisor: 1\n }\n });\n }\n }\n }\n\n updateResults({aggregationData, maxMinData, maxData, minData}) {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = aggregationData;\n count.maxMinData = maxMinData;\n count.maxData = maxData;\n count.minData = minData;\n }\n }\n\n // Private\n\n _updateAggregation(opts) {\n const {\n cpuGridAggregator,\n gpuGridAggregator,\n gridOffset,\n posOffset,\n translation = [0, 0],\n scaling = [0, 0, 0],\n boundingBox,\n projectPoints,\n gpuAggregation,\n numCol,\n numRow\n } = this.state;\n const {props} = opts;\n const {viewport} = this.context;\n const attributes = this.getAttributes();\n const vertexCount = this.getNumInstances();\n\n if (!gpuAggregation) {\n const result = cpuGridAggregator(props, {\n gridOffset,\n projectPoints,\n attributes,\n viewport,\n posOffset,\n boundingBox\n });\n this.setState({\n layerData: result\n });\n } else {\n const {weights} = this.state;\n gpuGridAggregator.run({\n weights,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset],\n numCol,\n numRow,\n translation,\n scaling,\n vertexCount,\n projectPoints,\n attributes,\n moduleSettings: this.getModuleSettings()\n });\n }\n }\n\n _updateWeightBins() {\n const {getValue} = this.state;\n\n const sortedBins = new BinSorter(this.state.layerData.data || [], {getValue});\n this.setState({sortedBins});\n }\n\n _uploadAggregationResults() {\n const {numCol, numRow} = this.state;\n const {data} = this.state.layerData;\n const {aggregatedBins, minValue, maxValue, totalCount} = this.state.sortedBins;\n\n const ELEMENTCOUNT = 4;\n const aggregationSize = numCol * numRow * ELEMENTCOUNT;\n const aggregationData = new Float32Array(aggregationSize).fill(0);\n for (const bin of aggregatedBins) {\n const {lonIdx, latIdx} = data[bin.i];\n const {value, counts} = bin;\n const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;\n aggregationData[cellIndex] = value;\n aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;\n }\n const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);\n const maxData = new Float32Array([maxValue, 0, 0, totalCount]);\n const minData = new Float32Array([minValue, 0, 0, totalCount]);\n this.updateResults({aggregationData, maxMinData, maxData, minData});\n }\n}\n\nGridAggregationLayer.layerName = 'GridAggregationLayer';\n"],"file":"grid-aggregation-layer.js"}
1
+ {"version":3,"sources":["../../src/grid-aggregation-layer.js"],"names":["GridAggregationLayer","dimensions","gl","context","setState","layerData","gpuGridAggregator","GPUGridAggregator","id","cpuGridAggregator","pointToDensityGridDataCPU","opts","updateAggregationState","state","aggregationDataDirty","aggregationWeightsDirty","gpuAggregation","getNumInstances","aggregationDirty","_updateAggregation","_updateWeightBins","_uploadAggregationResults","count","weights","aggregationBuffer","delete","shaders","updateShaders","log","assert","numRow","numCol","dataBytes","name","weight","Buffer","byteLength","accessor","size","type","divisor","aggregationData","maxMinData","maxData","minData","gridOffset","posOffset","translation","scaling","boundingBox","projectPoints","props","viewport","attributes","getAttributes","vertexCount","result","run","cellSize","xOffset","yOffset","moduleSettings","getModuleSettings","getValue","sortedBins","BinSorter","data","aggregatedBins","minValue","maxValue","totalCount","ELEMENTCOUNT","aggregationSize","Float32Array","fill","bin","i","lonIdx","latIdx","value","counts","cellIndex","updateResults","AggregationLayer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAEqBA,oB;;;;;;;;;;;;WACnB,+BAA8B;AAAA,UAAbC,UAAa,QAAbA,UAAa;AAC5B,UAAOC,EAAP,GAAa,KAAKC,OAAlB,CAAOD,EAAP;AACA,4HAAsBD,UAAtB;AACA,WAAKG,QAAL,CAAc;AAEZC,QAAAA,SAAS,EAAE,EAFC;AAGZC,QAAAA,iBAAiB,EAAE,IAAIC,0BAAJ,CAAsBL,EAAtB,EAA0B;AAACM,UAAAA,EAAE,YAAK,KAAKA,EAAV;AAAH,SAA1B,CAHP;AAIZC,QAAAA,iBAAiB,EAAEC;AAJP,OAAd;AAMD;;;WAED,qBAAYC,IAAZ,EAAkB;AAEhB,wHAAkBA,IAAlB;AAEA,WAAKC,sBAAL,CAA4BD,IAA5B;AAEA,wBAAwE,KAAKE,KAA7E;AAAA,UAAOC,oBAAP,eAAOA,oBAAP;AAAA,UAA6BC,uBAA7B,eAA6BA,uBAA7B;AAAA,UAAsDC,cAAtD,eAAsDA,cAAtD;;AACA,UAAI,KAAKC,eAAL,MAA0B,CAA9B,EAAiC;AAC/B;AACD;;AACD,UAAIC,gBAAgB,GAAG,KAAvB;;AAMA,UAAIJ,oBAAoB,IAAKE,cAAc,IAAID,uBAA/C,EAAyE;AACvE,aAAKI,kBAAL,CAAwBR,IAAxB;;AACAO,QAAAA,gBAAgB,GAAG,IAAnB;AACD;;AAED,UAAI,CAACF,cAAD,KAAoBF,oBAAoB,IAAIC,uBAA5C,CAAJ,EAA0E;AACxE,aAAKK,iBAAL;;AACA,aAAKC,yBAAL;;AACAH,QAAAA,gBAAgB,GAAG,IAAnB;AACD;;AAED,WAAKd,QAAL,CAAc;AAACc,QAAAA,gBAAgB,EAAhBA;AAAD,OAAd;AACD;;;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B;AACA,UAAMzB,OAAO,GAAG,IAAI8B,YAAJ,CAAiB,CAACJ,QAAD,EAAW,CAAX,EAAc,CAAd,EAAiBC,UAAjB,CAAjB,CAAhB;AACA,UAAM1B,OAAO,GAAG,IAAI6B,YAAJ,CAAiB,CAACL,QAAD,EAAW,CAAX,EAAc,CAAd,EAAiBE,UAAjB,CAAjB,CAAhB;AACA,WAAKY,aAAL,CAAmB;AAACzC,QAAAA,eAAe,EAAfA,eAAD;AAAkBC,QAAAA,UAAU,EAAVA,UAAlB;AAA8BC,QAAAA,OAAO,EAAPA,OAA9B;AAAuCC,QAAAA,OAAO,EAAPA;AAAvC,OAAnB;AACD;;;EA5K+CuC,yB;;;AA+KlDnF,oBAAoB,CAACoF,SAArB,GAAiC,sBAAjC","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 AggregationLayer from './aggregation-layer';\nimport GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {Buffer} from '@luma.gl/core';\nimport {log} from '@deck.gl/core';\nimport GL from '@luma.gl/constants';\nimport BinSorter from './utils/bin-sorter';\nimport {pointToDensityGridDataCPU} from './cpu-grid-layer/grid-aggregator';\n\nexport default class GridAggregationLayer extends AggregationLayer {\n initializeState({dimensions}) {\n const {gl} = this.context;\n super.initializeState(dimensions);\n this.setState({\n // CPU aggregation results\n layerData: {},\n gpuGridAggregator: new GPUGridAggregator(gl, {id: `${this.id}-gpu-aggregator`}),\n cpuGridAggregator: pointToDensityGridDataCPU\n });\n }\n\n updateState(opts) {\n // get current attributes\n super.updateState(opts);\n\n this.updateAggregationState(opts);\n\n const {aggregationDataDirty, aggregationWeightsDirty, gpuAggregation} = this.state;\n if (this.getNumInstances() <= 0) {\n return;\n }\n let aggregationDirty = false;\n // CPU aggregation is two steps\n // 1. Create bins (based on cellSize and position) 2. Aggregate weights for each bin\n // For GPU aggregation both above steps are combined into one step\n\n // step-1\n if (aggregationDataDirty || (gpuAggregation && aggregationWeightsDirty)) {\n this._updateAggregation(opts);\n aggregationDirty = true;\n }\n // step-2 (Applicalbe for CPU aggregation only)\n if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {\n this._updateWeightBins();\n this._uploadAggregationResults();\n aggregationDirty = true;\n }\n\n this.setState({aggregationDirty});\n }\n\n finalizeState() {\n const {count} = this.state.weights;\n if (count && count.aggregationBuffer) {\n count.aggregationBuffer.delete();\n }\n this.state.gpuGridAggregator?.delete();\n super.finalizeState();\n }\n\n updateShaders(shaders) {\n if (this.state.gpuAggregation) {\n this.state.gpuGridAggregator.updateShaders(shaders);\n }\n }\n\n // Methods that can be overriden by subclasses for customizations\n\n updateAggregationState(opts) {\n // Sublayers should implement this method.\n log.assert(false);\n }\n\n allocateResources(numRow, numCol) {\n if (this.state.numRow !== numRow || this.state.numCol !== numCol) {\n const dataBytes = numCol * numRow * 4 * 4;\n const gl = this.context.gl;\n const {weights} = this.state;\n for (const name in weights) {\n const weight = weights[name];\n if (weight.aggregationBuffer) {\n weight.aggregationBuffer.delete();\n }\n weight.aggregationBuffer = new Buffer(gl, {\n byteLength: dataBytes,\n accessor: {\n size: 4,\n type: GL.FLOAT,\n divisor: 1\n }\n });\n }\n }\n }\n\n updateResults({aggregationData, maxMinData, maxData, minData}) {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = aggregationData;\n count.maxMinData = maxMinData;\n count.maxData = maxData;\n count.minData = minData;\n }\n }\n\n // Private\n\n _updateAggregation(opts) {\n const {\n cpuGridAggregator,\n gpuGridAggregator,\n gridOffset,\n posOffset,\n translation = [0, 0],\n scaling = [0, 0, 0],\n boundingBox,\n projectPoints,\n gpuAggregation,\n numCol,\n numRow\n } = this.state;\n const {props} = opts;\n const {viewport} = this.context;\n const attributes = this.getAttributes();\n const vertexCount = this.getNumInstances();\n\n if (!gpuAggregation) {\n const result = cpuGridAggregator(props, {\n gridOffset,\n projectPoints,\n attributes,\n viewport,\n posOffset,\n boundingBox\n });\n this.setState({\n layerData: result\n });\n } else {\n const {weights} = this.state;\n gpuGridAggregator.run({\n weights,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset],\n numCol,\n numRow,\n translation,\n scaling,\n vertexCount,\n projectPoints,\n attributes,\n moduleSettings: this.getModuleSettings()\n });\n }\n }\n\n _updateWeightBins() {\n const {getValue} = this.state;\n\n const sortedBins = new BinSorter(this.state.layerData.data || [], {getValue});\n this.setState({sortedBins});\n }\n\n _uploadAggregationResults() {\n const {numCol, numRow} = this.state;\n const {data} = this.state.layerData;\n const {aggregatedBins, minValue, maxValue, totalCount} = this.state.sortedBins;\n\n const ELEMENTCOUNT = 4;\n const aggregationSize = numCol * numRow * ELEMENTCOUNT;\n const aggregationData = new Float32Array(aggregationSize).fill(0);\n for (const bin of aggregatedBins) {\n const {lonIdx, latIdx} = data[bin.i];\n const {value, counts} = bin;\n const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;\n aggregationData[cellIndex] = value;\n aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;\n }\n const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);\n const maxData = new Float32Array([maxValue, 0, 0, totalCount]);\n const minData = new Float32Array([minValue, 0, 0, totalCount]);\n this.updateResults({aggregationData, maxMinData, maxData, minData});\n }\n}\n\nGridAggregationLayer.layerName = 'GridAggregationLayer';\n"],"file":"grid-aggregation-layer.js"}
@@ -7,6 +7,18 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+
10
22
  var _core = require("@deck.gl/core");
11
23
 
12
24
  var _gpuGridAggregator = _interopRequireDefault(require("../utils/gpu-grid-aggregation/gpu-grid-aggregator"));
@@ -15,77 +27,95 @@ var _gpuGridLayer = _interopRequireDefault(require("../gpu-grid-layer/gpu-grid-l
15
27
 
16
28
  var _cpuGridLayer = _interopRequireDefault(require("../cpu-grid-layer/cpu-grid-layer"));
17
29
 
18
- const defaultProps = { ..._gpuGridLayer.default.defaultProps,
19
- ..._cpuGridLayer.default.defaultProps,
30
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
31
+
32
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
+
34
+ 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; }
35
+
36
+ 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; }
37
+
38
+ var defaultProps = _objectSpread(_objectSpread(_objectSpread({}, _gpuGridLayer.default.defaultProps), _cpuGridLayer.default.defaultProps), {}, {
20
39
  gpuAggregation: false
21
- };
40
+ });
22
41
 
23
- class GridLayer extends _core.CompositeLayer {
24
- initializeState() {
25
- this.state = {
26
- useGPUAggregation: true
27
- };
28
- }
42
+ var GridLayer = function (_CompositeLayer) {
43
+ (0, _inherits2.default)(GridLayer, _CompositeLayer);
29
44
 
30
- updateState({
31
- oldProps,
32
- props,
33
- changeFlags
34
- }) {
35
- const newState = {};
36
- newState.useGPUAggregation = this.canUseGPUAggregation(props);
37
- this.setState(newState);
38
- }
45
+ var _super = _createSuper(GridLayer);
39
46
 
40
- renderLayers() {
41
- const {
42
- data,
43
- updateTriggers
44
- } = this.props;
45
- const id = this.state.useGPUAggregation ? 'GPU' : 'CPU';
46
- const LayerType = this.state.useGPUAggregation ? this.getSubLayerClass('GPU', _gpuGridLayer.default) : this.getSubLayerClass('CPU', _cpuGridLayer.default);
47
- return new LayerType(this.props, this.getSubLayerProps({
48
- id,
49
- updateTriggers
50
- }), {
51
- data
52
- });
47
+ function GridLayer() {
48
+ (0, _classCallCheck2.default)(this, GridLayer);
49
+ return _super.apply(this, arguments);
53
50
  }
54
51
 
55
- canUseGPUAggregation(props) {
56
- const {
57
- gpuAggregation,
58
- lowerPercentile,
59
- upperPercentile,
60
- getColorValue,
61
- getElevationValue,
62
- colorScaleType
63
- } = props;
64
-
65
- if (!gpuAggregation) {
66
- return false;
52
+ (0, _createClass2.default)(GridLayer, [{
53
+ key: "initializeState",
54
+ value: function initializeState() {
55
+ this.state = {
56
+ useGPUAggregation: true
57
+ };
67
58
  }
68
-
69
- if (!_gpuGridAggregator.default.isSupported(this.context.gl)) {
70
- return false;
71
- }
72
-
73
- if (lowerPercentile !== 0 || upperPercentile !== 100) {
74
- return false;
59
+ }, {
60
+ key: "updateState",
61
+ value: function updateState(_ref) {
62
+ var oldProps = _ref.oldProps,
63
+ props = _ref.props,
64
+ changeFlags = _ref.changeFlags;
65
+ var newState = {};
66
+ newState.useGPUAggregation = this.canUseGPUAggregation(props);
67
+ this.setState(newState);
75
68
  }
76
-
77
- if (getColorValue !== null || getElevationValue !== null) {
78
- return false;
69
+ }, {
70
+ key: "renderLayers",
71
+ value: function renderLayers() {
72
+ var _this$props = this.props,
73
+ data = _this$props.data,
74
+ updateTriggers = _this$props.updateTriggers;
75
+ var id = this.state.useGPUAggregation ? 'GPU' : 'CPU';
76
+ var LayerType = this.state.useGPUAggregation ? this.getSubLayerClass('GPU', _gpuGridLayer.default) : this.getSubLayerClass('CPU', _cpuGridLayer.default);
77
+ return new LayerType(this.props, this.getSubLayerProps({
78
+ id: id,
79
+ updateTriggers: updateTriggers
80
+ }), {
81
+ data: data
82
+ });
79
83
  }
80
-
81
- if (colorScaleType === 'quantile' || colorScaleType === 'ordinal') {
82
- return false;
84
+ }, {
85
+ key: "canUseGPUAggregation",
86
+ value: function canUseGPUAggregation(props) {
87
+ var gpuAggregation = props.gpuAggregation,
88
+ lowerPercentile = props.lowerPercentile,
89
+ upperPercentile = props.upperPercentile,
90
+ getColorValue = props.getColorValue,
91
+ getElevationValue = props.getElevationValue,
92
+ colorScaleType = props.colorScaleType;
93
+
94
+ if (!gpuAggregation) {
95
+ return false;
96
+ }
97
+
98
+ if (!_gpuGridAggregator.default.isSupported(this.context.gl)) {
99
+ return false;
100
+ }
101
+
102
+ if (lowerPercentile !== 0 || upperPercentile !== 100) {
103
+ return false;
104
+ }
105
+
106
+ if (getColorValue !== null || getElevationValue !== null) {
107
+ return false;
108
+ }
109
+
110
+ if (colorScaleType === 'quantile' || colorScaleType === 'ordinal') {
111
+ return false;
112
+ }
113
+
114
+ return true;
83
115
  }
84
-
85
- return true;
86
- }
87
-
88
- }
116
+ }]);
117
+ return GridLayer;
118
+ }(_core.CompositeLayer);
89
119
 
90
120
  exports.default = GridLayer;
91
121
  GridLayer.layerName = 'GridLayer';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/grid-layer/grid-layer.js"],"names":["defaultProps","GPUGridLayer","CPUGridLayer","gpuAggregation","GridLayer","CompositeLayer","initializeState","state","useGPUAggregation","updateState","oldProps","props","changeFlags","newState","canUseGPUAggregation","setState","renderLayers","data","updateTriggers","id","LayerType","getSubLayerClass","getSubLayerProps","lowerPercentile","upperPercentile","getColorValue","getElevationValue","colorScaleType","GPUGridAggregator","isSupported","context","gl","layerName"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA,MAAMA,YAAY,GAAG,EACnB,GAAGC,sBAAaD,YADG;AAEnB,KAAGE,sBAAaF,YAFG;AAGnBG,EAAAA,cAAc,EAAE;AAHG,CAArB;;AAMe,MAAMC,SAAN,SAAwBC,oBAAxB,CAAuC;AACpDC,EAAAA,eAAe,GAAG;AAChB,SAAKC,KAAL,GAAa;AACXC,MAAAA,iBAAiB,EAAE;AADR,KAA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QAAIC,aAAa,KAAK,IAAlB,IAA0BC,iBAAiB,KAAK,IAApD,EAA0D;AAExD,aAAO,KAAP;AACD;;AACD,QAAIC,cAAc,KAAK,UAAnB,IAAiCA,cAAc,KAAK,SAAxD,EAAmE;AAEjE,aAAO,KAAP;AACD;;AACD,WAAO,IAAP;AACD;;AA9DmD;;;AAiEtDvB,SAAS,CAAC4B,SAAV,GAAsB,WAAtB;AACA5B,SAAS,CAACJ,YAAV,GAAyBA,YAAzB","sourcesContent":["import {CompositeLayer} from '@deck.gl/core';\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport GPUGridLayer from '../gpu-grid-layer/gpu-grid-layer';\nimport CPUGridLayer from '../cpu-grid-layer/cpu-grid-layer';\n\nconst defaultProps = {\n ...GPUGridLayer.defaultProps,\n ...CPUGridLayer.defaultProps,\n gpuAggregation: false\n};\n\nexport default class GridLayer extends CompositeLayer {\n initializeState() {\n this.state = {\n useGPUAggregation: true\n };\n }\n\n updateState({oldProps, props, changeFlags}) {\n const newState = {};\n newState.useGPUAggregation = this.canUseGPUAggregation(props);\n this.setState(newState);\n }\n\n renderLayers() {\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) {\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\nGridLayer.layerName = 'GridLayer';\nGridLayer.defaultProps = defaultProps;\n"],"file":"grid-layer.js"}
1
+ {"version":3,"sources":["../../../src/grid-layer/grid-layer.js"],"names":["defaultProps","GPUGridLayer","CPUGridLayer","gpuAggregation","GridLayer","state","useGPUAggregation","oldProps","props","changeFlags","newState","canUseGPUAggregation","setState","data","updateTriggers","id","LayerType","getSubLayerClass","getSubLayerProps","lowerPercentile","upperPercentile","getColorValue","getElevationValue","colorScaleType","GPUGridAggregator","isSupported","context","gl","CompositeLayer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,YAAY,iDACbC,sBAAaD,YADA,GAEbE,sBAAaF,YAFA;AAGhBG,EAAAA,cAAc,EAAE;AAHA,EAAlB;;IAMqBC,S;;;;;;;;;;;;WACnB,2BAAkB;AAChB,WAAKC,KAAL,GAAa;AACXC,QAAAA,iBAAiB,EAAE;AADR,OAAb;AAGD;;;WAED,2BAA4C;AAAA,UAA/BC,QAA+B,QAA/BA,QAA+B;AAAA,UAArBC,KAAqB,QAArBA,KAAqB;AAAA,UAAdC,WAAc,QAAdA,WAAc;AAC1C,UAAMC,QAAQ,GAAG,EAAjB;AACAA,MAAAA,QAAQ,CAACJ,iBAAT,GAA6B,KAAKK,oBAAL,CAA0BH,KAA1B,CAA7B;AACA,WAAKI,QAAL,CAAcF,QAAd;AACD;;;WAED,wBAAe;AACb,wBAA+B,KAAKF,KAApC;AAAA,UAAOK,IAAP,eAAOA,IAAP;AAAA,UAAaC,cAAb,eAAaA,cAAb;AACA,UAAMC,EAAE,GAAG,KAAKV,KAAL,CAAWC,iBAAX,GAA+B,KAA/B,GAAuC,KAAlD;AACA,UAAMU,SAAS,GAAG,KAAKX,KAAL,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from '@deck.gl/core';\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport GPUGridLayer from '../gpu-grid-layer/gpu-grid-layer';\nimport CPUGridLayer from '../cpu-grid-layer/cpu-grid-layer';\n\nconst defaultProps = {\n ...GPUGridLayer.defaultProps,\n ...CPUGridLayer.defaultProps,\n gpuAggregation: false\n};\n\nexport default class GridLayer extends CompositeLayer {\n initializeState() {\n this.state = {\n useGPUAggregation: true\n };\n }\n\n updateState({oldProps, props, changeFlags}) {\n const newState = {};\n newState.useGPUAggregation = this.canUseGPUAggregation(props);\n this.setState(newState);\n }\n\n renderLayers() {\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) {\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\nGridLayer.layerName = 'GridLayer';\nGridLayer.defaultProps = defaultProps;\n"],"file":"grid-layer.js"}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -10,15 +12,27 @@ exports.scaleToAspectRatio = scaleToAspectRatio;
10
12
  exports.getTextureCoordinates = getTextureCoordinates;
11
13
  exports.getTextureParams = getTextureParams;
12
14
 
15
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
+
13
17
  var _core = require("@luma.gl/core");
14
18
 
19
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { 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 = it.call(o); }, 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; } } }; }
20
+
21
+ 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); }
22
+
23
+ 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; }
24
+
15
25
  function getBounds(points) {
16
- const x = points.map(p => p[0]);
17
- const y = points.map(p => p[1]);
18
- const xMin = Math.min.apply(null, x);
19
- const xMax = Math.max.apply(null, x);
20
- const yMin = Math.min.apply(null, y);
21
- const yMax = Math.max.apply(null, y);
26
+ var x = points.map(function (p) {
27
+ return p[0];
28
+ });
29
+ var y = points.map(function (p) {
30
+ return p[1];
31
+ });
32
+ var xMin = Math.min.apply(null, x);
33
+ var xMax = Math.max.apply(null, x);
34
+ var yMin = Math.min.apply(null, y);
35
+ var yMax = Math.max.apply(null, y);
22
36
  return [xMin, yMin, xMax, yMax];
23
37
  }
24
38
 
@@ -30,26 +44,43 @@ function boundsContain(currentBounds, targetBounds) {
30
44
  return false;
31
45
  }
32
46
 
33
- const scratchArray = new Float32Array(12);
47
+ var scratchArray = new Float32Array(12);
34
48
 
35
- function packVertices(points, dimensions = 2) {
36
- let index = 0;
49
+ function packVertices(points) {
50
+ var dimensions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
51
+ var index = 0;
37
52
 
38
- for (const point of points) {
39
- for (let i = 0; i < dimensions; i++) {
40
- scratchArray[index++] = point[i] || 0;
53
+ var _iterator = _createForOfIteratorHelper(points),
54
+ _step;
55
+
56
+ try {
57
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
58
+ var point = _step.value;
59
+
60
+ for (var i = 0; i < dimensions; i++) {
61
+ scratchArray[index++] = point[i] || 0;
62
+ }
41
63
  }
64
+ } catch (err) {
65
+ _iterator.e(err);
66
+ } finally {
67
+ _iterator.f();
42
68
  }
43
69
 
44
70
  return scratchArray;
45
71
  }
46
72
 
47
73
  function scaleToAspectRatio(boundingBox, width, height) {
48
- const [xMin, yMin, xMax, yMax] = boundingBox;
49
- const currentWidth = xMax - xMin;
50
- const currentHeight = yMax - yMin;
51
- let newWidth = currentWidth;
52
- let newHeight = currentHeight;
74
+ var _boundingBox = (0, _slicedToArray2.default)(boundingBox, 4),
75
+ xMin = _boundingBox[0],
76
+ yMin = _boundingBox[1],
77
+ xMax = _boundingBox[2],
78
+ yMax = _boundingBox[3];
79
+
80
+ var currentWidth = xMax - xMin;
81
+ var currentHeight = yMax - yMin;
82
+ var newWidth = currentWidth;
83
+ var newHeight = currentHeight;
53
84
 
54
85
  if (currentWidth / currentHeight < width / height) {
55
86
  newWidth = width / height * currentHeight;
@@ -62,20 +93,24 @@ function scaleToAspectRatio(boundingBox, width, height) {
62
93
  newHeight = height;
63
94
  }
64
95
 
65
- const xCenter = (xMax + xMin) / 2;
66
- const yCenter = (yMax + yMin) / 2;
96
+ var xCenter = (xMax + xMin) / 2;
97
+ var yCenter = (yMax + yMin) / 2;
67
98
  return [xCenter - newWidth / 2, yCenter - newHeight / 2, xCenter + newWidth / 2, yCenter + newHeight / 2];
68
99
  }
69
100
 
70
101
  function getTextureCoordinates(point, bounds) {
71
- const [xMin, yMin, xMax, yMax] = bounds;
102
+ var _bounds = (0, _slicedToArray2.default)(bounds, 4),
103
+ xMin = _bounds[0],
104
+ yMin = _bounds[1],
105
+ xMax = _bounds[2],
106
+ yMax = _bounds[3];
107
+
72
108
  return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];
73
109
  }
74
110
 
75
- function getTextureParams({
76
- gl,
77
- floatTargetSupport
78
- }) {
111
+ function getTextureParams(_ref) {
112
+ var gl = _ref.gl,
113
+ floatTargetSupport = _ref.floatTargetSupport;
79
114
  return {
80
115
  format: (0, _core.isWebGL2)(gl) ? 34836 : 6408,
81
116
  type: floatTargetSupport ? 5126 : 5121
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer-utils.js"],"names":["getBounds","points","x","map","p","y","xMin","Math","min","apply","xMax","max","yMin","yMax","boundsContain","currentBounds","targetBounds","scratchArray","Float32Array","packVertices","dimensions","index","point","i","scaleToAspectRatio","boundingBox","width","height","currentWidth","currentHeight","newWidth","newHeight","xCenter","yCenter","getTextureCoordinates","bounds","getTextureParams","gl","floatTargetSupport","format","type"],"mappings":";;;;;;;;;;;;AACA;;AAEO,SAASA,SAAT,CAAmBC,MAAnB,EAA2B;AAEhC,QAAMC,CAAC,GAAGD,MAAM,CAACE,GAAP,CAAWC,CAA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EAAmBG,IAAnB,IAA2BsB,MAAjC;AACA,SAAO,CAAC,CAACb,KAAK,CAAC,CAAD,CAAL,GAAWhB,IAAZ,KAAqBI,IAAI,GAAGJ,IAA5B,CAAD,EAAoC,CAACgB,KAAK,CAAC,CAAD,CAAL,GAAWV,IAAZ,KAAqBC,IAAI,GAAGD,IAA5B,CAApC,CAAP;AACD;;AAGM,SAASwB,gBAAT,CAA0B;AAACC,EAAAA,EAAD;AAAKC,EAAAA;AAAL,CAA1B,EAAoD;AACzD,SAAO;AAELC,IAAAA,MAAM,EAAE,oBAASF,EAAT,gBAFH;AAGLG,IAAAA,IAAI,EAAEF,kBAAkB;AAHnB,GAAP;AAKD","sourcesContent":["import GL from '@luma.gl/constants';\nimport {isWebGL2} from '@luma.gl/core';\n\nexport function getBounds(points) {\n // Now build bounding box in world space (aligned to world coordiante system)\n const x = points.map(p => p[0]);\n const y = points.map(p => p[1]);\n\n const xMin = Math.min.apply(null, x);\n const xMax = Math.max.apply(null, x);\n const yMin = Math.min.apply(null, y);\n const yMax = Math.max.apply(null, y);\n\n return [xMin, yMin, xMax, yMax];\n}\n\n// true if currentBounds contains targetBounds, false otherwise\nexport function boundsContain(currentBounds, targetBounds) {\n if (\n targetBounds[0] >= currentBounds[0] &&\n targetBounds[2] <= currentBounds[2] &&\n targetBounds[1] >= currentBounds[1] &&\n targetBounds[3] <= currentBounds[3]\n ) {\n return true;\n }\n return false;\n}\n\nconst scratchArray = new Float32Array(12);\n\n// For given rectangle bounds generates two triangles vertices that coverit completely\nexport function packVertices(points, dimensions = 2) {\n let index = 0;\n for (const point of points) {\n for (let i = 0; i < dimensions; i++) {\n scratchArray[index++] = point[i] || 0;\n }\n }\n return scratchArray;\n}\n\n// Expands boundingBox:[xMin, yMin, xMax, yMax] to match aspect ratio of given width and height\nexport function scaleToAspectRatio(boundingBox, width, height) {\n const [xMin, yMin, xMax, yMax] = boundingBox;\n\n const currentWidth = xMax - xMin;\n const currentHeight = yMax - yMin;\n\n let newWidth = currentWidth;\n let newHeight = currentHeight;\n if (currentWidth / currentHeight < width / height) {\n // expand bounding box width\n newWidth = (width / height) * currentHeight;\n } else {\n newHeight = (height / width) * currentWidth;\n }\n\n if (newWidth < width) {\n newWidth = width;\n newHeight = height;\n }\n\n const xCenter = (xMax + xMin) / 2;\n const yCenter = (yMax + yMin) / 2;\n\n return [\n xCenter - newWidth / 2,\n yCenter - newHeight / 2,\n xCenter + newWidth / 2,\n yCenter + newHeight / 2\n ];\n}\n\n// Get texture coordiante of point inside a bounding box\nexport function getTextureCoordinates(point, bounds) {\n const [xMin, yMin, xMax, yMax] = bounds;\n return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];\n}\n\n// Returns format and type for creating texture objects\nexport function getTextureParams({gl, floatTargetSupport}) {\n return {\n // format: should be RGBA32F on WebGL2 (float textures), RGBA in WebGL1 for float or non float textures\n format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,\n type: floatTargetSupport ? GL.FLOAT : GL.UNSIGNED_BYTE\n };\n}\n"],"file":"heatmap-layer-utils.js"}
1
+ {"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer-utils.js"],"names":["getBounds","points","x","map","p","y","xMin","Math","min","apply","xMax","max","yMin","yMax","boundsContain","currentBounds","targetBounds","scratchArray","Float32Array","packVertices","dimensions","index","point","i","scaleToAspectRatio","boundingBox","width","height","currentWidth","currentHeight","newWidth","newHeight","xCenter","yCenter","getTextureCoordinates","bounds","getTextureParams","gl","floatTargetSupport","format","type"],"mappings":";;;;;;;;;;;;;;;;AACA;;;;;;;;AAEO,SAASA,SAAT,CAAmBC,MAAnB,EAA2B;AAEhC,MAAMC,CAAC,GAAGD,MAAM,CAACE,GAAP,CAAW,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAAC,CAAD,CAAL;AAAA,GAAZ,CAAV;AACA,MAAMC,CAAC,GAAGJ,MAAM,CAACE,GAAP,CAAW,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAAC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AA,MAAmBF,IAAnB;AAAA,MAAyBG,IAAzB;;AACA,SAAO,CAAC,CAACS,KAAK,CAAC,CAAD,CAAL,GAAWhB,IAAZ,KAAqBI,IAAI,GAAGJ,IAA5B,CAAD,EAAoC,CAACgB,KAAK,CAAC,CAAD,CAAL,GAAWV,IAAZ,KAAqBC,IAAI,GAAGD,IAA5B,CAApC,CAAP;AACD;;AAGM,SAASwB,gBAAT,OAAoD;AAAA,MAAzBC,EAAyB,QAAzBA,EAAyB;AAAA,MAArBC,kBAAqB,QAArBA,kBAAqB;AACzD,SAAO;AAELC,IAAAA,MAAM,EAAE,oBAASF,EAAT,gBAFH;AAGLG,IAAAA,IAAI,EAAEF,kBAAkB;AAHnB,GAAP;AAKD","sourcesContent":["import GL from '@luma.gl/constants';\nimport {isWebGL2} from '@luma.gl/core';\n\nexport function getBounds(points) {\n // Now build bounding box in world space (aligned to world coordiante system)\n const x = points.map(p => p[0]);\n const y = points.map(p => p[1]);\n\n const xMin = Math.min.apply(null, x);\n const xMax = Math.max.apply(null, x);\n const yMin = Math.min.apply(null, y);\n const yMax = Math.max.apply(null, y);\n\n return [xMin, yMin, xMax, yMax];\n}\n\n// true if currentBounds contains targetBounds, false otherwise\nexport function boundsContain(currentBounds, targetBounds) {\n if (\n targetBounds[0] >= currentBounds[0] &&\n targetBounds[2] <= currentBounds[2] &&\n targetBounds[1] >= currentBounds[1] &&\n targetBounds[3] <= currentBounds[3]\n ) {\n return true;\n }\n return false;\n}\n\nconst scratchArray = new Float32Array(12);\n\n// For given rectangle bounds generates two triangles vertices that coverit completely\nexport function packVertices(points, dimensions = 2) {\n let index = 0;\n for (const point of points) {\n for (let i = 0; i < dimensions; i++) {\n scratchArray[index++] = point[i] || 0;\n }\n }\n return scratchArray;\n}\n\n// Expands boundingBox:[xMin, yMin, xMax, yMax] to match aspect ratio of given width and height\nexport function scaleToAspectRatio(boundingBox, width, height) {\n const [xMin, yMin, xMax, yMax] = boundingBox;\n\n const currentWidth = xMax - xMin;\n const currentHeight = yMax - yMin;\n\n let newWidth = currentWidth;\n let newHeight = currentHeight;\n if (currentWidth / currentHeight < width / height) {\n // expand bounding box width\n newWidth = (width / height) * currentHeight;\n } else {\n newHeight = (height / width) * currentWidth;\n }\n\n if (newWidth < width) {\n newWidth = width;\n newHeight = height;\n }\n\n const xCenter = (xMax + xMin) / 2;\n const yCenter = (yMax + yMin) / 2;\n\n return [\n xCenter - newWidth / 2,\n yCenter - newHeight / 2,\n xCenter + newWidth / 2,\n yCenter + newHeight / 2\n ];\n}\n\n// Get texture coordiante of point inside a bounding box\nexport function getTextureCoordinates(point, bounds) {\n const [xMin, yMin, xMax, yMax] = bounds;\n return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];\n}\n\n// Returns format and type for creating texture objects\nexport function getTextureParams({gl, floatTargetSupport}) {\n return {\n // format: should be RGBA32F on WebGL2 (float textures), RGBA in WebGL1 for float or non float textures\n format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,\n type: floatTargetSupport ? GL.FLOAT : GL.UNSIGNED_BYTE\n };\n}\n"],"file":"heatmap-layer-utils.js"}