Skip to content

refactor: Create RasterTileLayer abstraction in deck.gl-raster package - #462

Merged
kylebarron merged 18 commits into
mainfrom
feat/raster-tile-layer
Apr 24, 2026
Merged

kylebarron merged 18 commits into
mainfrom
feat/raster-tile-layer

Conversation

@kylebarron

@kylebarron kylebarron commented Apr 24, 2026 •

Copy link
Copy Markdown
Member

Problem

The @developmentseed/deck.gl-raster package provides RasterLayer (renders a single spatially-oriented texture) and tile utilities implementing Tileset2D (RasterTileset2D, TileMatrixSetAdaptor, TilesetDescriptor). Wiring these into a full tiled raster layer currently lives in COGLayer (in deck.gl-geotiff) and was largely duplicated into ZarrLayer (in deck.gl-zarr). Lonboard re-implements the same wiring a third time in its widget.

Duplicated logic across these consumers includes:

  • Creating a RasterTileset2D factory subclass that captures the descriptor
  • Instantiating the upstream @deck.gl/geo-layers TileLayer
  • Wiring getTileData / renderSubLayers
  • Globe vs. Web Mercator coordinate system handling (COORDINATE_SYSTEM.CARTESIAN, modelMatrix, coordinateOrigin)
  • Per-tile RasterLayer construction with reprojectionFns and debug tile outlines
  • Forwarding TileLayer passthrough props
  • Combining the user's signal prop with TileLayer's per-tile AbortSignal

Goals

  • Introduce RasterTileLayer in @developmentseed/deck.gl-raster that encapsulates the shared tiled-raster infrastructure.
  • Make it directly usable by any consumer that can produce a TilesetDescriptor (notably Lonboard).
  • Make it subclassable so source-specific layers like COGLayer and ZarrLayer can expose a single "parse this source" prop to end users.
  • Migrate COGLayer and ZarrLayer to subclass RasterTileLayer without changing their public API.

Inspired by @deck.gl/geo-layers's MVTLayer extends TileLayer pattern: the base class is usable directly, and subclasses customize by overriding protected methods and adding their own props.

Non-Goals

  • Changing the public API of COGLayer or ZarrLayer.
  • Supporting per-tile transforms returned from getTileData (consumer-supplied transforms attached to fetched data). The descriptor owns transforms; if a future use case requires per-tile overrides, an optional return field can be added without breaking the current contract.
  • Ground Control Points (GCPs). The descriptor's per-tile tileTransform interface can represent non-affine transforms, but no GCP-based descriptor implementation is part of this work.

Change list

  • Create RasterTileLayer new export from deck.gl-raster package
  • Switch biome config to require block if and for statements instead of on one line.

Closes #404 , Closes #453

kylebarron and others added 11 commits April 23, 2026 10:43
Factors out the shared tile-layer wiring currently duplicated in COGLayer,
ZarrLayer, and Lonboard into a new RasterTileLayer in @developmentseed/deck.gl-raster.
Usable directly (Lonboard) or as a subclass (COGLayer/ZarrLayer) via the
MVTLayer-extends-TileLayer pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends TilesetLevel with tileTransform(col, row) returning forward and
inverse pixel↔CRS callbacks. Extends TilesetDescriptor with projectFrom4326
and projectFrom3857. Updates TileMatrixSetAdaptor and geoZarrToDescriptor
to populate them, and drops the redundant third-argument projection bundle
from RasterTileset2D's constructor (it now reads projectTo4326 from the
descriptor). No consumer-facing behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Addresses code review feedback on commit 130133a:
- TileMatrixAdaptor.tileTransform now reuses @developmentseed/affine's
  invert/apply instead of open-coding a 2x2 inversion, matching the
  ZarrTilesetLevel implementation.
- geoZarrToDescriptor takes a named options object (was 6 positional
  args).
- Remove redundant RasterTileset2D.projectTo4326 private field; read
  from the descriptor directly.
- Add JSDoc on the new tileTransform method implementations.
Introduces RasterTileLayer — a CompositeLayer that wraps @deck.gl/geo-layers
TileLayer with the shared wiring for rendering a tiled raster source backed
by a TilesetDescriptor. Directly usable with tilesetDescriptor / getTileData
/ renderTile props, or subclassable by overriding the three protected
accessor methods. No consumers migrated yet.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…vel lookup

- Merge types.ts into raster-tile-layer.ts to match deck.gl convention of
  "props type then layer class" in the same file.
- Guard _renderSubLayers against out-of-range tile zoom levels instead of
  asserting descriptor.levels[z] is defined.
- Drop redundant `| undefined` from accessor return types — the prop types
  already express optionality.
- Remove empty initializeState override; CompositeLayer initializes state
  to {} by default.

Addresses post-commit review of d08d237.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
COGLayer now inherits its tile-layer wiring from RasterTileLayer. The
class body shrinks to GeoTIFF parsing, default-pipeline inference, and
three protected accessor overrides that adapt the COG-specific
`getTileData(image, options)` signature into RasterTileLayer's
tile-centric signature. No public API change.

