Skip to content

feat(geotiff): New internal method to fetch multiple tiles concurrently, with range coalescing - #530

Merged
kylebarron merged 3 commits into
mainfrom
kyle/fetch-tiles-coalesce
May 12, 2026
Merged

kylebarron merged 3 commits into
mainfrom
kyle/fetch-tiles-coalesce

Conversation

@kylebarron

@kylebarron kylebarron commented May 12, 2026 •

Copy link
Copy Markdown
Member

Vendored from blacha/cogeotiff#1463

As explained in blacha/cogeotiff#1432 and #407 I would like a method to fetch multiple tiles so that we can merge ranges for neighboring requests.

This is modeled after the Rust object-store crate and its get_ranges method

Modifications

Vendored from blacha/cogeotiff#1463

For #273 and #407


Vendors the range-coalescing + batched byte/tile readers from cogeotiff PR #1463 into @developmentseed/geotiff, so we can use them before that PR is merged/released. A pnpm patch wouldn't work here — patches live in the root workspace and don't propagate to consumers of a published library — so the code is vendored into the package itself, mirroring the existing getTile/getBytes vendoring in fetch.ts.

Changes

  • packages/geotiff/src/coalesce.ts (new) — near-verbatim port of the PR's source.coalesce.ts: coalesceRanges(source, ranges, options?) plus the COALESCE_* constants and mergeRanges/findGroupIndex/dispatchMerged helpers. Typed against Pick<Source, "fetch">.
  • packages/geotiff/src/fetch.ts — adds getMultipleBytes and getTiles, sitting next to the already-vendored getTile/getBytes and routing tile data through the uncached dataSource. Exported package-internally; not added to index.ts. The PR's Source.fetchRanges branch is dropped (no such interface in @cogeotiff/[email protected]).
  • Tests — tests/coalesce.test.ts (ported from the PR's source.coalesce.test.ts, converted to Vitest) and tests/get-multiple-bytes.test.ts (mocked TiffImage + recording data source).

fetchTiles is intentionally unchanged — wiring it to actually coalesce is a follow-up PR.

Test plan

  • pnpm --filter @developmentseed/geotiff exec vitest run tests/coalesce.test.ts tests/get-multiple-bytes.test.ts — 21 passing
  • pnpm --filter @developmentseed/geotiff typecheck — clean
  • pnpm biome check packages/geotiff — clean
  • Note: tests/integration-rasterio.test.ts failures are pre-existing (the fixtures/geotiff-test-data submodule isn't initialized locally), unrelated to this change.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the feat label May 12, 2026
kylebarron and others added 2 commits May 12, 2026 16:10
…f PR #1463

Internal helpers only; fetchTiles is not yet wired to them.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kylebarron
kylebarron force-pushed the kyle/fetch-tiles-coalesce branch from bfb7035 to 3841d07 Compare May 12, 2026 20:11
@kylebarron kylebarron changed the title feat(geotiff): vendor batched-tile-fetch plumbing from cogeotiff PR #1463 feat(geotiff): New method to fetch multiple tiles concurrently, with range coalescing May 12, 2026
@kylebarron kylebarron changed the title feat(geotiff): New method to fetch multiple tiles concurrently, with range coalescing feat(geotiff): New internal method to fetch multiple tiles concurrently, with range coalescing May 12, 2026
@kylebarron
kylebarron enabled auto-merge (squash) May 12, 2026 20:17
@kylebarron
kylebarron merged commit 7b2bc80 into main May 12, 2026
7 checks passed
@kylebarron
kylebarron deleted the kyle/fetch-tiles-coalesce branch May 12, 2026 20:17
kylebarron added a commit that referenced this pull request May 12, 2026
…Tiles (#531)

* docs(geotiff): spec for routing fetchTiles through batched getTiles

Closes the design phase for #407: fetchTiles should issue coalesced
batched range requests via the getTiles/getMultipleBytes/coalesceRanges
helpers vendored in #530, instead of Promise.all over fetchTile.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(geotiff): extract assembleTile from fetchTile

Splits fetchTile into "fetch compressed bytes" + "decode/assemble the
RasterArray". No behavior change; assembleTile will be shared with the
batched fetchTiles path.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(geotiff): batch + coalesce reads in fetchTiles (closes #407)

fetchTiles now resolves every requested tile's byte range up front and
fetches the data through getTiles / getMultipleBytes (range-coalescing),
instead of Promise.all over fetchTile. Both planar configurations:
pixel-interleaved via getTiles; band-planar by flattening every
(tile, band) range into one getMultipleBytes call and regrouping. The
mask IFD, if any, is fetched the same batched way. Decoding is still
per-tile via the shared assembleTile.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(geotiff): parity + coalescing tests for batched fetchTiles

Covers fetchTiles vs per-tile fetchTile parity (pixel-interleaved,
band-planar, masked), input-order preservation, boundless: false
propagation, band-planar range coalescing, and empty input.

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 Oct 20, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

Bumps `version` to `0.9.0-beta.1` in the root `package.json` and in
every `packages/*/package.json`, ready for a beta release. The publish
workflow sees `beta` in the version and publishes to npm under the
`beta` dist-tag, so `latest` stays on 0.8.1.

`CHANGELOG.md` gets a `v0.9.0-beta.1` section listing the 44 PRs merged
since v0.8.1, plus the two new contributors. This also drops the old
"Unreleased" section: its three entries (#424, #530, #531) already
shipped in v0.7.0.

Once this is merged, tag the merge commit `v0.9.0-beta.1` and push the
tag.

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant