@deck.gl/aggregation-layers 8.10.0-alpha.7 → 9.0.0-alpha.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/dist.dev.js +9372 -356
- package/dist/es5/aggregation-layer.js +4 -6
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +13 -2
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +12 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/es5/cpu-grid-layer/grid-aggregator.js +12 -8
- package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +27 -13
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +19 -10
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-aggregation-layer.js +7 -9
- package/dist/es5/grid-aggregation-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +1 -1
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +3 -3
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +58 -55
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +22 -12
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +2 -0
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +23 -20
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +6 -6
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
- package/dist/es5/utils/bin-sorter.js.map +1 -1
- package/dist/es5/utils/cpu-aggregator.js +11 -7
- package/dist/es5/utils/cpu-aggregator.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +7 -2
- 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 +83 -60
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
- package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
- package/dist/es5/utils/prop-utils.js.map +1 -1
- package/dist/es5/utils/resource-utils.js +12 -23
- package/dist/es5/utils/resource-utils.js.map +1 -1
- package/dist/esm/aggregation-layer.js +4 -5
- package/dist/esm/aggregation-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js +7 -1
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -0
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/esm/cpu-grid-layer/grid-aggregator.js +2 -1
- package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +19 -10
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +13 -10
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-aggregation-layer.js +4 -8
- package/dist/esm/grid-aggregation-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js +1 -1
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js +3 -3
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +40 -58
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +13 -7
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +1 -0
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +21 -24
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -8
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/utils/aggregation-operation-utils.js.map +1 -1
- package/dist/esm/utils/bin-sorter.js.map +1 -1
- package/dist/esm/utils/cpu-aggregator.js +11 -7
- package/dist/esm/utils/cpu-aggregator.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +4 -3
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +62 -51
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
- package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
- package/dist/esm/utils/grid-aggregation-utils.js.map +1 -1
- package/dist/esm/utils/prop-utils.js.map +1 -1
- package/dist/esm/utils/resource-utils.js +10 -17
- package/dist/esm/utils/resource-utils.js.map +1 -1
- package/dist.min.js +185 -30
- package/package.json +7 -5
- package/src/aggregation-layer.ts +7 -6
- package/src/contour-layer/contour-layer.ts +25 -9
- package/src/cpu-grid-layer/cpu-grid-layer.ts +8 -3
- package/src/cpu-grid-layer/{grid-aggregator.js → grid-aggregator.ts} +28 -4
- package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +38 -27
- package/src/gpu-grid-layer/gpu-grid-layer.ts +18 -12
- package/src/grid-aggregation-layer.ts +39 -13
- package/src/grid-layer/grid-layer.ts +2 -2
- package/src/heatmap-layer/heatmap-layer-utils.ts +10 -4
- package/src/heatmap-layer/heatmap-layer.ts +74 -67
- package/src/heatmap-layer/triangle-layer.ts +26 -22
- package/src/hexagon-layer/{hexagon-aggregator.js → hexagon-aggregator.ts} +5 -1
- package/src/hexagon-layer/hexagon-layer.ts +8 -5
- package/src/index.ts +0 -1
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +36 -33
- package/src/screen-grid-layer/screen-grid-layer.ts +12 -11
- package/src/utils/{aggregation-operation-utils.js → aggregation-operation-utils.ts} +8 -2
- package/src/utils/bin-sorter.ts +1 -1
- package/src/utils/{cpu-aggregator.js → cpu-aggregator.ts} +42 -30
- package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-constants.js → gpu-grid-aggregator-constants.ts} +4 -4
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
- package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator.js → gpu-grid-aggregator.ts} +123 -94
- package/src/utils/{grid-aggregation-utils.js → grid-aggregation-utils.ts} +1 -1
- package/src/utils/resource-utils.ts +59 -0
- package/typed/aggregation-layer.d.ts +4 -3
- package/typed/aggregation-layer.d.ts.map +1 -1
- package/typed/contour-layer/contour-layer.d.ts +19 -5
- package/typed/contour-layer/contour-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +8 -3
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/grid-aggregator.d.ts +16 -4
- package/typed/cpu-grid-layer/grid-aggregator.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +18 -4
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +8 -3
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
- package/typed/grid-aggregation-layer.d.ts +39 -4
- package/typed/grid-aggregation-layer.d.ts.map +1 -1
- package/typed/grid-layer/grid-layer.d.ts +2 -2
- package/typed/grid-layer/grid-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +7 -5
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.d.ts +19 -6
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer.d.ts +10 -6
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-aggregator.d.ts +6 -3
- package/typed/hexagon-layer/hexagon-aggregator.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-layer.d.ts +5 -4
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/typed/index.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +10 -9
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer.d.ts +6 -4
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/typed/utils/aggregation-operation-utils.d.ts +18 -12
- package/typed/utils/aggregation-operation-utils.d.ts.map +1 -1
- package/typed/utils/bin-sorter.d.ts +1 -1
- package/typed/utils/bin-sorter.d.ts.map +1 -1
- package/typed/utils/cpu-aggregator.d.ts +28 -14
- package/typed/utils/cpu-aggregator.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +35 -33
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +29 -19
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +1 -1
- package/typed/utils/grid-aggregation-utils.d.ts +11 -5
- package/typed/utils/grid-aggregation-utils.d.ts.map +1 -1
- package/typed/utils/prop-utils.d.ts +1 -1
- package/typed/utils/prop-utils.d.ts.map +1 -1
- package/typed/utils/resource-utils.d.ts +13 -3
- package/typed/utils/resource-utils.d.ts.map +1 -1
- package/LICENSE +0 -19
- package/src/utils/resource-utils.js +0 -51
- /package/src/utils/gpu-grid-aggregation/{aggregate-all-fs.glsl.js → aggregate-all-fs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{aggregate-all-vs.glsl.js → aggregate-all-vs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-fs.glsl.js → aggregate-to-grid-fs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-vs.glsl.js → aggregate-to-grid-vs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-utils.js → gpu-grid-aggregator-utils.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{transform-mean-vs.glsl.js → transform-mean-vs.glsl.ts} +0 -0
- /package/src/utils/{prop-utils.js → prop-utils.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/grid-aggregation-utils.
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/grid-aggregation-utils.ts"],"names":["R_EARTH","toFinite","n","Number","isFinite","getBoundingBox","attributes","vertexCount","positions","value","yMin","Infinity","yMax","xMin","xMax","y","x","i","boundingBox","getTranslation","gridOffset","coordinateSystem","viewport","width","height","worldOrigin","COORDINATE_SYSTEM","CARTESIAN","log","assert","LNGLAT","DEFAULT","alignToCell","xOffset","yOffset","inValue","cellSize","sign","Math","abs","floor","getGridOffset","convertToMeters","centerLat","calculateGridLatLonOffset","getGridParams","translation","numCol","ceil","numRow","latitude","calculateLatOffset","calculateLonOffset","dy","PI","lat","dx","cos"],"mappings":";;;;;;;;;;AAAA;;AACA,IAAMA,OAAO,GAAG,OAAhB;;AAEA,SAASC,QAAT,CAAkBC,CAAlB,EAAqB;AACnB,SAAOC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,IAAqBA,CAArB,GAAyB,CAAhC;AACD;;AAIM,SAASG,cAAT,CAAwBC,UAAxB,E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ACA,SAAO;AAACd,IAAAA,UAAU,EAAVA,UAAD;AAAa0B,IAAAA,WAAW,EAAXA,WAAb;AAA0BvB,IAAAA,KAAK,EAALA,KAA1B;AAAiCC,IAAAA,MAAM,EAANA,MAAjC;AAAyCuB,IAAAA,MAAM,EAANA,MAAzC;AAAiDE,IAAAA,MAAM,EAANA;AAAjD,GAAP;AACD;;AASD,SAASL,yBAAT,CAAmCR,QAAnC,EAA6Cc,QAA7C,EAAuD;AACrD,MAAMhB,OAAO,GAAGiB,kBAAkB,CAACf,QAAD,CAAlC;AACA,MAAMH,OAAO,GAAGmB,kBAAkB,CAACF,QAAD,EAAWd,QAAX,CAAlC;AACA,SAAO;AAACF,IAAAA,OAAO,EAAPA,OAAD;AAAUD,IAAAA,OAAO,EAAPA;AAAV,GAAP;AACD;;AAQD,SAASkB,kBAAT,CAA4BE,EAA5B,EAAgC;AAC9B,SAAQA,EAAE,GAAGrD,OAAN,IAAkB,MAAMsC,IAAI,CAACgB,EAA7B,CAAP;AACD;;AAUD,SAASF,kBAAT,CAA4BG,GAA5B,EAAiCC,EAAjC,EAAqC;AACnC,SAASA,EAAE,GAAGxD,OAAN,IAAkB,MAAMsC,IAAI,CAACgB,EAA7B,CAAD,GAAqChB,IAAI,CAACmB,GAAL,CAAUF,GAAG,GAAGjB,IAAI,CAACgB,EAAZ,GAAkB,GAA3B,CAA5C;AACD","sourcesContent":["import {log, COORDINATE_SYSTEM} from '@deck.gl/core';\nconst R_EARTH = 6378000;\n\nfunction toFinite(n) {\n return Number.isFinite(n) ? n : 0;\n}\n\n// Parse input data to build positions, wights and bounding box.\n/* eslint-disable-next-line max-statements */\nexport function getBoundingBox(attributes, vertexCount) {\n // TODO - value might not exist (e.g. attribute transition)\n const positions = attributes.positions.value;\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 < vertexCount; i++) {\n x = positions[i * 3];\n y = positions[i * 3 + 1];\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 const boundingBox = {\n xMin: toFinite(xMin),\n xMax: toFinite(xMax),\n yMin: toFinite(yMin),\n yMax: toFinite(yMax)\n };\n\n return boundingBox;\n}\n/* eslint-enable max-statements */\n\n// Returns XY translation for positions to peform aggregation in +ve sapce\nfunction getTranslation(boundingBox, gridOffset, coordinateSystem, viewport) {\n const {width, height} = viewport;\n\n // Origin to define grid\n // DEFAULT coordinate system is treated as LNGLAT\n const worldOrigin =\n coordinateSystem === COORDINATE_SYSTEM.CARTESIAN ? [-width / 2, -height / 2] : [-180, -90];\n\n // Other coordinate systems not supported/verified yet\n log.assert(\n coordinateSystem === COORDINATE_SYSTEM.CARTESIAN ||\n coordinateSystem === COORDINATE_SYSTEM.LNGLAT ||\n coordinateSystem === COORDINATE_SYSTEM.DEFAULT\n );\n\n const {xMin, yMin} = boundingBox;\n return [\n // Align origin to match grid cell boundaries in CPU and GPU aggregations\n -1 * (alignToCell(xMin - worldOrigin[0], gridOffset.xOffset) + worldOrigin[0]),\n -1 * (alignToCell(yMin - worldOrigin[1], gridOffset.yOffset) + worldOrigin[1])\n ];\n}\n\n// Aligns `inValue` to given `cellSize`\nexport function alignToCell(inValue, cellSize) {\n const sign = inValue < 0 ? -1 : 1;\n\n let value = sign < 0 ? Math.abs(inValue) + cellSize : Math.abs(inValue);\n\n value = Math.floor(value / cellSize) * cellSize;\n\n return value * sign;\n}\n\n/**\n * Based on geometric center of sample points, calculate cellSize in lng/lat (degree) space\n * @param {object} boundingBox - {xMin, yMin, xMax, yMax} contains bounding box of data\n * @param {number} cellSize - grid cell size in meters\n * @param {boolean, optional} converToDegrees - when true offsets are converted from meters to lng/lat (degree) space\n * @returns {xOffset, yOffset} - cellSize size\n */\n\nexport function getGridOffset(boundingBox, cellSize, convertToMeters = true) {\n if (!convertToMeters) {\n return {xOffset: cellSize, yOffset: cellSize};\n }\n\n const {yMin, yMax} = boundingBox;\n const centerLat = (yMin + yMax) / 2;\n\n return calculateGridLatLonOffset(cellSize, centerLat);\n}\n\nexport function getGridParams(boundingBox, cellSize, viewport, coordinateSystem) {\n const gridOffset = getGridOffset(\n boundingBox,\n cellSize,\n coordinateSystem !== COORDINATE_SYSTEM.CARTESIAN\n );\n\n const translation = getTranslation(boundingBox, gridOffset, coordinateSystem, viewport);\n\n const {xMin, yMin, xMax, yMax} = boundingBox;\n\n const width = xMax - xMin + gridOffset.xOffset;\n const height = yMax - yMin + gridOffset.yOffset;\n\n const numCol = Math.ceil(width / gridOffset.xOffset);\n const numRow = Math.ceil(height / gridOffset.yOffset);\n return {gridOffset, translation, width, height, numCol, numRow};\n}\n\n/**\n * calculate grid layer cell size in lat lon based on world unit size\n * and current latitude\n * @param {number} cellSize\n * @param {number} latitude\n * @returns {object} - lat delta and lon delta\n */\nfunction calculateGridLatLonOffset(cellSize, latitude) {\n const yOffset = calculateLatOffset(cellSize);\n const xOffset = calculateLonOffset(latitude, cellSize);\n return {yOffset, xOffset};\n}\n\n/**\n * with a given x-km change, calculate the increment of latitude\n * based on stackoverflow http://stackoverflow.com/questions/7477003\n * @param {number} dy - change in km\n * @return {number} - increment in latitude\n */\nfunction calculateLatOffset(dy) {\n return (dy / R_EARTH) * (180 / Math.PI);\n}\n\n/**\n * with a given x-km change, and current latitude\n * calculate the increment of longitude\n * based on stackoverflow http://stackoverflow.com/questions/7477003\n * @param {number} lat - latitude of current location (based on city)\n * @param {number} dx - change in km\n * @return {number} - increment in longitude\n */\nfunction calculateLonOffset(lat, dx) {\n return ((dx / R_EARTH) * (180 / Math.PI)) / Math.cos((lat * Math.PI) / 180);\n}\n"],"file":"grid-aggregation-utils.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/prop-utils.
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/prop-utils.ts"],"names":["filterProps","props","filterKeys","filteredProps","key","includes"],"mappings":";;;;;;;AAoBO,SAASA,WAAT,CAAqBC,KAArB,EAA4BC,UAA5B,EAAwC;AAC7C,MAAMC,aAAa,GAAG,EAAtB;;AACA,OAAK,IAAMC,GAAX,IAAkBH,KAAlB,EAAyB;AACvB,QAAI,CAACC,UAAU,CAACG,QAAX,CAAoBD,GAApB,CAAL,EAA+B;AAC7BD,MAAAA,aAAa,CAACC,GAAD,CAAb,GAAqBH,KAAK,CAACG,GAAD,CAA1B;AACD;AACF;;AACD,SAAOD,aAAP;AACD","sourcesContent":["// Copyright (c) 2015 - 2019 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\nexport function filterProps(props, filterKeys) {\n const filteredProps = {};\n for (const key in props) {\n if (!filterKeys.includes(key)) {\n filteredProps[key] = props[key];\n }\n }\n return filteredProps;\n}\n"],"file":"prop-utils.js"}
|
|
@@ -1,24 +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.getFloatTexture = getFloatTexture;
|
|
9
7
|
exports.getFramebuffer = getFramebuffer;
|
|
10
8
|
exports.getFloatArray = getFloatArray;
|
|
9
|
+
var DEFAULT_PARAMETERS = {
|
|
10
|
+
minFilter: 'nearest',
|
|
11
|
+
magFilter: 'nearest'
|
|
12
|
+
};
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _core = require("@luma.gl/core");
|
|
15
|
-
|
|
16
|
-
var _DEFAULT_PARAMETERS;
|
|
17
|
-
|
|
18
|
-
var DEFAULT_PARAMETERS = (_DEFAULT_PARAMETERS = {}, (0, _defineProperty2.default)(_DEFAULT_PARAMETERS, 10240, 9728), (0, _defineProperty2.default)(_DEFAULT_PARAMETERS, 10241, 9728), _DEFAULT_PARAMETERS);
|
|
19
|
-
|
|
20
|
-
function getFloatTexture(gl) {
|
|
21
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
|
+
function getFloatTexture(device, opts) {
|
|
22
15
|
var _opts$width = opts.width,
|
|
23
16
|
width = _opts$width === void 0 ? 1 : _opts$width,
|
|
24
17
|
_opts$height = opts.height,
|
|
@@ -29,33 +22,29 @@ function getFloatTexture(gl) {
|
|
|
29
22
|
unpackFlipY = _opts$unpackFlipY === void 0 ? true : _opts$unpackFlipY,
|
|
30
23
|
_opts$parameters = opts.parameters,
|
|
31
24
|
parameters = _opts$parameters === void 0 ? DEFAULT_PARAMETERS : _opts$parameters;
|
|
32
|
-
var texture =
|
|
25
|
+
var texture = device.createTexture({
|
|
33
26
|
data: data,
|
|
34
|
-
format:
|
|
35
|
-
type: 5126,
|
|
36
|
-
border: 0,
|
|
27
|
+
format: 'rgba32float',
|
|
37
28
|
mipmaps: false,
|
|
38
|
-
|
|
39
|
-
dataFormat: 6408,
|
|
29
|
+
sampler: parameters,
|
|
40
30
|
width: width,
|
|
41
|
-
height: height
|
|
42
|
-
unpackFlipY: unpackFlipY
|
|
31
|
+
height: height
|
|
43
32
|
});
|
|
44
33
|
return texture;
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
function getFramebuffer(
|
|
36
|
+
function getFramebuffer(device, opts) {
|
|
48
37
|
var id = opts.id,
|
|
49
38
|
_opts$width2 = opts.width,
|
|
50
39
|
width = _opts$width2 === void 0 ? 1 : _opts$width2,
|
|
51
40
|
_opts$height2 = opts.height,
|
|
52
41
|
height = _opts$height2 === void 0 ? 1 : _opts$height2,
|
|
53
42
|
texture = opts.texture;
|
|
54
|
-
var fb =
|
|
43
|
+
var fb = device.createFramebuffer({
|
|
55
44
|
id: id,
|
|
56
45
|
width: width,
|
|
57
46
|
height: height,
|
|
58
|
-
|
|
47
|
+
colorAttachments: [texture]
|
|
59
48
|
});
|
|
60
49
|
return fb;
|
|
61
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/resource-utils.
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/resource-utils.ts"],"names":["DEFAULT_PARAMETERS","minFilter","magFilter","getFloatTexture","device","opts","width","height","data","unpackFlipY","parameters","texture","createTexture","format","mipmaps","sampler","getFramebuffer","id","fb","createFramebuffer","colorAttachments","getFloatArray","array","size","fillValue","length","Float32Array","fill"],"mappings":";;;;;;;;AAEA,IAAMA,kBAAgC,GAAG;AACvCC,EAAAA,SAAS,EAAE,SAD4B;AAEvCC,EAAAA,SAAS,EAAE;AAF4B,CAAzC;;AAeO,SAASC,eAAT,CAAyBC,MAAzB,EAAyCC,IAAzC,EAAoE;AACzE,oBAMIA,IANJ,CACEC,KADF;AAAA,MACEA,KADF,4BACU,CADV;AAAA,qBAMID,IANJ,CAEEE,MAFF;AAAA,MAEEA,MAFF,6BAEW,CAFX;AAAA,mBAMIF,IANJ,CAGEG,IAHF;AAAA,MAGEA,IAHF,2BAGS,IAHT;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ACD,SAAOF,KAAP;AACD","sourcesContent":["import {Device, Sampler, SamplerProps} from '@luma.gl/core';\n\nconst DEFAULT_PARAMETERS: SamplerProps = {\n minFilter: 'nearest',\n magFilter: 'nearest'\n};\n\ntype FloatTextureOptions = {\n id: string;\n width?: number;\n height?: number;\n data?: any;\n unpackFlipY?: boolean;\n parameters?: SamplerProps;\n};\n\n// TODO - not working\nexport function getFloatTexture(device: Device, opts: FloatTextureOptions) {\n const {\n width = 1,\n height = 1,\n data = null,\n unpackFlipY = true,\n parameters = DEFAULT_PARAMETERS\n } = opts;\n const texture = device.createTexture({\n data,\n format: 'rgba32float', // device.info.type === 'webgl2' ? 'rgba32float' : GL.RGBA,\n // type: GL.FLOAT,\n // border: 0,\n mipmaps: false,\n sampler: parameters,\n // dataFormat: GL.RGBA,\n width,\n height\n // ts-expect-error\n // unpackFlipY\n });\n return texture;\n}\n\nexport function getFramebuffer(device: Device, opts) {\n const {id, width = 1, height = 1, texture} = opts;\n const fb = device.createFramebuffer({\n id,\n width,\n height,\n colorAttachments: [texture]\n });\n\n return fb;\n}\n\nexport function getFloatArray(array, size, fillValue = 0) {\n if (!array || array.length < size) {\n return new Float32Array(size).fill(fillValue);\n }\n return array;\n}\n"],"file":"resource-utils.js"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CompositeLayer, AttributeManager, _compareProps as compareProps } from '@deck.gl/core';
|
|
2
|
-
import { cssToDeviceRatio } from '@luma.gl/core';
|
|
3
2
|
import { filterProps } from './utils/prop-utils';
|
|
4
3
|
export default class AggregationLayer extends CompositeLayer {
|
|
5
4
|
constructor(...args) {
|
|
@@ -41,20 +40,20 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
getAttributes() {
|
|
44
|
-
return this.getAttributeManager().
|
|
43
|
+
return this.getAttributeManager().getAttributes();
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
getModuleSettings() {
|
|
48
47
|
const {
|
|
49
48
|
viewport,
|
|
50
49
|
mousePosition,
|
|
51
|
-
|
|
50
|
+
device
|
|
52
51
|
} = this.context;
|
|
53
52
|
const moduleSettings = Object.assign(Object.create(this.props), {
|
|
54
53
|
viewport,
|
|
55
54
|
mousePosition,
|
|
56
55
|
pickingActive: 0,
|
|
57
|
-
devicePixelRatio: cssToDeviceRatio(
|
|
56
|
+
devicePixelRatio: device.canvasContext.cssToDeviceRatio()
|
|
58
57
|
});
|
|
59
58
|
return moduleSettings;
|
|
60
59
|
}
|
|
@@ -133,7 +132,7 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
_getAttributeManager() {
|
|
136
|
-
return new AttributeManager(this.context.
|
|
135
|
+
return new AttributeManager(this.context.device, {
|
|
137
136
|
id: this.props.id,
|
|
138
137
|
stats: this.context.stats
|
|
139
138
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/aggregation-layer.ts"],"names":["CompositeLayer","AttributeManager","_compareProps","compareProps","cssToDeviceRatio","filterProps","AggregationLayer","state","initializeAggregationLayer","dimensions","initializeState","context","setState","ignoreProps","constructor","_propTypes","data","props","updateState","opts","changeFlags","extensionsChanged","shaders","getShaders","defines","NON_INSTANCED_MODEL","updateShaders","_updateAttributes","updateAttributes","changedAttributes","getAttributes","getAttributeManager","getShaderAttributes","getModuleSettings","viewport","mousePosition","gl","moduleSettings","Object","assign","create","pickingActive","devicePixelRatio","isAggregationDirty","updateOpts","params","oldProps","compareAll","dimension","dataProps","accessors","updateTriggersChanged","dataChanged","all","accessor","newProps","propTypes","name","isAttributeChanged","isObjectEmpty","undefined","_getAttributeManager","id","stats","layerName","obj","isEmpty","key"],"mappings":"AAoBA,SACEA,cADF,EAEEC,gBAFF,EAIEC,aAAa,IAAIC,YAJnB,QAOO,eAPP;AAQA,SAAQC,gBAAR,QAA+B,eAA/B;AACA,SAAQC,WAAR,QAA0B,oBAA1B;AAMA,eAAe,MAA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UAAIhC,KAAK,CAACwC,IAAD,CAAL,KAAgBX,QAAQ,CAACW,IAAD,CAA5B,EAAoC;AAClC,eAAO,IAAP;AACD;AACF;;AACD,WAAO,KAAP;AACD;;AAQDC,EAAAA,kBAAkB,CAACD,IAAD,EAAgB;AAChC,UAAM;AAAC5B,MAAAA;AAAD,QAAsB,KAAKtB,KAAjC;;AACA,QAAI,CAACkD,IAAL,EAAW;AAET,aAAO,CAACE,aAAa,CAAC9B,iBAAD,CAArB;AACD;;AACD,WAAOA,iBAAiB,IAAIA,iBAAiB,CAAC4B,IAAD,CAAjB,KAA4BG,SAAxD;AACD;;AAKDC,EAAAA,oBAAoB,GAAG;AACrB,WAAO,IAAI5D,gBAAJ,CAAqB,KAAKU,OAAL,CAAayB,EAAlC,EAAsC;AAC3C0B,MAAAA,EAAE,EAAE,KAAK7C,KAAL,CAAW6C,EAD4B;AAE3CC,MAAAA,KAAK,EAAE,KAAKpD,OAAL,CAAaoD;AAFuB,KAAtC,CAAP;AAID;;AAxIuE;AAH5CzD,gB,CAIrB0D,S,GAAY,kB;;AA6IrB,SAASL,aAAT,CAAuBM,GAAvB,EAA4B;AAC1B,MAAIC,OAAO,GAAG,IAAd;;AAEA,OAAK,MAAMC,GAAX,IAAkBF,GAAlB,EAAuB;AACrBC,IAAAA,OAAO,GAAG,KAAV;AACA;AACD;;AACD,SAAOA,OAAP;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 {\n CompositeLayer,\n AttributeManager,\n LayerDataSource,\n _compareProps as compareProps,\n UpdateParameters,\n CompositeLayerProps\n} from '@deck.gl/core';\nimport {cssToDeviceRatio} from '@luma.gl/core';\nimport {filterProps} from './utils/prop-utils';\n\nexport type AggregationLayerProps<DataT> = CompositeLayerProps & {\n data: LayerDataSource<DataT>;\n};\n\nexport default abstract class AggregationLayer<\n DataT,\n ExtraPropsT extends {} = {}\n> extends CompositeLayer<Required<AggregationLayer<DataT>> & ExtraPropsT> {\n static layerName = 'AggregationLayer';\n\n state!: CompositeLayer['state'] & {\n ignoreProps?: Record<string, any>;\n dimensions?: any;\n };\n\n initializeAggregationLayer(dimensions: any) {\n super.initializeState(this.context);\n\n this.setState({\n // Layer props , when changed doesn't require updating aggregation\n ignoreProps: filterProps((this.constructor as any)._propTypes, dimensions.data.props),\n dimensions\n });\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n const {changeFlags} = opts;\n if (changeFlags.extensionsChanged) {\n const shaders = this.getShaders({});\n if (shaders && shaders.defines) {\n shaders.defines.NON_INSTANCED_MODEL = 1;\n }\n this.updateShaders(shaders);\n }\n\n // Explictly call to update attributes as 'CompositeLayer' doesn't call this\n this._updateAttributes();\n }\n\n updateAttributes(changedAttributes) {\n // Super classes, can refer to state.changedAttributes to determine what\n // attributes changed\n this.setState({changedAttributes});\n }\n\n getAttributes() {\n return this.getAttributeManager()!.getShaderAttributes();\n }\n\n getModuleSettings() {\n // For regular layer draw this happens during draw cycle (_drawLayersInViewport) not during update cycle\n // For aggregation layers this is called during updateState to update aggregation data\n // NOTE: it is similar to LayerPass._getModuleParameters() but doesn't inlcude `effects` it is not needed for aggregation\n const {viewport, mousePosition, gl} = this.context;\n const moduleSettings = Object.assign(Object.create(this.props), {\n viewport,\n mousePosition,\n pickingActive: 0,\n devicePixelRatio: cssToDeviceRatio(gl)\n });\n return moduleSettings;\n }\n\n updateShaders(shaders) {\n // Default implemention is empty, subclasses can update their Model objects if needed\n }\n\n /**\n * Checks if aggregation is dirty\n * @param {Object} updateOpts - object {props, oldProps, changeFlags}\n * @param {Object} params - object {dimension, compareAll}\n * @param {Object} params.dimension - {props, accessors} array of props and/or accessors\n * @param {Boolean} params.compareAll - when `true` it will include non layer props for comparision\n * @returns {Boolean} - returns true if dimensions' prop or accessor is changed\n **/\n isAggregationDirty(\n updateOpts,\n params: {compareAll?: boolean; dimension?: any} = {}\n ): string | boolean {\n const {props, oldProps, changeFlags} = updateOpts;\n const {compareAll = false, dimension} = params;\n const {ignoreProps} = this.state;\n const {props: dataProps, accessors = []} = dimension;\n const {updateTriggersChanged} = changeFlags;\n if (changeFlags.dataChanged) {\n return true;\n }\n if (updateTriggersChanged) {\n if (updateTriggersChanged.all) {\n return true;\n }\n for (const accessor of accessors) {\n if (updateTriggersChanged[accessor]) {\n return true;\n }\n }\n }\n if (compareAll) {\n if (changeFlags.extensionsChanged) {\n return true;\n }\n // Compare non layer props too (like extension props)\n // ignoreprops refers to all Layer props other than aggregation props that need to be comapred\n return compareProps({\n oldProps,\n newProps: props,\n ignoreProps,\n propTypes: (this.constructor as any)._propTypes\n });\n }\n // Compare props of the dimension\n for (const name of dataProps) {\n if (props[name] !== oldProps[name]) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Checks if an attribute is changed\n * @param {String} name - name of the attribute\n * @returns {Boolean} - `true` if attribute `name` is changed, `false` otherwise,\n * If `name` is not passed or `undefiend`, `true` if any attribute is changed, `false` otherwise\n **/\n isAttributeChanged(name?: string) {\n const {changedAttributes} = this.state;\n if (!name) {\n // if name not specified return true if any attribute is changed\n return !isObjectEmpty(changedAttributes);\n }\n return changedAttributes && changedAttributes[name] !== undefined;\n }\n\n // Private\n\n // override Composite layer private method to create AttributeManager instance\n _getAttributeManager() {\n return new AttributeManager(this.context.gl, {\n id: this.props.id,\n stats: this.context.stats\n });\n }\n}\n\n// Helper methods\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(obj) {\n let isEmpty = true;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const key in obj) {\n isEmpty = false;\n break;\n }\n return isEmpty;\n}\n"],"file":"aggregation-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/aggregation-layer.ts"],"names":["CompositeLayer","AttributeManager","_compareProps","compareProps","filterProps","AggregationLayer","state","initializeAggregationLayer","dimensions","initializeState","context","setState","ignoreProps","constructor","_propTypes","data","props","updateState","opts","changeFlags","extensionsChanged","shaders","getShaders","defines","NON_INSTANCED_MODEL","updateShaders","_updateAttributes","updateAttributes","changedAttributes","getAttributes","getAttributeManager","getModuleSettings","viewport","mousePosition","device","moduleSettings","Object","assign","create","pickingActive","devicePixelRatio","canvasContext","cssToDeviceRatio","isAggregationDirty","updateOpts","params","oldProps","compareAll","dimension","dataProps","accessors","updateTriggersChanged","dataChanged","all","accessor","newProps","propTypes","name","isAttributeChanged","isObjectEmpty","undefined","_getAttributeManager","id","stats","layerName","obj","isEmpty","key"],"mappings":"AAoBA,SACEA,cADF,EAEEC,gBAFF,EAIEC,aAAa,IAAIC,YAJnB,QAOO,eAPP;AAQA,SAAQC,WAAR,QAA0B,oBAA1B;AAMA,eAAe,MAAeC,gBAAf,SAGLL,cAHK,CAG2D;AAAA;AAAA;AAAA,SAGxEM,KAHwE;AAAA;;AASxEC,EAAAA,0BAA0B,CAACC,UAAD,EAAkB;AAC1C,UAAMC,eAAN,CAAsB,KAAKC,OAA3B;AAEA,SAAKC,QAAL,CAAc;AAEZC,M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AAC7B,MAAAA;AAAD,QAAsB,KAAKtB,KAAjC;;AACA,QAAI,CAACmD,IAAL,EAAW;AAET,aAAO,CAACE,aAAa,CAAC/B,iBAAD,CAArB;AACD;;AACD,WAAOA,iBAAiB,IAAIA,iBAAiB,CAAC6B,IAAD,CAAjB,KAA4BG,SAAxD;AACD;;AAKDC,EAAAA,oBAAoB,GAAG;AACrB,WAAO,IAAI5D,gBAAJ,CAAqB,KAAKS,OAAL,CAAawB,MAAlC,EAA0C;AAC/C4B,MAAAA,EAAE,EAAE,KAAK9C,KAAL,CAAW8C,EADgC;AAE/CC,MAAAA,KAAK,EAAE,KAAKrD,OAAL,CAAaqD;AAF2B,KAA1C,CAAP;AAID;;AA1IuE;AAH5C1D,gB,CAIrB2D,S,GAAY,kB;;AA+IrB,SAASL,aAAT,CAAuBM,GAAvB,EAA4B;AAC1B,MAAIC,OAAO,GAAG,IAAd;;AAEA,OAAK,MAAMC,GAAX,IAAkBF,GAAlB,EAAuB;AACrBC,IAAAA,OAAO,GAAG,KAAV;AACA;AACD;;AACD,SAAOA,OAAP;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 {\n CompositeLayer,\n AttributeManager,\n LayerDataSource,\n _compareProps as compareProps,\n UpdateParameters,\n CompositeLayerProps\n} from '@deck.gl/core';\nimport {filterProps} from './utils/prop-utils';\n\nexport type AggregationLayerProps<DataT> = CompositeLayerProps & {\n data: LayerDataSource<DataT>;\n};\n\nexport default abstract class AggregationLayer<\n DataT,\n ExtraPropsT extends {} = {}\n> extends CompositeLayer<Required<AggregationLayer<DataT>> & ExtraPropsT> {\n static layerName = 'AggregationLayer';\n\n state!: {\n ignoreProps?: Record<string, any>;\n dimensions?: any;\n changedAttributes?: Record<string, any>;\n };\n\n initializeAggregationLayer(dimensions: any) {\n super.initializeState(this.context);\n\n this.setState({\n // Layer props , when changed doesn't require updating aggregation\n ignoreProps: filterProps((this.constructor as any)._propTypes, dimensions.data.props),\n dimensions\n });\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n const {changeFlags} = opts;\n if (changeFlags.extensionsChanged) {\n const shaders = this.getShaders({});\n if (shaders && shaders.defines) {\n shaders.defines.NON_INSTANCED_MODEL = 1;\n }\n this.updateShaders(shaders);\n }\n\n // Explictly call to update attributes as 'CompositeLayer' doesn't call this\n this._updateAttributes();\n }\n\n updateAttributes(changedAttributes) {\n // Super classes, can refer to state.changedAttributes to determine what\n // attributes changed\n this.setState({changedAttributes});\n }\n\n getAttributes() {\n return this.getAttributeManager()!.getAttributes();\n }\n\n getModuleSettings() {\n // For regular layer draw this happens during draw cycle (_drawLayersInViewport) not during update cycle\n // For aggregation layers this is called during updateState to update aggregation data\n // NOTE: it is similar to LayerPass._getModuleParameters() but doesn't inlcude `effects` it is not needed for aggregation\n const {viewport, mousePosition, device} = this.context;\n const moduleSettings = Object.assign(Object.create(this.props), {\n viewport,\n mousePosition,\n pickingActive: 0,\n // @ts-expect-error TODO - assuming WebGL context\n devicePixelRatio: device.canvasContext.cssToDeviceRatio()\n });\n return moduleSettings;\n }\n\n updateShaders(shaders) {\n // Default implemention is empty, subclasses can update their Model objects if needed\n }\n\n /**\n * Checks if aggregation is dirty\n * @param {Object} updateOpts - object {props, oldProps, changeFlags}\n * @param {Object} params - object {dimension, compareAll}\n * @param {Object} params.dimension - {props, accessors} array of props and/or accessors\n * @param {Boolean} params.compareAll - when `true` it will include non layer props for comparision\n * @returns {Boolean} - returns true if dimensions' prop or accessor is changed\n **/\n isAggregationDirty(\n updateOpts,\n params: {compareAll?: boolean; dimension?: any} = {}\n ): string | boolean {\n const {props, oldProps, changeFlags} = updateOpts;\n const {compareAll = false, dimension} = params;\n const {ignoreProps} = this.state;\n const {props: dataProps, accessors = []} = dimension;\n const {updateTriggersChanged} = changeFlags;\n if (changeFlags.dataChanged) {\n return true;\n }\n if (updateTriggersChanged) {\n if (updateTriggersChanged.all) {\n return true;\n }\n for (const accessor of accessors) {\n if (updateTriggersChanged[accessor]) {\n return true;\n }\n }\n }\n if (compareAll) {\n if (changeFlags.extensionsChanged) {\n return true;\n }\n // Compare non layer props too (like extension props)\n // ignoreprops refers to all Layer props other than aggregation props that need to be comapred\n return compareProps({\n oldProps,\n newProps: props,\n ignoreProps,\n propTypes: (this.constructor as any)._propTypes\n });\n }\n // Compare props of the dimension\n for (const name of dataProps) {\n if (props[name] !== oldProps[name]) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Checks if an attribute is changed\n * @param {String} name - name of the attribute\n * @returns {Boolean} - `true` if attribute `name` is changed, `false` otherwise,\n * If `name` is not passed or `undefiend`, `true` if any attribute is changed, `false` otherwise\n **/\n isAttributeChanged(name?: string) {\n const {changedAttributes} = this.state;\n if (!name) {\n // if name not specified return true if any attribute is changed\n return !isObjectEmpty(changedAttributes);\n }\n return changedAttributes && changedAttributes[name] !== undefined;\n }\n\n // Private\n\n // override Composite layer private method to create AttributeManager instance\n _getAttributeManager() {\n return new AttributeManager(this.context.device, {\n id: this.props.id,\n stats: this.context.stats\n });\n }\n}\n\n// Helper methods\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(obj) {\n let isEmpty = true;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const key in obj) {\n isEmpty = false;\n break;\n }\n return isEmpty;\n}\n"],"file":"aggregation-layer.js"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GL } from '@luma.gl/constants';
|
|
1
2
|
import { LineLayer, SolidPolygonLayer } from '@deck.gl/layers';
|
|
2
3
|
import { generateContours } from './contour-utils';
|
|
3
4
|
import { log } from '@deck.gl/core';
|
|
@@ -46,6 +47,11 @@ const DIMENSIONS = {
|
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
export default class ContourLayer extends GridAggregationLayer {
|
|
50
|
+
constructor(...args) {
|
|
51
|
+
super(...args);
|
|
52
|
+
this.state = void 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
initializeState() {
|
|
50
56
|
super.initializeAggregationLayer({
|
|
51
57
|
dimensions: DIMENSIONS
|
|
@@ -139,7 +145,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
139
145
|
let gpuAggregation = props.gpuAggregation;
|
|
140
146
|
|
|
141
147
|
if (this.state.gpuAggregation !== props.gpuAggregation) {
|
|
142
|
-
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.
|
|
148
|
+
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
|
|
143
149
|
log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
|
|
144
150
|
gpuAggregation = false;
|
|
145
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contour-layer/contour-layer.ts"],"names":["LineLayer","SolidPolygonLayer","generateContours","log","GPUGridAggregator","AGGREGATION_OPERATION","getValueFunc","getBoundingBox","getGridParams","GridAggregationLayer","DEFAULT_COLOR","DEFAULT_STROKE_WIDTH","DEFAULT_THRESHOLD","defaultProps","cellSize","type","min","max","value","getPosition","x","position","getWeight","gpuAggregation","aggregation","contours","threshold","optional","compare","zOffset","POSITION_ATTRIBUTE_NAME","DIMENSIONS","data","props","weights","accessors","ContourLayer","initializeState","initializeAggregationLayer","dimensions","setState","contourData","projectPoints","count","size","operation","SUM","attributeManager","getAttributeManager","add","accessor","fp64","use64bitPositions","updateState","opts","contoursChanged","oldProps","aggregationDirty","state","_updateThresholdData","getNumInstances","_generateContours","renderLayers","contourSegments","contourPolygons","LinesSubLayerClass","getSubLayerClass","BandsSubLayerClass","lineLayer","length","getSubLayerProps","id","getSourcePosition","d","start","getTargetPosition","end","getColor","contour","color","getWidth","strokeWidth","bandsLayer","getPolygon","vertices","getFillColor","updateAggregationState","coordinateSystem","viewport","context","cellSizeChanged","isSupported","gl","warn","gpuAggregationChanged","positionsChanged","isAttributeChanged","boundingBox","getAttributes","gridOffset","translation","width","height","numCol","numRow","allocateResources","posOffset","slice","gridOrigin","aggregationDataDirty","isAggregationDirty","dimension","compareAll","aggregationWeightsDirty","_updateAccessors","_resetResults","getValue","aggregationData","thresholdData","aggregationBuffer","getData","cellWeights","getCellData","countsData","gridSize","xOffset","yOffset","Array","i","zIndex","layerName"],"mappings":"AAqBA,SAAQA,SAAR,EAAmBC,iBAAnB,QAA2C,iBAA3C;AACA,SAAQC,gBAAR,QAA+B,iBAA/B;AACA,SAKEC,GALF,QASO,eATP;AAWA,OAAOC,iBAAP,MAA8B,mDAA9B;AACA,SAAQC,qBAAR,EAA+BC,YAA/B,QAAkD,sCAAlD;AACA,SAAQC,cAAR,EAAwBC,aAAxB,QAA4C,iCAA5C;AACA,OAAOC,oBAAP,MAA8D,2BAA9D;AAEA,MAAMC,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAAtB;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,iBAAiB,GAAG,CAA1B;AAEA,MAAMC,YAA6C,G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,CAACrB,MAAD,EAASC,MAAT,CAHyB;AAInCI,MAAAA,UAJmC;AAKnC9F,MAAAA,QAAQ,EAAE,CAACqF,UAAU,CAAC0B,OAAZ,EAAqB1B,UAAU,CAAC2B,OAAhC;AALyB,KAAD,CAApC;AASA,SAAKtF,QAAL,CAAc;AAACC,MAAAA;AAAD,KAAd;AACD;;AAEOkB,EAAAA,oBAAoB,CAAC1B,KAAD,EAAQ;AAClC,UAAM;AAACR,MAAAA,QAAD;AAAWI,MAAAA;AAAX,QAAsBI,KAA5B;AACA,UAAMU,KAAK,GAAGlB,QAAQ,CAAC4C,MAAvB;AACA,UAAMiD,aAAa,GAAG,IAAIS,KAAJ,CAAUpF,KAAV,CAAtB;;AACA,SAAK,IAAIqF,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGrF,KAApB,EAA2BqF,CAAC,EAA5B,EAAgC;AAC9B,YAAMlD,OAAO,GAAGrD,QAAQ,CAACuG,CAAD,CAAxB;AACAV,MAAAA,aAAa,CAACU,CAAD,CAAb,GAAmB;AACjBlD,QAAAA,OADiB;AAEjBmD,QAAAA,MAAM,EAAEnD,OAAO,CAACmD,MAAR,IAAkBD,CAFT;AAGjBnG,QAAAA;AAHiB,OAAnB;AAKD;;AACD,SAAKW,QAAL,CAAc;AAAC8E,MAAAA;AAAD,KAAd;AACD;;AA1NsF;AAHpElF,Y,CAIZ8F,S,GAAY,c;AAJA9F,Y,CAKZvB,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2018 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport GL from '@luma.gl/constants';\nimport {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';\nimport {generateContours} from './contour-utils';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Layer,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\n\nconst DEFAULT_COLOR = [255, 255, 255, 255];\nconst DEFAULT_STROKE_WIDTH = 1;\nconst DEFAULT_THRESHOLD = 1;\n\nconst defaultProps: DefaultProps<ContourLayerProps> = {\n // grid aggregation\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n gpuAggregation: true,\n aggregation: 'SUM',\n\n // contour lines\n contours: {\n type: 'object',\n value: [{threshold: DEFAULT_THRESHOLD}],\n optional: true,\n compare: 3\n },\n\n zOffset: 0.005\n};\n\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize']\n },\n weights: {\n props: ['aggregation'],\n accessors: ['getWeight']\n }\n};\n\n/** All properties supported by ContourLayer. */\nexport type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by ContourLayer. */\nexport type _ContourLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default true\n */\n gpuAggregation?: boolean;\n\n /**\n * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Definition of contours to be drawn.\n * @default [{threshold: 1}]\n */\n contours: {\n /**\n * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.\n *\n * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.\n */\n threshold: number | number[];\n\n /**\n * RGBA color array to be used to render the contour.\n * @default [255, 255, 255, 255]\n */\n color?: Color;\n\n /**\n * Applicable for `Isoline`s only, width of the Isoline in pixels.\n * @default 1\n */\n strokeWidth?: number;\n\n /** Defines z order of the contour. */\n zIndex?: number;\n }[];\n\n /**\n * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).\n * @default 0.005\n */\n zOffset?: number;\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of each object.\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */\nexport default class ContourLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends GridAggregationLayer<DataT, ExtraPropsT & Required<_ContourLayerProps<DataT>>> {\n static layerName = 'ContourLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n contourData: {},\n projectPoints: false,\n weights: {\n count: {\n size: 1,\n operation: AGGREGATION_OPERATION.SUM\n }\n }\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n // this attribute is used in gpu aggregation path only\n count: {size: 3, accessor: 'getWeight'}\n });\n }\n\n updateState(opts: UpdateParameters<this>): void {\n super.updateState(opts);\n let contoursChanged = false;\n const {oldProps, props} = opts;\n const {aggregationDirty} = this.state;\n\n if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {\n contoursChanged = true;\n this._updateThresholdData(opts.props);\n }\n\n if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {\n this._generateContours();\n }\n }\n\n renderLayers(): Layer[] {\n const {contourSegments, contourPolygons} = this.state.contourData;\n\n const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);\n const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);\n\n // Contour lines layer\n const lineLayer =\n contourSegments &&\n contourSegments.length > 0 &&\n new LinesSubLayerClass(\n this.getSubLayerProps({\n id: 'lines'\n }),\n {\n data: this.state.contourData.contourSegments,\n getSourcePosition: d => d.start,\n getTargetPosition: d => d.end,\n getColor: d => d.contour.color || DEFAULT_COLOR,\n getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH\n }\n );\n\n // Contour bands layer\n const bandsLayer =\n contourPolygons &&\n contourPolygons.length > 0 &&\n new BandsSubLayerClass(\n this.getSubLayerProps({\n id: 'bands'\n }),\n {\n data: this.state.contourData.contourPolygons,\n getPolygon: d => d.vertices,\n getFillColor: d => d.contour.color || DEFAULT_COLOR\n }\n );\n\n return [lineLayer, bandsLayer];\n }\n\n // Aggregation Overrides\n\n /* eslint-disable max-statements, complexity */\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n let gpuAggregation = props.gpuAggregation;\n if (this.state.gpuAggregation !== props.gpuAggregation) {\n if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.gl)) {\n log.warn('GPU Grid Aggregation not supported, falling back to CPU')();\n gpuAggregation = false;\n }\n }\n const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;\n this.setState({\n gpuAggregation\n });\n\n const {dimensions} = this.state;\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n const {data, weights} = dimensions;\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n boundingBox,\n translation,\n posOffset: translation.slice(), // Used for CPU aggregation, to offset points\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n positionsChanged ||\n gpuAggregationChanged ||\n this.isAggregationDirty(opts, {\n dimension: data,\n compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation\n });\n const aggregationWeightsDirty = this.isAggregationDirty(opts, {\n dimension: weights\n });\n\n if (aggregationWeightsDirty) {\n this._updateAccessors(opts);\n }\n if (aggregationDataDirty || aggregationWeightsDirty) {\n this._resetResults();\n }\n this.setState({\n aggregationDataDirty,\n aggregationWeightsDirty\n });\n }\n /* eslint-enable max-statements, complexity */\n\n // Private (Aggregation)\n\n private _updateAccessors(opts) {\n const {getWeight, aggregation, data} = opts.props;\n const {count} = this.state.weights;\n if (count) {\n count.getWeight = getWeight;\n count.operation = AGGREGATION_OPERATION[aggregation];\n }\n this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});\n }\n\n private _resetResults() {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = null;\n }\n }\n\n // Private (Contours)\n\n private _generateContours() {\n const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;\n const {count} = this.state.weights;\n let {aggregationData} = count;\n if (!aggregationData) {\n aggregationData = count.aggregationBuffer.getData();\n count.aggregationData = aggregationData;\n }\n\n const {cellWeights} = GPUGridAggregator.getCellData({countsData: aggregationData});\n const contourData = generateContours({\n thresholdData,\n cellWeights,\n gridSize: [numCol, numRow],\n gridOrigin,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset]\n });\n\n // contourData contains both iso-lines and iso-bands if requested.\n this.setState({contourData});\n }\n\n private _updateThresholdData(props) {\n const {contours, zOffset} = props;\n const count = contours.length;\n const thresholdData = new Array(count);\n for (let i = 0; i < count; i++) {\n const contour = contours[i];\n thresholdData[i] = {\n contour,\n zIndex: contour.zIndex || i,\n zOffset\n };\n }\n this.setState({thresholdData});\n }\n}\n"],"file":"contour-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/contour-layer/contour-layer.ts"],"names":["GL","LineLayer","SolidPolygonLayer","generateContours","log","GPUGridAggregator","AGGREGATION_OPERATION","getValueFunc","getBoundingBox","getGridParams","GridAggregationLayer","DEFAULT_COLOR","DEFAULT_STROKE_WIDTH","DEFAULT_THRESHOLD","defaultProps","cellSize","type","min","max","value","getPosition","x","position","getWeight","gpuAggregation","aggregation","contours","threshold","optional","compare","zOffset","POSITION_ATTRIBUTE_NAME","DIMENSIONS","data","props","weights","accessors","ContourLayer","state","initializeState","initializeAggregationLayer","dimensions","setState","contourData","projectPoints","count","size","operation","SUM","attributeManager","getAttributeManager","add","accessor","fp64","use64bitPositions","updateState","opts","contoursChanged","oldProps","aggregationDirty","_updateThresholdData","getNumInstances","_generateContours","renderLayers","contourSegments","contourPolygons","LinesSubLayerClass","getSubLayerClass","BandsSubLayerClass","lineLayer","length","getSubLayerProps","id","getSourcePosition","d","start","getTargetPosition","end","getColor","contour","color","getWidth","strokeWidth","bandsLayer","getPolygon","vertices","getFillColor","updateAggregationState","coordinateSystem","viewport","context","cellSizeChanged","isSupported","device","warn","gpuAggregationChanged","positionsChanged","isAttributeChanged","boundingBox","getAttributes","gridOffset","translation","width","height","numCol","numRow","allocateResources","posOffset","slice","gridOrigin","aggregationDataDirty","isAggregationDirty","dimension","compareAll","aggregationWeightsDirty","_updateAccessors","_resetResults","getValue","aggregationData","thresholdData","aggregationBuffer","getData","cellWeights","getCellData","countsData","gridSize","xOffset","yOffset","Array","i","zIndex","layerName"],"mappings":"AAoBA,SAAQA,EAAR,QAAiB,oBAAjB;AACA,SAAQC,SAAR,EAAmBC,iBAAnB,QAA2C,iBAA3C;AACA,SAAQC,gBAAR,QAA+B,iBAA/B;AACA,SAKEC,GALF,QAUO,eAVP;AAYA,OAAOC,iBAAP,MAA8B,mDAA9B;AACA,SAAQC,qBAAR,EAA+BC,YAA/B,QAAkD,sCAAlD;AACA,SAAQC,cAAR,EAAwBC,aAAxB,QAA4C,iCAA5C;AACA,OAAOC,oBAAP,MAA8D,2BAA9D;AAEA,MAAMC,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAAtB;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,iBAAiB,GAAG,CAA1B;AAEA,MAAMC,YAA6C,GAAG;AAEpDC,EAAAA,QAAQ,EAAE;AAACC,IAAAA,IAAI,EAAE,QAAP;AAAiBC,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,IAA9B;AAAoCC,IAAAA,KAAK,EAAE;AAA3C,GAF0C;AAGpDC,EAAAA,WAAW,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBG,IAAAA,KAAK,EAAGE,CAAD,IAAYA,CAAC,CAACC;AAAxC,GAHuC;AAIpDC,EAAAA,SAAS,EAAE;AAACP,IAAAA,IAAI,EAAE,UAAP;AAA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AAMW,KAAK,GAAGnB,QAAQ,CAAC4C,MAAvB;AACA,UAAMiD,aAAa,GAAG,IAAIS,KAAJ,CAAUnF,KAAV,CAAtB;;AACA,SAAK,IAAIoF,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGpF,KAApB,EAA2BoF,CAAC,EAA5B,EAAgC;AAC9B,YAAMlD,OAAO,GAAGrD,QAAQ,CAACuG,CAAD,CAAxB;AACAV,MAAAA,aAAa,CAACU,CAAD,CAAb,GAAmB;AACjBlD,QAAAA,OADiB;AAEjBmD,QAAAA,MAAM,EAAEnD,OAAO,CAACmD,MAAR,IAAkBD,CAFT;AAGjBnG,QAAAA;AAHiB,OAAnB;AAKD;;AACD,SAAKY,QAAL,CAAc;AAAC6E,MAAAA;AAAD,KAAd;AACD;;AAzOsF;AAHpElF,Y,CAIZ8F,S,GAAY,c;AAJA9F,Y,CAKZvB,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2018 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {GL} from '@luma.gl/constants';\nimport {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';\nimport {generateContours} from './contour-utils';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Layer,\n log,\n Position,\n UpdateParameters,\n DefaultProps,\n LayersList\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\n\nconst DEFAULT_COLOR = [255, 255, 255, 255];\nconst DEFAULT_STROKE_WIDTH = 1;\nconst DEFAULT_THRESHOLD = 1;\n\nconst defaultProps: DefaultProps<ContourLayerProps> = {\n // grid aggregation\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n getPosition: {type: 'accessor', value: (x: any) => x.position},\n getWeight: {type: 'accessor', value: 1},\n gpuAggregation: true,\n aggregation: 'SUM',\n\n // contour lines\n contours: {\n type: 'object',\n value: [{threshold: DEFAULT_THRESHOLD}],\n optional: true,\n compare: 3\n },\n\n zOffset: 0.005\n};\n\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize']\n },\n weights: {\n props: ['aggregation'],\n accessors: ['getWeight']\n }\n};\n\n/** All properties supported by ContourLayer. */\nexport type ContourLayerProps<DataT = unknown> = _ContourLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by ContourLayer. */\nexport type _ContourLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default true\n */\n gpuAggregation?: boolean;\n\n /**\n * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Definition of contours to be drawn.\n * @default [{threshold: 1}]\n */\n contours: {\n /**\n * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.\n *\n * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.\n */\n threshold: number | number[];\n\n /**\n * RGBA color array to be used to render the contour.\n * @default [255, 255, 255, 255]\n */\n color?: Color;\n\n /**\n * Applicable for `Isoline`s only, width of the Isoline in pixels.\n * @default 1\n */\n strokeWidth?: number;\n\n /** Defines z order of the contour. */\n zIndex?: number;\n }[];\n\n /**\n * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).\n * @default 0.005\n */\n zOffset?: number;\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of each object.\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */\nexport default class ContourLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends GridAggregationLayer<DataT, ExtraPropsT & Required<_ContourLayerProps<DataT>>> {\n static layerName = 'ContourLayer';\n static defaultProps = defaultProps;\n\n state!: GridAggregationLayer<DataT>['state'] & {\n contourData: {\n contourSegments: {\n start: number[];\n end: number[];\n contour: any;\n }[];\n contourPolygons: {\n vertices: number[][];\n contour: any;\n }[];\n };\n thresholdData: any;\n };\n\n initializeState(): void {\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n contourData: {},\n projectPoints: false,\n weights: {\n count: {\n size: 1,\n operation: AGGREGATION_OPERATION.SUM\n }\n }\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n // this attribute is used in gpu aggregation path only\n count: {size: 3, accessor: 'getWeight'}\n });\n }\n\n updateState(opts: UpdateParameters<this>): void {\n super.updateState(opts);\n let contoursChanged = false;\n const {oldProps, props} = opts;\n const {aggregationDirty} = this.state;\n\n if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {\n contoursChanged = true;\n this._updateThresholdData(opts.props);\n }\n\n if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {\n this._generateContours();\n }\n }\n\n renderLayers(): LayersList {\n const {contourSegments, contourPolygons} = this.state.contourData;\n\n const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);\n const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);\n\n // Contour lines layer\n const lineLayer =\n contourSegments &&\n contourSegments.length > 0 &&\n new LinesSubLayerClass(\n this.getSubLayerProps({\n id: 'lines'\n }),\n {\n data: this.state.contourData.contourSegments,\n getSourcePosition: d => d.start,\n getTargetPosition: d => d.end,\n getColor: d => d.contour.color || DEFAULT_COLOR,\n getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH\n }\n );\n\n // Contour bands layer\n const bandsLayer =\n contourPolygons &&\n contourPolygons.length > 0 &&\n new BandsSubLayerClass(\n this.getSubLayerProps({\n id: 'bands'\n }),\n {\n data: this.state.contourData.contourPolygons,\n getPolygon: d => d.vertices,\n getFillColor: d => d.contour.color || DEFAULT_COLOR\n }\n );\n\n return [lineLayer, bandsLayer];\n }\n\n // Aggregation Overrides\n\n /* eslint-disable max-statements, complexity */\n updateAggregationState(opts: UpdateParameters<this>) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n let gpuAggregation = props.gpuAggregation;\n if (this.state.gpuAggregation !== props.gpuAggregation) {\n if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {\n log.warn('GPU Grid Aggregation not supported, falling back to CPU')();\n gpuAggregation = false;\n }\n }\n const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;\n this.setState({\n gpuAggregation\n });\n\n const {dimensions} = this.state;\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n const {data, weights} = dimensions;\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n boundingBox,\n translation,\n posOffset: translation.slice(), // Used for CPU aggregation, to offset points\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n positionsChanged ||\n gpuAggregationChanged ||\n this.isAggregationDirty(opts, {\n dimension: data,\n compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation\n });\n const aggregationWeightsDirty = this.isAggregationDirty(opts, {\n dimension: weights\n });\n\n if (aggregationWeightsDirty) {\n this._updateAccessors(opts);\n }\n if (aggregationDataDirty || aggregationWeightsDirty) {\n this._resetResults();\n }\n this.setState({\n aggregationDataDirty,\n aggregationWeightsDirty\n });\n }\n /* eslint-enable max-statements, complexity */\n\n // Private (Aggregation)\n\n private _updateAccessors(opts: UpdateParameters<this>) {\n const {getWeight, aggregation, data} = opts.props;\n const {count} = this.state.weights;\n if (count) {\n count.getWeight = getWeight;\n count.operation = AGGREGATION_OPERATION[aggregation];\n }\n this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});\n }\n\n private _resetResults() {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = null;\n }\n }\n\n // Private (Contours)\n\n private _generateContours() {\n const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;\n const {count} = this.state.weights;\n let {aggregationData} = count;\n if (!aggregationData) {\n aggregationData = count.aggregationBuffer!.getData() as Float32Array;\n count.aggregationData = aggregationData;\n }\n\n const {cellWeights} = GPUGridAggregator.getCellData({countsData: aggregationData});\n const contourData = generateContours({\n thresholdData,\n cellWeights,\n gridSize: [numCol, numRow],\n gridOrigin,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset]\n });\n\n // contourData contains both iso-lines and iso-bands if requested.\n this.setState({contourData});\n }\n\n private _updateThresholdData(props) {\n const {contours, zOffset} = props;\n const count = contours.length;\n const thresholdData = new Array(count);\n for (let i = 0; i < count; i++) {\n const contour = contours[i];\n thresholdData[i] = {\n contour,\n zIndex: contour.zIndex || i,\n zOffset\n };\n }\n this.setState({thresholdData});\n }\n}\n"],"file":"contour-layer.js"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GL } from '@luma.gl/constants';
|
|
1
2
|
import { GridCellLayer } from '@deck.gl/layers';
|
|
2
3
|
import { defaultColorRange } from '../utils/color-utils';
|
|
3
4
|
import { pointToDensityGridDataCPU } from './grid-aggregator';
|
|
@@ -88,6 +89,11 @@ const defaultProps = {
|
|
|
88
89
|
}
|
|
89
90
|
};
|
|
90
91
|
export default class CPUGridLayer extends AggregationLayer {
|
|
92
|
+
constructor(...args) {
|
|
93
|
+
super(...args);
|
|
94
|
+
this.state = void 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
initializeState() {
|
|
92
98
|
const cpuAggregator = new CPUAggregator({
|
|
93
99
|
getAggregator: props => props.gridAggregator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cpu-grid-layer/cpu-grid-layer.ts"],"names":["GridCellLayer","defaultColorRange","pointToDensityGridDataCPU","CPUAggregator","AggregationLayer","nop","defaultProps","colorDomain","colorRange","getColorValue","type","value","getColorWeight","colorAggregation","lowerPercentile","min","max","upperPercentile","colorScaleType","onSetColorDomain","elevationDomain","elevationRange","getElevationValue","getElevationWeight","elevationAggregation","elevationLowerPercentile","elevationUpperPercentile","elevationScale","elevationScaleType","onSetElevationDomain","gridAggregator","cellSize","coverage","getPosition","x","position","extruded","material","_filterData","optional","CPUGridLayer","initializeState","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","updateTriggers","getFillColor","bind","getElevation","getSubLayerProps","id","data","layerData","layerName"],"mappings":"AAqBA,SAAQA,aAAR,QAA4B,iBAA5B;AAGA,SAAQC,iBAAR,QAAgC,sBAAhC;AACA,SAAQC,yBAAR,QAAwC,mBAAxC;AACA,OAAOC,aAAP,MAA0B,yBAA1B;AACA,OAAOC,gBAAP,MAAsD,sBAAtD;;AAMA,SAASC,GAAT,GAAe,CAAE;;AAEjB,MAAMC,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEP,iBAHwC;AAIpDQ,EAAAA,aAAa,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJqC;AAKpDC,EAAAA,cAAc,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GALoC;AAMpDE,EAAAA,gBAAgB,EAAE,KANkC;AAOpDC,EAAAA,eAAe,EAAE;AAACJ,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,GAA9B;AAAmCL,IAAAA,KAAK,EAAE;AAA1C,GAPmC;AAQpDM,EAAAA,eAAe,EAAE;AAACP,IAAAA,IAAI,EAAE,QAAP;AAAiBK,IAAAA,GAAG,EAAE,CAAtB;AAAyBC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AL,EAAvB;;AAEA,WAAO,IAAII,aAAJ,CACL;AACE1C,MAAAA,QADF;AAEEC,MAAAA,QAFF;AAGEK,MAAAA,QAHF;AAIEV,MAAAA,cAJF;AAKES,MAAAA,QALF;AAOEwC,MAAAA,YAAY,EAAE,KAAKX,mBAAL,CAAyBY,IAAzB,CAA8B,IAA9B,CAPhB;AAQEC,MAAAA,YAAY,EAAE,KAAKV,uBAAL,CAA6BS,IAA7B,CAAkC,IAAlC,CARhB;AASEL,MAAAA,WAAW,EAAEA,WAAW,IAAI;AAC1BI,QAAAA,YAAY,EAAEJ,WAAW,CAAC/D,aAAZ,IAA6B+D,WAAW,CAAC5D,cAD7B;AAE1BkE,QAAAA,YAAY,EAAEN,WAAW,CAAClD,iBAAZ,IAAiCkD,WAAW,CAACjD;AAFjC;AAT9B,KADK,EAeL,KAAKwD,gBAAL,CAAsB;AACpBC,MAAAA,EAAE,EAAE,WADgB;AAEpBL,MAAAA;AAFoB,KAAtB,CAfK,EAmBL;AACEM,MAAAA,IAAI,EAAEvC,aAAa,CAACI,KAAd,CAAoBoC,SAApB,CAA8BD;AADtC,KAnBK,CAAP;AAuBD;;AAjFkF;AAHhEzC,Y,CAIZ2C,S,GAAY,c;AAJA3C,Y,CAKZlC,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport GL from '@luma.gl/constants';\nimport {GridCellLayer} from '@deck.gl/layers';\nimport {Accessor, AccessorFunction, Color, Position, Material, DefaultProps} from '@deck.gl/core';\n\nimport {defaultColorRange} from '../utils/color-utils';\nimport {pointToDensityGridDataCPU} from './grid-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\n\nimport {Layer, UpdateParameters, GetPickingInfoParams, PickingInfo} from '@deck.gl/core';\nimport {AggregateAccessor} from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction nop() {}\n\nconst defaultProps: DefaultProps<CPUGridLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n upperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n colorScaleType: 'quantize',\n onSetColorDomain: nop,\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n elevationScale: {type: 'number', min: 0, value: 1},\n elevationScaleType: 'linear',\n onSetElevationDomain: nop,\n\n gridAggregator: pointToDensityGridDataCPU,\n\n // grid\n cellSize: {type: 'number', min: 0, max: 1000, value: 1000},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n getPosition: {type: 'accessor', value: x => x.position},\n extruded: false,\n\n // Optional material for 'lighting' shader module\n material: true,\n\n // data filter\n _filterData: {type: 'function', value: null, optional: true}\n};\n\n/** All properties supported by CPUGridLayer. */\nexport type CPUGridLayerProps<DataT = any> = _CPUGridLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\n/** Properties added by CPUGridLayer. */\ntype _CPUGridLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * Color scale domain, default is set to the extent of aggregated weights in each cell.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`\n */\n colorRange?: Color[];\n\n /**\n * Cell size multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Cell elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default true\n */\n extruded?: boolean;\n\n /**\n * Filter cells and re-calculate color by `upperPercentile`.\n * Cells with value arger than the upperPercentile will be hidden.\n * @default 100\n */\n upperPercentile?: number;\n\n /**\n * Filter cells and re-calculate color by `lowerPercentile`.\n * Cells with value smaller than the lowerPercentile will be hidden.\n * @default 0\n */\n lowerPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationUpperPercentile`.\n * Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.\n * @default 100\n */\n elevationUpperPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationLowerPercentile`.\n * Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.\n * @default 0\n */\n elevationLowerPercentile?: number;\n\n /**\n * Scaling function used to determine the color of the grid cell, default value is 'quantize'.\n * Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.\n * @default 'quantize'\n */\n colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';\n\n /**\n * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.\n */\n elevationScaleType?: 'linear';\n\n // TODO - document\n gridAggregator?: (props: any, params: any) => any;\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a cell.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.\n * @default null\n */\n getColorValue?: AggregateAccessor<DataT> | null;\n\n /**\n * The weight of a data object used to calculate the elevation value for a cell.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.\n * @default null\n */\n getElevationValue?: AggregateAccessor<DataT> | null;\n\n /**\n * This callback will be called when bin color domain has been calculated.\n * @default () => {}\n */\n onSetColorDomain?: (minMax: [number, number]) => void;\n\n /**\n * This callback will be called when bin elevation domain has been calculated.\n * @default () => {}\n */\n onSetElevationDomain?: (minMax: [number, number]) => void;\n\n /**\n * (Experimental) Filter data objects\n */\n _filterData: null | ((d: DataT) => boolean);\n};\n\n/** Aggregate data into a grid-based heatmap. Aggregation is performed on CPU. */\nexport default class CPUGridLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends AggregationLayer<DataT, ExtraPropsT & Required<_CPUGridLayerProps<DataT>>> {\n static layerName = 'CPUGridLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n const cpuAggregator = new CPUAggregator({\n getAggregator: props => props.gridAggregator,\n getCellSize: props => props.cellSize\n });\n\n this.state = {\n cpuAggregator,\n aggregatorState: cpuAggregator.state\n };\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}\n });\n // color and elevation attributes can't be added as attributes\n // they are calcualted using 'getValue' accessor that takes an array of pints.\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n this.setState({\n // make a copy of the internal state of cpuAggregator for testing\n aggregatorState: this.state.cpuAggregator.updateState(opts, {\n viewport: this.context.viewport,\n attributes: this.getAttributes(),\n numInstances: this.getNumInstances()\n })\n });\n }\n\n getPickingInfo({info}: GetPickingInfoParams): PickingInfo {\n return this.state.cpuAggregator.getPickingInfo({info});\n }\n\n // create a method for testing\n _onGetSublayerColor(cell) {\n return this.state.cpuAggregator.getAccessor('fillColor')(cell);\n }\n\n // create a method for testing\n _onGetSublayerElevation(cell) {\n return this.state.cpuAggregator.getAccessor('elevation')(cell);\n }\n\n _getSublayerUpdateTriggers() {\n return this.state.cpuAggregator.getUpdateTriggers(this.props);\n }\n\n renderLayers(): Layer {\n const {elevationScale, extruded, cellSize, coverage, material, transitions} = this.props;\n const {cpuAggregator} = this.state;\n const SubLayerClass = this.getSubLayerClass('grid-cell', GridCellLayer);\n const updateTriggers = this._getSublayerUpdateTriggers();\n\n return new SubLayerClass(\n {\n cellSize,\n coverage,\n material,\n elevationScale,\n extruded,\n\n getFillColor: this._onGetSublayerColor.bind(this),\n getElevation: this._onGetSublayerElevation.bind(this),\n transitions: transitions && {\n getFillColor: transitions.getColorValue || transitions.getColorWeight,\n getElevation: transitions.getElevationValue || transitions.getElevationWeight\n }\n },\n this.getSubLayerProps({\n id: 'grid-cell',\n updateTriggers\n }),\n {\n data: cpuAggregator.state.layerData.data\n }\n );\n }\n}\n"],"file":"cpu-grid-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cpu-grid-layer/cpu-grid-layer.ts"],"names":["GL","GridCellLayer","defaultColorRange","pointToDensityGridDataCPU","CPUAggregator","AggregationLayer","nop","defaultProps","colorDomain","colorRange","getColorValue","type","value","getColorWeight","colorAggregation","lowerPercentile","min","max","upperPercentile","colorScaleType","onSetColorDomain","elevationDomain","elevationRange","getElevationValue","getElevationWeight","elevationAggregation","elevationLowerPercentile","elevationUpperPercentile","elevationScale","elevationScaleType","onSetElevationDomain","gridAggregator","cellSize","coverage","getPosition","x","position","extruded","material","_filterData","optional","CPUGridLayer","state","initializeState","cpuAggregator","getAggregator","props","getCellSize","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","updateTriggers","getFillColor","bind","getElevation","getSubLayerProps","id","data","layerData","layerName"],"mappings":"AAoBA,SAAQA,EAAR,QAAiB,oBAAjB;AACA,SAAQC,aAAR,QAA4B,iBAA5B;AAGA,SAAQC,iBAAR,QAAgC,sBAAhC;AACA,SAAQC,yBAAR,QAAwC,mBAAxC;AACA,OAAOC,aAAP,MAA0B,yBAA1B;AACA,OAAOC,gBAAP,MAAsD,sBAAtD;;AAMA,SAASC,GAAT,GAAe,CAAE;;AAEjB,MAAMC,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEP,iBAHwC;AAI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AADtC,KAnBK,CAAP;AAuBD;;AAtFkF;AAHhEzC,Y,CAIZ2C,S,GAAY,c;AAJA3C,Y,CAKZlC,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {GL} from '@luma.gl/constants';\nimport {GridCellLayer} from '@deck.gl/layers';\nimport {Accessor, AccessorFunction, Color, Position, Material, DefaultProps} from '@deck.gl/core';\n\nimport {defaultColorRange} from '../utils/color-utils';\nimport {pointToDensityGridDataCPU} from './grid-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\n\nimport {Layer, UpdateParameters, GetPickingInfoParams, PickingInfo} from '@deck.gl/core';\nimport {AggregateAccessor} from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction nop() {}\n\nconst defaultProps: DefaultProps<CPUGridLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n upperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n colorScaleType: 'quantize',\n onSetColorDomain: nop,\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},\n elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},\n elevationScale: {type: 'number', min: 0, value: 1},\n elevationScaleType: 'linear',\n onSetElevationDomain: nop,\n\n gridAggregator: pointToDensityGridDataCPU,\n\n // grid\n cellSize: {type: 'number', min: 0, max: 1000, value: 1000},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n getPosition: {type: 'accessor', value: (x: any) => x.position},\n extruded: false,\n\n // Optional material for 'lighting' shader module\n material: true,\n\n // data filter\n _filterData: {type: 'function', value: null, optional: true}\n};\n\n/** All properties supported by CPUGridLayer. */\nexport type CPUGridLayerProps<DataT = unknown> = _CPUGridLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\n/** Properties added by CPUGridLayer. */\ntype _CPUGridLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * Color scale domain, default is set to the extent of aggregated weights in each cell.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`\n */\n colorRange?: Color[];\n\n /**\n * Cell size multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Cell elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default true\n */\n extruded?: boolean;\n\n /**\n * Filter cells and re-calculate color by `upperPercentile`.\n * Cells with value arger than the upperPercentile will be hidden.\n * @default 100\n */\n upperPercentile?: number;\n\n /**\n * Filter cells and re-calculate color by `lowerPercentile`.\n * Cells with value smaller than the lowerPercentile will be hidden.\n * @default 0\n */\n lowerPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationUpperPercentile`.\n * Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.\n * @default 100\n */\n elevationUpperPercentile?: number;\n\n /**\n * Filter cells and re-calculate elevation by `elevationLowerPercentile`.\n * Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.\n * @default 0\n */\n elevationLowerPercentile?: number;\n\n /**\n * Scaling function used to determine the color of the grid cell, default value is 'quantize'.\n * Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.\n * @default 'quantize'\n */\n colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';\n\n /**\n * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.\n */\n elevationScaleType?: 'linear';\n\n // TODO - document\n gridAggregator?: (props: any, params: any) => any;\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a cell.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.\n * @default null\n */\n getColorValue?: AggregateAccessor<DataT> | null;\n\n /**\n * The weight of a data object used to calculate the elevation value for a cell.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.\n * @default null\n */\n getElevationValue?: AggregateAccessor<DataT> | null;\n\n /**\n * This callback will be called when bin color domain has been calculated.\n * @default () => {}\n */\n onSetColorDomain?: (minMax: [number, number]) => void;\n\n /**\n * This callback will be called when bin elevation domain has been calculated.\n * @default () => {}\n */\n onSetElevationDomain?: (minMax: [number, number]) => void;\n\n /**\n * (Experimental) Filter data objects\n */\n _filterData: null | ((d: DataT) => boolean);\n};\n\n/** Aggregate data into a grid-based heatmap. Aggregation is performed on CPU. */\nexport default class CPUGridLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends AggregationLayer<DataT, ExtraPropsT & Required<_CPUGridLayerProps<DataT>>> {\n static layerName = 'CPUGridLayer';\n static defaultProps = defaultProps;\n\n state!: AggregationLayer<DataT>['state'] & {\n cpuAggregator: CPUAggregator;\n aggregatorState: CPUAggregator['state'];\n };\n\n initializeState(): void {\n const cpuAggregator = new CPUAggregator({\n getAggregator: props => props.gridAggregator,\n getCellSize: props => props.cellSize\n });\n\n this.state = {\n cpuAggregator,\n aggregatorState: cpuAggregator.state\n };\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}\n });\n // color and elevation attributes can't be added as attributes\n // they are calcualted using 'getValue' accessor that takes an array of pints.\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n this.setState({\n // make a copy of the internal state of cpuAggregator for testing\n aggregatorState: this.state.cpuAggregator.updateState(opts, {\n viewport: this.context.viewport,\n attributes: this.getAttributes(),\n numInstances: this.getNumInstances()\n })\n });\n }\n\n getPickingInfo({info}: GetPickingInfoParams): PickingInfo {\n return this.state.cpuAggregator.getPickingInfo({info});\n }\n\n // create a method for testing\n _onGetSublayerColor(cell) {\n return this.state.cpuAggregator.getAccessor('fillColor')(cell);\n }\n\n // create a method for testing\n _onGetSublayerElevation(cell) {\n return this.state.cpuAggregator.getAccessor('elevation')(cell);\n }\n\n _getSublayerUpdateTriggers() {\n return this.state.cpuAggregator.getUpdateTriggers(this.props);\n }\n\n renderLayers(): Layer {\n const {elevationScale, extruded, cellSize, coverage, material, transitions} = this.props;\n const {cpuAggregator} = this.state;\n const SubLayerClass = this.getSubLayerClass('grid-cell', GridCellLayer);\n const updateTriggers = this._getSublayerUpdateTriggers();\n\n return new SubLayerClass(\n {\n cellSize,\n coverage,\n material,\n elevationScale,\n extruded,\n\n getFillColor: this._onGetSublayerColor.bind(this),\n getElevation: this._onGetSublayerElevation.bind(this),\n transitions: transitions && {\n getFillColor: transitions.getColorValue || transitions.getColorWeight,\n getElevation: transitions.getElevationValue || transitions.getElevationWeight\n }\n },\n this.getSubLayerProps({\n id: 'grid-cell',\n updateTriggers\n }),\n {\n data: cpuAggregator.state.layerData.data\n }\n );\n }\n}\n"],"file":"cpu-grid-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cpu-grid-layer/grid-aggregator.js"],"names":["createIterable","getGridOffset","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","ke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pClB,IAAAA,CAAC,GAAGtB,SAAS,CAACwC,CAAC,GAAGtC,IAAL,CAAb;AACAqB,IAAAA,CAAC,GAAGvB,SAAS,CAACwC,CAAC,GAAGtC,IAAJ,GAAW,CAAZ,CAAb;;AACA,QAAIuB,MAAM,CAACC,QAAP,CAAgBJ,CAAhB,KAAsBG,MAAM,CAACC,QAAP,CAAgBH,CAAhB,CAA1B,EAA8C;AAC5CuB,MAAAA,IAAI,GAAGvB,CAAC,GAAGuB,IAAJ,GAAWvB,CAAX,GAAeuB,IAAtB;AACAE,MAAAA,IAAI,GAAGzB,CAAC,GAAGyB,IAAJ,GAAWzB,CAAX,GAAeyB,IAAtB;AACAC,MAAAA,IAAI,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"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cpu-grid-layer/grid-aggregator.ts"],"names":["createIterable","getGridOffset","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,SAAQA,cAAR,QAA6B,eAA7B;AACA,SAAQC,aAAR,QAA4B,iCAA5B;AA6BA,OAAO,SAASC,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,CAACK,UAFhB;AAGLC,IAAAA,IAAI,EAAEJ;AAHD,GAAP;AAKD;;AAUD,SAASD,mBAAT,CACEH,KADF,EAEEC,iBAFF,EAOE;AACA,QAAM;AAACO,IAAAA,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,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\nexport type GridHash = {\n [key: string]: {\n count: number;\n points: unknown[];\n lonIdx: number;\n latIdx: number;\n };\n};\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-next-line max-statements, complexity */\nfunction pointsToGridHashing(\n props,\n aggregationParams\n): {\n gridHash: GridHash;\n gridOffset: {xOffset: number; yOffset: number};\n offsets: [number, number];\n} {\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, offsets: [0, 0]};\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({\n gridHash,\n gridOffset,\n offsets\n}: {\n gridHash: GridHash;\n gridOffset: {xOffset: number; yOffset: number};\n offsets: [number, number];\n}) {\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"}
|