Also widens `RasterTileLayer.defaultProps` type annotation from
`Partial<RasterTileLayerProps>` to the canonical deck.gl
`DefaultProps<RasterTileLayerProps>` so static-side inheritance works
for subclasses.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Re-export MinimalDataT from @developmentseed/deck.gl-raster instead of
  locally redeclaring it; simplifies the class generic back to the plan's
  specified form.
- Restore the TODO comment about micro-optimizing overview selection that
  was dropped in the e826ae8 refactor.
- Drop the dead-code `options.device ?? this.context.device` fallback —
  RasterTileLayer._wrapGetTileData always populates options.device.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ZarrLayer now inherits its tile-layer wiring from RasterTileLayer. The
class body shrinks to Zarr store parsing, CRS resolution, and the three
protected accessor overrides. No default renderTile is provided (GeoZarr
lacks metadata hints), matching prior behavior — users still supply their
own getTileData and renderTile. The existing public API (selection,
metadata, user-supplied getTileData/renderTile) is preserved. No
behavior change for consumers.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… up barrel

- RasterTileLayer now forwards `updateTriggers.renderTile` as
  `updateTriggers.renderSubLayers` on the inner TileLayer, preserving
  the pre-migration ZarrLayer behavior where users invalidate cached
  tile rendering by bumping render-side dependencies. COGLayer and
  direct consumers benefit as well.
- Re-export `SliceInput` from @developmentseed/deck.gl-zarr's barrel;
  in-file export alone left the type unreachable from outside.
- Tighten the ZarrLayer `_getGetTileData` closure-capture comment to
  accurately describe the cache-invalidation semantics.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ection

When a subclass passes COGLayerProps/ZarrLayerProps as ExtraProps (which
redeclares getTileData/renderTile with a domain-specific signature),
the previous class signature `Required<RasterTileLayerProps<DataT>> &
ExtraProps` intersected the base and subclass function signatures and
produced an impossible type at the user's construction site (e.g.
`new COGLayer({ getTileData: fn })` reported that `fn` was not
assignable to the intersection of base and COG signatures).

Split the base's declared prop shape from the overridable fields:
- `RasterTileLayerBaseProps<DataT>` = everything except the 3 overridable
- `ExtraProps` default = `Pick<RasterTileLayerProps<DataT>, 3 overridable>`
  (preserves direct-use ergonomics)
- Class now extends `CompositeLayer<BaseProps & ExtraProps>`

Base-class code accesses the 3 overridable fields via a private
`_baseProps` typed cast; subclasses override the protected accessors
and never go through the cast. Net: direct users see the full
RasterTileLayerProps surface, subclasses replace the overridable
signatures cleanly, and the function-signature intersection is gone.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions github-actions Bot added the docs label Apr 24, 2026
@kylebarron kylebarron changed the title docs: Add RasterTileLayer design spec refactor: Create RasterTileLayer abstraction in deck.gl-raster package Apr 24, 2026
@github-actions github-actions Bot added refactor and removed docs labels Apr 24, 2026
kylebarron and others added 6 commits April 24, 2026 09:45
_getTilesetDescriptor → _tilesetDescriptor
_getGetTileData      → _tileDataFn
_getRenderTile       → _renderTileFn

The old `_getGetTileData` read as "get [the] getTileData" and collided
awkwardly with the callback it returned. The new names treat these as
accessor-style computed-property methods ("the currently effective X"),
which reads cleaner both at the base-class declaration and at subclass
override sites in COGLayer and ZarrLayer.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… GetTileDataOptions

Both are always populated by the base layer before invoking the user's
`getTileData` callback — `device` from `this.context.device`, `signal`
from deck.gl's per-tile lifecycle signal (optionally composed with the
user's `signal` prop). Marking them required at the type level removes
the `options.device!` and `options.signal!` non-null assertions that
COGLayer and ZarrLayer were using to paper over the optional type.

Also tightens the COG- and Zarr-specific `GetTileDataOptions.signal`
to required, matching the base type.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The `T` suffix conventionally signals "this is a generic type parameter"
(e.g. `DataT`, `ExtraProps`), but MinimalDataT is a plain type used as
a constraint. Rename to MinimalTileData to drop the misleading suffix
and clarify intent: it's the minimal shape a tile's data must satisfy.

Also picks up a few formatting whitespace fixes from biome.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions github-actions Bot removed the feat label Apr 24, 2026
Adds braces around all single-statement if / else / for / while / do
branches. Per-user preference for readability and an explicit visual
block. Biome's style/useBlockStatements rule enforces this going
forward.

Auto-fixes applied with `biome check --write --unsafe` across 18
files in packages/ and examples/. Pure formatting — no behavior change;
tests and typecheck unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kylebarron
kylebarron marked this pull request as ready for review April 24, 2026 14:20
@kylebarron
kylebarron enabled auto-merge (squash) April 24, 2026 14:21
@kylebarron
kylebarron merged commit 7a08ce0 into main Apr 24, 2026
5 checks passed
@kylebarron
kylebarron deleted the feat/raster-tile-layer branch April 24, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass updateTriggers into TileLayer for COGLayer? Create RasterTileLayer in deck.gl-raster package

1 participant