Skip to content

feat(ui): a "Terrain type" field in a Shaded Relief's style pane (#3142, part 2) - #3313

Merged
elpidioassinaturas merged 1 commit into
opengeos:mainfrom
elpidioassinaturas:feat/3142-terrain-pane
Nov 29, 2026
Merged

elpidioassinaturas merged 1 commit into
opengeos:mainfrom
elpidioassinaturas:feat/3142-terrain-pane

Conversation

@elpidioassinaturas

@elpidioassinaturas elpidioassinaturas commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3142 (part 2 of 2; part 1 was #3304).

What it does

The style pane's Shaded Relief settings gain Terrain type (−1 to 1), after Aerial perspective. Moving it runs raster.symbology with "terrain", the setting part 1 added, so Undo, saving and the project capability work as they do for the command. Its tooltip: "How the sun lights slopes gentler or steeper than 30°: above 0 brings out low hills, below 0 stresses steep ground, from -1 to 1".

The user guide (docs/user-guide/data.md) describes the setting after Aerial perspective: what it does above and below 0, the curve, that only the sun's light uses it, that the colour bar is the same at any setting, and about 0.6 as a start for a plateau or a plain with low hills.

Style pane with Terrain type at 0.60

The pane above: Copernicus DEM GLO-30 of Ouro Preto (Minas Gerais), Terrain ramp, stretch 650–1,912 m, sun 315° / 40°, Z factor 2, terrain type 0.6, from the headless ui_shot example. DEM: Copernicus DEM GLO-30, © DLR e.V. and Airbus, provided under COPERNICUS by the European Union and ESA.

Surfaces

Tests

  • rustgis-render: a_reliefs_terrain_type_changes_its_frames_contrast_not_its_colour_bar draws a layout page with a frame over gentle hills (slopes of a few degrees) and a colour bar, at 0, +0.6 and −0.6. The frame's grey levels spread more at +0.6 and less at −0.6 than at 0; the colour bar's pixels are the same at all three.
  • Local runs (Windows): rustgis-render 999 passed; rustgis-ui-egui 1739 passed (lib). cargo fmt and cargo clippy -D warnings (render, ui-egui, all targets) pass.

Size: 105 changed lines (+103 −2) in 3 files, 82 of them the test.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • The Shaded Relief terrain setting now ranges from -1 to 1 and adjusts slope-lighting contrast without changing the color bar.
  • Documentation
    • Added guidance on the terrain setting’s default, effects, and how it interacts with other relief options and saved projects.

…ngeos#3142, part 2)

The style pane's Shaded Relief settings gain Terrain type (-1 to 1),
after Aerial perspective; it runs raster.symbology with "terrain", the
setting part 1 (opengeos#3304) added. The user guide describes it after Aerial
perspective. A layout render test draws a frame over gentle hills and a
colour bar at 0, +0.6 and -0.6: the frame's contrast grows at +0.6 and
falls at -0.6, and the colour bar is the same at all three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Shaded Relief pane now exposes a Terrain type control and sends changed values to raster.symbology. A rendering test checks frame contrast and colorbar pixels at three terrain values. The Rasters guide describes the setting.

Changes: Shaded Relief terrain setting

Layer / File(s) Summary
Expose and document terrain type
crates/ui-egui/src/panes.rs, crates/render/src/layout/tests.rs, docs/user-guide/data.md
The pane adds a Terrain type control from -1 to 1 and sends changed values as terrain. A rendering test checks frame contrast and colorbar pixels at three values. The guide describes the setting, its effects, limits, and project-saving behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Possibly related PRs

  • opengeos/RustGIS#3304: Adds the terrain setting and its validation and rendering behavior, which this PR's pane control uses.

Suggested reviewers: giswqs, deniial00, mavrick-f

Merge Risk: Minimal · up to d0672

This adds a Terrain type control to the Shaded Relief pane and documents it. It uses the existing raster.symbology setting, and the default leaves existing maps unchanged. No merge-blocking issues remain.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #3142 (direct, open) asks for a signed Terrain type setting (raster.symbology "terrain", -1 to 1, default 0). The reshaping g' = g0 × (g/g0)^p, with g0 = tan 30°, must feed only the sun's light.… Confirm, from the relief code in the merge base (the file that implements the terrain reshaping added by #3304, found under crates/render/src), that: (1) g' = g0 × (g/g0)^p with g0 = tan 30° and p = 1 − 0.5 × terrain; (2) slopes at 30° are …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the Terrain type field added to the Shaded Relief style pane, which is the main change in the UI pane diff. It also cites the issue and part number. It is specific and accurate, though…
Description check Passed The description follows the template. It has a Summary that explains the change and why, a Testing section with specific test names and results, and a UI evidence section with a screenshot and the par…
Out of Scope Changes check Passed All three changed files relate directly to the Terrain type setting. panes.rs exposes the control and sends the 'terrain' parameter to raster.symbology, which #3304 added. data.md documents the settin…
Full details: Title check

Explanation

The title names the Terrain type field added to the Shaded Relief style pane, which is the main change in the UI pane diff. It also cites the issue and part number. It is specific and accurate, though it is a little long at 80 characters.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the change and why, a Testing section with specific test names and results, and a UI evidence section with a screenshot and the parameters used. It also links the related issue (Closes #3142) and the prior part (#3304). The template's 'No visible UI change' line is not used, which is correct here because the PR adds a visible control. The Summary is detailed and clear.

Full details: Out of Scope Changes check

Explanation

All three changed files relate directly to the Terrain type setting. panes.rs exposes the control and sends the 'terrain' parameter to raster.symbology, which #3304 added. data.md documents the setting. The render test checks the setting's effect on frame contrast and confirms that the colour bar is unchanged. No unrelated code, refactoring, or configuration changes appear in the reviewed summary (105 lines in 3 files, 82 of them the test).

Full details: Linked Issues check

Explanation

Issue #3142 (direct, open) asks for a signed Terrain type setting (raster.symbology "terrain", -1 to 1, default 0). The reshaping g' = g0 × (g/g0)^p, with g0 = tan 30°, must feed only the sun's light. Its aspect must stay unchanged, slopes at 30° must stay unchanged, and steepening must be capped at 8×. This PR adds the UI control (crates/ui-egui/src/panes.rs: terrain_type, range -1 to 1, tooltip, sends terrain to raster.symbology), the user guide (docs/user-guide/data.md), and a render test (crates/render/src/layout/tests.rs: a_reliefs_terrain_type_changes_its_frames_contrast_not_its_colour_bar). The setting and its reshaping logic come from PR #3304, which is in the merge base (commit 8c46608, subject 'a Shaded Relief's terrain type reshapes the slopes the sun lights (#3142, part 1)'). The UI control and the render test cover the setting's visible behavior: frame contrast rises at +0.6, falls at -0.6, and the colour bar pixels are unchanged. I did not read the reshaping code. The reviewed inspections did not reach the relief code (the file read was truncated), so I could not confirm the 30° pivot, the 8× cap, the light-only use of the reshaped gradient, the aspect invariance, or the default of 0 in the base code.

Resolution

Confirm, from the relief code in the merge base (the file that implements the terrain reshaping added by #3304, found under crates/render/src), that: (1) g' = g0 × (g/g0)^p with g0 = tan 30° and p = 1 − 0.5 × terrain; (2) slopes at 30° are unchanged; (3) the steepening factor is capped at 8×; (4) the aspect is not changed; (5) cast shadows, sky, rock tint, and fill light use the original slope; (6) the default terrain value is 0 and existing maps are unchanged. A unit test covering the cap and the pivot would also settle items (2) and (3). If these hold, this check can pass.

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 taps the terrain dial,
And watches gentle hills arise.
The colorbar keeps every hue,
While frames gain contrast under skies.
The guide records the setting's range,
Then hops away through shaded greens.

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: 85921690-ca51-4fed-ad85-c274a30fedd8
Commits

Reviewing files that changed from the base of the PR and between fcbf9d9 and d067231.

Files selected for processing: 3

  • crates/render/src/layout/tests.rs
  • crates/ui-egui/src/panes.rs
  • docs/user-guide/data.md

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

Comment thread crates/render/src/layout/tests.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues, or AGENTS.md violations in this PR. It is a small UI field plus a doc section and a test, and it adds the terrain key to a setting that #3304 already validates and saves.

Bugs

None found.

What I checked:

  • Pane → command wiring (crates/ui-egui/src/panes.rs:7563, 7587, 7607). The new slider uses index 9, which does not collide with the existing indices. The value goes to raster.symbology as "terrain", and relief_terrain_type in crates/engine/src/cmd/raster.rs:1135 refuses values outside −1..1.
  • Other relief payloads in the pane. The band, balanced, tint, and rock payloads omit "terrain", so the command keeps cur_terrain (raster.rs:1048–1051, 1082). Changing one of those controls does not reset the terrain type.
  • Doc claims against the math. The formula in data.md matches terrain_type_factor in crates/map/src/raster.rs:1501–1507. The "at most 8 times steeper" cap is TERRAIN_TYPE_MAX_STEEPEN. The sun-only claim matches crates/render/src/raster.rs:1004–1006, where only the direct term uses the reshaped gradient and shadows, sky, fill, and rock keep the ground's own slope.
  • Test. The frame and colour-bar sampling rectangles fall inside the 48 dpi page at the stated layout coordinates. unwrap is allowed in tests by clippy.toml. Line lengths are within max_width = 140.

Security

None found. The new input is a bounded number and is checked before use.

Performance

None found. The change adds one more slider and one more closure capture.

Quality

  • Test comment geometry (crates/render/src/layout/tests.rs:3222, inline comment posted, confidence high). The comment says "800 m high and about 60 km across". The heights swing ±800 m, and the wavelengths work out to about 33–42 km. The slopes stay under about 6°, which "a few degrees" covers.

Earlier concerns: none. prior-reviews.json has no threads on this PR.

AGENTS.md

None found. The PR reaches the desktop and browser through the shared pane, and it leaves the CLI, Python, and assistant unchanged, as the PR body says. It adds no command, parameter, or schema change, so command-surface.txt and schema/project.schema.json need no update. The Terrain type label is wrapped in tl!.

I did not run the test suite, cargo fmt, or the wasm build, since I have no shell. I relied on the PR's stated local runs.

Change size

Compared with the base: the whole PR against main (merge base 8c46608 to PR head d067231).

Files changed Added Modified Removed Renamed Size before Size after Total size change
3 0 3 0 0 1.10 MB 1.10 MB +5.5 KB
Path Size before Size after Size change
crates/render/src/layout/tests.rs 449.2 KB 452.9 KB +3.8 KB
docs/user-guide/data.md 157.6 KB 158.7 KB +1.1 KB
crates/ui-egui/src/panes.rs 515.3 KB 515.6 KB +347 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3313/
Web app https://preview.rustgis.app/pr-3313/app/
Commit d067231

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

@elpidioassinaturas
elpidioassinaturas added this pull request to the merge queue Nov 29, 2026
Merged via the queue into opengeos:main with commit a378e9d Nov 29, 2026
28 checks passed
@elpidioassinaturas
elpidioassinaturas deleted the feat/3142-terrain-pane branch November 29, 2026 08:45
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.

[Feature]: Shaded Relief: a terrain type setting that brings out gentle relief without overdoing steep ground (or the reverse)

2 participants