Repository navigation
feat(data): read a window of a GeoTIFF in strips in place (#2592, part 1) - #3326
Conversation
, 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>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewReviewed the full diff (4 files, +206/−22) against BugsNone found. I checked these and they hold:
SecurityNone found. Performance
Quality
AGENTS.md
Change sizeCompared with
|
📖 Docs preview
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 |
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::layoutreads a GeoTIFF in strips (crates/data/src/raster/cog.rs): each strip is a tile as wide as the image andRowsPerStriprows tall (the whole image without the tag), fromStripOffsets/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::stripssays which.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.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 thetiffencoder 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).crates/tiles/src/cog.rs):window_info_untilhands a strip file's header tolayer.addUrlwith"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, andcube.reduce/stac.addCubeare part 4.Plan of the parts (≈400 lines each, with tests)
layer.addUrlwith"bbox". A window takes at mostMAX_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.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.cube.reduceandstac.addCubeon 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,proberefuse the file as before.rustgis-engine:a_window_of_a_geotiff_in_strips_comes_in_as_a_raster:layer.addUrlwith"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-data1954 + 70,rustgis-tiles597,rustgis-enginelib 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_numberandportable_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) andcargo xtask test-hygienepass.🤖 Generated with Claude Code
Summary by CodeRabbit