From 948dc7b9e711177c0d01507d0a1b62009f1c344d Mon Sep 17 00:00:00 2001 From: willjnz Date: Tue, 25 Aug 2026 11:11:20 +1000 Subject: [PATCH] Allow MultiCOGLayer sampler to be overridden --- .../deck.gl-geotiff/src/multi-cog-layer.ts | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/deck.gl-geotiff/src/multi-cog-layer.ts b/packages/deck.gl-geotiff/src/multi-cog-layer.ts index 7b50a574..eba5c1fb 100644 --- a/packages/deck.gl-geotiff/src/multi-cog-layer.ts +++ b/packages/deck.gl-geotiff/src/multi-cog-layer.ts @@ -48,7 +48,7 @@ import { metersPerUnit, parseWkt, } from "@developmentseed/proj"; -import type { Device, TextureFormat } from "@luma.gl/core"; +import type { Device, SamplerProps, TextureFormat } from "@luma.gl/core"; import { Texture } from "@luma.gl/core"; import proj4 from "proj4"; import { DEFAULT_CONCURRENCY_LIMITER } from "./default-concurrency-limiter.js"; @@ -185,6 +185,17 @@ export type MultiCOGLayerProps = CompositeLayerProps & */ renderPipeline?: RasterModule[]; + /** + * Sampler used for each band's GPU texture. + * + * Linear blends real data with nodata/out-of-bounds fill at mask, tile, + * and dataset edges. Use nearest to avoid that blending, at the cost of + * blocky pixels when zoomed in past native resolution. + * + * @default { minFilter: "linear", magFilter: "linear" } + */ + bandSampler?: SamplerProps; + /** * EPSG code resolver used to look up projection definitions for numeric * CRS codes found in GeoTIFF metadata. @@ -725,7 +736,11 @@ export class MultiCOGLayer extends RasterTileLayer< signal, }); - const texture = createBandTexture(device, tile.array); + const texture = createBandTexture( + device, + tile.array, + this.props.bandSampler, + ); const arr = tile.array; const byteLength = arr.layout === "pixel-interleaved" @@ -832,7 +847,11 @@ export class MultiCOGLayer extends RasterTileLayer< minRow: resolution.minRow, }); - const texture = createBandTexture(device, assembled); + const texture = createBandTexture( + device, + assembled, + this.props.bandSampler, + ); const assembledByteLength = assembled.layout === "pixel-interleaved" ? assembled.data.byteLength @@ -1024,7 +1043,11 @@ function selectImage(geotiff: GeoTIFF, z: number): GeoTIFF | Overview { * * TODO: use `inferTextureFormat` from `texture.ts` for full format support. */ -function createBandTexture(device: Device, array: RasterArray): Texture { +function createBandTexture( + device: Device, + array: RasterArray, + sampler: SamplerProps = { minFilter: "linear", magFilter: "linear" }, +): Texture { if (array.layout !== "pixel-interleaved") { throw new Error("Band-separate layout not yet supported in MultiCOGLayer"); } @@ -1048,7 +1071,7 @@ function createBandTexture(device: Device, array: RasterArray): Texture { format, width, height, - sampler: { minFilter: "linear", magFilter: "linear" }, + sampler, }); }