Skip to content

feat: Mosaic tile layer - #184

Merged
kylebarron merged 17 commits into
mainfrom
kyle/mosaic-tile-layer
Jan 15, 2026
Merged

kylebarron merged 17 commits into
mainfrom
kyle/mosaic-tile-layer

Conversation

@kylebarron

@kylebarron kylebarron commented Jan 13, 2026 •

Copy link
Copy Markdown
Member

Change list

  • Add MosaicLayer deck.gl layer that renders multiple items based on what's on screen. Under the hood it uses a TileLayer
  • Allow AbortSignal input into COGLayer
  • New NAIP mosaic example:
    • Render either true color, false color infrared, or NDVI with colormap
    • Define proj strings in app for bundle size

cc @gadomski

This was referenced Jan 15, 2026
@kylebarron
kylebarron merged commit acc6904 into main Jan 15, 2026
2 checks passed
@kylebarron
kylebarron deleted the kyle/mosaic-tile-layer branch January 15, 2026 21:38
@ds-release-bot ds-release-bot Bot mentioned this pull request Jan 26, 2026
kylebarron pushed a commit that referenced this pull request Jan 26, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>0.2.0</summary>

##
[0.2.0](v0.1.0...v0.2.0)
(2026-01-26)


### Features

* Mosaic tile layer
([#184](#184))
([acc6904](acc6904))
* Update land-cover example text
([#163](#163))
([790b5f5](790b5f5))


### Bug Fixes

* handle lowercase units
([#195](#195))
([918c241](918c241))


### Performance Improvements

* remove unnecessary object creation
([#181](#181))
([62c0c23](62c0c23))
</details>

<details><summary>deck.gl-geotiff: 0.2.0</summary>

##
[0.2.0](deck.gl-geotiff-v0.1.0...deck.gl-geotiff-v0.2.0)
(2026-01-26)


### Features

* Allow user-defined texture loader in COGLayer
([#101](#101))
([010e800](010e800))
* Direct rendering of paletted COG in Land Cover example
([#102](#102))
([5d8d6f1](5d8d6f1))
* Generic projection handler & NLCD example
([#81](#81))
([f2bf383](f2bf383))
* **geotiff:** Set up texture mapping from tiff tags to luma.gl texture
format
([#98](#98))
([9e766c3](9e766c3))
* Infer default COG render pipeline based on GeoTIFF metadata
([#154](#154))
([8fddeec](8fddeec))
* Mosaic tile layer
([#184](#184))
([acc6904](acc6904))
* Parse GeoTIFF ColorMap tag
([#116](#116))
([0bb7eed](0bb7eed))
* Pass geographic bounds in onGeoTIFFLoad callback
([#130](#130))
([d0e3677](d0e3677))
* Set up namespace exports
([#148](#148))
([933561c](933561c))
* Shader module system and dynamic injection
([#120](#120))
([7f40813](7f40813))
* Stabler `renderPipeline` inference with props placeholder
([#157](#157))
([61a46cc](61a46cc))
* Support varied input for GeoTIFF source
([#128](#128))
([cbcd1e4](cbcd1e4))


### Bug Fixes

* Ensure `loadTexture` returns `Texture`, not `TextureProps`
([#113](#113))
([20ce0c0](20ce0c0))
* handle lowercase units
([#195](#195))
([918c241](918c241))
* throw error when maxError is non-positive
([#151](#151))
([e57d17e](e57d17e)),
closes
[#18](#18)


### Performance Improvements

* Only compute COG bounds when the user supplies onGeoTIFFLoad callback
([#137](#137))
([125de6f](125de6f))
* remove unnecessary object creation
([#181](#181))
([62c0c23](62c0c23))
</details>

<details><summary>deck.gl-raster: 0.2.0</summary>

##
[0.2.0](deck.gl-raster-v0.1.0...deck.gl-raster-v0.2.0)
(2026-01-26)


### Features

* combine debug layer into main layer
([#49](#49))
([4d388df](4d388df))
* Extract TileMatrixSet definition from GeoTIFF object
([#50](#50))
([bde296c](bde296c))
* Generic projection handler & NLCD example
([#81](#81))
([f2bf383](f2bf383))
* Infer default COG render pipeline based on GeoTIFF metadata
([#154](#154))
([8fddeec](8fddeec))
* initial RasterLayer and RasterDebugLayer
([#40](#40))
([4a28770](4a28770))
* Set up namespace exports
([#148](#148))
([933561c](933561c))
* Set up shader injection through RasterLayer
([#99](#99))
([d7714e3](d7714e3))
* Shader module system and dynamic injection
([#120](#120))
([7f40813](7f40813))
* Stabler `renderPipeline` inference with props placeholder
([#157](#157))
([61a46cc](61a46cc))
* Update land-cover example text
([#163](#163))
([790b5f5](790b5f5))


### Bug Fixes

* Fix off-by-one error in RasterLayer mesh generation
([#63](#63))
([8d3f288](8d3f288))
* move deck.gl dependencies to peer dependencies
([#43](#43))
([4877f2f](4877f2f))
* throw error when maxError is non-positive
([#151](#151))
([e57d17e](e57d17e)),
closes
[#18](#18)
</details>

<details><summary>deck.gl-zarr: 0.2.0</summary>

##
[0.2.0](deck.gl-zarr-v0.1.0...deck.gl-zarr-v0.2.0)
(2026-01-26)


### Features

* Set up namespace exports
([#148](#148))
([933561c](933561c))


### Bug Fixes

* move deck.gl dependencies to peer dependencies
([#43](#43))
([4877f2f](4877f2f))
</details>

<details><summary>raster-reproject: 0.2.0</summary>

##
[0.2.0](raster-reproject-v0.1.0...raster-reproject-v0.2.0)
(2026-01-26)


### Features

* Set up namespace exports
([#148](#148))
([933561c](933561c))


### Bug Fixes

* move deck.gl dependencies to peer dependencies
([#43](#43))
([4877f2f](4877f2f))
* throw error when maxError is non-positive
([#151](#151))
([e57d17e](e57d17e)),
closes
[#18](#18)
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: ds-release-bot[bot] <116609932+ds-release-bot[bot]@users.noreply.github.com>
@ds-release-bot ds-release-bot Bot mentioned this pull request Feb 20, 2026
kylebarron added a commit that referenced this pull request Oct 16, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

`MosaicLayer` accepts `extent` and passes it to its inner `TileLayer`,
which hands it to `MosaicTileset2D`. But `MosaicTileset2D` overrides
`getTileIndices` and never reads `this.opts.extent`, so the prop does
nothing. Every source whose bbox meets the viewport is still fetched,
rendered and reported by `onViewportLoad`, with no warning. It has been
this way since `MosaicLayer` was added in #184.

#684 makes the same fix for `RasterTileset2D`, the repo's only other
`Tileset2D` subclass, and its description lists `MosaicTileset2D` as not
changed there. Ref #684

## Reproduction

```ts
new MosaicLayer({
  id: "mosaic",
  sources: [
    { bbox: [0, 0, 10, 10] }, // A
    { bbox: [20, 0, 30, 10] }, // B
    { bbox: [40, 0, 50, 10] }, // C
  ],
  extent: [15, -5, 35, 5], // overlaps only B
  getSource: async (source) => {
    console.log("fetching", source.bbox);
  },
  renderSource: () => null,
});
```

In a viewport that shows all three sources (longitude 25, latitude 5,
zoom 3, 512×512), `main` fetches all three. I ran a version of this with
named sources and an `onViewportLoad` callback through deck.gl's
`LayerManager` in vitest (no GPU device, public API only), logging what
`getSource` fetched and what `onViewportLoad` reported:

```
main     extent=[15,-5,35,5]: fetched=["A","B","C"] onViewportLoad=["A","B","C"]
this PR  extent=[15,-5,35,5]: fetched=["B"] onViewportLoad=["B"]
```

On `main`, changing `extent` on later renders (none, then
`[15,-5,35,5]`, then `[5,-5,25,5]`, then none) never changes the
selection. With this PR, `onViewportLoad` reports `["A","B","C"]`,
`["B"]`, `["A","B"]`, then `["A","B","C"]`.

## Fix

- `MosaicTileset2D.getTileIndices` keeps its zoom gate and its Flatbush
search of the viewport, then drops the hits whose bbox doesn't overlap
`extent`. It reads `this.opts.extent` on every call, because `TileLayer`
updates it through `setOptions`. The filter runs before the hits are
mapped, so a source's default tile id is still its position in
`sources`.
- It uses the same rule as deck.gl's `TileLayer` (`OSMNode.update`'s
`insideBounds`) and #684. The overlap is strict, so a source that only
touches the extent at an edge or a corner is skipped. Each source is
tested against the whole extent, not against the part of it in view, so
a source that is on screen and overlaps the extent off-screen still
loads (it is drawn in full).
- `extent` is no longer picked from `TileLayerProps`. `MosaicLayerProps`
now declares it with TSDoc, which covers:
  - the format: WGS84 `[minLng, minLat, maxLng, maxLat]`
- that an overlapping source is drawn in full, so to limit what it
loads, pass the same `extent` to the layers `renderSource` returns
- that unlike deck.gl's `TileLayer`, it doesn't keep sources loading
below `minZoom`

## Tests

There's a new `MosaicTileset2D extent` block in
`tests/mosaic-tileset-2d.test.ts`. Its tests check that the tileset:

- selects only the sources that overlap an asymmetric extent
- keeps array-position ids when the extent skips an earlier source
- skips sources that only touch the extent, at an east/west edge and at
a north edge
- keeps a visible source whose overlap with the extent is off-screen,
and skips an on-screen source that misses the extent
- applies an extent changed through `setOptions` on the next call

Red/green: with only `mosaic-tileset-2d.ts` and `mosaic-layer.ts`
reverted to `main`, all 5 new tests fail (`Tests 5 failed | 6 passed
(11)`). With this PR, `Tests 11 passed (11)`. I also tried these wrong
versions of the fix, and each one fails at least one test:

- inclusive comparisons, on both axes or on y alone
- the extent read with its axes swapped
- searching viewport ∩ extent instead of testing each source
- the extent captured once in the constructor
- ids numbered after filtering

Checks:

- `pnpm --filter @developmentseed/deck.gl-geotiff test`: `Test Files 7
passed (7)`, `Tests 38 passed (38)`.
- `pnpm --filter @developmentseed/deck.gl-geotiff typecheck` passes
under TypeScript 6.0.3. I haven't run it under TypeScript 7 (#685); CI
will.
- `pnpm exec biome ci .`: `Checked 385 files ... No fixes applied.`

## Open questions and judgment calls

- **Merge after #684?** The TSDoc tells users to pass `extent` to the
layers `renderSource` returns. That only limits what a `COGLayer` loads
once #684 makes `RasterTileset2D` read `extent`. If this PR lands first,
that sentence is ahead of the code until #684 does.
- **`minZoom`.** I kept the existing zoom gate, so setting `extent` does
not keep sources loading below `minZoom`, unlike in deck.gl's
`TileLayer`. #684 makes the same choice.
- **A `MosaicLayer`-level test?** This PR doesn't change how
`MosaicLayer` forwards `extent`, and no test covers that forwarding yet.
A test that `renderTileLayer(...)` passes `extent` to the inner
`TileLayer` needs no `LayerManager`. Turning the end-to-end reproduction
above into a test would make it the repo's first `LayerManager` test.
Without a device, deck.gl swallows `updateState` errors there, so it
could only assert positive outcomes.
- **#639 and #673** rewrite the same lines of `getTileIndices`, so
whichever lands second needs a manual merge. In #673 the check moves
into its per-source loop, as a `continue` when `extent` is set and
`!overlaps(source.bbox, extent)`, after the `source === undefined`
guard. In #639 it stays a `.filter` on `[...matched]` before the `.map`.
Since #673 shifts antimeridian-crossing bboxes so that `maxX > 180`,
should the check also test each bbox shifted by ±360? Otherwise a source
stored as `[178, -10, 182, 10]` misses an extent like `[-179, -10, -175,
10]`. An extent that itself crosses the antimeridian isn't supported, as
in deck.gl.

## Related bug, not fixed here

`MosaicLayer`'s `getSources` closure (`() => this.props.sources`) stays
bound to the first layer instance. `TileLayer` creates the tileset once,
and deck.gl moves `state` to each new layer instance but leaves the old
instance's `props` as they were. So after the first render, the tileset
pairs the rebuilt spatial index with the first `sources` array. In the
same `LayerManager` setup, with no `extent` (`main` gives the same
results):

```
# sources grow after the first render
sources=["A"]: fetched=["A"] onViewportLoad=["A"]
sources=["A","B","C"]: fetched=[] onViewportLoad=null
# sources shrink after the first render
sources=["A","B","C"]: fetched=["A","B","C"] onViewportLoad=["A","B","C"]
sources=["C"]: fetched=[] onViewportLoad=["A"]
```

So filtering `sources` yourself is not a reliable substitute for
`extent` once the layer has rendered. #673 switches the closure to
`this.state.sources`, which would fix this; it probably deserves its own
issue. The new filter assumes, like the existing `.map`, that every
index hit has a matching entry in `sources`, so it doesn't make this
worse.

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant