Repository navigation
Publication sheets scale their legend, scale bar and graticule labels with the sheet (#2581, part 3) - #2725
Conversation
…aticule labels with its short side (opengeos#2581) On a sheet, layout.publication sets the legend's text size, the scale bar's and the graticule's label sizes to their A4 sizes times the sheet's factor (its short side over 210 mm, as its titles already take), measures the legend and the scale bar's box at those sizes, and scales the strips the graticule's labels take inside the frame with them. A4 sheets and figures stay as they are.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewReviewed PR #2725 (sheets scale their legend, scale bar and graticule label text by the sheet's short side). I read the full diff, the base-branch AGENTS.md, and the surrounding code. I could not build or run the tests (no shell here), so the findings below come from reading the code. No prior review threads exist, so none were skipped. No inline comments were posted because nothing rose to a specific defect. BugsNone found. What I checked:
SecurityNone found. No new parameters, no new input parsing, no new file or network access. PerformanceNone found. The changed measurement calls run the same number of times as before, with a different font size. Quality (nits, not posted inline; may wait for the release quality pass)
AGENTS.mdNone found. The diff adds no unwraps or panics in non-test code, adds no new strings needing translation, and changes no saved field shape, so no schema or fixture update is needed. The Change sizeCompared: the whole PR against main (merge base 17773dd to PR head a4ef989).
|
📖 Docs preview
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 |
|
Thanks. No change in this PR for the three quality notes:
|
Code reviewChecked the 3-file diff ( Bugs: None found. The measured legend and scale-bar boxes use the same text sizes as the drawn elements (the search loops and the final element both pass Security: None found. No input parsing or external data handling is changed. Performance: None found. Measurement count per scale try is unchanged; the only added work is a Quality (nit, confidence high):
AGENTS.md: No violations found. The changed files need no Known and noted in the PR, not raised here: the colorbar and the 2 mm legend-box padding keep A4 sizes on sheets other than A4. Earlier review threads: none exist on this PR, so there were no earlier concerns to leave alone. Coverage: I did not run the test suite (no shell in this review). The PR reports Change sizeCompared: the whole PR against main (merge base 17773dd to PR head a4ef989).
|
Summary
Publication Layout sizes its title, subtitle and footer by the sheet's short side (A4 = 1), but its legend, scale bar labels and graticule labels stayed at their A4 sizes, and the strips kept for the graticule's labels stayed fixed in mm. On A2, A1 and A0 they came out tiny next to the title; on A5 portrait a long legend took so much of the page that the map was fitted at a smaller scale and veiled. Parts 1 (#2590) and 2 (#2660) gave the three elements a text size; this is part 3 of #2581: Publication Layout sets them with the sheet.
layout.publication(crates/engine/src/cmd/layout.rs): next to the sheet's factork(short side / 210 mm, 1 for a figure) that its titles already use, the legend'stextSizeis 9 × k, the scale bar'stextSize8 × k and the graticule'slabelSize8 × k, and the label strips (LABEL_ROOM_SIDE9 mm,LABEL_ROOM_END6 mm) are scaled by k. Every page size a sheet takes gives k from 0.70 (A5) to 4.0 (A0), so the sizes stay within the 4 to 100 points a text size takes; no clamp is needed.legend_sizes_with_no_data_mmwith the sheet's size, and the scale bar's box through the bar it will add. The strips set the fitted scale, the surrounds' margins, the panel and editorial frame's target height and the portrait or landscape choice.nullgives an element its own default, 9, 8 or 8 points, as it always has. A reset to the sheet's size would need the element to know its sheet, which it doesn't.layout-text-sizecapability from parts 1 and 2, and a RustGIS release older than that capability refuses it rather than drawing it at A4's sizes. No new capability, as no field is new;cargo xtask schema --checkpasses unchanged.docs/user-guide/layouts.md.Reach every surface
layout.publicationcommand, so all get the new sizes; no parameter is added, so no tool description changes.Not in this PR (noted for follow-ups): a publication's colorbar and the 2 mm padding of its legend box keep their A4 sizes; a thesis-half figure's reference line crosses the page edge on
mainalready (found by the new test's text-loss check, which here checks the legend and the scale bar only).Testing
checks.shon this branch (based onmainat 17773dd): fmt, doctests andcargo xtask layerspassed; nextest ran 8879 tests, 8878 passed. The one failure,portable_projects::reload::reload_reconverts_duckdb_table_and_keeps_only_its_original_geometry_branch, is the DuckDB test that fails on this machine's DuckDB, as noted in feat(layout): a legend takes a text size, its rows and swatches following (#2581 part 1) #2590 and Layout scale bars and grids take a label size (#2581, part 2) #2660; it touches no layout code. Clippy on the workspace with-D warningsandcargo xtask schema --checkpassed after a lint fix in the new test.hostile_params_never_panicpassed.engine::tests::a_publication_sheets_surround_texts_follow_its_short_side(new): on A4 portrait and landscape, a journal and a thesis figure, Letter, A5 and A0 (classic and panel), the legend is 9 × k, the scale bar 8 × k and the grid labels 8 × k; the saved project requireslayout-text-sizeexactly when k ≠ 1 and reads back identical; the legend and the scale bar lose no text when the page is drawn; after the A0 frame's scale is tripled, its scale bar keeps its size and loses no text. Before the change it failed at Letter: "a 9 pt legend".engine::tests::publication_layouts_fit_their_pages(updated helperpiaui_fits): the fitted scale is checked against strips scaled with the sheet; before the change it failed on A3 (1:4,300,000 for 1:4,403,636).engine::tests::publication_sheets_follow_the_page_sizes: every sheet size gives its surrounds a size within 4 to 100 points.engine::tests::a_publication_on_a5_portrait_keeps_its_legend_at_the_scale_that_fits(was…_at_a_smaller_scale): with the smaller A5 legend, Piauí's map is no longer drawn at a smaller scale and veiled; it is fitted at its own scale (1:8,900,000) and moved in its frame for the legend's room.ui_shotruns of the same script on this branch and onmain(A0 and A5 portrait sheets of Piauí, exported): the pages differ where the surrounds are, as below.UI evidence
The exported A0 portrait sheet of Piauí:
main(left), with the legend, scale bar and graticule labels at A4's sizes, and this branch (right), at four times those, next to the title.The A5 portrait sheet:
main(left) at 1:9,300,000, and this branch (right), with the surrounds at 0.7 times A4's and the map at 1:8,900,000.Related issue
Closes #2581
Summary by CodeRabbit