Skip to content

fix(geo-layers): clip MVTLayer sub layers to the tile under GlobeView - #10727

Merged
chrisgervang merged 10 commits into
visgl:masterfrom
cholmes:fix/mvt-layer-globe-tile-clip
Nov 7, 2026
Merged

chrisgervang merged 10 commits into
visgl:masterfrom
cholmes:fix/mvt-layer-globe-tile-clip

Conversation

@cholmes

@cholmes cholmes commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10716.

Background

renderSubLayers applies ClipExtension only when the viewport targets Mercator, a condition written before #10659 gave geometry-mode clipping GlobeView support. Tilers repeat a feature in every tile it crosses, so under GlobeView nothing 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 Mercator
  • MVTLayer: warn that clipBounds is reserved, reuse a caller-supplied ClipExtension
  • Unit tests
  • Documentation

Verified with yarn lint, the geo-layers and extensions headless suites, the MVT and ClipExtension render tests, and the FIRMS repro page: GlobeView loses the doubled-geometry band at tile boundaries while MapView stays 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 GlobeView on the left, MapView on 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:
before

After — seams gone, matches the MapView reference:
fix with 10659


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 MVTLayer across all viewports—including GlobeViewport—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.

MVTLayer now reserves clipBounds to clip sublayers to their tile-local unit square ([0, 0, 1, 1]), warning callers if custom bounds are specified while reusing any caller-supplied ClipExtension to prevent duplicate shader injections.

Reviewed by Cursor Bugbot for commit 0437413. Bugbot is set up for automated code reviews on this repo. Configure here.

cholmes and others added 2 commits September 21, 2026 12:11
`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]>
Comment on lines +255 to +258
`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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Cut all the docs down to just one bullet in the ## Remarks section - thanks for the review!

Comment on lines +249 to +253
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does a user need to know this detail if everything is working properly? If not, we don't need it in the docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Cool, I can cut it.

@coveralls

coveralls commented Sep 22, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 85.032% (+0.01%) from 85.022% — cholmes:fix/mvt-layer-globe-tile-clip into visgl:master

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]>

@chrisgervang chrisgervang left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

@chrisgervang

Copy link
Copy Markdown
Collaborator

Please mark as ready to review once you think it is ready

@cholmes

cholmes commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! This seems like a clean focused fix. The image comparisons are very helpful.

Thanks!

Is there a code snippet or example that can be used to reproduce?

10727-example.html should show it, and
#10716 also has repro section.

Also, the change is enhanced with the ClipExtension fix - but I might merge it before that is landed since this targets master

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.

Please mark as ready to review once you think it is ready

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.

@cholmes
cholmes marked this pull request as ready for review September 22, 2026 19:44
@greptile-apps

greptile-apps Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest change appears safe to merge; it adds a matching type without changing runtime behavior.

Summary

MVTLayer clips each tile under both map and globe views, reuses an existing ClipExtension, and warns about conflicting bounds.

  • MVTLayer keeps each tile’s drawing inside its own boundary.

Reviews (5) · Last reviewed commit: "fix(geo-layers): type the MVTLayer tile ..." · Reviewed by Greptile

@chrisgervang

Copy link
Copy Markdown
Collaborator

Oh ok, I'll hold off until #10659 lands since we're still iterating and aligning on how to approach that stack of PRs

@chrisgervang chrisgervang mentioned this pull request Oct 7, 2026
53 of 66 tasks
@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Oct 22, 2026
@chrisgervang chrisgervang mentioned this pull request Oct 29, 2026
29 of 30 tasks
…-tile-clip

# Conflicts:
#	modules/geo-layers/src/mvt-layer/mvt-layer.ts
#	test/modules/geo-layers/mvt-layer.spec.ts
@cholmes

cholmes commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

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 GlobeView support in ClipExtension), plus reserving clipBounds with a warning and reusing a caller-supplied ClipExtension instead of adding a second one.

Re-verified against master: geo-layers/extensions headless suites and the MVT + ClipExtension render tests pass, and on the FIRMS repro page GlobeView loses the doubled-geometry band at tile boundaries while MapView output is pixel-identical to master.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

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.
@chrisgervang
chrisgervang merged commit bf303a1 into visgl:master Nov 7, 2026
9 checks passed
@chrisgervang

Copy link
Copy Markdown
Collaborator

Released in deck.gl 9.4.2, as #11060 on 9.4. Thanks @cholmes!

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.

MVTLayer: features spanning tile boundaries are drawn once per tile under GlobeView (ClipExtension skipped)

3 participants