Skip to content

COGLayer: inferRenderPipeline called unconditionally, breaks custom getTileData/renderTile for non-uint COGs #257

@james-willis

Description

@james-willis

Problem

COGLayer._parseGeoTIFF() unconditionally calls inferRenderPipeline(), which throws for any SampleFormat other than Uint (e.g. Float32, Int):

Inferring render pipeline for non-unsigned integers not yet supported. Found SampleFormat: 3,3,3,3,3

This happens even when the user provides both getTileData and renderTile props, in which case the inferred defaults are never used. The user has no way to use COGLayer with Float32 COGs, even with fully custom rendering.

Relevant source: cog-layer.ts_parseGeoTIFF()

// This is called unconditionally:
const { getTileData: defaultGetTileData, renderTile: defaultRenderTile } =
  inferRenderPipeline(geotiff, this.context.device);

Suggested fix

Skip inferRenderPipeline when the user has provided both getTileData and renderTile:

let defaultGetTileData;
let defaultRenderTile;
if (!this.props.getTileData || !this.props.renderTile) {
  const inferred = inferRenderPipeline(geotiff, this.context.device);
  defaultGetTileData = inferred.getTileData;
  defaultRenderTile = inferred.renderTile;
}

This should be a minimal, non-breaking change — the inferred defaults are only used as fallbacks in _getTileData and _renderSubLayers when the user hasn't provided their own.

Context

We're using COGLayer with custom getTileData/renderTile to render Float32 COGs. We had to patch the built dist/cog-layer.js via patch-package to work around this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions