Skip to content

fix(deck.gl-raster): Infer missing TileMatrixSet bounds and honor extent - #684

Merged
kylebarron merged 6 commits into
mainfrom
kyle/infer-tms-bounds
Oct 21, 2026
Merged

kylebarron merged 6 commits into
mainfrom
kyle/infer-tms-bounds

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

TileMatrixSetAdaptor threw "Bounding Box inference not yet implemented" for any TileMatrixSet without the optional boundingBox. That includes every TileMatrixSet in morecantile's registry (e.g. WebMercatorQuad) and titiler's /tileMatrixSets/{id} responses, which is how lonboard hit it when rendering titiler .npy tiles.

Changes

  • Infer projectedBounds when boundingBox is missing, from the coarsest tile matrix, the same way morecantile's TileMatrixSet.xy_bbox does. It uses xy_bounds, like the per-tile corners, so it handles cornerOfOrigin: "bottomLeft" and follows the same axis conventions. An explicit boundingBox still wins, since it can be tighter than the grid (e.g. a TileMatrixSet generated for one COG).
  • Honor the extent prop in RasterTileset2D. RasterTileLayer already forwarded extent to its tileset, but RasterTileset2D.getTileIndices overrides deck.gl's implementation and never read it, so it was silently ignored. It's now intersected with the descriptor's bounds on every call, so setOptions updates apply. This matters once bounds can be inferred: for a global TileMatrixSet like WebMercatorQuad they cover the whole world, and extent is how to load only the dataset's area. extent is now documented on RasterTileLayerProps as WGS84 [minLng, minLat, maxLng, maxLat].
  • Add an internal intersectBounds helper for that intersection. createRootTiles used the same inline arithmetic to cull root tiles to the viewport, so it uses the helper too.

With this, #469's buildDescriptor no longer needs to inject a boundingBox; passing the dataset bounds as extent limits tile loading instead.

Tests

  • New tile-matrix-set-bounds.test.ts: WebMercatorQuad without boundingBox (the OGC example in the morecantile spec submodule), an explicit boundingBox, and a 3×2 bottomLeft grid.
  • New raster-tileset-2d-extent.test.ts: only tiles overlapping an asymmetric extent are selected; an extent that misses the data selects nothing; an extent changed through setOptions applies on the next call.
  • 5 of the 6 new tests fail against main. The explicit-boundingBox test is a guard and passes either way.
  • With main (350b898) merged in, pnpm --filter @developmentseed/deck.gl-raster test (196/196), pnpm --filter @developmentseed/deck.gl-raster typecheck and biome ci . pass.
  • With the exact TileMatrixSet JSON lonboard sends (morecantile's WebMercatorQuad, no boundingBox), v0.8.1 throws and this branch returns ±20037508.342789244 on both axes.

Notes

  • Unlike deck.gl's default tileset, extent doesn't keep tiles loading below minZoom here. The TSDoc says so.
  • Not changed here: MosaicTileset2D in deck.gl-geotiff also overrides getTileIndices without reading extent, although MosaicLayer forwards it.

🤖 Written by Claude Code

kylebarron and others added 2 commits October 1, 2026 11:27
…issing

`boundingBox` is optional in OGC TMS 2.0, and no TileMatrixSet in
morecantile's registry (e.g. WebMercatorQuad) sets it, so
`TileMatrixSetAdaptor.projectedBounds` threw and no RasterTileset2D could be
built from them. Infer the bounds from the coarsest tile matrix, like
morecantile's `xy_bbox`; an explicit `boundingBox` still wins, since it may be
tighter than the grid.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RasterTileLayer forwards `extent` to its tileset, but RasterTileset2D
overrides `getTileIndices` without reading it, so the prop was silently
ignored. Intersect it with the descriptor's bounds on every call, since for a
global TileMatrixSet like WebMercatorQuad those bounds cover the whole world
and `extent` is the only way to limit which tiles load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the fix label Oct 1, 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]>
kylebarron added a commit that referenced this pull request Oct 21, 2026
…689)

> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

`RasterTileset2D` selects the same tile many times on aligned grids such
as WebMercatorQuad.

## Problem

Both `crsBoundsToTileRange` implementations (`TileMatrixAdaptor` and
`AffineTilesetLevel`) floor the box's max edge, so a tile that only
touches the box's right or bottom edge counts as overlapping. The
traversal finds a tile's children by passing the tile's bounds to the
next level's `crsBoundsToTileRange`. In an aligned pyramid
(WebMercatorQuad, or COG overviews that exactly halve), each parent's
right and bottom edges lie on child tile edges, so most parents also
claim their neighbors' children:

