fix: clip AffineTilesetLevel tile corners to array extent#580
Open
kylebarron wants to merge 1 commit into
Open
fix: clip AffineTilesetLevel tile corners to array extent#580kylebarron 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) <noreply@anthropic.com>
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.
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