Skip to content

feat: read and serialize richer virtual rasters - #248

Merged
giswqs merged 18 commits into
mainfrom
feat/vrt-interoperability
Oct 24, 2026
Merged

giswqs merged 18 commits into
mainfrom
feat/vrt-interoperability

Conversation

@giswqs

@giswqs giswqs commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Serialized VRTs retain lazy source reads through warped datasets, selected scalar derived bands and kernel filters. A native warp destination ending in .vrt writes a virtual description without reading all source pixels. Python and JavaScript/WebAssembly can open XML with uploaded source maps.

  • Preserve relative/remote/archive/subdataset references, masks, kernel halos and GDAL Float32 filter/lookup arithmetic.
  • Cross-read affine/reprojection, polynomial GCP, TPS, homography and RPC transformers. Warped windows retain the VRT block boundaries, source band order/duplicates, per-band nodata and unified validity modes. Per-band and raw Float32 TIFF nodata is retained in a PAM sidecar. Source overview selection and mixed-band working types survive serialization. Persistent VRT sources use a bounded LRU, and relativeToVRT follows GDAL CWD/directory semantics.
  • Parse transformer/options once per read and validate block windows. Unknown CRS follows the normal warp identity behavior.
  • Document the supported subset and source access model. Serialized cutline/alpha/geolocation warps, external functions and complex derived buffers remain unsupported. Pansharpened VRTs follow separately.
  • Refresh roadmap/gap assessments for VRT, geolocation and merged viewshed support.

Validation after merging current main (bb871f6):

  • 457 real USGS/GDAL comparisons pass: 445 pixel-exact; 12 affine-sum cases within one Float32 ULP (with the documented GDAL 3.12 generic clipping discrepancy). Includes source overview AUTO/AUTO-1/NONE/explicit levels, types, band nodata, grids and cropped reads.
  • Full workspace tests (416 core passed, one ignored), 39 real-data tests and changed-file pre-commit/Clippy pass. Mixed Some/None TIFF nodata and selected per-band mosaic nodata round-trip through whole and streamed output.
  • Rebuilt Python extension: 14 focused VRT/overview/pansharpen tests pass.
  • Rebuilt core WASM and Node suite: 20 pass, 72 feature/data skips.
  • MCP virtual-warp and counted I/O regressions verify lazy behavior; opening a virtual warp reads no source pixels.

Refs #238 (item 4).

Summary by CodeRabbit

  • New Features

    • Added lazy support for serialized virtual rasters, including warped VRTs, derived bands, kernel filters, masks, and source windows.
    • Added VRT opening in Python and JavaScript, with sources supplied as files or in-memory data.
    • Added per-band nodata handling across raster reads, summaries, translations, warps, and writes.
    • Added UNIFIED_SRC_NODATA options for command-line warping.
  • Documentation

    • Documented serialized VRT support, supported features, limitations, and conformance testing.

Read source windows lazily through warped, derived and kernel VRT descriptions, retaining masks and GDAL arithmetic. Expose uploaded source maps in Python and WebAssembly, and serialize native virtual warps without materializing their pixels.
…lity

# Conflicts:
#	crates/terrio/src/ops/warp.rs
#	docs/testing.md
#	scripts/conformance.py
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 1bda2dbe-f969-4fcc-be9d-1668d4a1e4f4
Commits

Reviewing files that changed from the base of the PR and between 52188d6 and ad11225.

Files selected for processing: 14
  • ROADMAP.md
  • crates/terrio/src/cog.rs
  • crates/terrio/src/dataset.rs
  • crates/terrio/src/drivers/common.rs
  • crates/terrio/src/drivers/gtiff_write.rs
  • crates/terrio/src/drivers/nodata.rs
  • crates/terrio/src/geotiff.rs
  • crates/terrio/src/ops/mosaic.rs
  • crates/terrio/src/ops/strips.rs
  • crates/terrio/src/ops/vrt/virtual_raster.rs
  • crates/terrio/src/ops/warp.rs
  • docs/cli.md
  • docs/testing.md
  • scripts/compare_vrt_with_gdal.py
Walkthrough

This change adds lazy VRT parsing and reading, serialized warped VRT output, and per-band nodata support across raster operations and TIFF sidecars. It exposes VRT opening in Python and JavaScript and adds VRT comparison and conformance coverage.

