Skip to content

Commit

Permalink
Merge branch 'master' into felix/carto-private-fetchmap
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer authored Sep 4, 2024
2 parents 05b9d84 + f944077 commit c54c198
Show file tree
Hide file tree
Showing 20 changed files with 772 additions and 608 deletions.
2 changes: 2 additions & 0 deletions modules/aggregation-layers/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export type AggregateAccessor<DataT = any> = (
data: any;
}
) => number;

export type ScaleType = 'linear' | 'quantize' | 'quantile' | 'ordinal';
25 changes: 22 additions & 3 deletions modules/aggregation-layers/src/common/utils/color-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import type {Color} from '@deck.gl/core';
import type {Device, Texture} from '@luma.gl/core';
import type {NumericArray, TypedArray, TypedArrayConstructor} from '@math.gl/types';
import type {ScaleType} from '../types';

export const defaultColorRange: Color[] = [
[255, 255, 178],
Expand Down Expand Up @@ -63,15 +64,33 @@ export function colorRangeToFlatArray(
return flatArray;
}

export function colorRangeToTexture(device: Device, colorRange: Color[] | NumericArray): Texture {
export const COLOR_RANGE_FILTER: Record<ScaleType, 'linear' | 'nearest'> = {
linear: 'linear',
quantile: 'nearest',
quantize: 'nearest',
ordinal: 'nearest'
} as const;

export function updateColorRangeTexture(texture: Texture, type: ScaleType) {
texture.setSampler({
minFilter: COLOR_RANGE_FILTER[type],
magFilter: COLOR_RANGE_FILTER[type]
});
}

export function createColorRangeTexture(
device: Device,
colorRange: Color[] | NumericArray,
type: ScaleType = 'linear'
): Texture {
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);

return device.createTexture({
format: 'rgba8unorm',
mipmaps: false,
sampler: {
minFilter: 'linear',
magFilter: 'linear',
minFilter: COLOR_RANGE_FILTER[type],
magFilter: COLOR_RANGE_FILTER[type],
addressModeU: 'clamp-to-edge',
addressModeV: 'clamp-to-edge'
},
Expand Down
219 changes: 0 additions & 219 deletions modules/aggregation-layers/src/common/utils/scale-utils.js

This file was deleted.

Loading

0 comments on commit c54c198

Please sign in to comment.