Repository navigation
feat: Split COG tile traversal off TileMatrixSet - #480
Merged
Merged
Conversation
Splits COG tile traversal off TileMatrixSet by introducing a generic AffineTilesetLevel/AffineTileset pair in deck.gl-raster, fixing #327 (rotated COGs) and #375 (non-square pixel COGs) and unifying the COG and Zarr tileset code paths. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Generic TilesetLevel implementation parameterized by an affine transform plus tile and array sizes. Handles axis-aligned, rotated, and non-square-pixel grids uniformly. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Move matrixWidth, matrixHeight, metersPerPixel, tileWidth, and tileHeight to readonly fields set in the constructor. Avoids repeating the ceil/sqrt math on every getter access during traversal. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
For bboxes that lie entirely outside the array, the symmetric
[0, maxIdx] clamp on both ends collapsed the range to a single
spurious tile (e.g., {minCol: maxIdx, maxCol: maxIdx}). Asymmetric
clamping only floor-clamps minCol/minRow and ceiling-clamps
maxCol/maxRow, so non-overlapping bboxes naturally produce min > max
and the consumer's `for (i = min; i <= max; i++)` loop emits no
tiles.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Port rotation() from the Python affine library — counter-clockwise rotation by an angle in degrees about an optional pivot. Use it in the AffineTilesetLevel test to express rotated/scaled affines via library chaining instead of hand-written matrix elements. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The comment described the operations in the wrong order. compose(A, B) applies B first then A, so the actual pixel→CRS sequence is scale, rotate, translate — not rotate, scale, translate. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Calls out the lineage (port of Python rasterio/affine), the subset of operations covered, and the compose() ordering convention that trips people up. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
A TilesetDescriptor backed by per-level affine transforms. Adds a projectedBounds field to AffineTilesetLevel (computed from the affine applied to the array corners) and AffineTileset delegates to the coarsest level for the dataset bounds. Exports both new primitives from the raster-tileset barrel. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Delete the inline ZarrTilesetLevel class and projectedBounds derivation; geoZarrToDescriptor is now thin glue around the shared primitives in deck.gl-raster. Also re-exports the new primitives from the deck.gl-raster top-level barrel so downstream packages can import them. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Builds an AffineTileset from a GeoTIFF without going through TMS, correctly handling rotated, skewed, and non-square-pixel COGs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces generateTileMatrixSet + TileMatrixSetAdaptor with the new affine-based descriptor. Fixes rendering for COGs with rotated/skewed transforms (#327) and non-square pixels (#375). The mpu calculation moves out of the helper and into the layer, mirroring how ZarrLayer already computes it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces generateTileMatrixSet + TileMatrixSetAdaptor with the new affine-based descriptor and drops morecantile/fromAffine helpers in favor of TilesetLevel.tileTransform. The internal SourceState's tms field is dropped (it was unused outside the per-tile transform lookup). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces [geotiff, ...overviews] spread + index lookup with a direct selection. Also corrects the off-by-one in the previous TODO comment: the full-res level is at z === overviews.length (the last index), not overviews.length - 1. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The function is no longer used internally; COG layers now use geoTiffToDescriptor instead. The implementation and its tests stay in the source tree in case TMS-from-COG synthesis is needed in the future. The tile-matrix-set test imports the function via a relative path so it continues to exercise the implementation. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
commented
Apr 27, 2026
CI typecheck was failing because tile-matrix-set.test.ts mixed barrel imports (dist GeoTIFF type) with relative imports (src GeoTIFF type) of generateTileMatrixSet — TypeScript treats the two as distinct nominal types because of a private field on DecoderPool. Switching all package-internal tests + helpers + polyfills to relative imports keeps the type universe consistent. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Port cos_sin_deg from the Python rasterio/affine library: rotation() now returns exact 0 / ±1 entries for multiples of 90° instead of the ~6e-17 floating-point noise from Math.cos/Math.sin. Slots derived from -sa carry -0 when sa is 0, matching upstream Python behavior (Affine.rotation(180) returns Affine(-1, -0, 0, 0, -1, 0) there too). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Only consumed internally by COGLayer and MultiCOGLayer (both via relative imports). External users either go through those layers (the intended path) or build their own AffineTileset out of AffineTilesetLevel directly. The barrel export was dead surface area. Co-Authored-By: Claude Opus 4.7 (1M context) <[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 test image render from #375: (@cbdj is this a public image that's ok to host in an example?)
Working rotated umbra image from #327 (
http://umbra-open-data-catalog.s3.amazonaws.com/sar-data/tasks/Port%20of%20Rotterdam%2C%20Netherlands/00864c2c-0b0f-49ef-b283-997735b27878/2025-07-29-11-17-12_UMBRA-08/2025-07-29-11-17-12_UMBRA-08_GEC.tif):Summary
AffineTilesetLevelandAffineTilesetin@developmentseed/deck.gl-raster— a genericTilesetDescriptorshape backed by a per-level affine transform plus tile and array sizes. Handles axis-aligned, rotated/skewed, and non-square-pixel grids uniformly.COGLayerandMultiCOGLayerthrough a newgeoTiffToDescriptorglue function instead ofgenerateTileMatrixSet+TileMatrixSetAdaptor. Fixes Support COGs with rotated transforms #327 (rotated COGs no longer throw) and Failing rendering with non-square pixels #375 (non-square-pixel COGs render correctly).geoZarrToDescriptoronto the same shared primitives — the inlineZarrTilesetLeveland bounds derivation are gone.MultiCOGLayerper-tile reprojection now goes throughTilesetLevel.tileTransform()instead of morecantile +fromAffine, dropping a small layer of indirection.rotation()to@developmentseed/affine(port of Pythonrasterio/affine's rotation classmethod), and switchesidentitydocumentation along with a few other small cleanups.generateTileMatrixSetfrom the@developmentseed/geotiffpublic exports. The implementation and its tests stay in the source tree in case TMS-from-COG synthesis is needed in the future.Spec:
dev-docs/specs/2026-04-27-affine-tileset-design.mdCloses #456
Fixes #327
Fixes #375
Test plan
pnpm -w test)AffineTilesetLevelcover axis-aligned, rotated, non-square pixels, and the empty-range caseAffineTilesetcover bounds derivation for axis-aligned and rotated coarsest levelsgeoTiffToDescriptorcover level ordering and bounds propagationaffine.rotation()cover origin pivot, non-origin pivot, and pivot-fixed-point invariant🤖 Generated with Claude Code