Skip to content

test(render): keep polygon label blockers clear of neighbouring places - #3587

Merged
Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/polygon-label-windows
Dec 2, 2026
Merged

Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/polygon-label-windows

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

The polygon-placement order test fails with Segoe UI on both Windows runners and with the built-in Ubuntu Light font. At a 30-degree tilt, its normal-size interior blocker also covers the last bottom candidate, so the test reports seven outside positions although the renderer generates all eight.

Use small blockers for this fixture, addressed by their returned layer IDs, covering each chosen position without hiding its neighbours. An assertion keeps the polygon label at its original size. The expected eight-position order is unchanged. This changes one test; desktop, browser, CLI, Python, phone and command behavior are unchanged.

Testing

  • Full fork Linux CI passed, including lint, workspace tests and the wasm gate: https://github.com/Mavrick-F/RustGIS/actions/runs/46797747757
  • Reproduced the original test failure locally with RUSTGIS_BUILTIN_FONTS=1; the installed server font passes the original test.
  • The updated test and helpers, extracted into a scratch-only executable against the real renderer, pass all four bearing/pitch cases under both font choices. Restoring the wrong-layer write fails the new polygon-size assertion (2 instead of 10).
  • Same-font probe wall time, three fresh processes per case: median 1.35 s with the failing fixture and 2.16 s with the passing fixture. The corrected fixture reaches the additional candidate and final unplaced frame. No new test case or CI job.
  • Formatting and local contribution preflight passed. Windows checks requested.

UI evidence

No visible UI change.

Related issue

Unblocks #2931; the identical Windows assertion also fails on main.

Summary by CodeRabbit

  • Tests
    • Updated polygon-label placement checks to evaluate candidate positions explicitly, enforce the 24-position limit, and verify that changing a blocker label’s size leaves the polygon label size unchanged. Checks for outside placements using the ROUND setting are retained. These updates affect validation coverage only; no end-user-visible behavior changes are included.

@Mavrick-F Mavrick-F added the ci:windows Run the Windows CI jobs on this pull request label Dec 2, 2026
@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 polygon-corner placement test now records candidate positions directly, blocks each candidate, and checks that the polygon label size remains 10.0. The blocker helpers return the IDs of the layers they create.

Changes: Polygon label placement

Layer / File(s) Summary
Candidate placement and blocking
crates/render/src/polygon_labels_tests.rs
The blocker helpers return the IDs of created layers. The test records up to 24 candidate positions, blocks each with a label size of 2.0, and checks that the polygon label size remains 10.0. The existing side-order assertion remains unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#3492: This PR adds the polygon placement order that the updated test fixture exercises.

Suggested reviewers: jgregoriorincon

Merge Risk: Minimal · up to 095ae

This change only adjusts a test fixture so the polygon-placement order test checks all eight candidate positions. It does not change shipped behavior, and no merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change accurately: the test fixture in polygon label tests now uses blockers that stay clear of neighbouring place candidates. The raw summary confirms the fixture now uses a small…
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.
Description check Passed The description is thorough and follows the template. It has a clear Summary explaining the failure on Segoe UI and Ubuntu Light fonts at a 30-degree tilt, and the fix of using small blockers addresse…
Full details: Title check

Explanation

The title names the change accurately: the test fixture in polygon label tests now uses blockers that stay clear of neighbouring place candidates. The raw summary confirms the fixture now uses a smaller blocker size (2.0) and returns the blocker ID, which matches the 'keep blockers clear' wording. The 'test(render)' prefix follows the conventional-commit style and names the affected crate. The title is 70 characters, slightly over a typical 50-72 range but still within limits. It is specific and does not use vague terms.

Full details: Description check

Explanation

The description is thorough and follows the template. It has a clear Summary explaining the failure on Segoe UI and Ubuntu Light fonts at a 30-degree tilt, and the fix of using small blockers addressed by returned layer IDs with an assertion that the polygon label keeps its size. The Testing section lists CI, local reproduction, a scratch probe, timing data, and a pending Windows check. The UI evidence section correctly states 'No visible UI change.' The Related issue section names #2931. The description does not reference a CI run link that matches the objectives (the description links runs/46797747757 while the objectives cite runs/46792664094), which is a minor inconsistency worth reviewing, but the template sections are all filled in.

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 counts each corner’s place,
Then sets a blocker in the space.
The labels keep their measured size,
While twenty-four candidates arise.
The sides still follow their order.

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: 95e074e6-c58e-4b77-8fee-24e49770e202
Commits

Reviewing files that changed from the base of the PR and between e9df031 and 095ae6a.

Files selected for processing: 1

  • crates/render/src/polygon_labels_tests.rs

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

// Cover this place, not its neighbours: at a tilt the inside label point can be
// close enough to the bottom edge that a normal-size blocker also hides the last
// outside place with some fonts (Segoe UI and the built-in Ubuntu Light).
m.layers.last_mut().unwrap().labels.default.size = 2.0;

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.

This write hits the wrong layer, so the blocker is still normal size and the Lake label is shrunk instead.

