Skip to content

Feat/new viewer - #30

Draft
vincentsarago wants to merge 3 commits into
mainfrom
feat/new-viewer
Draft

vincentsarago wants to merge 3 commits into
mainfrom
feat/new-viewer

Conversation

@vincentsarago

Copy link
Copy Markdown
Member

This PR does:

  • add LocalTileMatrixSet to the list of accepted TMS in /tiles/{}/{z}/{x}/{y} endpoint
  • add /LocalTileMatrixSet endpoint to retried the TMS of a specific file (COG only for now)
  • replace the /{tileMatrixSetId}/map.html endpoint by a simple /map.html endpoint

The new map.html viewer is built using deck-gl-raster with the idea of using the LocalTileMatrixSet TMS (so no reprojection is done by GDAL) and using NPY tile so the rendering is done on the client as well

Screenshot 2026-09-18 at 16 22 50

});
</script>
</body>
</html>

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.

@kylebarron this is almost 💯 vibe coded, I'll iterate to

  • make a better band selection tool
  • enable histogram stretching
  • globe projection?
  • handle mask (numpy tile should provide a mask)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't officially support globe view right now (the reprojection is hard to ensure we have correct). We should probably release globe view even if it's not perfect.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be interesting to get histogram stretching working; I'm not exactly sure what it entails.

And yes mask handling would be good

Comment thread async_titiler/templates/map.html Outdated

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is exciting!

Comment thread async_titiler/templates/map.html
Comment thread async_titiler/tms.py
Comment on lines +240 to +246
function renderTile(data) {
return {
renderPipeline: [
{ module: CreateTexture, props: { textureName: data.texture } },
],
};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for the non-rgb data did you want to apply a colormap or something?

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.

no, for now it's a simple linear rescaling

return out;
}

function makeGetTileData(bandIdxList) {

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.

🤔 maybe I misunderstood how the whole deck-gl-library worked. I assume we could update the render after fetching the tiles, but it seems that we have to re-create a layer every time we want to change the rendering option

🤖 👇

I checked the actual deck.gl-raster source (v0.8.0-beta.2) — the answer is yes, we currently need to, and it's not just a stylistic choice.

RasterTileLayer._renderTileLayer wraps a standard deck.gl TileLayer internally with a fixed sub-layer id (`raster-tile-layer-${this.id}`), and its updateTriggers only forwards updateTriggers.renderTile → the sublayer's renderSubLayers trigger:


updateTriggers: {
  renderSubLayers: updateTriggers?.renderTile,
},
There's no updateTriggers.getTileData hook exposed. That means if we kept the same outer layer id and just swapped the getTileData closure for a different band, the underlying TileLayer's tile cache (keyed by that fixed sub-layer id + tile x/y/z) would keep showing the already-cached texture from the old band for every tile already on screen — only tiles newly entering the viewport (via pan/zoom) would pick up the new getTileData. Band switching would silently do nothing for visible tiles.

So changing the outer layer id per band/mode combination is the correct way, given this library version's public API, to force deck.gl to discard the stale tile cache and refetch/re-render all currently-visible tiles with the new band selection. The cost is bounded thanks to the earlier fix (no bidx in the URL + browser HTTP cache), so re-creating the layer only re-parses/re-stretches already-cached bytes rather than re-hitting the tiler.

If this becomes a real perf concern later, the alternative would be filing/patching upstream for a getTileData update-trigger, but for now the current approach is the correct workaround, not something to refactor away.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, it's expected in deck.gl to create new layer instances. Layer instances are cheap; they represent more complex resources under the hood.

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.

2 participants