Skip to content

feat(examples): experimental titiler .npy tile example - #700

Merged
kylebarron merged 1 commit into
mainfrom
kyle/titiler-example
Oct 8, 2026
Merged

kylebarron merged 1 commit into
mainfrom
kyle/titiler-example

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

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

A rebased version of #469: an experimental example that renders tiles from titiler.xyz with RasterTileLayer directly. titiler serves each tile as a raw NumPy .npy array, and the browser decodes it with npyjs and uploads an RGBA texture plus a mask texture.

titiler example

Closes #461, closes #469

Changes from #469

  • Lives in examples/experimental/titiler-cog, published at the flat /examples/titiler-cog/ URL, badged experimental, and listed in the experimental section of the docs examples page (with a new card image).
  • Uses the shared example components (ControlPanel, DebugControls, DeckGlOverlay, LoadingWidget) and current dependency versions.
  • Adapts to the TilesetDescriptor → RasterTilesetDescriptor rename.
  • Destroys both tile textures in onTileUnload.
  • Doesn't pass titiler's minzoom (8) as minZoom. RasterTileLayer renders nothing below minZoom, so the imagery vanished when zooming out, though titiler serves coarser tiles fine.
  • Checks npy Fortran order, since the RGBA repack assumes C order.
  • Shows the tilejson data_type and band count in the panel.

titiler.xyz CORS caching workaround

titiler echoes the request's Origin as Access-Control-Allow-Origin, but titiler.xyz's CloudFront cache doesn't include Origin in its cache key and sends no Vary: Origin. A response cached for one site, or for a request with no Origin (curl), is served to every other site for up to an hour (max-age=3600), and the browser blocks it. I reproduced this on fresh URLs, and at one point the exact /tileMatrixSets/WebMercatorQuad URL this example fetched was cached without any CORS header.

As a workaround, every titiler URL gets a host=<location.host> parameter, so each site has its own cache entries. It's the host, not the full origin, because the CDN returns 403 for query strings containing http://localhost. The parameter can go once the CDN varies on Origin.

Test plan

  • Example typecheck and build pass.
  • Checked in headed Chrome: tiles render from titiler.xyz, the mask clips the no-data edges, zooming out below z8 still renders, and the debug overlay and opacity slider work. The only console messages are the dev server's favicon 404 and luma.gl's existing Binding sampler not set warning, which comes from SimpleMeshLayer.

🤖 Written by Claude Code

Port #469 onto current main as an experimental example. It renders
tiles from the public titiler.xyz instance with RasterTileLayer directly:
titiler serves each tile as a raw NumPy `.npy` array, which the browser
decodes with npyjs and uploads as an RGBA texture plus a mask texture.

Changes from #469:

- Move to `examples/experimental/titiler-cog`. It keeps the flat
  `/examples/titiler-cog/` URL, and is badged experimental and listed in
  the experimental section of the docs examples page.
- Use the shared example components (ControlPanel, DebugControls,
  DeckGlOverlay, LoadingWidget) and current dependency versions.
- Adapt to the `TilesetDescriptor` -> `RasterTilesetDescriptor` rename.
- Destroy tile textures in `onTileUnload`, following the ownership model
  from the destroy-tile-textures design.
- Don't pass titiler's `minzoom` as `minZoom`. RasterTileLayer renders
  nothing below `minZoom`, so the imagery vanished when zooming out past
  z8, though titiler serves coarser tiles fine.
- Add a `host=` query parameter to every titiler URL. titiler echoes the
  request `Origin` as `Access-Control-Allow-Origin`, but titiler.xyz's
  CDN caches responses without regard to `Origin`, so it can serve a page
  a response cached for another site (or for curl, with no CORS header at
  all) and the browser blocks it. The host, rather than the full origin,
  because the CDN rejects query strings containing `http://localhost`.
- Check npy Fortran order, since the RGBA repack assumes C order.
- Show titiler's tilejson `data_type` and band count in the panel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feat label Oct 8, 2026
@kylebarron
kylebarron merged commit e33065f into main Oct 8, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/titiler-example branch October 8, 2026 18:07
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.

Create example reading from titiler backend

1 participant