-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPU Aggregation: miscellaneous clean up #9142
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
94670a6
ScreenGridLayer
Pessimistress 009a251
extract common code to util
Pessimistress 32c7d61
merge error
Pessimistress 3121f03
Aggregation layer test app
Pessimistress 194e352
lint
Pessimistress 28ff0e6
bug fix
Pessimistress 010b21c
fix test
Pessimistress bb51aac
render test
Pessimistress 88bde1b
update docs
Pessimistress 01ff5c5
Use UBO for binOptions
Pessimistress File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
modules/aggregation-layers/src/common/utils/bounds-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** Utility to estimate binIdRange as expected by AggregatorProps */ | ||
export function getBinIdRange({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Export this function for use in custom layers? |
||
dataBounds, | ||
getBinId, | ||
padding = 0 | ||
}: { | ||
/** Bounds of the input data */ | ||
dataBounds: [min: number[], max: number[]]; | ||
/** Given a data point, returns the bin id that it belongs to */ | ||
getBinId: (p: number[]) => number[]; | ||
/** Add a border around the result to avoid clipping */ | ||
padding?: number; | ||
}): [number, number][] { | ||
const corners = [ | ||
dataBounds[0], | ||
dataBounds[1], | ||
[dataBounds[0][0], dataBounds[1][1]], | ||
[dataBounds[1][0], dataBounds[0][1]] | ||
].map(p => getBinId(p)); | ||
|
||
const minX = Math.min(...corners.map(p => p[0])) - padding; | ||
const minY = Math.min(...corners.map(p => p[1])) - padding; | ||
const maxX = Math.max(...corners.map(p => p[0])) + padding + 1; | ||
const maxY = Math.max(...corners.map(p => p[1])) + padding + 1; | ||
|
||
return [ | ||
Pessimistress marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[minX, maxX], | ||
[minY, maxY] | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {Deck, OrthographicView} from '@deck.gl/core'; | ||
import {HistogramLayer} from './histogram-layer'; | ||
|
||
const deckgl = new Deck({ | ||
views: new OrthographicView(), | ||
initialViewState: { | ||
target: [0, 0, 0], | ||
zoom: 1 | ||
}, | ||
controller: true | ||
}); | ||
|
||
const slider = document.getElementById('bin-size-slider') as HTMLInputElement; | ||
slider.oninput = updateLayer; | ||
updateLayer(); | ||
|
||
function updateLayer() { | ||
const layer = new HistogramLayer({ | ||
data: generateData(10000, 0, 100), | ||
getPosition: d => d, | ||
gpuAggregation: true, | ||
binSize: Number(slider.value), | ||
heightScale: 1 | ||
}); | ||
deckgl.setProps({layers: [layer]}); | ||
} | ||
|
||
function generateData(count: number, mean: number, stdev: number) { | ||
const result: number[] = []; | ||
for (let i = 0; i < count; i++) { | ||
// Gaussian random | ||
const u = 1 - Math.random(); | ||
const v = Math.random(); | ||
const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v); | ||
result.push(z * stdev + mean); | ||
} | ||
return result; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it only an estimate?