Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions packages/deck.gl-geotiff/src/multi-cog-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
}
Expand All @@ -1048,7 +1071,7 @@ function createBandTexture(device: Device, array: RasterArray): Texture {
format,
width,
height,
sampler: { minFilter: "linear", magFilter: "linear" },
sampler,
});
}

Expand Down
Loading