Repository navigation
fix(layout): say when a map frame's tile credits are cut off on export - #3565
jgregoriorincon wants to merge 5 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Code reviewReviewed the full diff (9 files) against Bugs
Security
Performance
Quality
AGENTS.md
Earlier concerns left alone: 0 (no prior review threads on this PR). Change sizeCompared with the base branch: the whole PR against main (merge base eaf74c0 to PR head 6fdd13a).
|
Code reviewI read the full diff, the base-branch AGENTS.md, and the surrounding code, then checked the twin paths. I could not build or run the tests here, so every finding below comes from reading the code. Bugs
The earlier thread (verdict versus placement disagreeing on a shape) is fixed in Security
Performance
Quality
AGENTS.md
Twins checked
I left one earlier concern alone, the verdict/placement disagreement, because it is already fixed in the head. Change sizeCompared: the whole PR against main (merge base eaf74c0 to PR head cb07128).
|
…t a cell short as a cut
Code reviewI read the full diff, the base-branch AGENTS.md, and the source around the changed code. I could not run the tests (no shell here), so everything below rests on reading the code. Bugs
Security
Performance
Quality
AGENTS.md
Prior threads (left alone: 2)
Twins checked
Change sizeCompared with the base branch (merge base eaf74c0 to head 3dae5a5).
|
📖 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 |
| // The box [`attribution_inset`] keeps clear of the labels: the credit's width, its height with | ||
| // its halo. | ||
| let (x0, y0) = (crate::attribution_center(w, tw, right) - tw / 2.0, h - bottom - size * 0.9 - size * 0.8); | ||
| let (cols, rows) = ((tw * ppp).floor().max(1.0) as u32, (size * 1.6 * ppp).floor().max(1.0) as u32); |
There was a problem hiding this comment.
The verdict can miss a credit that overhangs the shape by less than one pixel. floor(tw * ppp) leaves out the credit's last partial pixel column, so the mask's right edge stops up to 1/ppp points short of the credit's right end. Whenever the shape's edge falls in that gap, contains(&0) never sees the overhang and the credit goes unsaid. That is the silent loss the earlier thread on this line asked to close. The loss is up to 0.5 pt at ppp 2, and up to 2 pt on a 36 dpi export (ppp 0.5, which the engine tests use). The non-anti-aliased fill tests pixel centres, so the box should count the pixel centres that lie below tw. That is ceil(tw * ppp - 0.5). The rows have the same truncation.
Suggested fix: count pixel centres inside the credit's box, and add a case to a_credit_is_said_cut_when_its_box_leaves_the_shape at ppp 0.5 with a fractional tw. The current cases pass only at the widths they use. I have not run the tests (no shell here), so the reasoning is from reading the code.
Category: bug
Code reviewThe PR adds a notice when a map frame's tile credit is wider than the frame, or than every row of its shape, so the credit's ends get cut off on export. I read the diff, the surrounding layout and export code, and the earlier review threads. I could not build or run the tests here (no shell), so everything below comes from reading the code. Bugs
Security
Performance
Quality
AGENTS.md
Earlier review threads
Surfaces checked (twins)
Change sizeCompared with the base branch (merge base eaf74c0 to PR head fd0a020). The stats are not truncated.
|
Summary
A layout map frame narrower than its tile layers' credits (several layers, or a small frame) cut the ends of the credit off, and nothing said so. An export now says which frames' credits don't fit, in one notice naming each frame by name and id (the first ten, and how many more):
Map frame "Map Frame" (4): its tile credits don't fit in it, so their ends are cut off; make it larger, or show fewer tile layers in it. A report names the layout each frame is in.A frame is said to cut its credit when no place in it holds all of it: a rectangle narrower than the credit, or a shape (circle, ellipse, polygon, lasso) with no row as wide as it (#3473 centres such a credit on the shape's widest row). It is known as the frame is drawn, so it costs nothing besides the drawing; the list is a per-thread collector opened around the export, the pattern
unfitted_legendsalready uses, with no state kept between exports.Two drawn changes, both from
attribution_centerkeeping a credit's ends inside the frame when they can be: a credit that fits the frame but not with its 4 pt right margin used to lose its left end by up to 4 pt, and now goes into the margin and is drawn whole; a credit wider than the frame is now centred on it (it sat 4 pt left of the frame's middle), so it runs past both edges alike.The same
attribution_centerdraws the credit of the plain map export (share.exportMap, the map's PDF and SVG), so a credit that fits there also goes whole into the margin; that export's own silent cut of a credit wider than the view is not in this PR.Not changed: where a credit that fits goes; the layout view on screen (as for legends that don't fit, the notice is the export's); the credit is not split over lines (a word wider than the frame would still be cut, so the notice would still be needed).
presentation.exportsays the notice too (a slide's size is a project field, so a long credit or a narrow slide cuts it), with the same collector; a PNG is the first page only.Surfaces: the notice goes through
Session::warn, so the desktop app, the browser, the command line and Python (take_notices) all get it, from the publication preview (itswarnings), fromlayout.export(PNG, JPG, PDF, SVG, a page of a series, a region), fromreport.exportand frompresentation.export. No command, parameter, project format or UI text changes.Testing
New tests in
crates/render/src/layout/tests.rs: a frame says its credit is cut exactly when no place holds it (rectangle, circle, ellipse, triangle, two credits, none); a credit within the margin of the frame's width is drawn whole; a shape's verdict is the drawn credit's box against the shape (a fraction of a point wider isn't a cut, narrower is; a trapezoid swept against its edges; labels over the rows); the collector lists each frame once and nests; the notice's wording for one, two and twelve frames; a label over the rows that hold a shape's credit isn't a cut.New
crates/engine/src/tests/layout_credits.rs: with an MBTiles layer crediting a long text, a wide frame says nothing, a narrow one says so on PNG, SVG and PDF exports, two narrow frames are one notice, a frame with no tile layer says nothing, a report names the layout, and a presentation slide narrower than its credit says so.deliver.sh: fmt, clippy (-D warnings, also with theschemafeature), doctests, layers and schema pass. The workspace run is 11946 of 11954; the 8 failures (sevenrustgis-geolibretests andline_strokes_editor_edits_one_class) also fail on this machine without this change. Aui_shotexport isn't attached because nothing in the interface changes; the notice is text.UI evidence
No visible UI change: the only drawn difference is at most 4 pt in where a credit starts.
Related issue
Closes #3474