Repository navigation
feat: draw imagery across the antimeridian in output mode - #714
Closed
kylebarron wants to merge 13 commits into
Closed
kylebarron wants to merge 13 commits into
kylebarron wants to merge 13 commits into
Conversation
The 2026-05-27 spec cut each crossing tile in two because keeping it as one mesh needed crossing detection, vertices outside [0, 512], and an inverse projection that agrees on every world copy. Output-pixel error (#711) removes the inverse, walking from the first corner needs no detection, and clipping at the world edge brings vertices back into [0, 512]. This spec replaces the old one, which is marked superseded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A projection returns x in one copy of the world, so an image that crosses the antimeridian has corners on both sides of it, its triangles span the whole world, and refinement never converges. With wrapX (one world width), each vertex goes on the copy next to its neighbors: - a test point is measured against the copy nearest where the GPU draws it, and keeps that copy when it becomes a vertex; - each corner of the initial triangulation is unwrapped by walking to it from the first corner (unwrapAlong), so a 360°-wide image keeps its width; - the pixel size is measured the short way around the wrap. wrapX requires output mode, which never calls the inverse functions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the reprojector's wrapX, the mesh of an image that crosses the antimeridian stays in one piece, so part of it runs past the world's edge. RasterLayer's new @internal _wrapX prop passes the period to the reprojector and cuts the finished mesh at every multiple of it, moving each part back into the world. Each crossing triangle is clipped (Sutherland–Hodgman) and fan-triangulated, with texture coordinates interpolated along the cut edges. A mesh that lies inside one world is unchanged. The debug overlay draws the cut mesh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- RasterTileLayer passes `_wrapX` (one world) to Web Mercator tiles when `_errorSpace` is "output". Input mode and the globe are unchanged. - Tile selection: each reference point of a tile's bounding volume is unwrapped from the tile's center, so a crossing tile's box hugs it instead of spanning the world. A box that runs past the world's edge is also tested one world over, where its other part is drawn, so either part alone in view selects the tile, with or without `repeat`. The dataset-bounds check allows a one-world shift. - The debug tile outline unwraps each corner by walking the tile's edge, and PathLayer cuts it at ±180°. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every tile of every level of the five antimeridian fixtures (EPSG:4326, rotated, UTM 60N, EPSG:3832 and edge to edge), through the projections COGLayer builds and RasterLayer in output mode, converges, never goes the long way across the world, and is drawn inside the world. Each is selected with the view on the seam and on either side of it, with and without `repeat`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The five antimeridian fixtures from the geotiff-test-data submodule are selectable in development, served with range requests by a Vite middleware (ported from the cut-in-two prototype). Picking one switches the mesh to output pixels, which is what can draw across 180°, and draws the antimeridian for reference. Switching back to input pixels shows today's broken mesh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Walking to each corner from the first corner breaks when that corner is a pole, where longitude is undefined: a corner of a polar grid's quadrant tile landed a world away, and refinement ended in a stack overflow in _legalize. Walk from the center of the seed's UV bounds instead, which is inside the image and is where the pixel size is measured. That tile now meshes exactly as it does without wrapX. unwrapAlong's docs now state when its answer is right, and it's marked @internal: it's exported for deck.gl-raster, not as public API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A tile that contains a pole winds through every longitude, so unwrapping its reference points spread them over more than a world, and its box plus the copy one world over left a gap. Views in that gap, such as 20°W, 55°N on NSIDC's EPSG:3413 grid, selected no tiles, in every error mode. A box half a world wide or more now covers the whole world. Also keep proj4's x for a reference point the walk can't place, build the clamped projection once per box, and fix a comment the other-part test made stale. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ipping A triangle with an infinite x made clipMeshToWorld loop forever over world copies. Leave such a triangle where it is, and find each triangle's copies without allocating arrays. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A request for the fixtures directory itself threw EISDIR from an unhandled stream error, which stopped the dev server. Pass directories and read errors on to the next handler. The flag for the antimeridian test images is renamed, since the edge-to-edge image touches 180° without crossing it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Seed corners are walked from the center, tiles around a pole get a box across the whole world, polar grids aren't clamped short of the pole, tile selection changes in input mode too, and the dataset's bounds aren't unwrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An image that stops just short of 180° still crosses it when its edge tiles are fetched as full blocks, as MultiCOGLayer does: the padding runs on past 180° (#366's Digital Earth Pacific COG in EPSG:3832 ends at 179.97°E, and its 512 px edge blocks reach 180.07°E). Pin that such a block meshes the short way with wrapX, and note the case in the spec. 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.
Note
This PR was written by Claude (Claude Code) on behalf of @kylebarron, not by @kylebarron.
An image that crosses the antimeridian now renders in Web Mercator as one mesh, straight across 180°, when mesh error is measured in output pixels (
_errorSpace: "output"). Today its mesh never converges and is drawn the long way around the world.Why it broke. proj4 returns x inside one copy of the world. So a tile that crosses 180° has its west corners near +180° and its east corners near −180°, and its triangles span the whole world. The GPU then draws points near the seam in the middle of the world, and refinement piles up along the seam until it hits the iteration cap.
An image that stops just short of 180° can cross it too, when its edge tiles are fetched as full blocks, as
MultiCOGLayerdoes. The blocks' padding runs on past 180° even though the image doesn't. #366's Digital Earth Pacific COG, in EPSG:3832, ends at 179.97°E, and its 512 px edge blocks reach 180.07°E.COGLayercuts edge tiles to the image, so it doesn't hit this.What changes. Each tile stays one mesh, in "unwrapped" x that may run past the world's edge, and is then cut at the edge.
@developmentseed/raster-reprojectgets awrapXoption: the period of the output x axis, one world. With it, each vertex goes on the copy next to its neighbors:unwrapAlong, which is exported as@internal. This keeps a 360°-wide image a world wide. Starting from the center, not a corner, means a corner at a pole can't throw the walk off.wrapXrequires_errorSpace: "output". Output mode never calls the inverse projection, which is what made this hard in input mode (feat: antimeridian support #673).@developmentseed/deck.gl-rasterRasterLayergets an@internal_wrapXprop. It passes it to the reprojector and cuts the finished mesh at the world's edge, moving each part back into the world. The cut uses Sutherland–Hodgman clipping and interpolates UVs along cut edges. The debug overlay draws the cut mesh.RasterTileLayerpasses_wrapX: 512to Web Mercator tiles in output mode. Input mode and the globe are unchanged.repeat, and the tile is no longer selected from the far side of the world. A tile that contains a pole has no continuous unwrap, so it is bounded across the whole world. This part applies in input mode too.cog-basiclists the five antimeridian fixtures fromfixtures/geotiff-test-dataas sources in development. Picking one switches to output pixels and draws the antimeridian for reference.Spec:
dev-docs/specs/2026-10-14-antimeridian-unwrap-design.mdreplaces the 2026-05-27 cut-in-two spec, which is now marked superseded. It explains why output-pixel error makes one mesh the better design.Tests. The main requirement is that a crossing image is never drawn the long way around. The tests check that:
They run on synthetic images, and on every tile of every level of the five fixtures through the projections
COGLayerbuilds. A polar stereographic grid (NSIDC's EPSG:3413 extent) must be selected at every longitude, and a polar tile with the pole at a corner must mesh exactly as it does withoutwrapX. An EPSG:3832 edge block whose padding crosses 180°, though its image doesn't, must mesh the short way. The fixtures are EPSG:4326, rotated, UTM 60N (where the seam is curved), EPSG:3832, and 180°W to 180°E. Each fixture is also selected with the view centered on the seam and on either side of it, with and withoutrepeat. A crossing tile meshes exactly like the same tile moved off the seam, and a tile that doesn't cross is unchanged.Not changed here:
MultiCOGLayermeshes the full block of an edge tile, including the zero-filled padding past the image. In output mode, padding that crosses 180° is drawn just east of −180°, unless the render pipeline hides zeros. A follow-up could mesh only the image part of edge blocks.COGLayer's geographic bounds for a projected image that crosses 180° span the whole world. Socog-basic'sfitBoundszooms out to the world for the UTM and EPSG:3832 fixtures.MosaicLayerandMultiCOGLayersource bounds across 180° (fix(deck.gl-geotiff): Select MosaicLayer sources across the antimeridian #639).Closes #171
Closes #366
Closes #269
Closes #374
Closes #576
Closes #673
🤖 Written by Claude Code