Repository navigation
fix(geo-layers): clip MVTLayer sub layers to the tile under GlobeView - #10727
Conversation
`renderSubLayers` applied `ClipExtension` only inside the branch that sets up the tile-local CARTESIAN coordinate system, and that branch is skipped when the viewport has a `resolution` (GlobeView). Sub layer data is then WGS84 with nothing constraining a feature to its tile, so a feature the tiler wrote into every tile it touches is drawn once per tile. Clip on the WGS84 path too, against the tile's own lng/lat bbox. Co-Authored-By: Claude Opus 5 <[email protected]>
Follow-up to the tile clip, addressing code review findings. - Widen the `renderSubLayers` parameter type with `ClipExtensionProps` so assigning `clipBounds` type checks - Set `clipBounds` explicitly on both coordinate paths instead of relying on the `ClipExtension` default on the Mercator path - Warn and override when a user supplies `clipBounds`, which would otherwise break the per-tile clip - Reuse a user-supplied `ClipExtension` rather than appending a second one, which injected the same shader declarations twice - Unify the two remaining `viewport.resolution` checks on `_isWGS84()` - Document the half-open clip boundary and the non-geographic `bbox` fallthrough - Cover the clip at zoom 2 so per-tile bounds are asserted, and add a test for the user clip prop override - Document sub layer clipping in the MVTLayer API reference Co-Authored-By: Claude Opus 5 <[email protected]>
| `clipBounds` is reserved by this layer. A value passed through `extensions`/`clipBounds` or | ||
| `_subLayerProps` is overridden with a warning, and a `ClipExtension` that is already present is | ||
| reused rather than added twice. To clip to an area of your own, use | ||
| `MVTLayer`'s own [`extent`](./tile-layer.md#extent) prop or clip the source data. |
There was a problem hiding this comment.
We don't need to explain the implementation here, just that the prop is ignored and to use extent instead.
Move to a bullet in a ## Remarks section to match repo documentation style
There was a problem hiding this comment.
Cut all the docs down to just one bullet in the ## Remarks section - thanks for the review!
| A tiler writes a feature into the buffer of every tile that it touches, so without clipping the | ||
| shared geometry is drawn once per tile. `MVTLayer` therefore adds a | ||
| [`ClipExtension`](../extensions/clip-extension.md) to each sub layer and sets its `clipBounds` to | ||
| that tile, either in tile local coordinates or, when the sub layer data is in WGS84 (under | ||
| [`GlobeView`](../core/globe-view.md)), in longitude and latitude. |
There was a problem hiding this comment.
Does a user need to know this detail if everything is working properly? If not, we don't need it in the docs.
There was a problem hiding this comment.
Cool, I can cut it.
Drop the sub layer clipping explanation. Users only need to know that `clipBounds` is ignored and to reach for `extent` instead. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
Thanks! This seems like a clean focused fix. The image comparisons are very helpful.
Is there a code snippet or example that can be used to reproduce?
Also, the change is enhanced with the ClipExtension fix - but I might merge it before that is landed since this targets master
|
Please mark as ready to review once you think it is ready |
Thanks!
10727-example.html should show it, and
As things currently stand this will make things look worse on master - above the first image is master currently, and the second is if you apply this without #10659 But I defer to you, just wanted to flag that it'd make things a bit worse before they get better with that one landing.
It's ready from my side, so will mark it as ready - just wanted to be sure there was awareness of it needing #10659 to fully work. |
[Medium impact] The latest change appears safe to merge; it adds a matching type without changing runtime behavior. Summary
Reviews (5) · Last reviewed commit: "fix(geo-layers): type the MVTLayer tile ..." · Reviewed by Greptile |
|
Oh ok, I'll hold off until #10659 lands since we're still iterating and aligning on how to approach that stack of PRs |
…-tile-clip # Conflicts: # modules/geo-layers/src/mvt-layer/mvt-layer.ts # test/modules/geo-layers/mvt-layer.spec.ts
|
Updated now that #10659 has landed — merged latest master into the branch. The fix got simpler in the process. Since the tile-local refactor in #10874, sub layer data is tile-local under every view, so the WGS84 clipping branch this PR originally added is gone. What remains is extending the existing tile clip to non-Mercator views (the Mercator-only condition predated #10659's Re-verified against master: geo-layers/extensions headless suites and the MVT + ClipExtension render tests pass, and on the FIRMS repro page |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 4bab671. Configure here.
…in MVTLayer ClipExtension adds its default clipBounds ([0, 0, 1, 1]) to the layer's props, so attaching it without setting clipBounds still triggered the reserved-clipBounds warning. Only warn when the bounds differ from the tile's unit square.
|
Released in deck.gl 9.4.2, as #11060 on 9.4. Thanks @cholmes! |

Closes #10716.
Background
renderSubLayersappliesClipExtensiononly when the viewport targets Mercator, a condition written before #10659 gave geometry-mode clippingGlobeViewsupport. Tilers repeat a feature in every tile it crosses, so underGlobeViewnothing keeps a feature inside its tile and it is drawn once per tile.Change List
MVTLayer: apply the per-tile clip under every view, not only MercatorMVTLayer: warn thatclipBoundsis reserved, reuse a caller-suppliedClipExtensionVerified with
yarn lint, the geo-layers and extensions headless suites, the MVT and ClipExtension render tests, and the FIRMS repro page:GlobeViewloses the doubled-geometry band at tile boundaries whileMapViewstays pixel-identical to master.TODO
Ideally this would share a tile clip with CARTO's
VectorTileLayer, which duplicates the logic. Left out of scope here, but happy to add it if you'd prefer.Supporting Images
From the original report, before the tile-local refactor in #10874; the failure mode is the same today. Each image is
GlobeViewon the left,MapViewon the right as the reference, with a translucent fill so a doubly drawn polygon shows up brighter.Before — no clip reaches the sub layers under

GlobeView:After — seams gone, matches the

MapViewreference:Note
Low Risk
Low risk bug fix ensuring consistent tile-boundary clipping across viewports with safeguards for extension reuse and reserved props.
Overview
Enables per-tile clipping in
MVTLayeracross all viewports—includingGlobeViewport—by removing the restriction that previously limited clipping to Mercator projections. This prevents shared buffer geometries from duplicating at tile seams in non-Mercator views.MVTLayernow reservesclipBoundsto clip sublayers to their tile-local unit square ([0, 0, 1, 1]), warning callers if custom bounds are specified while reusing any caller-suppliedClipExtensionto prevent duplicate shader injections.Reviewed by Cursor Bugbot for commit 0437413. Bugbot is set up for automated code reviews on this repo. Configure here.