Skip to content

feat(data): read a window of a GeoTIFF in strips in place (#2592, part 1) - #3326

Merged
elpidioassinaturas merged 1 commit into
opengeos:mainfrom
elpidioassinaturas:feat/2592-strips-part1
Nov 29, 2026
Merged

elpidioassinaturas merged 1 commit into
opengeos:mainfrom
elpidioassinaturas:feat/2592-strips-part1

Conversation

@elpidioassinaturas

@elpidioassinaturas elpidioassinaturas commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2592 (part 1 of 4). #2629 already lifted the first cause (a header past 2 GiB); this part lifts the second: a GeoTIFF in strips is no longer refused for a window.

What changes

  • cog::layout reads a GeoTIFF in strips (crates/data/src/raster/cog.rs): each strip is a tile as wide as the image and RowsPerStrip rows tall (the whole image without the tag), from StripOffsets / StripByteCounts, so the window, decode and cancel paths stay one code path, as the issue proposes. Overviews of a file in strips are read in strips too; a tiled file's image in strips still ends the overview scan, as before. Layout::strips says which.
  • Strips too large to decode one at a time (more than the 32 MiB a tile may take once read) are still read whole, and say so: strips of N rows take M MiB each once read, more than the 32 MiB one may take: too large to read in place, so it is read whole.
  • A small file's header read whole serves a strip's reads (Sparse::read): a part read is looked for among the earlier parts too, so a file whose first read holds it all, with its IFD written after the strips (as the tiff encoder and the Brazil Data Cube write them), decodes a strip whose own bytes were added after it. Before, the read past the strip's end found the strip's part and stopped there (bytes not read yet).
  • Only a window reads the strips (crates/tiles/src/cog.rs): window_info_until hands a strip file's header to layer.addUrl with "bbox" (read_window_raster). Everything that draws a file in place (info, info_landed, info_until/info_blocking, probe, the map's tiles, the in-place overview) still refuses it with the same message as before (not a cloud-optimised GeoTIFF: a GeoTIFF in strips is read whole), so the map draws such a file from it downloaded whole, exactly as today. A file in strips has no overviews to draw from at a small scale, and cube.reduce / stac.addCube are part 4.

Plan of the parts (≈400 lines each, with tests)

  1. This PR: read a window of a GeoTIFF in strips in place, a strip a tile, through layer.addUrl with "bbox". A window takes at most MAX_VALUE_TILES (4096) strips, so for now a window of one-row strips is at most 4096 rows, and each strip is its own range request.
  2. Merge the requests: consecutive strips (contiguous in these files) become one range request of a few MB, several under way at once (8 by default), each decoded strip cropped to the window's columns; the 4096-chunk bound then counts requests, not strips, for a file in strips.
  3. Skip rows by cellSize: a window asked at a cell size coarser than the file's reads every n-th strip (decimation by rows, as GDAL does) and every n-th column, so a coarse preview of a 57,470 × 58,936 WPM scene stays within the 64-million-value cap and reads a fraction of the file.
  4. cube.reduce and stac.addCube on the Brazil Data Cube's strip collections (CB4A-WPM-L4-DN-1, CB4-PAN5M-L4-DN-1, CB4-MUX-L4-DN-1, AMZ1-WFI-L4-DN-1…): their windows read through the same code. Only that last part completes the issue.

Tests

  • rustgis-data: strips_are_tiles_as_wide_as_the_image (a Deflate Int16 file in 4-row strips, the last one short: layout, and each strip decoded to its rows), strips_too_large_to_read_in_place_are_read_whole.
  • rustgis-tiles: a_window_of_a_geotiff_in_strips_reads_its_rows_by_range: only the window's strips are fetched (byte count checked), values where they lie; info, info_until, probe refuse the file as before.
  • rustgis-engine: a_window_of_a_geotiff_in_strips_comes_in_as_a_raster: layer.addUrl with "bbox" over a served file in one-row strips; without a box it is still downloaded whole.

The test files are made in the tests (cog::example_strips); nothing reads the Brazil Data Cube.