Map::insert_on_top (crates/map/src/lib.rs:3254) does self.layers.insert(0, layer), so the newest layer is at index 0, not the end. block adds the blocker through add_dataset, which calls insert_on_top, so the stack after the first block is [blocker, Lake]. Map::new starts with no layers (lib.rs:2511), so m.layers.last_mut() returns the Lake layer. The line therefore sets the Lake label's font size (symbology.rs:3013) to 2.0 on every pass, and the blocker keeps its default size. The fixture no longer does what the comment says, and the test's subject (the Lake label's size) has changed, so a passing result doesn't show the blocker fix works. I haven't been able to run the test here, so I can't say whether it passes by accident.

Suggested fix (the top of the stack is first_mut):

Suggested change
m.layers.last_mut().unwrap().labels.default.size = 2.0;
m.layers.first_mut().unwrap().labels.default.size = 2.0;

Consider also setting the blocker size inside block/block_at (the layer id is known there), so the test doesn't depend on layer order.

Category: bug

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 095ae6a. block and block_at now return the inserted layer's ID, and this fixture resizes that exact blocker. An assertion verifies that the polygon label remains at size 10. Restoring the old last_mut write fails that assertion (2 versus 10); the corrected fixture passes with both the built-in and installed fonts. The full Linux fork gate passed on this head.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • Wrong layer is resized (high confidence, posted inline at crates/render/src/polygon_labels_tests.rs:809). insert_on_top inserts at index 0, so m.layers.last_mut() returns the Lake polygon layer, not the blocker block() just added. The write shrinks the Lake label's font to 2.0 and leaves the blocker at its normal size, which is the problem the PR is meant to fix. The suggested fix is m.layers.first_mut(). I could not run the test here (no shell), so I can't say whether it passes by accident.

Security

  • None found in this change.

Performance

  • None found. The loop is bounded by the existing taken.len() < 24 guard.

Quality

  • Nit: the new loop duplicates every_place with a different blocker size. A size parameter on every_place would avoid the copy. Left for the release quality pass.
  • Nit: a size set by position after block() is fragile. Setting it inside block/block_at would be clearer.

AGENTS.md

  • None found. The change is test-only and adds no new command, layer, or platform code.

Checked

  • every_place still has many callers, so the change doesn't leave dead code that would fail -D warnings.
  • Map::new starts with no layers and add_dataset goes through insert_on_top, which is what the bug finding relies on.
  • No earlier review threads exist on this PR, so nothing was skipped as already raised.

Change size

Compared with main (merge base bd87062 to PR head e9df031).

Files changed Added Modified Removed Renamed
1 0 1 0 0
Size before Size after Total change
49.4 KB 49.9 KB +526 B
Path Size before Size after Size change
crates/render/src/polygon_labels_tests.rs 49.4 KB 49.9 KB +526 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-3587/
Web app https://preview.rustgis.app/pr-3587/app/
Commit 095ae6a

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

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

I reviewed the one-file change to crates/render/src/polygon_labels_tests.rs against pr-context/AGENTS.md, the prior thread, and the surrounding helpers (every_place, places, Map::add_dataset, insert_on_top, layer_mut). I could not build or run the tests here, so the Windows and font claims are taken from the PR description.

Bugs: None found. The earlier wrong-layer write (last_mut, which hits the Lake label because insert_on_top puts new layers at index 0) is fixed. block and block_at now return the id from add_dataset, and the edit goes through layer_mut(blocker). The while let loop is bounded by assert!(taken.len() < 24), and the places result owns its data, so the borrow of m is fine. Confidence: high.

Security: None. Test-only change.

Performance: None. The test now runs one render per place, which the PR measured as roughly 1.35 s to 2.16 s per process.

Quality:

  • The new loop at polygon_labels_tests.rs:803 duplicates every_place (line 125), differing only in the small blocker and the size assertion. Posted as an inline comment. Confidence: high. Quality pass.
  • The literals 2.0 and 10.0 (lines 810 and 811) could be named constants. Nit, confidence: high.

Twins: The PR fixes only the test at line 797. The tilted test around lines 1061–1100 (pitch 30, every_place with normal-size blockers) has the same blocker-covers-neighbour exposure to font metrics. I did not verify it, and the PR does not mention it. It is outside the diff, so I did not post an inline comment. Confidence: medium-low. The author may want to confirm that this test passes with Segoe UI or the built-in Ubuntu Light font.

AGENTS.md: No breaks found. The change is test-only, so the never-crash, never-silent and wasm rules do not apply. The new assert_eq! sides are distinct tokens, and the loop has no timer waits.

Prior reviews: One thread from github-actions (the wrong-layer write). The author fixed it in 095ae6a and replied, and the thread is marked outdated. I did not re-raise it. Concerns left alone: 1.

Change size

Compared with the base branch: the whole PR against main (merge base bd87062 to PR head 095ae6a).

Measure Value
Files changed 1 (added 0, modified 1, removed 0, renamed 0)
Size before 49.4 KB
Size after 50.1 KB
Total size change +690 B
Path Before After Change
crates/render/src/polygon_labels_tests.rs 49.4 KB 50.1 KB +690 B

@Mavrick-F

Copy link
Copy Markdown
Member Author

The inside-placement twin, with_both_places_inside_taken_a_name_that_fits_goes_to_more_places_inside, passed with Segoe UI in both the main Windows run and #2931's Windows run. Its candidate spacing is measured from the label's width/height plus clearance, and it checks only admissible inside positions. The fixed outside-placement fixture instead requires all eight positions around the polygon. Windows result.

Helper deduplication and named size constants are left for the release quality pass.

@Mavrick-F
Mavrick-F added this pull request to the merge queue Dec 2, 2026
Merged via the queue into opengeos:main with commit 4aafdfc Dec 2, 2026
34 checks passed
@Mavrick-F
Mavrick-F deleted the fix/polygon-label-windows branch December 2, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:windows Run the Windows CI jobs on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant