Skip to content

feat(labels): set a point layer's obstacle weight in the Labeling pane (#3526) - #3609

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/3526-obstacle-weight-pane
Dec 2, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/3526-obstacle-weight-pane

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #3526. #3531 made a point layer's points obstacles for labels, with an obstacle weight set by command only. This adds the pane row for it.

  • Labeling pane › Position: a row "Labels keep off these points: weight" under Weight, 0 to 10 (0: no obstacle), written when the drag or typing is let go, one undo step, as Weight is.
  • It is the layer's, so every class of the layer shows the same value; the class's own Weight is not touched.
  • Shown only where the engine takes the value: a layer with points that isn't a graphics, cluster or heat map layer. Lines and polygons have no row until they are obstacles ([Feature]: Label placement: candidate positions, conflicts, obstacles and fitting #995 steps 5b and 5c).
  • One rule for where the value is taken: Layer::takes_obstacle_weight() (points, not a graphics, cluster or heat map layer) now serves labels.placement's refusal and the pane's row; the engine's messages are the same.
  • User guide: the obstacle weight paragraph now names the pane.

Surfaces: the desktop pane only. The web app shares the pane; the command, CLI, Python, the Assistant and the saved project are unchanged (the weight, its command and its label-obstacles capability are #3531's). Undo: one step per change.

Not in this PR: a layer that already holds a weight and then becomes a cluster or heat map layer keeps it with the row hidden; it is inert there (such a layer draws no points), but a saved project still requires label-obstacles while it holds one. labels.placement with obstacleWeight: 0 clears it.

Testing

  • an_obstacle_weight_is_set_in_the_pane (new): shows the layer's weight, typing sets it in one undo step, the class's weight is unchanged, no row for lines, polygons, a cluster layer or a graphics layer, and the row comes back for points.
  • checks.sh for rustgis-ui-egui: fmt, clippy, doctests, layers and schema green. nextest: 12180 of 12188 pass; the 8 failures (7 in rustgis-geolibre, line_strokes_editor_edits_one_class) fail the same on main on this machine.
  • After the last changes (the shared rule, the wider test): fmt, clippy of rustgis-map, rustgis-engine and rustgis-ui-egui, and the 55 obstacle and pane tests, green.
  • ui_shot replay of the pane with Cities at weight 4.

UI evidence

After (new UI): the new row under Weight, Cities at 4.

3526-obstacle-weight-row.png

Related issue

Closes #3526 (its PR 1 is #3531).

Summary by CodeRabbit

  • New Features
    • Added an obstacle weight control under Position for layers with points. The setting applies to all classes in the layer and can also be configured with a command.
  • Bug Fixes
    • Positive obstacle weights are now accepted only for supported point layers; zero remains valid for all layers.
  • Documentation
    • Clarified where to find the obstacle weight setting and how it applies across a layer.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change defines which layers support obstacle weight, updates command validation to use that eligibility rule, and adds a layer-scoped control in the labeling pane. Tests cover the control’s visibility and updates. User documentation describes its location and scope.

Changes: Point Obstacle Weight

Layer / File(s) Summary
Layer eligibility and command validation
crates/map/src/lib.rs, crates/engine/src/cmd/labels.rs
Layer::takes_obstacle_weight() returns true for non-graphics point layers without aggregation. labels.placement uses this method to reject positive values for ineligible layers with case-specific errors.
Labeling pane control and documentation
crates/ui-egui/src/labelpane.rs, docs/user-guide/cartography.md
The pane displays and updates obstacle weight for eligible layers. Tests check the control, value update, undo step, and unchanged class weight. Documentation describes the control’s location, layer scope, and point-avoidance behavior.

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

Change: Feature

Possibly related issues

  • Issue 995 — Its proposed layer obstacle weight covers a broader feature set; this change adds the labeling pane control for point obstacle weight.

Possibly related PRs

  • opengeos/RustGIS#3531 — Adds the point-layer obstacle-weight value and command that this change edits through the labeling pane.

Suggested reviewers: pick2510, giswqs

Merge Risk: Minimal · up to 7bd71

This adds a Labeling pane row for point-obstacle weight on eligible point layers. It reuses the same eligibility rule as the command. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a point layer's obstacle weight can now be set from the Labeling pane. It matches the changeset, which adds the pane row, the shared takes_obstacle_weight rule, and th…
Description check Passed The description follows the template. It has Summary, Testing, UI evidence (with an after screenshot, which fits the new UI), and Related issue (Closes #3526). The Testing section lists the new test, …
Linked Issues check Passed Directly linked issue #3526 is open. Its coding requirements for this step are the Labeling pane row for the per-layer obstacle weight (0 to 10, 0 by default), written on settle, with one undo step pe…
Out of Scope Changes check Passed All changed areas connect to the pane row objective of #3526:
- crates/ui-egui/src/labelpane.rs: the new pane row and its test. In scope.
- crates/map/src/lib.rs: Layer::takes_obstacle_weight(). The P…
Full details: Title check

Explanation

The title names the main change: a point layer's obstacle weight can now be set from the Labeling pane. It matches the changeset, which adds the pane row, the shared takes_obstacle_weight rule, and the user guide update. The title is specific and follows the conventional commit form. Its length (78 characters) is acceptable.

Full details: Description check

Explanation

The description follows the template. It has Summary, Testing, UI evidence (with an after screenshot, which fits the new UI), and Related issue (Closes #3526). The Testing section lists the new test, checks run, and the known unrelated failures. The UI evidence section contains a screenshot instead of the 'No visible UI change' line, which is correct for this PR. The description is complete and specific.

Full details: Linked Issues check

Explanation

Directly linked issue #3526 is open. Its coding requirements for this step are the Labeling pane row for the per-layer obstacle weight (0 to 10, 0 by default), written on settle, with one undo step per change. The engine behavior (setting, rule, capability, command validation) is delivered by #3531, which is in the merge base, so this PR does not need to reimplement it.

Evidence from the whole-PR summary (merge base 8beac7b to head 7bd7110):

  • crates/ui-egui/src/labelpane.rs: in the Position section under Weight, a layer-scoped control for points. It is initialized from l.labels.obstacle_weight. A settled drag or edit runs labels.placement with obstacleWeight when the rounded value changes. Test an_obstacle_weight_is_set_in_the_pane covers display, one-step undo, unchanged class weight, and row visibility for lines, polygons, cluster and graphics layers.
  • crates/map/src/lib.rs: Layer::takes_obstacle_weight() defines the row visibility rule (point geometry, not graphics, no aggregation), as the issue requires for point layers only.
  • docs/user-guide/cartography.md: documents the control under Position, beneath Weight.

Not verified by reading source: the clamping of input to 0 to 10 and the exact notice text. The summary states the 0 to 10 range but does not show the clamp code. The issue's engine rows (for example, placement rules, undo, locked labels, export) rely on #3531 and were not re-read here.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to the pane row objective of #3526:

  • crates/ui-egui/src/labelpane.rs: the new pane row and its test. In scope.
  • crates/map/src/lib.rs: Layer::takes_obstacle_weight(). The PR uses it as the one shared rule for the pane row and the labels.placement refusal. This is a supporting change for the row's visibility rule. In scope.
  • crates/engine/src/cmd/labels.rs: labels.placement now resolves the layer first and uses takes_obstacle_weight() for the refusal. The PR states that engine messages are unchanged. This is a refactor that keeps the shared rule in one place. Its ordering change of checks is a minor behavior detail; the summary does not show a change in accepted or rejected inputs beyond the case-specific error. Supporting refactor, in scope.
  • docs/user-guide/cartography.md: documents the pane row. In scope.

No change adds command, CLI, Python, Assistant, or saved-project behavior, which the PR description excludes. No demonstrated unrelated change was found.

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 checks the point-layer pane,
Then taps a weight with careful aim.
The labels leave the points some room,
The docs show where the controls bloom.
One undo waits if edits change,
And carrots mark the settings range.

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: 871e9b83-ce2f-4d26-9c84-6cd3f36d1932
Commits

Reviewing files that changed from the base of the PR and between ad8c2f3 and 7bd7110.

Files selected for processing: 4

  • crates/engine/src/cmd/labels.rs
  • crates/map/src/lib.rs
  • crates/ui-egui/src/labelpane.rs
  • docs/user-guide/cartography.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.

ui.end_row();
// The layer's points as obstacles (#3526), for the layers the engine takes it for, whatever
// the class shown; 0 is none.
if l.takes_obstacle_weight() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A layer that already holds an obstacle weight and then stops taking one (it becomes a cluster or heat map layer, or a graphics layer) loses its row, so the user can't see or clear the weight from the pane. The weight stays saved, and the project keeps requiring label-obstacles on that account, so the requirement has no visible cause. The PR describes this as a known limit, so this is a follow-up, not a blocker. A small fix is to keep the row while a weight is set, so it can be set to 0 (which labels.placement always accepts):

Suggested change
if l.takes_obstacle_weight() {
if l.takes_obstacle_weight() || l.labels.obstacle_weight > 0 {

Category: quality

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues, or AGENTS.md violations in this PR. One quality follow-up is posted inline.

Bugs: none found.

  • The engine refusal in crates/engine/src/cmd/labels.rs:292 keeps the old three messages and their order. It now calls Layer::takes_obstacle_weight() (crates/map/src/lib.rs:1420). That predicate matches the old checks: has_geometry(Point), !graphics, aggregation.is_none(). has_geometry is the same call held_geometries already made for points.
  • The pane's row (labelpane.rs:1025-1042) writes through labels.placement, so it is one undo step. It shares the command's rule, so the row and the refusal can't disagree.
  • label_weight clamps and rounds, and the comparison against l.labels.obstacle_weight is type-consistent (both u8).
  • Engine tests in crates/engine/src/tests/label_obstacles.rs:61-75 still cover the graphics and cluster refusals.

Security: none found. The change adds no input parsing and no new external data.

Performance: none found. The row adds one takes_obstacle_weight() call per frame, and that is cheap.

Quality:

  • Inline, labelpane.rs:1025: a layer that keeps a stale obstacle weight after becoming a cluster, heat map or graphics layer loses its row. The weight can't be seen or cleared from the pane, and the project keeps requiring label-obstacles. The PR already lists this as a known limit. I suggested keeping the row while a weight is set. Confidence: medium.
  • Nit (not posted): takes_obstacle_weight has no unit test in the map crate. The pane and engine tests cover it indirectly, which is enough for this PR.

Surfaces and twins:

  • The command, its refusal messages and the saved format are unchanged, so the CLI, Python, the Assistant and command-surface.txt need no change. The PR says so.
  • The user guide (docs/user-guide/cartography.md) matches the new row.
  • No #[cfg(target_arch = "wasm32")] branch is touched. ui-egui and map are shared with the web build, and the new code uses no desktop-only API.
  • Twins checked: the labels.placement obstacle path is the only writer of obstacle_weight in the diff's scope. The render and project-capability readers (render/src/lib.rs:4235, project_capabilities.rs:76, 441, 1730) read the stored value and need no change.

Prior concerns: none. prior-reviews.json has no threads, so I left none alone.

Change size

Compared with the base branch: the whole PR against main (merge base 8beac7b to PR head 7bd7110).

Measure Value
Files changed 4 (0 added, 4 modified, 0 removed, 0 renamed)
Size before 596.3 KB
Size after 601.5 KB
Total size change +5.2 KB
Path Before After Change
crates/ui-egui/src/labelpane.rs 142.4 KB 147.0 KB +4.6 KB
crates/map/src/lib.rs 295.3 KB 295.7 KB +442 B
docs/user-guide/cartography.md 82.8 KB 82.9 KB +133 B
crates/engine/src/cmd/labels.rs 75.8 KB 75.8 KB −9 B

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3609/
Web app https://preview.rustgis.app/pr-3609/app/
Commit 7bd7110

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

@jgregoriorincon
jgregoriorincon marked this pull request as ready for review December 2, 2026 13:55
.on_hover_text(tl!(
"A label whose class's weight isn't above this isn't placed over one of this layer's points, except its own feature's. 0: the points are no obstacle."
));
if drag.settled(ui, &r, &mut v) && label_weight(v) != l.labels.obstacle_weight {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low-confidence nit: label_weight maps a non-finite value to DEFAULT_LABEL_WEIGHT (5), but the obstacle weight's default is 0. The Weight row has the same fallback. A non-finite value is unlikely to reach this drag, but if it did, this row would write 5 to the layer, which turns on an obstacle the user never set. Skipping non-finite values here avoids that.

Suggested change
if drag.settled(ui, &r, &mut v) && label_weight(v) != l.labels.obstacle_weight {
if drag.settled(ui, &r, &mut v) && v.is_finite() && label_weight(v) != l.labels.obstacle_weight {

Category: quality

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

I read the four changed files, the diff, and the surrounding code in crates/map, crates/render and crates/engine. I could not build or run the tests here, so the findings below come from reading the code.

Bugs

None found. The engine's labels.placement refactor keeps the old behaviour. held_geometries used has_geometry(Point), which is what takes_obstacle_weight() now uses. The three refusal messages are checked in the same order as before (lines, then graphics, then cluster or heat map). Confidence: high.

Security

None found.

Performance

None found. takes_obstacle_weight() runs every frame in the pane, but has_geometry goes through the allocation-keyed geometry_kinds memo, so it does not rescan features each frame. Confidence: medium-high.

Quality

  • Non-finite fallback in the obstacle row (inline at labelpane.rs:1037): label_weight maps NaN to 5, not 0, so a non-finite value would turn an obstacle on. The Weight row has the same pattern, and the input is unlikely to produce NaN. Confidence: low.
  • Not re-raised: the existing thread at labelpane.rs:1025 says a layer that stops taking a weight loses its row. The code is unchanged and the thread is not outdated, so I left it alone. The PR calls this a known limit. Confidence in the concern: high.
  • Not verified: the new control is in the Labeling pane's Position section. AGENTS.md requires the every_control_can_be_reached_* tests to cover new controls. The PR reports checks.sh green apart from 8 failures that also occur on main, so it probably passes, but I could not confirm it.

AGENTS.md

No breaks found. Checks against the rules:

  • Never silent: no new loss. The stored weight on a layer that stops taking one is covered by the existing thread.
  • Expression and command surface: no new parameter, so command-surface.txt is unaffected.
  • Schema: nothing new is saved, so schema/project.schema.json is unaffected.
  • Translation: the new strings use tl!.
  • Surfaces: the PR body states which surfaces it reaches and why the rest don't apply.

Twins checked

  • Renderer obstacle gathering (crates/render/src/lib.rs:4235, 6351): it checks aggregation, graphics and upright directly and works from the points it draws. It does not need the new rule.
  • project_capabilities.rs:76, 1730: the label-obstacles requirement uses the stored weight on any layer type. That matches the known limit in the existing thread.
  • Weight and clearance rows: they use the same drag pattern and the same label_weight or label_clearance clamp.

Change size

Compared with the base branch (merge base 8beac7b to PR head 7bd7110). Sizes are file sizes from stats.json.

Measure Value
Files changed 4 (0 added, 4 modified, 0 removed, 0 renamed)
Size before 596.3 KB
Size after 601.5 KB
Total size change +5.2 KB
File Before After Change
crates/ui-egui/src/labelpane.rs 142.4 KB 147.0 KB +4.6 KB
crates/map/src/lib.rs 295.3 KB 295.8 KB +442 B
docs/user-guide/cartography.md 82.8 KB 82.9 KB +133 B
crates/engine/src/cmd/labels.rs 75.8 KB 75.8 KB -9 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Dec 2, 2026
Merged via the queue into opengeos:main with commit db12d1c Dec 2, 2026
29 checks passed
@jgregoriorincon
jgregoriorincon deleted the feat/3526-obstacle-weight-pane branch December 2, 2026 14:54
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]: Labels keep off a point layer's points, with an obstacle weight per layer (step 5a of #995)

1 participant