Checks (local, Windows): rustgis-data 1954 + 70, rustgis-tiles 597, rustgis-engine lib 2836 and integration 244 pass, except two failures this machine has shown on other branches too, which don't touch rasters: tests::layout_report_text::a_report_measures_each_layout_page_with_its_own_page_number and portable_projects::reload::wrong_geometry_missing_file_and_missing_chosen_table_leave_the_layer_unchanged (the OS's "file not found" message is localised). cargo fmt --check, clippy --all-targets -D warnings (data, tiles, engine) and cargo xtask test-hygiene pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for loading strip-organized GeoTIFFs with windowed reads, fetching only the image strips needed for the requested area.
    • Strip-organized GeoTIFFs can also be loaded without a window to access the full raster.
  • Bug Fixes
    • Improved raster window metadata handling for strip-organized GeoTIFFs.
    • Strip-organized files are identified as unsupported for standard cloud-optimized drawing.

, part 1)

A GeoTIFF in strips (the Brazil Data Cube's CBERS and Amazonia scenes) is
laid out as tiles as wide as the image and RowsPerStrip rows tall, from its
strip offsets and byte counts, so a window (layer.addUrl with bbox) reads
only its rows' strips by range. Strips too large to decode one at a time
are still read whole, and say so. Drawing such a file in place stays
refused as before, so the map draws it from the file downloaded whole.

A small file's header read whole now also serves a chunk's reads past the
chunk read after it (its IFD written after the strips).

Part of opengeos#2592.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds strip-organized GeoTIFF parsing and supports strip metadata in window reads. The drawing metadata path continues to reject strip-organized files. The engine uses the window-specific metadata API, with tests covering windowed and full-raster reads.

Changes: Strip-organized GeoTIFF window reads

Layer / File(s) Summary
Parse and decode strip layouts
crates/data/src/raster/cog.rs
Layout parsing represents strips as image-width tiles and reads strip offsets and byte counts. It checks decoded strip size, updates Sparse::read, and adds strip examples and tests.
Separate window and drawing metadata paths
crates/tiles/src/cog.rs
The drawing metadata path rejects strip layouts. The desktop window metadata path accepts them, and a test checks window values and fetched strips.
Route engine window reads through strip metadata
crates/engine/src/cmd/layer.rs, crates/engine/src/tests.rs
read_window_raster uses the window-specific metadata API. An integration test checks windowed and full-raster reads from a strip-organized GeoTIFF.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LayerAddUrl
  participant ReadWindowRaster
  participant WindowInfoUntil
  participant WithAnyInfo
  LayerAddUrl->>ReadWindowRaster: request a window with a bounding box
  ReadWindowRaster->>WindowInfoUntil: request window metadata
  WindowInfoUntil->>WithAnyInfo: load metadata without the drawing restriction
  WithAnyInfo-->>WindowInfoUntil: return strip metadata
  WindowInfoUntil-->>ReadWindowRaster: return window metadata
Loading

Possibly related issues

Suggested reviewers: giswqs, choupeanut

Merge Risk: Minimal · up to 85356

This change lets a windowed read of a strip-organized GeoTIFF fetch only the strips covering the window, while drawing paths keep refusing such files as before. Nothing found indicates a merge-blocking problem. A test for a multi-band planar strip file would be worthwhile follow-up coverage.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(data): read a window of a GeoTIFF in strips in place (#2592, part 1)" matches the main change: strip-organized GeoTIFFs are now read as image-width tiles, and a window can be read in p…
Description check Passed The description follows the repository template. It has a Summary with a clear account of what changes and why, a Testing section listing the new tests and local check results, and a related issue ref…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(data): read a window of a GeoTIFF in strips in place (#2592, part 1)" matches the main change: strip-organized GeoTIFFs are now read as image-width tiles, and a window can be read in place through layer.addUrl with a bounding box. The changes in crates/tiles and crates/engine support that windowed read, and the title names the core behavior. The title is specific and concise, and it accurately names the scope as part 1 of the series.

Full details: Description check

Explanation

The description follows the repository template. It has a Summary with a clear account of what changes and why, a Testing section listing the new tests and local check results, and a related issue reference (Part of #2592). The UI evidence section is present and correctly states that there is no visible UI change. The description is detailed and covers the scope limits, such as drawing paths that still refuse strip files. The template's Related issue placeholder is filled with a 'Part of' reference, as the template suggests.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the strips in rows
Where each wide tile begins and goes
A window picks the bands it needs
While full-raster paths still read
The rabbit hops, content with speed

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 79ae4004-1605-4083-aa11-a29eb838ec78
Commits

Reviewing files that changed from the base of the PR and between 6bf5ad4 and 853566c.

Files selected for processing: 4

  • crates/data/src/raster/cog.rs
  • crates/engine/src/cmd/layer.rs
  • crates/engine/src/tests.rs
  • crates/tiles/src/cog.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Reviewed the full diff (4 files, +206/−22) against pr-context/AGENTS.md. There are no prior review threads, so no earlier concerns were left alone. I posted one inline comment; everything else is below.

Bugs

None found. I checked these and they hold:

  • Division by zero: a RowsPerStrip of 0 is caught by the existing tw == 0 || th == 0 guard (cog.rs:572) before the div_ceil calls. Confidence: high.
  • Gating of the in-place paths: drawn covers info, info_landed, with_info (which feeds probe, info_until, info_blocking, and the map's tile fetch), and cube/stac through info_blocking. Strip files stay refused there, as the PR states. Confidence: high.
  • Sparse::read change: an earlier chunk that reaches pos is now used. Overlapping chunks hold the same file bytes, so this is correct. Confidence: high.
  • wasm: the new window_info_until, info_until_then and read_window_raster are all cfg(not(wasm32)), and with_any_info is always used by with_info, so nothing becomes dead code in the browser build. Confidence: medium-high. I did not build for wasm.

Security

None found.

Performance

  • Sparse::read now scans every earlier chunk when pos is in no chunk. This happens only on a miss, which ends the read, and header Sparses hold few chunks. Negligible. Confidence: high that it is harmless.
  • Design limit, not raised inline: if an overview in strips is too large to read in place, the whole file is refused for windows, even though its full-resolution strips could be read. The refusal is said, so nothing is silent, and this is no worse than before. Confidence: high.

Quality

  • Posted inline (crates/data/src/raster/cog.rs:582): the "so it is read whole" wording is wrong for a bbox request, which fails there and reads nothing whole. Confidence: medium.
  • Nit: a_window_of_a_geotiff_in_strips_reads_its_rows_by_range (crates/tiles/src/cog.rs) calls clear_fetcher only after all assertions pass. A failing assertion leaves a global fetcher set for other tests in that binary. Consider a drop guard. Confidence: medium.

AGENTS.md

  • The PR description does not state which surfaces the change reaches, as "Reach every surface" asks. The change sits on layer.addUrl with "bbox", which the desktop, browser, CLI, Python and phone all share. The PR should say so, and say that the Assistant and MCP tool descriptions and the undo path need no change. The cube.reduce/stac.addCube gap is correctly deferred to part 4. Confidence: medium.
  • No command, parameter, schema, or layer-storage change, so command-surface.txt, schema/, row-uses.txt and the memory multiple don't apply. The stored strip index is 16 bytes per strip. Confidence: high.
  • Fixture coverage (schema/fixtures/) does not apply, since the project read path is unchanged.

Change size

Compared with main (merge base c5f197f to PR head 853566c).

Measure Value
Files changed 4 (0 added, 4 modified, 0 removed, 0 renamed)
Size before 4.41 MB
Size after 4.42 MB
Total size change +10.99 KB
Path Before After Change
crates/data/src/raster/cog.rs 69.2 KB 74.8 KB +5.59 KB
crates/tiles/src/cog.rs 132.8 KB 136.5 KB +3.78 KB
crates/engine/src/tests.rs 3.76 MB 3.76 MB +1.54 KB
crates/engine/src/cmd/layer.rs 467.9 KB 467.9 KB +84 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3326/
Web app https://preview.rustgis.app/pr-3326/app/
Commit 853566c

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants