Skip to content

fix(layout): a publication's map isn't moved toward a pole and drawn smaller for the legend's room (#3514) - #3566

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3514-publication-move-keeps-size
Dec 1, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3514-publication-move-keeps-size

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3514

What changed

layout.publication tries moving the map aside for the legend's room. A move changes the ground scale the
frame is drawn at where the projection stretches (Web Mercator with the latitude), and the only check was
that the extent stayed inside the frame's margins, which a shrunken extent passes easily. On a world extent
with a one-column legend the map was moved toward a pole and drawn at about a tenth of its size, with nothing said.

A move that would draw the extent more than 20 % larger or smaller (MOVE_SIZE_CHANGE, 1 - 1/1.25: the step the
search already zooms out by, said) is no longer made. Moves a high-latitude extent keeps today (Europe, a Nordic
extent: #1379's tests) are unchanged; at 10 % they are refused.

Reach

Shared engine code behind layout.publication, so desktop, browser, CLI, Python, the Assistant/MCP and plugins
get it; no command, parameter, answer field or project format changes, so there is no ribbon, undo or schema entry.

Testing

  • New a_move_for_the_legends_room_does_not_shrink_the_extent_toward_a_pole (a4-portrait, a5-portrait,
    thesis-full): red on main (the frame's centre drew the extent at 0.10 of its size), green here.
  • cargo test -p rustgis-engine: the Europe and north/south move tests still pass. fmt, clippy, layers, schema green;
    8 tests fail on main too (7 geolibre, 1 smoke).
  • Manual: issue's call before/after, below.

project.sample, then layout.publication {"profile": "a4-portrait", "extent": [-111.5, -16.6, 146.5, 62.6], "legend": {"columns": 1}} (headless ui_shot).

Before (main):

before

After:

after

Strings: none added.

Summary by CodeRabbit

  • Bug Fixes

    • Map frames moved to make room for a legend now retain a similar drawn size: moves that change the size by more than 20% are not made.
  • Documentation

    • Clarified how map scale and frame size are handled when making room for a legend.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Publication layout placement now rejects a nonzero map move when it fails the frame-margin check or changes the extent’s drawn size by more than 20%. A regression test covers three profiles, and the user guide describes the updated scale rule.

Changes: Publication map move constraint

Layer / File(s) Summary
Check moved map size
crates/engine/src/cmd/layout/publication/mod.rs, crates/engine/src/tests.rs, crates/engine/src/tests/layout_publication_moves.rs, docs/user-guide/layouts.md
The placement search compares ground scales at the original and candidate centers. It rejects moves that fail the margin check or change the extent’s drawn size by more than 20%. The regression test checks three profiles, and the user guide documents the constraint.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: giswqs, elpidioassinaturas

Merge Risk: Minimal · up to 5a974

This change stops publication layouts from shrinking the map toward a pole when it moves for legend space. No merge-blocking risk was found, and the new regression test and docs cover the behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: layout.publication no longer moves a map toward a pole and draws it smaller to make room for the legend. It matches the changeset, which adds a 20% size-change check (…
Description check Passed The description follows the template. It has a Summary that explains the change and why it was made, a Testing section with the new regression test, the full cargo test results, and before/after scree…
Linked Issues check Passed Issue #3514 requires that a layout.publication move for legend room is not made when it changes how large the extent is drawn beyond a small tolerance. The PR's summary describes a new check in crates…
Out of Scope Changes check Passed All changed files relate to #3514. The mod.rs change adds the size-ratio check and constant for the legend-room move. The new test module in crates/engine/src/tests.rs and tests/layout_publication_mov…
Full details: Title check

Explanation

The title names the main change: layout.publication no longer moves a map toward a pole and draws it smaller to make room for the legend. It matches the changeset, which adds a 20% size-change check (MOVE_SIZE_CHANGE) to the map-placement search. The title is specific and follows the conventional fix(scope) form.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the change and why it was made, a Testing section with the new regression test, the full cargo test results, and before/after screenshots, and a Related issue line (Closes #3514). The UI evidence section is filled with before and after images. The template says the section should read 'No visible UI change' when nothing is visible, but this change does alter the rendered map, so the screenshots are the correct content. The description is complete.

Full details: Linked Issues check

Explanation

Issue #3514 requires that a layout.publication move for legend room is not made when it changes how large the extent is drawn beyond a small tolerance. The PR's summary describes a new check in crates/engine/src/cmd/layout/publication/mod.rs: a nonzero move is rejected when the drawn-size ratio exceeds MOVE_SIZE_CHANGE (0.20). The new test layout_publication_moves.rs::a_move_for_the_legends_room_does_not_shrink_the_extent_toward_a_pole, present at head, covers a4-portrait, a5-portrait and thesis-full with the issue's extent and a one-column legend. It asserts the legend stays in one column with no veil or map shift, that the reported scale matches the centred layout, and that the frame-centre stretch is within 0.20 of 1. These assertions match the issue's expected behaviour. Limitation: the mod.rs diff and the MOVE_SIZE_CHANGE declaration could not be read at head (diff unavailable; the file read was truncated before the placement search). The implementation is therefore supported by the test assertions and the PR summary, not by direct reading of the check.

Full details: Out of Scope Changes check

Explanation

All changed files relate to #3514. The mod.rs change adds the size-ratio check and constant for the legend-room move. The new test module in crates/engine/src/tests.rs and tests/layout_publication_moves.rs covers that move. The docs/user-guide/layouts.md edit states the new 20% rule for the moved frame. The PR reports no new commands, parameters, answer fields, strings or project-format changes. No unrelated change was identified in the available evidence. The mod.rs hunks were not directly readable, so this verdict relies on the PR summary for that file.

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 map’s new place,
And keeps its scale within its space.
If size shifts past twenty percent,
The map stays put; the move is spent.
Three profiles hop through the test,
The guide tells readers what is best.

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: 535d33c3-9851-4d7b-bedd-64465371f9dd
Commits

Reviewing files that changed from the base of the PR and between 2e238c0 and 5a974bb.

Files selected for processing: 4

  • crates/engine/src/cmd/layout/publication/mod.rs
  • crates/engine/src/tests.rs
  • crates/engine/src/tests/layout_publication_moves.rs
  • docs/user-guide/layouts.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

No bugs, security issues, or AGENTS.md breaks found. I could not build or run the tests (no shell here), so the fix and the new test are checked by reading only.

Bugs: none found. I checked the new size_change gate against the existing drift value and the continue paths. size_change is the same ratio that drift already used, so only the new refusal changes behaviour. The ratio is ground_here / ground_at, and Web Mercator's ground scale shrinks toward the poles, so the test's stretch is the drawn-size ratio. The 20 % bound is symmetric as the docs state.

  • Open question, low confidence (about 40 %), not verified: for a figure (sheet false), a move the new gate refuses leaves no further scale to try, so the legend falls back to the centred place. Before this change that case moved the map silently. I did not confirm whether that fallback is said. If it is not, the "never silent" rule applies to the newly reachable path.

Security: none.

Performance: none. The added work is one division per candidate move.

Quality:

  • The test hard-codes 0.20 and asks a reader to keep it equal to MOVE_SIZE_CHANGE by hand (inline comment on layout_publication_moves.rs:38).
  • The test covers one extent and three profiles. It does not exercise the sheet zoom-out path or the figure no-move path.

AGENTS.md: no breaks. The change touches no command surface, schema, or saved format. The test's unwrap and panic! are in test code, which the rules allow. The docs and the constant's comment agree with the code. The change is shared engine code, so every surface gets it.

Twins checked: the change is confined to layout.publication. The sibling functions in publication/area.rs, layout/frame.rs and qgis.rs compute scale or extent but do no move search, so none needs the same change. The layer.add*, overlay-tool and project.open* families are not involved, and the diff touches no wasm32 branch.

Earlier concerns: none. prior-reviews.json has no threads, so nothing was left alone for that reason.

Change size

Compared with the base branch: the whole PR, merge base 342ebb8 to head 5a974bb.

Measure Value
Files changed 4 (1 added, 3 modified, 0 removed, 0 renamed)
Size before 4.1 MB
Size after 4.1 MB
Total size change +3.6 KB
Path Before After Change
crates/engine/src/tests/layout_publication_moves.rs 0 B 2.3 KB +2.3 KB
crates/engine/src/cmd/layout/publication/mod.rs 149.2 KB 150.4 KB +1.1 KB
docs/user-guide/layouts.md 105.4 KB 105.5 KB +93 B
crates/engine/src/tests.rs 3.8 MB 3.8 MB +77 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-3566/
Web app https://preview.rustgis.app/pr-3566/app/
Commit 5a974bb

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 1, 2026 21:59
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

Scope: the move search in layout.publication (crates/engine/src/cmd/layout/publication/mod.rs), its new test, and the user-guide paragraph. The change is a size check on legend-room moves, which is a sound fix for #3514. I found no crash or panic paths. Three findings are worth raising, and I'm posting them inline.

Bugs

  • Legend may cover map data with no notice (medium confidence). For a figure (sheet false), a refused move now leaves the legend where the map is. The notice block around unknown_at does not cover that case. The new test locks in one column, no veil and no shift, but not whether the legend overlaps the drawing. Needs a screenshot check or a notice. Inline at mod.rs:1714.
  • NaN passes the size check (low confidence). size_change > MOVE_SIZE_CHANGE is false when size_change is NaN, so a zero or non-finite ground scale lets the move through. Suggested fail-closed form: !(size_change <= MOVE_SIZE_CHANGE). I haven't confirmed a reachable centre produces this. Inline at mod.rs:1652.

Security

  • None found.

Performance

  • None found. ground_at is computed once per scale and the extra work per move is two divisions.

Quality

  • Test duplicates the constant (high confidence). layout_publication_moves.rs types 0.20 and keeps it equal to MOVE_SIZE_CHANGE by a comment only. Making the constant pub(crate) and comparing against it removes the drift risk. Inline at layout_publication_moves.rs:39.
  • Nits, left for the release quality pass: the comment block at mod.rs:1617–1638 is long enough that the move rules are hard to follow. The drift variable now duplicates size_change, so it could be derived in one place.

AGENTS.md

  • No rule breaks found. Checked: .view() and undo are unaffected, no command, parameter or schema change, no new strings to translate, and no timer waits or ignored tests.

Twins checked: the change touches only the publication move search. I checked the other ground_per_unit users (area.rs, navigate.rs, sharing.rs, qgis.rs) and none of them move a frame for legend room, so no twin needs the same change. The layouts.md paragraph matches the code.

Prior reviews: none on this PR, so no earlier concerns were left alone.

Change size

Compared with the base branch: the whole PR against main (merge base 342ebb8 to PR head 5a974bb).

Files changed Added Modified Removed Renamed Size before Size after Total change
4 1 3 0 0 4.09 MB 4.10 MB +3.6 KB
Path Before After Change
crates/engine/src/tests/layout_publication_moves.rs 0 B 2.3 KB +2.3 KB
crates/engine/src/cmd/layout/publication/mod.rs 149.2 KB 150.4 KB +1.1 KB
docs/user-guide/layouts.md 105.4 KB 105.5 KB +93 B
crates/engine/src/tests.rs 3.84 MB 3.84 MB +77 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Dec 1, 2026
Merged via the queue into opengeos:main with commit 8d415ca Dec 1, 2026
29 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3514-publication-move-keeps-size branch December 1, 2026 23:19
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]: A publication layout's map can be moved toward a pole and drawn several times smaller

1 participant