Repository navigation
fix: traverse tiles across world copies (#517) - #518
Merged
Merged
Conversation
Captures the agreed approach for fixing #517: re-run RasterTileNode.update() at world offsets +/-1, +/-2, ... so frustum culling considers the dataset's shifted copies, mirroring upstream tile-2d-traversal. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…me translation Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Threads worldOffset through getBoundingVolume; non-zero offsets return a fresh translated copy without polluting the offset-0 cache. update() now plumbs the param through but keeps current reset semantics (additive behavior follows in a separate commit). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…date Skips the per-frame resets when worldOffset!==0 so a tile selected by the primary pass cannot be unselected by a later world-copy pass. Necessary because the LOD test depends on metersPerCSSPixel, which varies with the OBB center, which moves with worldOffset. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When viewport.subViewports?.length > 1 (e.g. WebMercatorViewport with repeat:true panning across the antimeridian), re-run the traversal at world offsets ±1, ±2 ... ±MAX_MAPS, stopping early on a side that selects no tiles. Mirrors @deck.gl/geo-layers/tile-2d-traversal.ts. The bounds check now uses the offset-0 AABB regardless of pass: a tile at (x, y, z) represents the same data in every world copy, only its drawn position changes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…sal model Captures the model, why we re-run rather than union frusta, why non-zero passes are additive, the bounds-check invariant, termination, and pointers to the upstream prior art. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Member
Author
|
This looks good but I don't have the mental energy to review this right now |
# Conflicts: # packages/deck.gl-raster/src/raster-tileset/raster-tile-traversal.ts
Bind the offset-0 bounding volume to `primaryWorldVolume` instead of destructuring `commonSpaceBounds` inline, clarifying that the bounds check intentionally tests the untranslated primary-world AABB regardless of the current world offset. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The docs justified additive non-zero passes by claiming the LOD test can differ across world offsets. It cannot: `metersPerCSSPixel` derives from latitude only and the offset translation is along common-space X, so `devicePixelsPerSourcePixel` is offset-invariant. The real reason is the frustum/reset interaction — a tile selected at offset 0 must survive a later pass that finds it out of frustum, so non-zero passes skip the resets. Corrected both the living doc and the design spec. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
commented
May 21, 2026
kylebarron
commented
May 21, 2026
…rsal - Rename `hit` to `cacheHit` in getBoundingVolume for clarity. - Document that `base` is the primary-world (offset-0) volume, translated for non-zero offsets, and that translateBoundingVolume's commonSpaceBounds output is for API symmetry / tests (update() re-reads the offset-0 bounds). - Fix inverted offset +1/-1 direction in two world-copies test names and comments: a dataset west of the antimeridian viewed from the east is selected via offset -1 (not +1), and its mirror via offset +1. Assertions were already correct; only the explanatory labels were swapped. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
#547 (cf189cc) renamed TilesetDescriptor → RasterTilesetDescriptor and TilesetLevel → RasterTilesetLevel on main, after this branch last merged it. raster-tile-traversal.ts auto-merged cleanly; world-copies.test.ts (added on this branch, untouched by #547) still imported the old names, failing CI typecheck (TS2305 + cascading implicit-any). Update the references. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
enabled auto-merge (squash)
May 21, 2026 18:58
kylebarron
added a commit
that referenced
this pull request
May 22, 2026
Reconciles the globe-view work with #518 ("traverse tiles across world copies"), which refactored raster-tile-traversal.ts. The globe additions (globe bounding volume, REF_POINTS_11, lnglat LOD via getMetersPerPixelAtCommonSpaceBounds) layer onto main's worldOffset structure; update() now also destructures commonSpaceBounds for the LOD latitude. World-copy passes are gated on viewport.subViewports (>1), so they never run on a globe. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks done
kylebarron
added a commit
that referenced
this pull request
May 27, 2026
…hes to ±85.051° (#574) * docs(specs): add antimeridian crossing-tile (cut-in-two) design Design for rendering imagery crossing ±180° in Web Mercator (issues #171, #366). Splits a crossing tile at the antimeridian into west/east pieces so each reprojects as a normal non-crossing tile — avoiding the proj4-rewrap unwrap that prior attempts (#353/#374/#269) stumbled on. Generalizes the RasterReprojector to accept a delaunator-shaped initial-triangulation seed (subsuming #351 uvBounds / pole clamp), splits in _renderSubLayers into two single-mesh RasterLayers, and uses a two-box bounding volume composing with the merged world-copy traversal (#518). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(specs): refine antimeridian spec — add test fixture, handle slanted cuts - Use the vendored geotiff-test-data antimeridian.tif fixture (42x42 EPSG:4326, crosses -180 at column 24) as the primary deterministic crossing test. - Handle slanted (rotated-geotransform) cuts, not just vertical: any straight cut yields convex pieces delaunator triangulates exactly; error only on curved/concave cuts. createInitialConditions is therefore part of the MVP crossing path. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(raster-reproject): add createInitialConditions (delaunator-backed seed) Add the InitialTriangulation type and a tree-shakeable createInitialConditions helper that builds a Delaunay seed from a UV point set. delaunator is confined to its own module (initial-conditions.ts); delatin.ts does not import it and the package is sideEffects:false, so it tree-shakes out for consumers that don't use it. Foundation for antimeridian cut-in-two and the sub-domain capability in #351. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(raster-reproject): document delaunator seed pattern, don't ship a wrapper Per review: a one-line delaunator wrapper isn't worth a runtime dependency. Expose only the InitialTriangulation type and show the delaunator one-liner in its docstring. delaunator moves to devDependencies — used by tests to validate winding compatibility, not shipped to consumers. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(specs): drop createInitialConditions wrapper from antimeridian design raster-reproject exposes only the InitialTriangulation type + documents the delaunator one-liner; delaunator is a dev/test dep (winding validation), not shipped. Runtime seed-building for crossing tiles is the deck.gl-raster builder's job (follow-up plan). Mark stage 1 done. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(raster-reproject): seed RasterReprojector from an initial triangulation Generalize the constructor to accept an optional initialTriangulation seed (delaunator's data shape), defaulting to a hardcoded unit-square seed so behavior is unchanged and the package needs no runtime triangulation dep. Refinement only ever splits existing triangles, so a sub-domain seed confines the mesh to that region. Tests build seeds via delaunator (the documented pattern) to validate winding compatibility + sub-domain confinement. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(raster-reproject): add rectangleSeed helper for sub-rectangle seeds Build an axis-aligned 2-triangle rectangle seed for a UV sub-rectangle (no delaunator, runtime-safe). UNIT_SQUARE_SEED is now rectangleSeed(0,0,1,1). Used to clamp a mesh to a UV band — e.g. the valid Web Mercator latitude band (#182 / #351) — and reused by the antimeridian vertical-cut case. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(deck.gl-raster): add webMercatorClampSeed (clamp mesh to ±85.051°) Pure helper that returns a rectangleSeed clamping a north-up geographic tile's reprojection mesh to the Web Mercator latitude band, or undefined when no clamp is needed/possible (rotated/projected tiles, fully-polar tiles). Avoids the degenerate near-pole triangles from #182 / #351. Unit-tested with synthetic corner latitudes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(deck.gl-raster): clamp Web Mercator meshes to valid latitude band Wire the reprojector seed through the render path: RasterLayer gains an initialTriangulation prop (passed to RasterReprojector, regenerated on change); getTileMetadata computes a per-tile _webMercatorReprojectorSeed via webMercatorClampSeed; _renderSubLayers passes it in the Web Mercator branch only (globe shows the poles, full mesh). Fixes the degenerate near-pole triangles for EPSG:4326 imagery reaching ±90° (#182 / #351). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(deck.gl-raster): name clamp seed as initialTriangulation Rename webMercatorClampSeed → webMercatorInitialTriangulation and the tile metadata field _webMercatorReprojectorSeed → _webMercatorInitialTriangulation, for consistency with the InitialTriangulation type and the RasterLayer.initialTriangulation prop (drops the ad-hoc 'seed'/'ReprojectorSeed' terms). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(deck.gl-raster): rename clamp fn to createInitialWebMercatorTriangulation Verb-prefixed name for the builder (was webMercatorInitialTriangulation); the tile metadata field stays _webMercatorInitialTriangulation. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(raster-reproject): rename rectangleSeed -> triangulateRectangle Active verb name for the helper that triangulates a UV rectangle into an InitialTriangulation; internal UNIT_SQUARE_SEED -> UNIT_SQUARE_TRIANGULATION; test file renamed to match. Updates the deck.gl-raster clamp caller too. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor: apply triangulateRectangle rename across source + caller Completes the rename (a657eb8 only moved the test file): rectangleSeed -> triangulateRectangle in delatin.ts + index export + the renamed test, and the deck.gl-raster web-mercator-clamp caller. UNIT_SQUARE_SEED -> UNIT_SQUARE_TRIANGULATION. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Jun 2, 2026
…erLayers
In the Web Mercator branch of _renderSubLayers, when tile._antimeridianCut is
defined, emit two RasterLayers (id `${id}-raster-west` + `${id}-raster-east`)
seeded with triangulateRectangle(0, 0, uCut, 1) and triangulateRectangle(
uCut, 0, 1, 1) respectively. Both pieces share one reprojectionFns object
using _projectPositionWrapped — only the initial-triangulation seed differs.
Spec correction: the original design said "west stock + east wrapped" on the
assumption that proj4 maps the seam to +max_X (common-x 512). Empirically
proj4 4326→3857 maps native −180 to −max_X (cx 0) and native +180 to +max_X
(cx 512), so which piece is broken under stock depends on the seam family:
antimeridian.tif (seam = native −180): west piece broken (spans cx [0, 478])
hypothetical [170, 190] (seam = +180): east piece broken (spans [14, 512])
Applying the wrapped projection ("if cx > TILE_SIZE/2, subtract TILE_SIZE")
to both pieces folds everything into the (−256, 256] world copy, where the
two pieces meet continuously at cx 0 for either family. Idempotent for any
vertex already in [0, 256]. World-copy traversal (#518) then renders the
composite at every in-view world offset.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Jun 2, 2026
…ped projection The wrapped projection (cx > TILE_SIZE/2 ⇒ subtract TILE_SIZE) made the forward continuous across the seam but had no clean inverse: at the cx=0 boundary the same wrapped value could come from stock cx=0 OR cx=TILE_SIZE. The reprojector's error metric round-trips every sample through inverseReproject + inverseTransform to recover pixel coords; stock unprojectPosition for the wrapped piece returned the canonical-normalized lng (e.g. +156° for a piece whose native is −204°), which then projected through inverseTransform as pixel column +360 instead of 0 — a huge "error" that triggered pathological mesh refinement on one piece and accidentally fooled the metric into one big triangle on the other (visible in cog-basic with antimeridian.tif: rainbow over-refinement vs giant pink triangle). Replace it with a per-piece longitude shift composed into the forwardTransform/inverseTransform. For each piece, k·360° is chosen so the piece's native lngs land inside proj4's valid [−180°, 180°]. The piece then uses the stock projectPosition / unprojectPosition (no wrap fold) and round-trips cleanly. The visual side effect is that the two pieces render in different world copies; deck.gl `repeat: true` + the world-copy traversal (#518) bring them together on screen. Removed: - projectPositionWrapped on RasterTileset2D - _projectPositionWrapped on RasterTileMetadata - TILE_SIZE import (only the wrap fold used it) Added: - buildPieceReprojection() builds a ReprojectionFns bundle for one piece, choosing lngShift from the piece's native midpoint. - _westReprojection / _eastReprojection on RasterTileMetadata, computed in getTileMetadata when _antimeridianCut is set. Tests now exercise both seam families (native [−204, −162] crossing −180, native [170, 190] crossing +180) and verify the per-piece geotransform round-trip. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
willjnz
added a commit
to willjnz/deck.gl-raster
that referenced
this pull request
Aug 25, 2026
MosaicTileset2D.getTileIndices queried its Flatbush spatial index once, using the viewport's raw (possibly unwrapped) longitude bounds. Once a WebMercatorViewport with repeat: true pans past +-180 degrees, viewportBounds extends past that range while sources are still indexed at their true, unwrapped bbox, so items on the far side of the antimeridian were never selected -- RasterTileLayer's own world-copy traversal (developmentseed#517 / developmentseed#518) never gets a chance to run, since a source's layer is never built if it's never selected. Repeats the query at world-copy offsets (same subViewports.length > 1 gate and MAX_MAPS walk-until-empty pattern as raster-tile-traversal.ts) shifting the search bounds by worldOffset * 360 degrees of longitude instead of translating a bounding volume, since Flatbush operates on WGS84 degrees rather than deck.gl common space. Documented as a second, independent layer in dev-docs/world-copies.md.
kylebarron
added a commit
that referenced
this pull request
Oct 21, 2026
…ian (#639) > [!NOTE] > This description was written by Claude (Claude Code), not by @kylebarron or @willjnz. @willjnz's original description, with screenshots and a test app, is in the edit history. `MosaicLayer` missed sources on the far side of the antimeridian, in Web Mercator with `repeat` and on a globe. @willjnz found it with two land cover COGs over Fiji, one on each side of 180°: centered between them, only one loaded. **Cause:** `MosaicTileset2D` picks sources by searching a Flatbush index of their bboxes with `viewport.getBounds()`. The bboxes lie within [-180, 180] longitude, but near the antimeridian the viewport's bounds run past ±180°. Web Mercator with `repeat` draws another copy of the world there, and a globe's `getBounds()` runs past ±180° around the camera's longitude. So the search found only the sources on one side. A source it doesn't pick never gets a `RasterTileLayer`, so the world-copy traversal from #518 never sees it. On a globe the bounds cross ±180° far from it when zoomed out: centered at 178°E at zoom 1, they are [-2, 242.7], so every source between -180° and -117° was missed. **Fix:** when the viewport draws past ±180° (Web Mercator with `repeat`, or a globe), `MosaicTileset2D` moves the bounds back within [-180, 180] and splits them in two at ±180° if they cross it. Every source lies in one world, so these one or two searches cover every world copy in view. Web Mercator without `repeat` draws nothing past ±180°, so its bounds are searched as they are. `MosaicLayer`'s fetch priority now measures longitude the short way around. It ranked a source 1.6° across the antimeridian as 358.4° away, so with the default limit of 6 requests per origin, its fetches waited behind every other source. This only affects apps that pass `getSource`. `dev-docs/world-copies.md` gets a "Mosaic sources" section. ### Not covered A source whose bbox crosses the antimeridian, written with `minX > maxX` as in GeoJSON and STAC, is an inverted box to Flatbush, so it's only selected when nearly the whole world is in view. Indexing it as two boxes would fix that, separately. ### Tests The new `MosaicTileset2D across the antimeridian` tests use real `WebMercatorViewport` and `_GlobeViewport` instances and one source on each side of the antimeridian. They check that: - Web Mercator with `repeat`, centered at 179.9° or -179.9°, selects both - Web Mercator without `repeat` selects only the side it draws - a globe centered at 179.9° or -179.9° selects both - a center longitude of 899.9°, which controllers wrap but a view state set directly may not, selects both - a view of more than one world selects every source - a source whose bbox spans every longitude is selected once Against main's `MosaicTileset2D`, the first, third and fourth fail (5 of the 19 tests). A new `MosaicLayer fetch priority` test checks that the source 1.6° across the antimeridian gets priority 1.6, not 358.4. In Chrome, through MapLibre with an interleaved deck.gl overlay, a `MosaicLayer` of the two Fiji COGs centered at 179.5° draws both on the globe and in Mercator with world copies. Before, only the west one drew on the globe. With 10,000 sources, `getTileIndices` takes 0.06 ms in a normal view (main: 0.04 ms), and 0.59 ms zoomed out until every source is in view (main: 0.28 ms). The difference is the `Set` that merges the searches. `pnpm -r --filter="!docs" typecheck`, the deck.gl-geotiff tests and `biome check` pass, and so does CI. 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Kyle Barron <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Screen.Recording.2026-05-21.at.2.49.24.PM.mov
Summary
RasterTileNode.update()at world offsets ±1, ±2, ... ±MAX_MAPSwhenviewport.subViewports?.length > 1, so tiles drawn in adjacent world copies pass frustum culling instead of getting evicted.worldOffsetthroughgetBoundingVolume; non-zero offsets return a translated copy derived from the offset-0 cache.selectedfromfalse→truebut never the reverse — to avoid LOD-flip pathologies when the OBB center moves with the offset.Mirrors the upstream pattern in
@deck.gl/geo-layers/tile-2d-traversal.ts.Closes #517.
Design + docs
dev-docs/specs/2026-05-07-multi-world-copy-tile-traversal-design.mddev-docs/world-copies.mdTest Plan
pnpm --filter @developmentseed/deck.gl-raster test --run— 93 passing (was 86; +7 multi-world tests).pnpm typecheck— clean.cog-basic: pan east of +180° / west of −180° at a moderate zoom; tiles should remain visible across the antimeridian instead of disappearing as in the issue's videos.Out of scope
createRootTilesdoes not yet consider world-copy intersections. Tracked as a follow-up if a zarr dataset surfaces the same symptom.🤖 Generated with Claude Code