```ts
const { levels } = new TileMatrixSetAdaptor(webMercatorQuad, projections);
const { topLeft, bottomRight } = levels[1]!.projectedTileCorners(0, 0);
levels[2]!.crsBoundsToTileRange(topLeft[0], bottomRight[1], bottomRight[0], topLeft[1]);
// main:    { minCol: 0, maxCol: 2, minRow: 0, maxRow: 2 }
// this PR: { minCol: 0, maxCol: 1, minRow: 0, maxRow: 1 }
```

In zoom 2 tile units, tile 1/0/0 covers `[0, 2] x [0, 2]`. `floor(2)` is
2, so main also takes column 2 and row 2, whose tiles only share an edge
with it:

```
      x=0   x=1   x=2   x=3
  y=0 +-----+-----+-----+
      |  A  |  B  |  C  |     tile 1/0/0 covers A, B, D and E
  y=1 +-----+-----+-----+
      |  D  |  E  |  F  |     main:    floor(0)..floor(2) = 0..2 per axis -> A to I
  y=2 +-----+-----+-----+     this PR: 0..1 per axis -> A, B, D and E
      |  G  |  H  |  I  |
  y=3 +-----+-----+-----+
```

`RasterTileNode.children` builds a new node for every tile in the range,
and each node is selected on its own, so `getTileIndices` returns a tile
once per parent that claimed it. The extra children get extra children
of their own, so it compounds down the pyramid. For a 512×512
`WebMercatorViewport` at lng/lat 0, where every level's tile edges meet:

| TileMatrixSet | zoom 3 | zoom 10 |
| --- | --- | --- |
| titiler's WebMercatorQuad | 48 indices for 9 tiles | 286 for 9 |
| OGC example WebMercatorQuad (rounded cellSizes) | 64 for 9 | 3844 for
9 |

That view is the worst case for flat maps. With titiler's TileMatrixSet,
ordinary flat views get about 2-10× as many indices as tiles (e.g. 110
for 20 over San Francisco at zoom 12). The OGC example's gets more (1215
for 20 there), and pitched views get far more. lonboard's `RasterLayer`
and #469's titiler example go through this path.

What the repeats cost with deck.gl 9.4.0's `Tileset2D`:

- **No duplicate requests or draws.** `getTileData` runs once per tile,
and `renderLayers` iterates the unique `tileset.tiles`.
- **Cache size.** `selectedTiles` keeps every repeat, and the default
cache cap is `5 * selectedTiles.length`: 1430 instead of 45 for the zoom
10 view above. `onViewportLoad` also receives the repeats.
- **Traversal time** per `getTileIndices` call (warm cache, 1024×768
unless noted). Pitch 60 is lonboard's default maximum for map views.

  | View | main | this PR |
  | --- | --- | --- |
  | lng/lat 0, zoom 10, 512×512, titiler's TMS | 1.93 ms | 0.08 ms |
  | same, OGC example TMS | 15.2 ms | 0.08 ms |
  | Berlin, zoom 16, flat | 0.14 ms | 0.09 ms |
| Berlin, zoom 18, pitch 60 | 54.5 ms (26952 indices for 76 tiles) |
0.19 ms |
  | lat 50, zoom 8, pitch 75, bearing 45 | 874 ms | 3.3 ms |

- **Overlapping tiles.** Where the selected zoom level changes, a parent
can recurse while its right or bottom neighbor is selected at the
coarser level. The parent's extra child lies inside that neighbor and is
selected too, so the same area is fetched and drawn at two resolutions.
For example, at lat 40, zoom 2, pitch 45 that's 38 extra tiles.

  ```
  z     |------ P (recurses) ------|------ Q (selected) ------|
  z+1   |---- a -----|---- b ------|---- c -----|---- d ------|
  ```

On main, P's children are a, b and c. Q is selected at z, but c is still
tested at z+1 as P's child, so it's selected too and drawn over part of
Q.

The other two callers of `crsBoundsToTileRange` see the same rule.
`createRootTiles` (the culled path for large root matrices) keeps roots
that only touch the viewport. `resolveSecondaryTiles` (`MultiCOGLayer`)
fetches up to 2×2 secondary tiles for a primary tile whose right or
bottom edge lies on a secondary tile edge: 256 secondary fetches for 121
primary tiles on a Sentinel-2-like 10 m / 20 m pair, where 121 suffice.

