← Back to Pull requests

fix(raster): open low-bit scans in black and white #3623

Open
unknown opened this pull request with 381 lines diff across 4 files
View on GitHub
unknown unknown commented on Dec 02, 2026 18:51 UTC
Author

Summary

A 1-bit GeoTIFF scan currently opens with two class colours because its few integer values select Unique Values. Open single-band grey GeoTIFFs with 1, 2 or 4 bits per sample as a grey MinMax stretch instead; at 1 bit, 0 draws black and 1 white. MinIsWhite reverses that through the existing normalizer.

The rule uses file bit depth, so a 0/1 raster created in a session still defaults to categories. Palette files keep their colour table. MinMax derives bounds from the pixels instead of storing fixed custom bounds, avoiding a stored-value warning when reopening a saved MinIsWhite layer.

Whole-file, local window and COG reads retain the bit depth, including world-file rotation. Desktop, browser, CLI, Python and phone share the default style path. Existing add-data commands reach it from the ribbon, command search, Assistant, MCP and plugins; no command parameter or tool description changes. Layers can still be restyled, removed and reopened through existing commands, with existing undo behavior. Saved styles retain their explicit renderer.

Memory adds one Option<u8> per raster and per COG layout; no pixel buffer or layer copy is added. No dependency, project-format, command or plugin-interface change. This is additive file metadata supporting a default-display bug fix.

Testing

  • cargo test -p rustgis-data -p rustgis-map -p rustgis-tiles --lib: 2,129 data, 683 map and 612 tiles tests passed (11 existing data tests ignored).

  • Engine tests a_window_of_a_geotiff_in_strips_comes_in_as_a_raster and a_cog_window_comes_in_as_a_raster passed.

  • cargo fmt --all --check, private contribution preflight and publication hooks passed.

  • Fork CI gate passed for 05375b1411878cd74266a097f3c869ef1fd0b573: https://github.com/Mavrick-F/RustGIS/actions/runs/46938925389.

  • Release CLI exports inspected. Whole-file and stream:true exports of the georeferenced 1-bit sample are pixel-identical.
  • UI evidence

    The same synthetic georeferenced 1-bit GeoTIFF exported through rustgis-cli. Before is reproduced by explicitly selecting the previous Unique Values/Harbour style in the changed build; after uses the default on opening the file.

    !Before: previous Unique Values style

    !After: default black and white

    Related issue

    Relates to #2761.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Single-band grayscale images with 1-, 2-, or 4-bit samples now receive a default contrast stretch for clearer display.
    * Grayscale rendering respects images where zero represents white; palette-based images retain their existing rendering behavior.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 381 lines (+285 / -96) across 4 files Reviewer: github-actions[bot] Review duration: 25m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 381 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.356
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3623"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.0% (MEDIUM) · Higher = larger blast radius
    43.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.9% · Safe to merge
    22.9%