Skip to content

fix(analysis): report terrain edge treatment counts - #3210

Merged
Mavrick-F merged 3 commits into
opengeos:mainfrom
Mavrick-F:fix/terrain-edge-notices
Nov 28, 2026
Merged

Mavrick-F merged 3 commits into
opengeos:mainfrom
Mavrick-F:fix/terrain-edge-notices

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Slope, aspect and hillshade filled missing neighbours and computed boundary cells without explaining that policy. Raster Functions and function chains now report affected valid output cells and document the existing behavior: outside-grid samples use the nearest edge cell, invalid sampled neighbours use the centre elevation, and a missing centre remains NoData.

Counting shares the terrain traversal and keeps the optimized valid interior path. Existing terrain formulas, default output and command parameters remain unchanged. Held and tiled functions use the same reported calculation; notices land after the result, including background runs and held hillshade.

For a single function or the last terrain step in a tiled chain, counts exclude disposable block margins. Intermediate chained steps also evaluate margins needed downstream; their notices explicitly give upper bounds that can include repeated intermediate margin evaluations. The two treatment counts can overlap for one output cell.

The shared analysis and engine paths reach desktop, browser, CLI, Python and phone Raster Functions and the Function Editor. The change adds counters and stage metadata, with no extra full-raster pass or raster-sized storage. It keeps the existing undo and cancellation paths.

Testing

  • The actual command regression failed on the baseline because no edge-treatment notice was emitted.
  • A five-by-five grid with a NoData centre requires 16 clamped-boundary outputs and 8 centre-filled outputs for each terrain function.
  • Additional regressions cover kept-core counts, a clean interior, thread parity, and whole-versus-block pixel/notice parity with a missing cell at four block corners. Chained intermediate counts must identify their upper-bound basis.
  • Independent review approved the complete change with no blocking findings. The targeted engine terrain group (21 tests) and analysis terrain group (5 tests) passed. The source-layout contract and five analysis terrain tests passed after placing the test adapter inside the existing test module. The full Linux fork gate passed on 32a65633496a6f7f54c269c79f40f93f8a4430df, including the broad engine, Python and Assistant checks.

Related issue

Part of #1998.

Summary by CodeRabbit

  • New Features
    • Slope, aspect, and hillshade results now include notices counting valid output cells that used edge or missing-neighbour elevation handling. A cell may be included in both counts.
    • For block-based processing, counts reflect retained output cells. Terrain steps in chained workflows may report an upper-bound count.
  • Documentation
    • Clarified how terrain analysis handles missing centre cells, raster edges, and invalid neighbours.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Terrain operations now report counts for outputs that use clamped or filled neighbours. Raster workflows aggregate these counts across blocks and terrain chains, then include them in notices. Block callbacks also receive the retained core rectangle used to scope counts.

Changes: Terrain edge reporting

Layer / File(s) Summary
Terrain traversal counts
crates/analysis/src/rasterops.rs
Terrain traversal counts finite outputs that use clamped or filled neighbours, with optional core-rectangle filtering. terrain_reported selects a terrain function and returns pixels, edge counts, and percent-slope overflow counts. Existing terrain entrypoints retain their pixel-only results.
Block windows and terrain notices
crates/engine/src/cmd/in_blocks.rs, crates/engine/src/cmd/workflows.rs
Block callbacks receive the retained core rectangle. Raster workflows pass windows to terrain reporting, aggregate counts by stage, and add terrain notices. Chained terrain steps retain extra halo cells needed by later terrain steps.
Terrain reporting validation and documentation
crates/engine/src/tests/tiled_files.rs, docs/user-guide/analysis.md
Tests compare whole-raster and blockwise outputs and check boundary counts and notices. The guide documents neighbour handling and the scope of counts.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Blocks
  participant Source
  participant RasterWorkflow
  participant terrain_reported
  participant Remaps
  Blocks->>Source: run_window supplies block and offset
  Source->>RasterWorkflow: raster, bounds, and core rectangle
  RasterWorkflow->>terrain_reported: terrain function and core window
  terrain_reported-->>RasterWorkflow: pixels and edge counts
  RasterWorkflow->>Remaps: aggregate counts by stage
  Remaps-->>RasterWorkflow: terrain notices
Loading

Possibly related PRs

  • opengeos/RustGIS#1130: Adds the row-window interior path and edge handling used by the terrain traversal that now counts edge treatments.
  • opengeos/RustGIS#2896: Adds blockwise terrain execution and chain halo behavior used by the new core-window count handling.

Suggested reviewers: pick2510, giswqs

Merge Risk: Low · up to 32a65

This change reports how many slope, aspect and hillshade outputs used edge clamping or centre-filled neighbours, without altering the terrain formulas. No defect was found in the reviewed code. The browser (wasm32) build check failed for a reason that could not be determined, so confirm whether that failure comes from this change or from the base before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: terrain edge treatment counts are now reported for slope, aspect, and hillshade in the analysis crate. The title uses the conventional type(scope) prefix and is concis…
Description check Passed The description follows the template's Summary, Testing, and Related issue sections. The Summary explains what changed and why. Testing lists the regression, the new tests, and the full gate run. The …
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 names the main change: terrain edge treatment counts are now reported for slope, aspect, and hillshade in the analysis crate. The title uses the conventional type(scope) prefix and is concise. It does not cover the chained-step upper-bound wording or the engine-side notice plumbing, which is expected for a short title.

Full details: Description check

Explanation

The description follows the template's Summary, Testing, and Related issue sections. The Summary explains what changed and why. Testing lists the regression, the new tests, and the full gate run. The UI evidence section is missing. The PR does not show a visible UI change, but the template asks the author to keep the 'No visible UI change.' line, and the description omits it. The description also cites many environments and mentions 'phone' and 'Function Editor' surfaces. Those are claims about reach, not visible UI evidence. The Related issue entry 'Part of #1998' is present, while the objectives reference PR #3210.

Resolution

Add the template's UI evidence line, 'No visible UI change.', under a UI evidence heading. Confirm that no UI-visible change exists, since the description mentions the Function Editor and notices. Optionally reconcile the issue reference, since the objectives cite PR #3210 and the description cites issue #1998.

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 hops where raster edges meet,
It counts the clamped cells beneath its feet.
If neighbours are missing, the centre steps in,
Then notices gather each treatment within.
Across blocks and chains, the counts all appear.

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: 51d15220-6057-4965-ad7f-0aa3dc6c5f96
Commits

Reviewing files that changed from the base of the PR and between e041087 and 32a6563.

Files selected for processing: 5

  • crates/analysis/src/rasterops.rs
  • crates/engine/src/cmd/in_blocks.rs
  • crates/engine/src/cmd/workflows.rs
  • crates/engine/src/tests/tiled_files.rs
  • docs/user-guide/analysis.md

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

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3210/
Web app https://preview.rustgis.app/pr-3210/app/
Commit 32a6563

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).

Merged via the queue into opengeos:main with commit 7ffe842 Nov 28, 2026
41 of 43 checks passed
@Mavrick-F
Mavrick-F deleted the fix/terrain-edge-notices branch November 28, 2026 08:14
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