Separately, when levels don't line up (COG overviews of odd sizes, e.g.
1373 → 2745 px), a child tile can straddle two parents and really is a
child of both. The traversal selects it once through each, so even with
exact ranges a 10980 px COG returns 16 indices for 9 tiles.

For a 10980 px COG with 512 px tiles, in full-resolution pixels:

```
                0            2048         4096         6144         8192
2745 px level   |---- c0 ----|---- c1 ----|---- c2 ----|---- c3 ----|
1373 px level   |---------- P0 ----------|---------- P1 -----------|
                0                     4094.5                      8189
```

c1 is 2046.5 px inside P0 and 1.5 px inside P1. If P1 recurses and P0
doesn't, c1 is the only finer tile that covers P1's 1.5 px sliver, so
both parents' ranges have to keep it.

## Changes

- **`crsBoundsToTileRange` leaves out tiles that only touch the box.** A
new internal helper, `overlappingTileSpan`, returns `[floor(start + ε),
ceil(end - ε) - 1]` along one axis with ε = 1e-6 of a tile. Both
implementations use it and keep their existing clamping. The
`RasterTilesetLevel` docs now state the rule, and the two test doubles
that compute ranges follow it.
- **`getTileIndices` returns each `z/x/y` once**, keeping the first
node, for levels that don't line up.

Across about 75 views and tilesets checked during the investigation
(flat, pitched up to 75°, rotated, world copies, globe; both
WebMercatorQuads, UTM31 through proj4; power-of-two, odd-size, 1:1 and
rotated COG pyramids), the new selection had no repeats and was always a
subset of the old one. No sampled screen point lost coverage: every tile
it no longer selects lies under a coarser tile that is still selected.
The timings above come from that investigation, on code with the same
source logic as this PR.

## Tests

- New `tile-children.test.ts`:
- Child ranges for both WebMercatorQuads (tile 1/0/0, and a sample of
tiles at every zoom), a power-of-two COG pyramid, a 1:1 level pair (tile
size doubles as cellSize halves), and a 10980 px COG whose coarser
overviews don't line up. The last one checks that every child that
really overlaps its parent is kept.
- `getTileIndices` with both WebMercatorQuads in six views (flat at zoom
3 and 10, pitched and rotated, pitched across zoom levels, world copies,
globe): no tile is selected twice or together with one of its ancestors.
  - `getTileIndices` on the 10980 px COG selects each tile once.
- `create-root-tiles.test.ts`: roots that only touch the viewport are
left out (6 roots instead of 12 on a 1° grid).
- `secondary-tile-resolver.test.ts`: one 20 m tile for a 10 m tile whose
edges lie on its edges, with real `AffineTilesetLevel`s. The mock level
used to count a tile that touches the box's left or top edge as
overlapping, so the existing "spanning two secondary tiles" case only
touched the first tile. The mock now follows the rule, and that case
uses a secondary grid that the primary tile really straddles.

Every new test fails on `main`. With the four changed source files
reverted (keeping the new helper), the three files give `Tests 22 failed
| 7 passed (29)`, and the 7 that pass are existing tests. For example:

- tile 1/0/0: `expected { minCol: +0, maxCol: 2, …(2) } to deeply equal
{ minCol: +0, maxCol: 1, …(2) }`
- titiler, zoom 10: `expected [ '11/1024/1023', …(276) ] to deeply equal
[]`

The non-aligned COG test fails against the first commit alone (`expected
16 to be 9`) and passes with the second.

With `main` (fff98f1) merged in:

- `pnpm -r --filter="!docs" build` and `pnpm -r --filter="!docs"
typecheck` pass (27 of 29 projects, every example included).
- `pnpm --filter @developmentseed/deck.gl-raster test` (197/197),
`@developmentseed/deck.gl-geotiff` (71/71) and
`@developmentseed/deck.gl-zarr` (16/16) pass.
- `pnpm exec biome ci .` passes.

## Notes

