Skip to content

fix(labels): keep a label's position and offset upright on a turned map - #3510

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3508-turned-label-offset
Dec 1, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3508-turned-label-offset

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On a turned or tilted map, a label class's offset pointed a different way depending on the place the label took: it turned with the map at a point's places, at a polygon's label without Try other places inside and around the polygon, and at its first places inside, but stayed upright at the places round a polygon and further inside it. The class's position turned the same way, so Above put a point's name beside it on a map turned 90 degrees.

Labels are placed in a north-up frame and then moved into the view shown. Position and offset were added in that frame, before the move. They are now added in the view shown, so they are the screen's at every place, as on a map north up.

  • On a map north up and untilted nothing changes.
  • On a turned map, position and offset are the screen's, including the eight places round a point.
  • On a tilted map the offset is its size in points on the screen, no longer shortened with the ground. Where the moved place has no ground under it (past the horizon), the label keeps the old offset.
  • A label square to a line still takes its offset along and across that direction.
  • Whether a point out of view still has its offset label in view is now measured in the view shown, where the offset is applied.

Testing

  • New tests in crates/render/src/polygon_labels_tests/offsets.rs. Run against main, the position and offset ones fail and the one pinning the square-to-a-line case, which doesn't change, passes. Two more pin a point out of a turned view and out of the far side of a tilted view that keeps its offset label.
  • cargo nextest run -p rustgis-render: 1196 passed, 1 skipped.
  • cargo fmt --all --check and cargo clippy -p rustgis-render --all-targets -- -D warnings: clean.

Surfaces

The change is in rustgis-render, so it reaches every place that draws a turned or tilted map: the desktop app, the browser, the touch interface, the command line, Python and turned map frames in layouts. No command, parameter or setting is added or changed, so the ribbon, command search, the Assistant and MCP, plugins and undo are unaffected.

UI evidence

Before (left) and after (right), on a map turned 90 degrees.

Cities with their position set to Above:

3508-position-above-before-after

Countries with an offset of 30 points to the right:

3508-offset-right-before-after

Related issue

Closes #3508

Summary by CodeRabbit

  • Bug Fixes
    • Label offsets now follow screen directions on turned or tilted maps, keeping placement and visibility more consistent.
  • Documentation
    • Clarified how label offsets behave on turned or tilted maps and for labels positioned relative to lines.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Label placement checks and offsets now use the displayed view for turned and tilted frames. New tests cover point and polygon placements across bearings and pitches. The user guide describes how offsets behave in those views and for labels placed relative to lines.

Changes: Label offsets in turned and tilted views

Layer / File(s) Summary
Map placement checks to the shown view
crates/render/src/lib.rs
The label pass maps positions into the displayed view and uses its dimensions for placement bounds and offset-reach checks.
Apply offsets in shown-view coordinates
crates/render/src/lib.rs
Offsets for turned or tilted frames are applied in shown-view coordinates and mapped back to frame coordinates. Later polygon placements use the same mapping.
Validate and document offset behavior
crates/render/src/polygon_labels_tests.rs, crates/render/src/polygon_labels_tests/offsets.rs, docs/user-guide/cartography.md
Tests cover offsets across bearings, pitches, and point and polygon placements. The guide states that offsets use screen coordinates on turned or tilted maps, line-square offsets follow the line direction, and offsets do not move labels along a line.

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

Change: Bug fix

Possibly related PRs

  • opengeos/RustGIS#3492: Adds around-polygon label positions that use the class offset and are upright in the displayed view.
  • opengeos/RustGIS#1025: Adds alternative point-label positions that use the class offset and move through turned and tilted views.

Suggested reviewers: giswqs, elpidioassinaturas, pick2510

Merge Risk: Minimal · up to db113

Label offsets now stay in screen directions on turned and tilted maps, and north-up maps are unchanged. No merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Requirement of #3508: the offset must point the same way at every label place on a turned map. The reproduction table gives four cases: point, polygon with other places off, polygon first inside place… Make the changed blobs for crates/render/src/lib.rs available at the reviewed head, or provide the whole-PR diff for that file. Confirm the label placement code applies position and offset in the displayed view's screen directions for turne…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the fix (labels) and the specific behavior (position and offset staying upright on a turned map). The raw summary and objectives say the change applies label position and offset in the…
Description check Passed The description follows the template. It has a Summary that explains the cause and the fix, a Testing section with new tests and command results, and a UI evidence section with before and after screen…
Out of Scope Changes check Passed The PR summary lists these changes: crates/render/src/lib.rs (offset and in-view placement logic), crates/render/src/polygon_labels_tests.rs (adds mod offsets), crates/render/src/polygon_labels_tests/…
Full details: Title check

Explanation

The title names the fix (labels) and the specific behavior (position and offset staying upright on a turned map). The raw summary and objectives say the change applies label position and offset in the displayed view on turned or tilted maps, so the title matches the main change. It is specific and concise.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the cause and the fix, a Testing section with new tests and command results, and a UI evidence section with before and after screenshots, which the template requires for visible changes. The Related issue section links to #3508. The template's comment asks for a "Closes #123" style reference, and the description uses "Closes #3508", so it matches. The sections are complete and specific.

Full details: Out of Scope Changes check

Explanation

