Repository navigation
fix: clip AffineTilesetLevel tile corners to array extent - #580
Closed
kylebarron wants to merge 1 commit into
Closed
kylebarron wants to merge 1 commit into
kylebarron wants to merge 1 commit into
Conversation
Tiles at the right/bottom edge of a level's matrix can nominally extend past the array when matrixWidth*tileWidth > arrayWidth (likewise for height). The affine still extrapolates past the data, but for projections whose valid domain isn't a rectangle aligned with the affine — Mollweide, Sinusoidal, Equal Earth — those extrapolated points fall outside the projection's domain and proj4 collapses them onto the pole. The downstream Web Mercator clamp then sends every such corner to one horizontal line at ±85.05°, producing a degenerate bounding volume that the `tileMaxY > minY` check in `insideBounds` rejects (0 > 0 is false). Every tile gets culled and nothing renders. Clip the tile's pixel-space rectangle to [0, arrayWidth]×[0, arrayHeight] before applying the affine so every corner stays inside the data extent. Interior tiles are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
marked this pull request as draft
June 2, 2026 15:43
4 of 5 tasks
This was referenced Oct 21, 2026
kylebarron
added a commit
that referenced
this pull request
Oct 21, 2026
before (black border): <img width="2800" height="1724" alt="before-fit" src="https://github.com/user-attachments/assets/e42d808f-47a2-4593-9a76-5946aec0a98b" /> after: <img width="2800" height="1724" alt="after-fit" src="https://github.com/user-attachments/assets/d129b0e3-8bb5-4649-b14c-a357161a3669" /> before: <img width="2800" height="1724" alt="3-before-20m-corner" src="https://github.com/user-attachments/assets/dac357ee-9498-4210-977c-a1ca556ea766" /> after: <img width="2800" height="1724" alt="4-after-20m-corner" src="https://github.com/user-attachments/assets/b54ac9bb-2a70-4029-a86f-dd52a507770f" /> before and after for mollweide example (still broken 😄 ) <img width="2800" height="1724" alt="5-before-mollweide" src="https://github.com/user-attachments/eassets/d7c6519a-6800-4f64-8de2-38209c7338fc" /> <img width="2800" height="1724" alt="6-after-mollweide" src="https://github.com/user-attachments/assets/24ccfad8-7fe8-4604-98a4-c84f70bf82bf" /> ----- > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. `MultiCOGLayer` now fetches edge tiles with `boundless: false`, as `COGLayer` does, and meshes only the part of each tile inside the image. Before, it drew every tile at full size, so the padding past the image's right and bottom edges showed as a band past the scene. That padding holds whatever the file's writer stored there, not necessarily nodata. In Digital Earth Australia's Sentinel-2 files (nodata -999) it is 0, which a nodata filter can't remove. Coarser bands are stitched from clipped tiles too, which works because every step uses the same clipped geometry: - `AffineTilesetLevel.projectedTileCorners` clips the tiles in the last column and row to the array (the change from #580). - `resolveSecondaryTiles` takes the stitched texture's size from the far clipped corner, so it matches the UV transform it computes from the clipped extents. - `assembleTiles` already accepts clipped edge tiles (#753). Clipping the corners also affects `COGLayer` and `ZarrLayer`, which already drew only the clipped part: their culling `bbox`, bounding volumes, Web Mercator pole clamp, and debug outlines now match what they draw. It also fixes #580's case, a full-world Mollweide COG whose padded corners fall outside the projection's domain, so every tile was culled. That file now selects and draws tiles, though its polar tiles still smear because pixels outside Mollweide's ellipse don't reproject, which is a separate problem. `dev-docs/boundless-tiles.md` is rewritten to match. Closes #580, closes #651 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- 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.
Working to solve source-cooperative/cog-viewer#8
Summary
AffineTilesetLevel.projectedTileCornersextrapolates past the array whenmatrixWidth*tileWidth > arrayWidth(or height equivalent). For projections whose valid domain isn't aligned with the affine — Mollweide, Sinusoidal, Equal Earth — those extrapolated points fall outside the projection's domain, proj4 maps them to the pole, and the Web Mercator clamp collapses every such corner onto a single horizontal line at ±85.05°. The bounding-volume sampler then produces a zero-height OBB, thetileMaxY > minYtest ininsideBoundsfails (0 > 0is false), and every tile gets culled.Net effect: a full-world Mollweide COG (e.g. Vizzuality HFP 100) loads, fires
onGeoTIFFLoad, thengetTileIndicesreturns[]and nothing renders — not even the debug overlay.This PR clips the tile's pixel-space rectangle to
[0, arrayWidth] × [0, arrayHeight]inprojectedTileCornersso every corner stays inside the data extent. Interior tiles are unaffected (their nominal corners are already inside the array). The hfp file now correctly selects tiles, traverses to finer levels, and renders. See screenshot below: debug overlay showing the two selectedz=1tiles spanning the world.Adds a HFP 100 entry to the
cog-basicexample dropdown for manual verification — the data renders ~black against the dark basemap on its own (a separate render-pipeline ergonomics issue for unscaled uint16 data), but the debug overlay confirms the traversal is correct.Test plan
pnpm -r test— 384 pass (+2 new edge-clipping tests inaffine-tileset-level.test.ts)pnpm -r typecheck— clean across all 23 projectspnpm biome check— cleanx=0 y=0 z=1andx=1 y=0 z=1(pre-fix: nothing)Written by Claude on behalf of @kylebarron
🤖 Generated with Claude Code