- **Behavior changes.** `MultiCOGLayer` now fetches one secondary tile,
not up to 2×2, for a primary tile whose right or bottom edge lies on a
secondary tile edge. With linear filtering those edges now clamp to the
texture edge, as the left and top edges always did. I haven't checked
this visually. Root culling is also tighter.
- **Tolerance.** Float error at aligned edges measured at most 3.3e-9 of
a tile, and 1e-6 of a 4096 px tile is about 0.004 px. It doesn't absorb
TileMatrixSets that round their cellSizes to a few digits. In the OGC
CDB1GlobalGrid example (2^-14 listed as 6.10351562e-05), 2269 of 2879
parents per row at that level still claim a neighbor's column. The
second commit keeps the output unique there, but the extra traversal
remains. Deriving children with integer arithmetic when levels line up
would fix that; I'd leave it for a follow-up.
- **Repeats are dropped from the output rather than avoided.** Keeping
one `RasterTileNode` per `z/x/y` within a traversal would also stop
shared children in non-aligned pyramids from being traversed twice. I
went with the smaller change.

With one node per `z/x/y`, the shared c1 from the example above would be
built and visited once:

  ```
  this PR: a tree                    one node per z/x/y: a DAG

      P0          P1                     P0          P1
     /  \        /  \                   /  \        /  \
    c0   c1    c1   ...                c0   \      /   ...
         |      |                            \    /
        ...    ...   built and                 c1
                     visited twice             |
... built and visited once
  ```

- **Rotated or skewed affine grids** don't benefit from the range
change, because child ranges come from the bounding box of the parent's
bounding box. The second commit keeps their output unique, but they
still traverse extra nodes.
- **`overlappingTileSpan` stays internal.** `RasterTilesetLevel` is
public, so other implementations follow the rule documented on the
interface rather than calling the helper.
- **Fixture.** `tile-children.test.ts` reads the OGC WebMercatorQuad
example from the morecantile spec submodule, as #684's tests do. CI
checks out submodules, but a clone without them fails these tests. If it
should be inlined, it's probably worth doing for both PRs together.
- **#684.** Its `raster-tileset-2d-extent.test.ts` dedups
`getTileIndices` output because "the traversal can return the same tile
more than once". Whichever of the two PRs lands second can drop that and
assert there are no repeats.
- Not checked: rendering in a browser (memory use, blending of
overlapping tiles below opacity 1), and whether repeated secondary
fetches were deduplicated at the HTTP level.

Ref #523 (per-frame traversal cost, which these extra nodes inflate),
Ref #684

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron and others added 2 commits October 20, 2026 20:38
getTileIndices returns each tile once since #689, so tileKeys no longer needs a Set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some wording edits but lgtm

return [];
}

// Read `extent` on every call: TileLayer updates it through `setOptions`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Read `extent` on every call: TileLayer updates it through `setOptions`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Read `extent` on every call: TileLayer updates it through `setOptions`.
// Limit tile selection to those within WGS84 extent bbox

Comment on lines +263 to +269
const [minX, minY, maxX, maxY] = extent as Bounds;
wgs84Bounds = [
Math.max(wgs84Bounds[0], minX),
Math.max(wgs84Bounds[1], minY),
Math.min(wgs84Bounds[2], maxX),
Math.min(wgs84Bounds[3], maxY),
];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an "intersect bounds" helper somewhere already?

Comment on lines +224 to +225
* `extent` (`[minX, minY, maxX, maxY]`, in WGS84 longitude/latitude) limits
* selection to tiles that overlap both it and the descriptor's bounds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `extent` (`[minX, minY, maxX, maxY]`, in WGS84 longitude/latitude) limits
* selection to tiles that overlap both it and the descriptor's bounds.

we can move the text below, where extent is applied

