Skip to content

Unify the deck.gl zoom floor and coalesce time-driven reloads - #420

Open
CarsonDavis wants to merge 6 commits into
developmentfrom
feature/reduce-tile-requests
Open

CarsonDavis wants to merge 6 commits into
developmentfrom
feature/reduce-tile-requests

Conversation

@CarsonDavis

@CarsonDavis CarsonDavis commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Line breakdown

Category Lines added %
Tests 545 52.3%
Production code 490 47.0%
Config/build 6 0.6%
Docs 1 0.1%

This cuts the redundant tile requests time-driven layers make: time-change reloads throttle to one per 200 ms window, forced refetches travel as URL changes, deck.gl layers get the zoom floor and ceiling their configuration declares, and Configure's Populate Fields button reads TiTiler's tilejson.

What this does

Time changes

  • Windowed reloads — a committed time change reloads the time-enabled layers at most once per 200 ms: the commit that opens a window reloads immediately, and commits inside it collapse into one trailing reload carrying the last time set.
  • Playback keeps moving — continuous 100 ms play ticks reload every window, because a commit books the pending reload instead of restarting the timer.
  • The clock never lags — every commit writes the layers' times and their on-screen labels immediately, while a Leaflet raster layer's per-tile options are written by the reload, so a tile exposed by panning mid-window matches the tiles around it.
  • Direct calls count as the window's reload — TimeControl.reloadTimeLayers() runs at once, drops a booking it satisfies, and opens a fresh window so commits behind it are throttled against it.
  • Mission re-init drops pending work — TimeControl.init() cancels any booked reload, so the previous mission's last time change cannot land on the new mission's layers.
  • One update path — updateLayersTime() synchronizes layer times, the labels that read them, and a Leaflet raster layer's tile options, and returns the names of the layers it updated.

Refresh

  • The refresh contract is url and tileOptions — RefreshContext carries only those two, and the Leaflet adapter always calls layer.refresh(url, false, tileOptions), so a tile whose URL is unchanged stays in cache on both engines.
  • Forced requery travels as a URL change — a requery that must refetch identical tiles arrives as the nocache param TimeControl.performTimeUrlReplacements appends to the URL, and both engines reload on it.
  • deck.gl WMS skips no-op rebuilds — the layer records the URL its image source was built from and is kept when a refresh compiles to the same URL, avoiding a GetCapabilities plus GetMap for an image already drawn.
  • Shared refreshers — deck.gl tile and WMS refreshers are functions in src/essence/Basics/Layers_/deckTileRefresher.js, both declining to refresh when the source URL is null or compiles to empty, so the engine keeps the layer it holds.

deck.gl zoom floor and ceiling

  • Zoom floor — a configured minZoom hides the layer and stops its requests at the same view zoom Leaflet shows the same layer, by turning the Leaflet tile level into deck.gl's visibleMinZoom (minZoom − log2(512 / tileSize) − 0.5), so minZoom: 5 appears at view zoom 3.5 for 256 px raster tiles and 4.5 for 512 px vector tiles.
  • Zoom ceiling — above maxNativeZoom (falling back to maxZoom), deck.gl scales the service's deepest level instead of requesting levels the service does not have.
  • Missing fields stay unset — absent or NaN zoom fields leave the floor and ceiling unset, rather than hiding the layer everywhere.
  • One tile size for both — the floor is computed from the tile size the layer is actually built with, where a nativeOptions.tileSize outranks the layer's own tileSize.
  • Pinned against deck.gl itself — a test drives deck's own tileset with the layer's props, so a deck.gl upgrade that changes its tile-level rounding fails the suite instead of silently shifting every layer's visibility.

Bounding boxes

  • One reader — parseBoundingBox is the only reader of a layer config's boundingBox, and it accepts four numbers, four strings, or one comma-separated string, orders transposed corners the way Leaflet's latLngBounds does, and returns [west, south, east, north] degrees.
  • Degrees only — a box with any non-finite corner, or one outside ±180/±90 (a projected extent in metres, say), is refused whole rather than handed to L.latLng, which throws on a NaN and takes the layer's load down with it.
  • What it feeds — Leaflet raster tile and data layer bounds, video placement, and the layers:getBounds fallback that zoom-to-layer uses.
  • A bad box is a warning — a layer declaring a box that does not parse logs a warning naming the layer and the value and loads without a footprint, and a video layer with no usable box is skipped with a message saying what it needs and what it declared.

