Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Feature]: Evaluate Terrio as a COG writer dependency

Aperta
#663 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
24/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, wasm
Ambito
backend, databases

Direzione di ricerca

Read experiments/terrio-cog/README.md and inspect the pinned result files under experiments/terrio-cog/results/ to understand the comparison and its reproduction. Run the provided classes export command, then inspect its first overview with gdal_translate and gdalinfo -hist. The evaluation recommends keeping the native writer; done means preserving this reproducible evidence and rerunning the comparison after Terrio addresses the listed overview and writer gaps.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
Before you start
  • I searched the existing issues and the roadmap and did not find a duplicate request.
What problem does this solve?

In #629, @giswqs asked to keep Terrio out of the native COG writer PR and to experiment with it separately once Terrio supported narrower Cargo features. opengeos/terrio#154 added those features, so I evaluated Terrio's GeoTIFF/COG path without changing RustGIS's production writer or I/O.

Evidence of experiment branch: deniial00/RustGIS@terrio-cog-evaluation, pinned to commit ee149b8 on that branch:

The experiment is a standalone Cargo workspace with its own lockfile. It is not a RustGIS workspace member, so normal RustGIS builds do not resolve or compile Terrio. Terrio is pinned to ce3c4463f19864284d743720123c4d022784c497 with default-features = false, features = ["geotiff"].

Findings

Recommendation: keep the native writer for now. Terrio's minimal build works on native and wasm32-unknown-unknown, and its files pass GDAL's COG validator. But it does not produce equivalent overview pixels for several RustGIS export cases.

Both writers received identical inputs and settings: EPSG:32617, a north-up 30 m grid, 512×512 tiles, pixel interleaving, DEFLATE level 6, predictor 1 and automatic overviews.

Case Native Terrio Finding
RGB Pass Pass Exact pixels and overviews
Odd dimensions Pass Pass Edge dimensions and pixels match
BigTIFF Pass Pass 64-bit TIFF header and COG layout
Float32 + no-data Pass Fail 2,501 wrong second-level overview pixels
UInt16 + no-data Pass Fail 2,585 wrong second-level overview pixels: 2,501 no-data weighting errors (up to 2,977) plus 84 off-by-one rounding differences
Palette Pass Fail Overviews invent class indexes
Classes Pass Fail Overviews invent classes (9 where class 19 was expected)
Grey + alpha Pass Fail Transparent pixels darken colour overviews
RGBA Pass Fail Expected (200,100,50), got (100,50,25)

All 18 desktop outputs pass GDAL's full COG validator with no warnings or errors. Full-resolution pixels are identical between the two writers in every case, and georeferencing, EPSG, no-data values, palettes, UInt16 storage, alpha bands, odd dimensions and BigTIFF are all preserved. The failures are only in the overviews, which a viewer uses when zoomed out. The actual wasm exports show the same six failures.

The quickest way to see it is the classes case, whose first overview should only contain 1, 7 and 19 (run from a checkout of the branch above):

cargo run --release --manifest-path experiments/terrio-cog/Cargo.toml --features terrio -- export terrio classes 1025 769 terrio-classes.tif
gdal_translate -ovr 0 terrio-classes.tif terrio-classes-ov0.tif
gdalinfo -hist terrio-classes-ov0.tif   # also contains 4, 9, 10, 12, 13, ...

Main causes in the pinned Terrio revision:

  • COG export ignores overview_resampling, so a request for nearest overviews on classes still averages.
  • Colour overviews are not weighted by alpha.
  • Recursive overview averaging loses the original valid-pixel weights.
Cost measurements

These are small export programs, not the full RustGIS app or web bundle. Tests ran on an Apple M1 Pro with rustc 1.98.1 and GDAL 3.13.3.

Measurement Native With Terrio
Desktop clean build 136.8 s 239.3 s
Stripped desktop executable 1.58 MiB 8.13 MiB
Wasm clean build 104.1 s 194.8 s
Wasm, gzip -9 0.301 MiB 1.365 MiB
Wasm, Brotli 11 0.221 MiB 1.092 MiB

Desktop export, 4096×4096, median of 3 fresh processes; the times include writing and syncing the file:

Input Writer Export ms Peak memory MiB Output MiB
RGB Native 1254.8 202.3 21.88
RGB Terrio 326.5 323.1 20.64
Float32 + no-data Native 411.8 74.4 1.55
Float32 + no-data Terrio 84.8 194.8 3.01

Terrio is faster for these inputs but uses more peak memory. Its large Float32 output also fails the overview checks, so that speed is not for an equivalent file.

Proposed solution

Do not replace or add Terrio in the production writer yet. Keep the experiment as reproducible evidence and file the upstream Terrio issue(s) later. Re-evaluate after Terrio provides:

  1. COG overview resampling that honours nearest selection for categorical rasters.
  2. Alpha-weighted averaging for colour overviews.
  3. Valid-pixel-aware overviews, either by preserving weights recursively or by building from the full-resolution image.
  4. A public COG writer with bounded memory, for borrowed samples and a Write destination, on native and wasm.
  5. Optional JPEG XL/WebP and other unrelated codecs in the wbraster/wbgeotiff dependency chain.

After those fixes, rerun the same comparison before considering a production integration.

Estimated scope

Medium: a broader feature that is feasible in a reasonable timeframe

Alternatives considered
  • Keep RustGIS's native writer: no new dependency, and it passes this comparison.
  • Adopt Terrio now: rejected, because it gives different overview results for classes, alpha, and no-data rasters.
  • Patch Terrio's behaviour in an adapter: rejected, because precomputed overviews or local fixes would hide upstream gaps and duplicate writer logic.
Lingua principale
Rust
Stelle
1.9k
Fork
268
Merge medio
3h 9m
PR unite (30g)
611

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opengeos/RustGIS

Tutte le issue di opengeos/RustGIS

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.