The PR summary lists these changes: crates/render/src/lib.rs (offset and in-view placement logic), crates/render/src/polygon_labels_tests.rs (adds mod offsets), crates/render/src/polygon_labels_tests/offsets.rs (tests for the #3508 cases), and docs/user-guide/cartography.md (documents screen-relative label offsets). Each change connects to the offset and position behavior in #3508. The tests cover the reported cases and a square-to-line regression check. The PR says no command, parameter, or setting changes. I found no evidence of unrelated changes. The lib.rs body was not read, so this verdict rests on the summary and the test and doc files read.

Full details: Linked Issues check

Explanation

Requirement of #3508: the offset must point the same way at every label place on a turned map. The reproduction table gives four cases: point, polygon with other places off, polygon first inside place, and polygon places round it. The test file crates/render/src/polygon_labels_tests/offsets.rs encodes this requirement. It asserts that a 30-point right offset moves each place by (39.9, 0.0) at bearings 0, 90, 180 and 270. It covers point places, the polygon places inside and round it, and the square-to-line case. The PR summary says the change applies offsets in the displayed view's screen directions in crates/render/src/lib.rs. The code diff for lib.rs could not be read: the diff operation reported missing changed blobs, and a file read of lib.rs returned only the top of the module, truncated before the label placement code. The author's test and check results (1196 passed, 1 skipped) are self-reported and were not verified. I could not confirm from source that the placement code produces the required behavior, so compliance is not established.

Resolution

Make the changed blobs for crates/render/src/lib.rs available at the reviewed head, or provide the whole-PR diff for that file. Confirm the label placement code applies position and offset in the displayed view's screen directions for turned and tilted frames. Confirm that the offsets.rs tests pass at the reviewed head.

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 turns the map around,
And checks each label’s place and ground.
The offsets follow screen directions,
Tests check bearings and projections.
The rabbit hops, then reads the guide.

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: a3493edb-cfe1-4b3d-b0c8-0e318bb4c4da
Commits

Reviewing files that changed from the base of the PR and between 5453f49 and db11321.

Files selected for processing: 4

  • crates/render/src/lib.rs
  • crates/render/src/polygon_labels_tests.rs
  • crates/render/src/polygon_labels_tests/offsets.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; 6 remain after this review.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

I read the full diff, the changed render code in context, the area-label helpers, and the camera projection. I could not build or run the tests in this environment (no shell), so the findings below come from reading the code.

Bugs

  • None found. I traced the coordinate spaces through the change and they agree. pole() returns (frame, shown). shown_rings() and around() produce shown-view rings. search_origin, left/top/right/bottom and the later grid use nudged in the shown view and then slot/from_shown. first, the lock anchors and on_map stay in the frame. Confidence: high.
  • The (0, 0) default for (x, y) when there is no point only reaches place() on paths that either continue or are overwritten. Moved labels use moved directly, so they are not affected. Confidence: medium-high.

Security

  • None. The change is pure label geometry; it adds no parsing or I/O.

Performance

  • Negligible. Each candidate place now adds two camera transforms, and off-view culling adds one to_shown per feature when offset_reach > 0. Confidence: high that this doesn't matter in practice.

Quality

  • crates/render/src/lib.rs (cull filter, around line 6322): the frame point is cast to f32 and back before the view bounds check. This is harmless at map scales, but ctx.screen(c) is f64 and to_shown could take f64 directly. Nit, low impact. Confidence: medium.
  • crates/render/src/lib.rs (place_at, around line 6452): when a moved place has no counterpart, the offset falls back to the frame's north-up nudge. The PR documents this, and I agree it is intentional, so I am not flagging it as a bug. Confidence the behaviour is as described: high.
  • Test coverage gap (low priority): no test covers Labels::Tilted combined with a lock at a later place (locked_later), or the Labels::Shared path. The existing tests cover the main turned and tilted cases. Confidence: medium.
  • docs/user-guide/cartography.md (around lines 324–327): the paragraph is re-wrapped unevenly, so a few lines are much shorter than the rest. Cosmetic only.

AGENTS.md

  • None. No unwrap/expect in non-test code (clippy.toml allows them in tests). No new commands, parameters or saved fields, so command-surface.txt and schema/ are not affected. No wasm or cfg branches are touched. No new layer data is stored, so the memory-multiple note is not needed.
  • Twins: I searched for every other place the label offset or placement is applied (.offset(bw, offset[0] * 1.33, offset[1] * 1.33). The only sites are the ones in this diff, so there is no missed twin. The square-to-line branch (around line 6716) computes its offset in the frame, which is the intended "turns with the line" behaviour that the PR says it keeps.

No inline comments were posted. All findings above are nits or confidence notes, so I grouped them here rather than posting them one by one.

Prior reviews: 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 5453f49 to PR head db11321).

Measure Value
Files changed 4 (1 added, 3 modified, 0 removed, 0 renamed)
Size before 1072.2 KB
Size after 1079.4 KB
Total size change +7.2 KB
File Before After Change
crates/render/src/polygon_labels_tests/offsets.rs 0 B 6.0 KB +6.0 KB
crates/render/src/lib.rs 941.9 KB 942.9 KB +1.0 KB
docs/user-guide/cartography.md 80.9 KB 81.0 KB +155 B
crates/render/src/polygon_labels_tests.rs 49.4 KB 49.4 KB +14 B

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3510/
Web app https://preview.rustgis.app/pr-3510/app/
Commit db11321

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 added this pull request to the merge queue Dec 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 1, 2026
@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Dec 1, 2026
Merged via the queue into opengeos:main with commit 26cd32e Dec 1, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3508-turned-label-offset branch December 1, 2026 10:28
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.

[Bug]: On a turned map, a polygon label's later places apply the class offset upright, while its first place turns it with the map

1 participant