Comment on lines +197 to +200
* Uses the TileMatrixSet's `boundingBox` when present. It is optional in OGC
* TMS 2.0 (none of morecantile's registry TileMatrixSets set it), so
* otherwise this is inferred from the extent of the coarsest tile matrix,
* like morecantile's `TileMatrixSet.xy_bbox`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Uses the TileMatrixSet's `boundingBox` when present. It is optional in OGC
* TMS 2.0 (none of morecantile's registry TileMatrixSets set it), so
* otherwise this is inferred from the extent of the coarsest tile matrix,
* like morecantile's `TileMatrixSet.xy_bbox`.
* Uses the TileMatrixSet's `boundingBox` when present; otherwise it is computed from the extent of the coarsest tile matrix.

Tighten the extent and projectedBounds comments as suggested in review, and replace the two inline bounds intersections (the extent in RasterTileset2D.getTileIndices and root culling in createRootTiles) with an internal intersectBounds helper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron

Copy link
Copy Markdown
Member Author

LGTM

@kylebarron
kylebarron enabled auto-merge (squash) October 21, 2026 01:06
@kylebarron
kylebarron merged commit 084e4f2 into main Oct 21, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/infer-tms-bounds branch October 21, 2026 01:08
kylebarron added a commit to developmentseed/lonboard that referenced this pull request Nov 13, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

Bumps:

- `@deck.gl/*` 9.4.0 →
[9.4.1](https://github.com/visgl/deck.gl/releases/tag/v9.4.1)
-
`@developmentseed/{deck.gl-raster,affine,morecantile,raster-reproject}`
0.8.1 →
[0.9.0](https://github.com/developmentseed/deck.gl-raster/releases/tag/v0.9.0)
→
[0.10.0](https://github.com/developmentseed/deck.gl-raster/releases/tag/v0.10.0)

The deck.gl overrides in `pnpm-workspace.yaml` go to `^9.4.1` too.
Without that, pnpm keeps every overridden deck.gl package at 9.4.0 and
only `@deck.gl/react` moves. deck.gl-raster 0.10 now depends on
`@developmentseed/range-reader`, so I added it to the commented-out
local-checkout overrides.

The breaking changes in deck.gl-raster 0.9 and 0.10 are in
`deck.gl-geotiff`, `deck.gl-zarr` and `geotiff`, which Lonboard doesn't
use. Lonboard only imports `RasterTileLayer`, `TileMatrixSetAdaptor` and
`MinimalTileData`, and needs no code changes.

Upstream fixes relevant to Lonboard:

- deck.gl-raster: tile textures are destroyed when a raster layer is
removed (developmentseed/deck.gl-raster#728), and a WebGL vertex array
no longer leaks per tile (developmentseed/deck.gl-raster#786).
- deck.gl-raster: missing TileMatrixSet bounds are inferred and `extent`
is honored (developmentseed/deck.gl-raster#684). The `TMSBoundingBox`
step in `examples/raster-titiler.ipynb` (#1327) should no longer be
needed. That isn't tested here.
- deck.gl: the MapLibre overlay container is removed with the overlay
(visgl/deck.gl#10899), and `GlobeController` can zoom past level 12
(visgl/deck.gl#10737).

The `beforeId` fix for interleaved MapLibre (visgl/deck.gl#10734) merged
after 9.4.1, so the `idle` workaround tracked in #1293 stays.

Supersedes Dependabot's #1350, which stops at deck.gl-raster 0.9.0.

Closes #1350

## Testing

- `pnpm build`, `pnpm check` and `pnpm test` (12 tests) pass.
- `uv run pytest` passes: 367 passed, 1 skipped, including `tests/ui`.
- `tsc --noEmit` reports the same 9 errors as `main`, and no new ones.
- No test covers `RasterLayer.from_geotiff`, the only path that uses
deck.gl-raster's `RasterTileLayer`. I checked it by hand with a
throwaway UI test. It opens a 2048×2048 EPSG:32618 COG with 3 overviews
and renders it with no basemap. Tiles reach the canvas on this branch
and on `main`, and the browser console output is the same on both.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron added a commit to developmentseed/lonboard that referenced this pull request Nov 13, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

Adds `examples/raster-titiler.ipynb`, which renders a Sentinel-2
true-color COG from titiler.xyz's `.npy` tile endpoint with
`RasterLayer`'s generic constructor: an async fetch callback that loads
each tile with `np.load`, and a render callback that uses TiTiler's mask
band as the alpha band. It's an example of the "any Python code"
rendering that the COG examples describe, with a tile server as the
source instead of a GeoTIFF.

The notebook passes morecantile's `WebMercatorQuad` as is, and `extent`
keeps tile requests inside the scene. That needs deck.gl-raster 0.9 or
later (developmentseed/deck.gl-raster#684), which `main` bundles since
#1355. Lonboard 0.17.0 bundles 0.8.1, so the notebook requires
`lonboard>0.17.0`. Don't publish the docs with this example until that
release is out.

Also adds the example's screenshot to `assets/`, an entry in
`examples/index.md`, and the docs nav entry.

## Testing

I ran the notebook's code against titiler.xyz in the `tests/ui` browser
harness, on a build of `main`. All 9 tiles of the scene loaded at zoom
9, no request fell outside `extent`, and the map matched the screenshot
in `assets/`. The "Debugging the render callback" cells also work.

🤖 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant