modules/aggregation-layers/src/utils/gpu-grid-aggregation/grid-aggregation-utils.js
function getGPUAggregationParams({boundingBox, cellSize, worldOrigin}) {
  const {yMin, yMax, xMin, xMax} = boundingBox;

  // NOTE: this alignment will match grid cell boundaries with existing CPU implementation
  // this gurantees identical aggregation results when switching between CPU and GPU aggregation.
  // Also gurantees same cell boundaries, when overlapping between two different layers (like ScreenGrid and Contour)
  // We first move worldOrigin to [0, 0], align the lower bounding box , then move worldOrigin to its original value.
  const originX = alignToCell(xMin - worldOrigin[0], cellSize[0]) + worldOrigin[0];
  const originY = alignToCell(yMin - worldOrigin[1], cellSize[1]) + worldOrigin[1];

  // Setup transformation matrix so that every point is in +ve range
  const gridTransformMatrix = new Matrix4().translate([-1 * originX, -1 * originY, 0]);

  // const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
  const gridOrigin = [originX, originY];
  const width = xMax - xMin + cellSize[0];
  const height = yMax - yMin + cellSize[1];

  const gridSize = [Math.ceil(width / cellSize[0]), Math.ceil(height / cellSize[1])];

  return {
    gridOrigin,
    gridSize,
    width,
    height,
    gridTransformMatrix
  };
}
function getGPUAggregationParams({boundingBox, cellSize, worldOrigin}) {
  const {yMin, yMax, xMin, xMax} = boundingBox;

  // NOTE: this alignment will match grid cell boundaries with existing CPU implementation
  // this gurantees identical aggregation results when switching between CPU and GPU aggregation.
  // Also gurantees same cell boundaries, when overlapping between two different layers (like ScreenGrid and Contour)
  // We first move worldOrigin to [0, 0], align the lower bounding box , then move worldOrigin to its original value.
  const originX = alignToCell(xMin - worldOrigin[0], cellSize[0]) + worldOrigin[0];
  const originY = alignToCell(yMin - worldOrigin[1], cellSize[1]) + worldOrigin[1];

  // Setup transformation matrix so that every point is in +ve range
  const gridTransformMatrix = new Matrix4().translate([-1 * originX, -1 * originY, 0]);

  // const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
  const gridOrigin = [originX, originY];
  const width = xMax - xMin + cellSize[0];
  const height = yMax - yMin + cellSize[1];

  const gridSize = [Math.ceil(width / cellSize[0]), Math.ceil(height / cellSize[1])];

  return {
    gridOrigin,
    gridSize,
    width,
    height,
    gridTransformMatrix
  };
}
function getGPUAggregationParams ( { boundingBox , cellSize , worldOrigin } ) { const { yMin , yMax , xMin , xMax } = boundingBox ; // NOTE: this alignment will match grid cell boundaries with existing CPU implementation // this gurantees identical aggregation results when switching between CPU and GPU aggregation. // Also gurantees same cell boundaries, when overlapping between two different layers (like ScreenGrid and Contour) // We first move worldOrigin to [0, 0], align the lower bounding box , then move worldOrigin to its original value. const originX = alignToCell ( xMin - worldOrigin [ 0 ] , cellSize [ 0 ] ) + worldOrigin [ 0 ] ; const originY = alignToCell ( yMin - worldOrigin [ 1 ] , cellSize [ 1 ] ) + worldOrigin [ 1 ] ; // Setup transformation matrix so that every point is in +ve range const gridTransformMatrix = new Matrix4 ( ) . translate ( [ - 1 * originX , - 1 * originY , 0 ] ) ; // const cellSize = [gridOffset.xOffset, gridOffset.yOffset]; const gridOrigin = [ originX , originY ] ; const width = xMax - xMin + cellSize [ 0 ] ; const height = yMax - yMin + cellSize [ 1 ] ; const gridSize = [ Math . ceil ( width / cellSize [ 0 ] ) , Math . ceil ( height / cellSize [ 1 ] ) ] ; return { gridOrigin , gridSize , width , height , gridTransformMatrix } ; }
Calculate grid parameters
Calculate grid parameters