Configure: Populate Fields

  • Reads TiTiler's tilejson — titiler/cog/{tileMatrixSet}/tilejson.json (default WebMercatorQuad, the same rule tile requests use) reports minzoom, maxzoom and lng/lat bounds in one call, fetched through the configured API base so it works under a subpath.
  • Partial results are written and named — only the fields the source reported are written, the ones it did not are named in a warning and left unchanged, and all writes dispatch as one configuration update.
  • Footprints only in degrees — a bounding box is written only when it came back in degrees, so a projected extent, including gdal2tiles' raster-profile tilemapresource.xml, is refused rather than saved.
  • Errors surface — a 4xx from TiTiler surfaces as an error naming the status and message, instead of succeeding on an empty document.

Decisions to review

  1. Degrees-only footprints are a load-time contract on config data. parseBoundingBox is the one reader of boundingBox, and what it guards is Leaflet raster and data layer bounds, video placement, and zoom-to-layer. A refused box costs a tile or data layer a console warning and an unbounded load; a video layer with a projected box is skipped rather than placed at corners that are not lng/lat degrees. Antimeridian boxes are unrepresentable, as they are in Leaflet. Nothing upstream enforces the rule — server-side validate.js and Configure's validators range-check nothing — so a projected box saved by hand or copied in by auxiliary/bulk_tiles passes validation and is refused at load.

  2. A fixed 200 ms leading-and-trailing throttle on every committed time change, API included. An isolated setTime() reloads immediately; a second call inside the window defers its reload by up to 200 ms. One constant serves both the 100 ms play loop and any tile service, fast or slow, and the window is global rather than per-layer. reloadTimeLayers() is public API and opens a window of its own, so an external caller polling it holds UI-driven time changes to one reload per window.

  3. force is not in the refresh contract. A forced requery is expressed as a URL change, the nocache param performTimeUrlReplacements appends. That leaves one channel: anything that keeps the param off the compiled tile URL — a signed URL, a service that rejects unknown params — turns forced requery into a silent no-op.

  4. The deck.gl zoom floor is arithmetic over deck internals. visibleMinZoom = minZoom − log2(512 / tileSize) − 0.5 hardcodes deck's 512 px world size and its half-up tile-level rounding, because deck's own minZoom behaves differently depending on whether the layer has an extent. The test that pins it drives deck's real _Tileset2D.getTileIndices at the floor and just below it, so a deck upgrade that moves either constant fails the suite, at the cost of importing a _-prefixed export.

  5. WMS refresh dedupe rides on a custom prop stored inside the deck.gl layer. WMSImageSource is a new object per build and deck.gl compares data by identity, so the layer carries wmsSourceUrl — the URL its source was built from — and the refresher reads it back to skip a no-op clone. The alternative is a module-level map keyed by layer id, keeping the state out of a third-party object. As written it assumes layer.clone() keeps carrying unrecognized props, which a test pins but deck.gl does not promise.

  6. Configure populates from the per-TMS tilejson and writes partial results. titiler/cog/{tileMatrixSet}/tilejson.json gives zooms and degree bounds in one call, numbered in the same pyramid the layer's own tile requests use, and requires the deployed TiTiler to expose it. It also depends on tileMatrixSet being right before the button is pressed, and that field exists only on the tile layer form — data and image layers always populate as WebMercatorQuad. Fields the source did not report are left unchanged and named in a warning, so the button can leave a layer half-configured and call it a warning rather than a failure.

  7. The degrees rule exists twice. lngLatBoundingBox in configure/ restates parseBoundingBox because configure/ cannot import from src/. It saves strings in written order while the runtime orders corners at load, so the two agree only by that convention, and the writer and the reader of the same field can drift.

Part of #522

A tile layer's configured boundingBox reached Leaflet as `bounds` and was
dropped on the deck.gl path, so deck.gl requested tiles across the whole
viewport for layers covering one scene. The tile service answered each of
those with an uncacheable "tile is outside bounds" 404 - 545 of them in a
five-minute session on the disasters dashboard.