Changes: VRT interoperability and nodata

Layer / File(s) Summary
Per-band nodata metadata and persistence
crates/terrio/src/dataset.rs, crates/terrio/src/drivers/*, crates/terrio/src/geotiff.rs, crates/terrio/src/cog.rs, crates/terrio/src/histogram.rs, crates/terrio/src/info.rs, crates/terrio/src/ops/{mosaic,strips,translate}.rs
Raster datasets and TIFF/PAM sidecars now retain per-band nodata values. Raster summaries, histograms, translation, mosaics, and streamed TIFF writes use or preserve those values.
Warp options and serialized output
crates/terrio/src/ops/{gcp,warp}.rs, crates/terrio-cli/src/cmd/warp.rs, crates/terrio-cli/tests/mcp.rs
Warping now supports per-band nodata, unified source validity settings, source-transform and homography overrides, and serialized VRT output. The CLI parses UNIFIED_SRC_NODATA values and an MCP test checks VRT output and lazy reads.
VRT parsing, serialization, and lazy reads
crates/terrio/src/ops/vrt.rs, crates/terrio/src/ops/vrt/virtual_raster.rs, crates/terrio/src/cog.rs
The VRT reader supports lazy source and window reads, supported derived bands and kernel filters, masks, and warped VRTs. Serialization, source resolution, data-type promotion, and validation are included.
Bindings, conformance, and documentation
python/src/ops.rs, python/python/terrio/*, python/tests/test_vrt.py, js/src/lib.rs, js/tests/node.test.mjs, scripts/*vrt*, scripts/conformance.py, docs/*, js/README.md, ROADMAP.md, crates/terrio/NOTICE
Python and JavaScript expose VRT opening. Tests and a GDAL comparison suite cover VRT behavior. Documentation describes supported features and limitations; roadmap entries and NOTICE attribution are updated.

Priority: Normal

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant VirtualRaster
  participant LazyRaster
  participant SourceRaster
  Caller->>VirtualRaster: Parse VRT XML and resolve source references
  VirtualRaster->>LazyRaster: Create lazy raster
  Caller->>LazyRaster: Request a raster window
  LazyRaster->>SourceRaster: Read required source window and mask
  SourceRaster->>LazyRaster: Return source data
  LazyRaster->>Caller: Return VRT window
Loading

Possibly related issues

  • GDAL feature-parity parent tracker: this change implements its richer VRT interoperability item, including serialized warped VRTs, derived bands, and kernel-filtered sources.

Suggested labels: ci:all

Merge Risk: Moderate · up to 52188

Writing rasters whose bands have different nodata values can make a band without nodata reopen with another band's nodata value, which masks valid pixels. Mosaics built from per-band-nodata sources can also lose a band's nodata. Fix both before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 151 functions across 24 files. (8 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: read and serialize richer virtual rasters" matches the main change. The PR adds a VirtualRaster type that reads and serializes warped, derived-band, and kernel-filtered VRTs, plus ope…
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: read and serialize richer virtual rasters" matches the main change. The PR adds a VirtualRaster type that reads and serializes warped, derived-band, and kernel-filtered VRTs, plus open_vrt bindings for Python and JavaScript. The title is specific and short. It omits the per-band nodata work and the GeoTIFF PAM sidecar changes, but those are secondary to the main change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 45.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 151 functions across 24 files. (8 skipped: 8 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • 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 a window wide,
Through VRT paths the pixels glide.
Each band keeps nodata in its place,
Kernels lend the values grace.
A lazy hop, then reads appear,
The rabbit thumps: “The maps are clear!”

Comment @coderabbitai help to get the list of available commands.

@giswqs giswqs mentioned this pull request Oct 24, 2026
9 tasks done
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I reviewed virtual_raster.rs in full. I did not read the other 21 changed files in detail, including the warp, Python, JS and docs changes. Three inline comments are posted. I could not run anything, so none of this was tested.

Bugs

  • Empty SourceSRS on write (medium). VirtualRaster::warped writes an empty <SourceSRS></SourceSRS> when only one of the source and target CRS is known. The reader then calls SpatialRef::parse("")?, which likely errors, so the VRT Terrio just wrote may not reopen. I haven't checked how SpatialRef::parse("") behaves.
  • Possible underflow in warped_blocks (low–medium). width - x and height - y can underflow if a window extends past the raster. That would panic in debug builds and wrap in release. Callers probably clamp windows, but WindowSource::read is a trait boundary, so saturating_sub or an explicit bounds check would be safer.

Security

  • Untrusted VRT source references (medium that the exposure is real, low that it's a regression). Source names, and the RPC DEMPath, are passed to open_raster_lazy. A hostile VRT can reach absolute local paths, .. traversal or remote URLs. The CLI also backs the MCP interface, so this is a file-read and SSRF surface. GDAL behaves the same way. I'd suggest either an opt-in or an allowlist, or at least documenting it.

Performance

  • XML re-cloned and re-parsed per block (low). Reader::warped clones the whole XML root and re-parses all warp options for every 512×128 block. Parse them once per read or once at open.
  • Mask reads rebuild a VirtualRaster each time (low). read_mask clones the root and builds a new VirtualRaster on every call. Cache the mask description.
  • mode neighborhood function is O(n²) (low). The cost is per pixel, so it only matters for large kernels.

Quality

  • SKIP_NOSOURCE is mapped to options.rpc_output_window, which is a surprising coupling and deserves a comment.
  • virtual_raster.rs is about 1,150 lines. The pixel functions, kernel filter and GCP/RPC serialization could move into submodules.

CLAUDE.md

  • The PR adds the regression tests, conformance script entries, NOTICE attribution, docs and I/O-count test that AGENTS.md asks for. I found no violations in what I read.
  • I couldn't verify the claimed validation results (219 real-data GDAL comparisons exact, the Rust/Python/WASM test runs).

Preserve serialized band mappings and per-band nodata, including partial unified validity and TIFF PAM metadata. Parse warp options once per read, validate block windows, handle unknown CRS consistently, and document source reference resolution.
Comment thread crates/terrio/src/drivers/common.rs Resolved
Comment thread crates/terrio/src/ops/warp.rs Resolved
Comment thread crates/terrio/src/ops/warp.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff, the core, warp and driver changes, and the main paths in virtual_raster.rs. I did not read every line of that 1,293-line file or the docs and bindings. I could not run any code, so none of these findings has been confirmed by running anything.

Bugs

  • PAM sidecar read/write mismatch (drivers/common.rs, write_band_nodata_pam; medium). It reads the existing .aux.xml through memfs::read but writes it with std::fs::write. A sidecar that exists only on disk may be missed and then overwritten, losing its CRS and statistics. Element::to_xml may also lose content when it round-trips a GDAL-written sidecar.
  • Default multiband warps now skip all-nodata pixels (ops/warp.rs, global_validity; medium). It defaults to on for every warp with more than one band. Warps unrelated to VRT can now keep the destination fill where all bands are nodata. This should match GDAL's PARTIAL mode, but I'd like to see a GDAL comparison for non-VRT multiband per-band-nodata warps.
  • warp_to_path with a .vrt output drops options without an error (ops/warp.rs; medium). It ignores RasterWriteOptions and any warp options VirtualRaster::warped doesn't serialize, such as source_extra, sample_steps_all and order. The virtual result can then differ from the real warp. It should return Unsupported or the limits should be documented.

Security

  • Untrusted VRT sources are opened without restriction (virtual_raster.rs, open_virtual_raster; medium). Any .vrt now goes through this path, and the sources it names are opened as given: absolute local paths, remote URLs and archives. Opening an untrusted VRT through the CLI, MCP or Python can read local files or make outbound requests. GDAL behaves the same way, but this exposure is new. Consider an opt-in or an allowlist for absolute and remote sources.

Performance

  • Mask reads rebuild the description each time (virtual_raster.rs, Reader::read_mask; medium). Each call clones the description, re-serializes it to XML, re-parses it and swaps it in. Build the mask VirtualRaster once and cache it. If a read panics partway through the swap, the original description stays replaced.
  • Warped VRT reads redo setup per block (virtual_raster.rs, warped_blocks; low). Every read re-runs parse_warp, and every block calls warp_lazy_bands, which rebuilds the plan and transformer. Caching the parsed warp would help on repeated windowed reads.

Quality

  • write_raster_dataset now also writes a PAM sidecar when an old .aux.xml exists next to the output. That is reasonable, but it is an implicit side effect and should be documented.
  • Nodata::PerBand and the band_nodata vectors duplicate lookup logic across dataset.rs, cog.rs, geotiff.rs, nodata.rs and mosaic.rs. A shared helper would reduce drift.
  • virtual_raster.rs is 1,293 lines. Consider splitting it into warp, derived-band and kernel modules.

CLAUDE.md / AGENTS.md

  • The PR adds the NOTICE entries, docs, Python, JS and MCP tests, and conformance registration, so it follows the repository rules. I could not confirm the lazy-I/O measurement and the clippy and fmt results from here. The PR description reports them.

Cache parsed mask descriptions, preserve serialized sampling options and GDAL resampler names, and reject unsupported virtual creation options. Keep native format nodata authoritative and retain per-band nodata through translation, statistics and sidecar updates. Expand conformance to every warp resampler, explicitly recording the GDAL generic sum clipping difference.
Comment thread crates/terrio/src/ops/warp.rs Resolved
Comment thread crates/terrio/src/drivers/common.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff except most of the 1,800-line virtual_raster.rs. I skimmed that file's source cache, window math and unwrap/cast sites, and did not review its kernel arithmetic or XML parsing line by line. I did not build or run anything. Seven inline comments are posted.

Bugs

  • PAM nodata handling (drivers/common.rs, medium). When a sidecar lists nodata only for bands other than 1, parse_pam sets nodata to None, which discards a dataset-level NoDataValue. nodata::apply only applies band overrides when the dataset has no nodata, but read_geotiff always applies them. Those two paths disagree.
  • Stale sidecar check (dataset.rs, strips.rs, medium). They use Path::exists() on .aux.xml, while the PAM read and write go through memfs. On WASM or in-memory files, a stale sidecar is not detected or cleared.
  • Source cache eviction (virtual_raster.rs Reader::source, medium). It evicts an arbitrary HashMap key once more than 32 sources are open, so a many-tile VRT can reopen files repeatedly. The cache is keyed by name only, although path resolution also depends on relative (low).
  • UNIFIED_SRC_NODATA=PARTIAL rewrites --srcnodata (CLI warp.rs, low-medium). PARTIAL converts Nodata::Values to PerBand, so a later YES in the same --wo list no longer takes the default unify path.

Security

  • Nothing found. XML attribute and text output are escaped, and the source cache is bounded.

Performance

  • Per-pixel validity check on every multiband warp (warp.rs, medium). global_validity is true for every multiband warp, so the all-bands-invalid check runs on every pixel even when no source has nodata. Gating it on the source nodata would avoid that.

Quality

  • Dangling doc comment (warp.rs, high, cosmetic). A doc line about output_dataset now sits in front of the warp_lazy_many docs.
  • Warped-VRT output (warp_to_path, low-medium). It writes with std::fs::write rather than going through memfs. The long list of rejected creation options will not flag new RasterWriteOptions fields. Destructuring the struct would make that a compile error.
  • Rewrites existing .aux.xml (write_raster_dataset, dataset.rs, low). For GTiff/COG it now rewrites any existing sidecar even when the dataset has no per-band nodata, which silently modifies a user file. Please document it.

CLAUDE.md / AGENTS.md

  • Formatting (high for that one line). The UNIFIED_SRC_NODATA match arm in the CLI warp.rs has an over-long single-line return Err(...), so cargo fmt --check would likely fail.
  • Attribution (OK). The NOTICE entries for the ported vrtfilters.cpp arithmetic are present.
  • Regression tests (OK). The PR adds MCP, Python, JS and unit tests, plus a GDAL comparison script.

- Preserve PAM XML mixed content, comments, CRS and statistics while updating nodata through the same disk/memory I/O layer.
- Compare ordinary multiband warps with distinct per-band nodata and destination fill against GDAL for nearest and bilinear resampling.
Comment thread crates/terrio/src/ops/warp.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the non-virtual_raster.rs parts of the diff in full: core, CLI, warp, mosaic, strips, PAM and dataset. I did not review crates/terrio/src/ops/vrt/virtual_raster.rs (about 1,900 new lines) or scripts/compare_vrt_with_gdal.py line by line. I only had the diff and sources on disk, so I could not run any tests.

Bugs

  • No confirmed bugs in the code I read.
  • cog.rs:453 and cog.rs:568: band_nodata[0] is indexed without a guard. It panics if the band list is empty. Probably unreachable. Confidence: low.
  • ops/mosaic.rs: with Nodata::Auto, the VRT nodata now comes from the first source only. It was the first source that had nodata. This is covered by a test and is probably what GDAL does, but it is a behavior change for mosaics whose first tile has no nodata. The PR should call it out. Confidence: low-medium.

Security

  • Nothing found. The PAM and XML handling uses quick_xml with balanced-depth checks, and the VRT writer refuses to overwrite its own source (strips::overwrites).

Performance

  • drivers/common.rs:384: parse_pam parses the sidecar XML twice on every read. Parse it once. Confidence: medium.

Quality

  • drivers/common.rs:384: reading a malformed sidecar silently drops per-band nodata (.ok()), while write_band_nodata_pam returns an error for the same input. Confidence: medium.
  • ops/warp.rs:1481: warp_reader_selected takes six positional parameters, several of them Option/bool. It also uses working.is_some() as a stand-in for "this is a serialized VRT read", which skips overview selection. An options struct would be clearer. Confidence: medium.
  • ops/warp.rs, dataset.rs, cog.rs and translate.rs each repeat the pattern has_nodata = band_nodata[0].is_some(); raster.nodata = band_nodata[0].unwrap_or(-9999.). A single RasterDataset::set_band_nodata helper would keep these in sync. Confidence: medium.

CLAUDE.md / AGENTS.md

  • The PR adds UNIFIED_SRC_NODATA to the CLI, Python and JS surfaces, and adds NOTICE attribution for the GDAL vrtfilters.cpp port. The PR description reports GDAL conformance results (446 comparisons). It also registers the comparisons in scripts/conformance.py.
  • I did not see an I/O-measurement regression for the new read_mask path on Inner::Source. The PR text says counted-I/O regressions exist, but I did not verify them. Confidence: low.

- Parse optional PAM XML once when collecting dataset and per-band nodata.
- Avoid unchecked first-band metadata indexing in lazy raster headers and windows.
Comment thread crates/terrio/src/dataset.rs Resolved
Comment thread crates/terrio-cli/src/cmd/warp.rs Resolved
Comment thread crates/terrio/src/ops/strips.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the first ~1,100 lines of the diff, which covers everything except the following:

  • virtual_raster.rs, which is 1,865 lines and was not read.
  • The rest of warp.rs.
  • The bindings, scripts and docs.

Nothing below was compiled or run.

Bugs

  • Stale nodata after field edits (medium-low). RasterDataset::nodata() now returns band_nodata[0] and ignores has_nodata and raster.nodata whenever band_nodata is non-empty. Those fields are public. Code that clones a dataset and edits has_nodata or raster.nodata without clearing band_nodata will keep the old value. memory.rs, warp.rs and tiles/raster.rs have such edits today. They happen to work only because band_nodata is empty there. (dataset.rs:182)
  • UNIFIED_SRC_NODATA=PARTIAL depends on option order (medium). It converts Nodata::Values to PerBand only if --srcnodata was parsed before -wo. In the other order it does nothing. (cmd/warp.rs:189)
  • Stale .aux.xml when a streamed write fails (low-medium). StripWriter writes the PAM sidecar in finish(). If that fails, only the TIFF is removed, so a stale or partial .aux.xml stays behind. A later file at the same path would then pick up its nodata. (ops/strips.rs:74)

Security

  • No issues found in the parts I read. The PAM XML rewrite is built on quick_xml events, so it doesn't concatenate strings. It rejects unbalanced or missing roots.

Performance

  • No issues found.

Quality

  • The line at cmd/warp.rs:189 is about 150 characters wide and may fail cargo fmt --check (low).
  • common.rs has two separate test modules for write_band_nodata_pam. They could be merged (nit).

CLAUDE.md / AGENTS.md

  • The GDAL port in vrtfilters.cpp is attributed in both NOTICE files.
  • UNIFIED_SRC_NODATA appears in the CLI, and the roadmap is updated. I did not check whether Python and JS expose it for warp.
  • A regression test is added for MCP warp-to-VRT. I could not confirm GDAL comparisons beyond the registration in scripts/conformance.py, so please check CI for that and for Clippy -D warnings.

- Parse PAM XML once and preserve explicit dataset nodata fallbacks when band declarations are incomplete.
- Use optional first-band access for empty nodata metadata instead of indexing.
…review/pr-248

# Conflicts:
#	crates/terrio/src/cog.rs
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the new virtual_raster.rs module (about 1,900 lines) in full. I did not review warp.rs, mosaic.rs, strips.rs or the other changed files. I also did not confirm the CLAUDE.md validation and conformance requirements (GDAL comparison, scripts/conformance.py) beyond noting the new scripts and docs in the file list.

Bugs

  • No definite correctness bugs found in the reviewed code.
  • Checked and fine: VrtDataset::from_xml rejects VRTs with no bands, so the bands[0] accesses are safe. The ReadDepth guard releases correctly on early error returns. The source cache LRU eviction is consistent. The kernel filter's clamp bounds are safe because the area is non-empty.

Security

  • Untrusted VRT sources (low–medium confidence). A VRT with relativeToVRT="0" passes the source name unchanged to open_raster_lazy. An untrusted VRT can make the process open arbitrary local paths or remote URLs. GDAL behaves the same way, but this PR now exposes it through the CLI, MCP, Python and JS. See the inline comment on virtual_raster.rs line 866.
  • Unbounded block sizes (medium confidence). BlockXSize/BlockYSize from the XML have no upper bound. A single small read can allocate and warp a huge block. See the inline comment on line 516.

Performance

  • XML clone on every read (medium confidence). read_description clones every VRTRasterBand element tree on each window read. Borrowing would avoid it. See the inline comment on line 805.

Quality

  • virtual_raster.rs is a single 1,865-line file. It mixes XML validation, the warp serializer, the pixel functions, the kernel filter and the reader. Splitting it into submodules would make it easier to maintain (low confidence, style only).
  • Several nodata and working-type conventions are reproduced by hand to match GDAL, such as PARTIAL treated as true for the sink, the union_value inference, and f32 rounding. These are fragile and only the conformance tests protect them. Keep the scripts/compare_vrt_with_gdal.py coverage broad.

CLAUDE.md / AGENTS.md

  • NOTICE files were updated for the GDAL ports (vrtfilters.cpp), as the instructions require.
  • Docs, Python/JS bindings, CLI/MCP and conformance scripts were added.
  • I could not confirm that cargo fmt, Clippy, tests and the WASM build pass. CI should confirm this before merge.

- Borrow VRT band XML descriptions instead of cloning every element per window.
- Reject oversized declared warped blocks before source reads or buffer allocation.
- Remove incomplete streamed raster sidecars on failure and document per-band nodata precedence.
Comment thread crates/terrio-cli/src/cmd/warp.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the first ~600 lines of the diff in detail: NOTICE, ROADMAP, CLI warp options, cog.rs, dataset.rs, PAM handling in drivers/common.rs, nodata.rs and geotiff.rs. I did not review the remaining ~1,900 lines. That includes ops/vrt/virtual_raster.rs, ops/warp.rs, ops/mosaic.rs, ops/strips.rs, the Python/JS bindings and the scripts. Treat this as a partial review.

Bugs

  • Per-band PAM nodata is ignored on the eager read path when the TIFF has a GDAL_NODATA tag (drivers/nodata.rs:562, medium confidence). apply() is guarded by !ds.has_nodata. The new writer emits both the shared tag and a PAM override when bands differ. On a round trip, apply_pam then drops the override, while the lazy path (LazyRaster::band_nodata) honors it. The two read paths disagree.

Quality

  • UNIFIED_SRC_NODATA=PARTIAL mutates src_nodata as a side effect (terrio-cli/src/cmd/warp.rs:189, low-medium confidence). The result may depend on whether -srcnodata is processed before -wo. The long single-line match arm also likely fails cargo fmt --check.
  • GeoTags::apply_sidecar_crs now also sets nodata. The name no longer describes what it does (low confidence).

Security

  • None found in the portions reviewed. The new PAM XML rewrite parses and re-emits through quick_xml, and it rejects malformed or multi-root documents.

Performance

  • None found in the portions reviewed.

CLAUDE.md / AGENTS.md

  • The NOTICE attribution for the ported vrtfilters.cpp is present, and the root and crate copies match.
  • Regression tests were added for MCP, Python, JS and PAM.
  • I could not confirm that fmt, Clippy and the full test suite pass, because I have no way to run them.

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.

1 participant