[go: nahoru, domu]

Skip to content
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 (4/8): ScreenGridLayer #8942

Merged
merged 9 commits into from
Jun 24, 2024
Merged
Prev Previous commit
Next Next commit
type picking info
  • Loading branch information
Pessimistress committed Jun 22, 2024
commit 6a07194dba4097846783c8548545486b3cdf90ae
5 changes: 4 additions & 1 deletion modules/aggregation-layers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export type {HexagonLayerProps} from './hexagon-layer/hexagon-layer';
export type {CPUGridLayerProps} from './cpu-grid-layer/cpu-grid-layer';
export type {GridLayerProps} from './grid-layer/grid-layer';
export type {GPUGridLayerProps} from './gpu-grid-layer/gpu-grid-layer';
export type {ScreenGridLayerProps} from './screen-grid-layer/screen-grid-layer';
export type {
ScreenGridLayerProps,
ScreenGridLayerPickingInfo
} from './screen-grid-layer/screen-grid-layer';

export type {WebGLAggregatorProps} from './aggregation-layer-v9/gpu-aggregator/webgl-aggregator';
export type {CPUAggregatorProps} from './aggregation-layer-v9/cpu-aggregator/cpu-aggregator';
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ export type _ScreenGridLayerProps<DataT> = {
aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
};

export type ScreenGridLayerPickingInfo<DataT> = PickingInfo<{
/** Column index of the picked cell, starting from 0 at the left of the viewport */
col: number;
/** Row index of the picked cell, starting from 0 at the top of the viewport */
row: number;
/** Aggregated value */
value: number;
/** Number of data points in the picked cell */
count: number;
/** Indices of the data objects in the picked cell. Only available if using CPU aggregation. */
pointIndices?: number[];
/** The data objects in the picked cell. Only available if using CPU aggregation and layer data is an array. */
points?: DataT[];
}>;

/** Aggregates data into histogram bins and renders them as a grid. */
export default class ScreenGridLayer<
DataT = any,
Expand Down Expand Up @@ -273,18 +288,27 @@ export default class ScreenGridLayer<
);
}

getPickingInfo({info}: GetPickingInfoParams): PickingInfo {
getPickingInfo(params: GetPickingInfoParams): ScreenGridLayerPickingInfo<DataT> {
const info: ScreenGridLayerPickingInfo<DataT> = params.info;
const {index} = info;
if (index >= 0) {
const bin = this.state.aggregator.getBin(index);
let object: ScreenGridLayerPickingInfo<DataT>['object'];
if (bin) {
info.object = {
object = {
col: bin.id[0],
row: bin.id[1],
weight: Number.isFinite(bin.value[0]) ? bin.value[0] : undefined,
value: bin.value[0],
count: bin.count
};
if (bin.points) {
object.pointIndices = bin.points;
object.points = Array.isArray(this.props.data)
? bin.points.map(i => (this.props.data as DataT[])[i])
: [];
}
}
info.object = object;
}

return info;
Expand Down