The box now travels to deck.gl's TileLayer as `extent`, which is the same
[west, south, east, north] order mission configuration writes, so it needs no
conversion. Parsing moves into a shared parseBoundingBox that makeTileLayer
reads once for both engines: a box that does not parse whole is refused whole,
because a half-NaN extent clamps every viewport to NaN and the layer would
draw nothing - and Leaflet, which used to throw on such a box, now ignores it.

deck.gl treats an extent as licence to keep requesting below minZoom: it
clamps to minZoom and fetches the whole footprint's worth of tiles where,
without one, it hides the layer. visibleMinZoom keeps the layer hidden there,
which is also what Leaflet does, so no configuration requests more than it
did before.
Every committed time change reloaded every time-enabled layer, and each reload
evicts that layer's whole deck.gl tileset and refetches the viewport. Play mode
commits as often as every 100ms and a datepicker commits per keystroke, so the
commits outran the tiles: 40% of the tile requests in a five-minute session on
the disasters dashboard were abandoned before the response, each one already
being answered by the tile service.

Two limits, both on the reload rather than on the commit - the clock, the
labels and the time:changed broadcast still move on every commit:

- The reload of the time-enabled layers now runs once per 200ms window,
  trailing: the first commit books it, later commits fall into the same
  booking, and it reads the layers' times when it fires. A burst reloads once
  on the time it ended on, and continuous playback still reloads every window
  because a commit never pushes the booking back. Only the commit path waits;
  TimeControl.reloadTimeLayers stays immediate for the plugins and tools that
  call it directly.
- A deck tile layer whose compiled URL is unchanged is left alone instead of
  being cloned, so a time step inside the layer's current time bucket costs
  nothing. An explicitly forced refresh still reloads.

The deck tile refresher moves out of makeTileLayer into its own module,
alongside the COG one, so the URL comparison can be tested directly. The copy
of it the engine refresh spec carried goes with that; its cases are covered
against the real one.
…resh guard

Bounding boxes are parsed once: corners ordered per axis, refused outside
+-180/+-90, and accepted as a comma-separated string. One helper in Map_
parses and warns for tile, vectortile and data layers, and one helper
builds the Leaflet bounds the four Leaflet call sites share. Vector tile
layers now receive the footprint as extent on deck.gl and bounds on Leaflet.

deck.gl no longer receives minZoom; visibleMinZoom is the single floor for
every tile layer, with or without an extent, derived from the tile size the
layer is actually built with. maxZoom falls back to the first finite of
maxNativeZoom and maxZoom.

The identical-URL guard and the force flag are gone from the refresh path:
deck's TileLayer compares data URLs by value, and a requery arrives as a
nocache param in the URL. WMS layers get their own refresher that rebuilds
the image source and keeps the instance when the compiled URL is unchanged.

A timeline commit updates layer times and labels immediately and leaves the
Leaflet tile options to the reload it books; the public updateLayersTime
still writes them.

Configure's populate button reads /cog/info.geojson, whose bbox is in
degrees on the pinned TiTiler, through the API base, writes only the fields
the response carries, filters projected extents on both the COG and XML
branches, and reports what it populated.
…floor against deck.gl

A committed time change reloads immediately when no window is open and
coalesces the commits inside a window into one trailing reload, so an
isolated setTime() no longer waits 200 ms. Configure's Populate Fields
reads TiTiler's per-TMS tilejson, which reports zooms and degree bounds
together. The deck.gl zoom floor is tested by driving deck's own tileset
at and just below the floor.
The admin-typed boundingBox is not a trustworthy footprint, so deck.gl
tile and vector tile layers request tiles without one and Leaflet vector
tile layers are not clipped to it. parseBoundingBox keeps guarding the
Leaflet raster and data layer bounds, video placement, and zoom-to-layer.
@CarsonDavis CarsonDavis changed the title Keep deck.gl tile layers inside their bounds and coalesce time-driven reloads Unify the deck.gl zoom floor and coalesce time-driven reloads Sep 14, 2026

This branch has not been deployed

No deployments
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