Skip to content

Layouts: a publication layout's surrounds keep off the data; a decimal comma (#682, part 3) - #709

Merged
giswqs merged 28 commits into
opengeos:mainfrom
elpidioassinaturas:feat/682-placement
Oct 23, 2026
Merged

giswqs merged 28 commits into
opengeos:mainfrom
elpidioassinaturas:feat/682-placement

Conversation

@elpidioassinaturas

@elpidioassinaturas elpidioassinaturas commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 3 of #682, the last.

#706 (part 2, the locator) is in, and main is merged into this branch, so the diff is this part's changes only.

  • Surrounds by data coverage: the north arrow, the legend, the scale bar and the locator each take the corner where they cover the least of what the map draws.
    • The new render::layout::frame_coverage draws the frame's map on a coarse grid (about 96 cells across) with the basemap set to Blank. Where a layer or its labels drew is data, and the frame's background isn't.
    • Every way of giving the surrounds a corner each is tried (at most 24), and the one covering the least data, in mm², wins.
    • A surround off its own corner costs a hundredth of its area. So when it makes no difference (no data in the corners, or data under every corner alike), they keep part 1's corners: locator top left, arrow top right, legend bottom left, scale bottom right.
    • The legend still stops short of whatever is beside it and above or below it, in whichever corners they end up.
  • Warnings:
    • Crowding: with more surrounds than free corners, one warning names those left on the data ("the north arrow sits on what the map shows, the freer corners having gone to the others"). Data under every corner alike, such as a context layer filling the frame, has nothing better to offer and isn't warned about.
    • Overlap: two surrounds that overlap (a frame too small for them all) are said too.
  • Decimal comma: "decimal": "," on layout.publication, or on layout.page for any layout, sets a new Layout::decimal_comma.
    • The graticule labels, the scale bar's numbers, the colorbar ticks and {scale} then print with a decimal comma and points between thousands (0,05, 1:6.300.000).
    • Other text is left as it is.
    • The field is serialized only when on, so existing layout files don't change.
    • graphics::thousands is now public, for {scale}.
  • A colorbar for a raster theme, which [Feature]: Publication layout in one command: a finished map sheet or figure sized to the page (layout.publication) #682 asked for as part of the legend: the topmost visible raster drawn on a ramp gets a horizontal colorbar at the bottom of the legend's box. The legend's rows list only vector layers. The box is sized for both, and placed as one surround.
  • A UTM zone's EPSG code named: {projection} and {datum} read UTM zone 23S and SIRGAS 2000 for EPSG:31983, rather than the code over its GRS 1980 ellipsoid. A UTM code's PROJ definition gives only +ellps=GRS80 and its label only the code. The new wkt::utm_of_code is the inverse of the table wkt::utm reads names with: WGS 84, NAD83, ETRS89 and SIRGAS 2000 zones.
  • Both came from making a real map with it: the NDVI trend of Piauí, Brazil, read by cube.trend straight from the Brazil Data Cube, on UTM 23S.
  • Docs: the publication layouts section of layouts.md, and the assistant's print-layout skill.

Testing

  • publication_surrounds_keep_off_the_data (engine) uses a polygon layer in three cases:
    • in the middle only: every surround keeps its corner, with no warnings;
    • filling the bottom left: the legend leaves that corner, the north arrow (smallest) takes it, and one warning names it;
    • filling the frame: nothing to warn about, and every surround keeps its corner.
  • The same test covers "decimal": ",", layout.page's decimal, and bad values refused.
  • a_publication_layouts_raster_gets_a_colorbar (engine): a raster on a ramp gets a colorbar inside the legend's box, and a map of vectors only gets none. wkt's UTM test now reads every code's name back (utm_of_code then utm), and the publication test checks that EPSG:31983 reads "UTM zone 23S" and "SIRGAS 2000".
  • a_decimal_comma_swaps_the_marks (render): the marks swap in numbers. With a decimal comma, {scale} reads 1:6.300.000 and the text around it keeps its own comma.
  • The part 1 and 2 tests now check that surrounds don't overlap, whichever corners they take, rather than fixed corners. Over the sample world's land, the surrounds now move to its one corner of sea.
  • I checked the exported A4s visually: the legend moved off a filled corner, and a decimal-comma scale reads 1:7.600.000.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings and cargo xtask layers are clean.
  • rustgis-engine 283 passed (3 ignored), rustgis-data 325, rustgis-render 137, rustgis-map 126, rustgis-assistant 206 and rustgis-ui-egui 264 (unit tests).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Publication layouts place surrounds—such as the legend, scale bar, north arrow, and locator—in corners that cover less map content. Warnings identify surrounds that still cover data or overlap.
    • Legends can be shortened or omitted when space is limited; visible raster layers with a color scale can include a colorbar inside the legend.
    • Decimal-comma formatting is available for graticule, scale-bar, colorbar, and scale-token values.
    • Publication references identify recognized UTM projections by zone, hemisphere, and datum.

elpidiofilho and others added 2 commits October 22, 2026 13:20
… area outlined (opengeos#682, part 2)

layout.publication takes "locator": "globe" (a sheet's default: a new map
of the map's polygon layers on the globe, unlabelled, in a round frame at
the map's top left, sized from the renderer's own globe disc), "inset" (the
surrounding region on the map itself) or "none" (a figure's default). The
map frame's extent indicator outlines the area on either; the legend stops
short of it; undo takes the globe's map away with the layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l comma (opengeos#682, part 3)

The north arrow, the legend, the scale bar and the locator each take the corner
where they cover the least of what the map draws (render::layout::frame_coverage:
the frame drawn coarse on a blank basemap), keeping their own corners when it
makes no difference; one warning names those crowded onto the data. "decimal":
"," (layout.publication, layout.page) sets Layout::decimal_comma: graticule,
scale bar and colorbar numbers and {scale} print 0,05 and 1:6.300.000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ 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: 5a5ebeed-a3e1-4a9e-a42b-4e10a28bd388
📥 Commits

Reviewing files that changed from the base of the PR and between 571832d and 5d93ecc.

📒 Files selected for processing: 1
  • crates/engine/src/cmd/layout.rs

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

📝 Walkthrough

Publication layouts now place surrounds based on map coverage, with warnings for crowding and overlap. Layouts support decimal-comma formatting, and recognized UTM codes appear with their zone, hemisphere, and datum in projection labels.

Changes: Publication layout behavior

Layer / File(s) Summary
Layout settings and UTM identification
crates/data/src/raster/wkt.rs, crates/engine/src/cmd/layout.rs, crates/map/src/layout.rs, crates/engine/src/tests.rs
Layout commands accept decimal-mark options. Supported UTM EPSG codes resolve to zone, hemisphere, and datum for projection labels.
Numeric formatting and frame coverage
crates/render/src/layout.rs, crates/map/src/graphics.rs
Graticule, scale-bar, colorbar, and {scale} values use decimal-comma formatting when enabled. frame_coverage returns a sampled mask of drawn pixels.
Coverage-based surround placement
crates/engine/src/cmd/layout.rs, crates/engine/src/tests.rs, docs/user-guide/layouts.md, crates/assistant/skills/print-layout/SKILL.md
Publication layouts score corner assignments, place surrounds and eligible raster colorbars, and report crowding or overlap warnings. Tests and documentation cover the updated placement and formatting behavior.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PublicationLayout
  participant frame_coverage
  participant MapRenderer
  PublicationLayout->>frame_coverage: Request sampled frame coverage
  frame_coverage->>MapRenderer: Render frame at sampled resolution
  MapRenderer-->>frame_coverage: Return rendered pixels
  frame_coverage-->>PublicationLayout: Return coverage mask
  PublicationLayout->>PublicationLayout: Score corner assignments and place surrounds
Loading

Possibly related issues

  • Issue 682: The PR adds publication-layout behavior described in the issue, including data-aware placement, decimal-comma formatting, and raster colorbars.

Suggested reviewers: giswqs

Merge Risk: ⚪ Minimal · up to 5d93e

No actionable merge-blocking risk is established by the reviewed changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main changes: data-aware surround placement in publication layouts and decimal-comma support.
Description check Passed The description includes a detailed summary and testing section. It explains the related issues in the summary, although it does not use a separate Related issue heading.
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.
✨ 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 four corners,
A quiet legend finds its place.
Commas mark the printed numbers,
A colorbar joins the raster’s face.
The north arrow rests beside the frame,
And warnings note what still overlaps.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no blocking bugs in PR #709. I read the whole diff and checked publication, page, the render changes and the new tests against the surrounding code. I did not build the code or run the tests.

Bugs

  • None found. The locator map is added to project.maps only after the last ? or return Err in publication, so a refused command leaves no stray map behind. Confidence: medium-high.
  • The {scale} comma swap and the label swaps in decimal() only exchange . and , in numbers the layout itself prints, so surrounding text keeps its punctuation. a_decimal_comma_swaps_the_marks covers {scale}. Confidence: medium.

Security

  • None. The new decimal and locator parameters are validated against fixed values and return errors on junk. There are no new panics, unwraps or indexing in the non-test code; covered uses get() and clamped ranges. Confidence: medium-high.

Performance

  • frame_coverage clones the whole map and renders it once per layout.publication. The grid is capped at 8–512 cells, so this is acceptable. Confidence: low concern.

Quality

  • The corner search uses four hard-coded nested loops (see the inline comment). With fewer than four surrounds it repeats the same assignments, and a fifth surround would silently fall back to the default corners. A small permutation helper would fix both. Confidence: medium (nit).
  • publication_layouts_fit_their_pages now only requires that any warnings contain "on what the map shows". That is weaker than the old "no warnings" assertion, though the new placement tests make up for most of it. Confidence: low.

AGENTS.md

  • No unwraps or panics were added outside tests, and the decimal and locator parameters are documented in layouts.md, the SKILL.md file and the command param strings.
  • Nothing in the PR can break the wasm build: it uses no std::time, filesystem or other native-only APIs.
  • New UI strings: none, since all changes are in the engine, render and map crates.

Change size

The whole PR against main (merge base 60ae3e9 to PR head e2e1648).

Metric Value
Files changed 7 (0 added, 7 modified, 0 removed, 0 renamed)
Size before 1,065,904 B (1.02 MB)
Size after 1,091,532 B (1.04 MB)
Total size change +25,628 B (+25.0 KB)
File Before After Change
crates/engine/src/cmd/layout.rs 100.2 KB 110.5 KB +10.3 KB
crates/engine/src/tests.rs 758.2 KB 767.0 KB +8.9 KB
crates/render/src/layout.rs 96.7 KB 100.4 KB +3.7 KB
docs/user-guide/layouts.md 15.2 KB 16.6 KB +1.4 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +472 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.4 KB +207 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-709/
Web app https://preview.rustgis.app/pr-709/app/
Commit 5d93ecc

GitHub Pages takes a minute or two to publish a new commit.

…s box; a UTM zone's EPSG code named by its zone and datum

Found making the greening lesson's map with it: the topmost visible raster
drawn on a ramp now gets a colorbar under the legend's rows (the legend lists
vectors only), and EPSG:31983 reads 'UTM zone 23S' on 'SIRGAS 2000' rather
than its code on its GRS 1980 ellipsoid (wkt::utm_of_code, the inverse of
the name-to-code table).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread crates/engine/src/cmd/layout.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff and checked the {scale} handling against graphics.rs. I did not build the code or run the tests.

Bugs

  • Placement can overlap surrounds without avoiding it (low confidence). The corner search scores only coverage of the data and distance from each surround's home corner. It does not check whether two surrounds overlap. Overlaps are only reported as warnings afterwards. In a very small frame, such as a figure-1col with locator: "globe", the result can be an overlapping layout that the search could have avoided. The shrink applied to the legend covers only the legend, not the locator.
  • Globe locator map is cloned from the whole map (low confidence). s.map().clone() copies every layer's data before the non-polygon layers are filtered out. This is wasteful on large projects. Filtering before the clone would avoid it. The same applies to frame_coverage, which clones the map on every call.

Security

  • Nothing found. The new decimal and locator params are validated and return errors for bad values, and layout.page parses decimal before it changes the layout.

Performance

  • Coverage render clones and re-renders the map (low confidence). frame_coverage clones the map and renders it on a coarse grid. The corner search loops up to 4⁴ times, calling covered each time. The cost is small, but see the inline comment on the dead condition and the repeated evaluations.

Quality

  • Dead condition and redundant loops (high confidence, minor). See the inline comment on crates/engine/src/cmd/layout.rs:909.
  • decimal swaps characters across whole strings (low confidence). Today it is only applied to numeric labels and the formatted scale, so it works. If it is later applied to free text, it would corrupt that text.
  • Scale formatting is duplicated (low confidence). expand in crates/render/src/layout.rs computes the scale twice, once for the comma case and once for TokenValues. Computing it once would keep the two from drifting apart.

AGENTS.md

  • There are no unwrap, expect or panic! calls in non-test code, and the new wasm-relevant code uses no std::time.
  • The new utm_of_code is public and is checked against utm() in a round-trip test, which is good.
  • New messages such as the decimal is … error are command-layer strings, so they don't need tl!.
  • Tests exercise the new commands, including the bad-value errors for locator and decimal.

Change size

Compared with: the whole PR against main (merge base 60ae3e9 to PR head fea4013).

Metric Value
Files changed 8 (added 0, modified 8, removed 0, renamed 0)
Size before 1.08 MB
Size after 1.11 MB
Total size change +30.6 KB
File Before After Change
crates/engine/src/cmd/layout.rs 100.2 KB 112.4 KB +12.2 KB
crates/engine/src/tests.rs 758.1 KB 769.2 KB +11.1 KB
crates/render/src/layout.rs 96.7 KB 100.4 KB +3.7 KB
crates/data/src/raster/wkt.rs 69.4 KB 70.8 KB +1.4 KB
docs/user-guide/layouts.md 15.2 KB 16.6 KB +1.4 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.4 KB +207 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

elpidiofilho and others added 2 commits October 22, 2026 23:43
…orced over it

The globe's map was a clone of the whole map with its non-polygon layers
dropped, so it copied every layer's features first and kept the map's web
tiles, swipe, time slider and groups: a map on a web basemap drew its tiles
on the disc. It is now a new map with the basemap (the land and borders
around the area), graticule and body, and only the polygon layers that
show, unlabelled.

The legend's corner was given at least 10 mm, so a sheet whose frame was
near its smallest drew the legend over the locator (or the scale bar). A
corner too small now leaves the legend out, with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… out where it has no room, surrounds kept apart

From opengeos#706: the globe locator is a new map of what it draws, and a legend
corner too small leaves the legend out with a warning. Here that check
moves into the corner placement: the legend's room is measured against the
surrounds beside and above or below its corner, and the warning names the
one in the way.

The corner search now tries each assignment once (4^n codes, the first
surround's corner changing slowest, so ties still go the same way) instead
of re-running identical picks in unused inner loops, and the dead length
check is gone. Two surrounds over each other cost ten times their overlap,
so in a frame too small for them all the search keeps them apart when some
assignment can.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elpidioassinaturas

Copy link
Copy Markdown
Contributor Author

On the review above, in 59b2751 (which also merges #706's review fixes):

  • Placement can overlap surrounds: fixed. Two surrounds over each other now cost ten times their overlap in the corner search, more than any data under them, so in a small frame the search keeps them apart whenever some assignment can; the overlap warning stays for frames too small for any. The legend's corner is also checked against the surrounds beside and above or below it: with under 10 mm of room the legend is left out with a warning naming what is in the way, instead of being forced to 10 mm over it.
  • Globe locator cloned from the whole map: fixed in Layouts: a publication layout's locator, a globe or an inset with the area outlined (#682, part 2) #706 (769b002), merged here: the globe is a new map with only the polygon layers that show.
  • Dead condition and redundant loops: fixed (inline thread).
  • frame_coverage clones and re-renders the map: left as is. It runs once per layout, on a coarse 96-cell grid, and the 4ⁿ search reads its result, not the map; the cost is a fraction of the layout's own export.
  • decimal swaps characters across whole strings: it is applied only to numeric labels and the formatted scale, as you note; keeping it there.
  • Scale formatted twice in expand: both go through the same formatter with the same inputs; I'll fold them into one if the maintainer prefers.

🤖 Addressed by Claude Code

Comment thread crates/render/src/layout.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff and checked the refusal paths in publication for ordering. I could not build or run anything, so nothing here is tested.

PR #709 adds a locator (globe or inset), corner placement of the surrounds by how little data they cover, a decimal-comma option, and UTM names for the projection and datum text. I found no definite bugs. The never crash, no unwrap and wasm rules look respected in the non-test code.

Bugs

  • None found. The ? returns in publication (lines 701, 738, 757) all run before the globe map is pushed to s.project.maps, so a refused call leaves no stray locator map (high confidence).
  • utm_of_code ranges match utm(): SIRGAS 2000 north is 31965..=31976 plus 6210 and 6211, and south is 31977..=31985 plus 5396. The round-trip test covers them (medium-high confidence).

Performance

  • frame_coverage in crates/render/src/layout.rs deep-clones the whole Map and renders it synchronously on each layout.publication call. A project with large vector layers could stall the UI thread or the web build (inline comment, medium-low confidence).
  • The corner search tries at most 4⁴ = 256 combinations, which is negligible (high confidence).

Quality

  • The placement code in publication is long: the locator, coverage, search, legend fitting and warnings all sit in one function. Pulling placement into a helper that returns the rectangles and warnings would make it testable without a Session (low-medium confidence).
  • pick[..i].contains(&pick[i]) uses indexing. It is bounded by construction, but the repo prefers get() (low confidence, nit).
  • decimal() swaps every . and , in a label. That is correct for the numeric labels used today, but it would mangle any label that carries other text, such as a unit string with a comma. Keep it applied only to numeric strings (low confidence).
  • The publication_layouts_fit_their_pages test now accepts any warning containing "on what the map shows". This is a weaker check than the old empty-warnings assertion, though the comment explains it.

Security

  • No issues. The new parameters decimal and locator are validated strictly. The locator map name goes through numbered, so it stays unique.

AGENTS.md

  • The new cmd params text, docs and the skill file are updated.
  • No new user-visible UI strings were added, so tl! and the i18n rules do not apply.
  • Layout::decimal_comma is #[serde(default)], so old projects still load.
  • No new dependencies and no asset changes.

Change size

Compared: the whole PR against main (merge base 60ae3e9 to PR head 59b2751).

Metric Value
Files changed 8 (0 added, 8 modified, 0 removed, 0 renamed)
Size before 1,110.3 KB
Size after 1,145.8 KB
Total size change +35.6 KB
File Before After Change
crates/engine/src/cmd/layout.rs 100.2 KB 114.4 KB +14.2 KB
crates/engine/src/tests.rs 758.1 KB 772.1 KB +13.9 KB
crates/render/src/layout.rs 96.7 KB 100.4 KB +3.7 KB
docs/user-guide/layouts.md 15.2 KB 16.7 KB +1.5 KB
crates/data/src/raster/wkt.rs 69.4 KB 70.8 KB +1.4 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.4 KB +207 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

elpidiofilho and others added 2 commits October 23, 2026 00:00
…be's streamed layers left out, said

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	crates/assistant/skills/print-layout/SKILL.md
#	docs/user-guide/layouts.md
Comment thread crates/render/src/layout.rs Resolved
Comment thread crates/engine/src/cmd/layout.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no blocking bugs. I read the diff and the surrounding source, but I didn't build the code or run the tests. The PR adds a locator (globe or inset), corner placement of the layout surrounds based on map coverage, a decimal-comma option, and UTM naming for the reference text. I confirmed the new publication code has no ? or return Err after the locator map is pushed, so a refused command can't leave an orphan map behind.

Bugs

  • None confirmed. The corner search is bounded at 4⁴ = 256 combinations. The corners default is kept if no combination is better. The legend, locator and scale box overlap checks look consistent with the placement code.
  • utm_of_code accepts every code in broad ranges (for example NAD83 26901..=26960 and ETRS89 25801..=25860), though EPSG defines fewer. This is harmless because the code comes from the active projection. Confidence: low.

Security

  • No issues. The new parameters (locator, decimal) are validated strictly and return errors on junk input, in line with the hostile-input rule.

Performance

  • crates/render/src/layout.rs:1025: frame_coverage clones the whole Map and renders it in full just to build a ~96-cell occupancy grid, on every layout.publication call. This can be costly for large projects. Confidence: medium.

Quality

  • crates/render/src/layout.rs:1025: the "drawn" test treats any pixel with all channels ≥245 as empty. Pale or white fills and thin light lines can therefore be missed, so surrounds can still land on them. Confidence: medium-low.
  • crates/engine/src/cmd/layout.rs:833: each run with the default globe locator adds a " Locator" map to the project. Only undo removes it, so repeated runs, or deleting the layout, leave orphan maps. Confidence: medium-low.
  • The sheet test now accepts any warning containing "on what the map shows", which is weaker than the previous "no warnings" assertion. The dedicated placement test covers part of that gap.

AGENTS.md

  • No unwrap, expect or panic! in the non-test changes, and no unsafe. The diff touches no UI crate, so tl! and i18n::fmt don't apply.
  • Docs and the assistant skill are updated, and the changes add regression tests.
  • Not verified: cargo xtask ci and the wasm build. Neither can be run here.

Change size

Compared: the whole PR against main (merge base 60ae3e9 to PR head 8ce81fb).

Metric Value
Files changed 8 (0 added, 8 modified, 0 removed, 0 renamed)
Size before 1,110.3 KB
Size after 1,146.3 KB
Total size change +36.0 KB
File Before After Change
crates/engine/src/cmd/layout.rs 100.2 KB 114.4 KB +14.2 KB
crates/engine/src/tests.rs 758.2 KB 772.3 KB +14.2 KB
crates/render/src/layout.rs 96.7 KB 100.4 KB +3.7 KB
docs/user-guide/layouts.md 15.2 KB 16.9 KB +1.7 KB
crates/data/src/raster/wkt.rs 69.4 KB 70.8 KB +1.4 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.5 KB +292 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

elpidiofilho and others added 3 commits October 23, 2026 00:06
…next, not left behind

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t, none on a figure)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the skill); the coverage drawn on the map itself

frame_coverage cloned the whole map (every layer's features) on each
layout.publication just to draw a coarse grid. It now draws the map
itself, its basemap set aside for the drawing and put back, as is a label
lock waiting to be filled, which the coarse drawing would otherwise fill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread crates/render/src/layout.rs Resolved
Comment thread crates/engine/src/cmd/layout.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff and checked the {scale} computation, the utm inverse and the placement logic against the surrounding source. I found no crashes or correctness bugs. I did not run the code or the tests. I posted two inline comments.

Bugs

  • Data coverage test misses pale fills (render/src/layout.rs, frame_coverage). A cell counts as "drawn" only if its colour is below 245, so white or very pale fills read as empty and a surround can land on them. Rendering onto a transparent background and testing alpha > 0 would be more robust. Confidence: medium. Inline comment posted.
  • Colorbar handling when the legend box is small (engine/src/cmd/layout.rs). The "legend lists more than fits" warning also fires when only the colorbar doesn't fit, and it blames the rows. When the box is shrunk, the legend rows are clipped to 1 mm. The colorbar's y can also fall above the box if ih < bar_h. Confidence: low-medium. Inline comment posted.

Security

  • Nothing found. decimal and locator are validated strictly, and the new code uses get() and clamps without unwrap, expect or unsafe.

Performance

  • frame_coverage renders the whole map once at about 96 cells wide, and the corner search tries at most 256 combinations. That is bounded and fine. A layer with very large vector data is still processed in full once per layout.publication call. Confidence: low, informational.

Quality

  • {scale} is now computed in two places: once in expand, and again inside graphics::expand. They agree today. A shared helper would keep them from drifting. Confidence: low.
  • utm_of_code mirrors the ranges utm reads, including codes that aren't real EPSG zones (for example NAD83 zones 24 and above, and ETRS89 zones outside 28–38). This is harmless, because the codes come from real CRSs, and the round-trip test covers the ones that matter. Confidence: low.

AGENTS.md

  • No unwrap, panic or unsafe in non-test code. Tests cover the new behaviour, including the hostile-parameters path through decimal and locator.
  • The new rustgis-data dependency and the skill and docs updates fit the layering.
  • Layer and CLI strings aren't user-facing UI text, so tl! doesn't apply.

Change size

Compared: the whole PR against main (merge base 60ae3e9 to PR head 9812bf3)

Metric Value
Files changed 8 (0 added, 8 modified, 0 removed, 0 renamed)
Size before 1,110.3 KB
Size after 1,149.0 KB
Total size change +38.7 KB
File Before After Change
crates/engine/src/cmd/layout.rs 100.2 KB 115.7 KB +15.4 KB
crates/engine/src/tests.rs 758.1 KB 773.3 KB +15.2 KB
crates/render/src/layout.rs 96.7 KB 100.7 KB +4.0 KB
docs/user-guide/layouts.md 15.2 KB 17.0 KB +1.8 KB
crates/data/src/raster/wkt.rs 69.4 KB 70.8 KB +1.4 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.5 KB +353 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

frame_coverage counted a pixel as drawn only when a channel fell under
245, so a pale fill (such as #FAFAF5) with no outline read as empty and a
surround could be placed on it. The blank basemap is pure opaque white
with no graticule, so anything else now counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread crates/engine/src/cmd/layout.rs Resolved
Comment thread crates/engine/src/cmd/layout.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I reviewed the first 600 lines of the diff, which cover crates/engine/src/cmd/layout.rs, crates/data/src/raster/wkt.rs, the skill text and the start of the new tests. I did not read the rest, which includes crates/render/src/layout.rs, crates/map/src/layout.rs, crates/map/src/graphics.rs, the docs and the later tests. I did not build the code or run the tests. I did check that the only refusals (return Err, ?) in publication come before the locator map is pushed into project.maps, so a failed call does not leave a stray map behind.

Bugs

  • Locator map overwrite (crates/engine/src/cmd/layout.rs:822, confidence: medium-low). The code treats any unshown globe map named <map> Locator[ N] as its own leftover and overwrites it. A user's own globe map with that name would be silently replaced. Matching on a name pattern is fragile, and a marker on the generated map would be safer.

Security

  • Nothing found. The new decimal and locator parameters are validated against fixed values, and the new code does no file or network access.

Performance

  • Corner search (crates/engine/src/cmd/layout.rs:954, confidence: low). The search tries 4^n corner assignments and recomputes coverage for each. With at most 4 surrounds that is 256 combinations, which is fine today. It would grow quickly if a fifth surround is added, so a comment noting the limit would help.

Quality

  • The 4-corner search indexes pick[..i] and pick[i] directly. The indices are generated in range, but it differs from the "get() over indexing" rule (confidence: low).
  • The publication function keeps growing, so splitting out locator creation and corner placement would help readability (confidence: low).
  • The tests look good. They cover utm_of_code round-tripping through utm, the locator, and the UTM zone naming. The weakened existing assertion on warnings, which now only requires "on what the map shows", is acknowledged in a comment.

AGENTS.md

  • No unwrap, expect or panic! in non-test code, and the new unwraps in engine/src/tests.rs and wkt.rs are test-only. decimal_mark and the locator parse reject bad input with an error.
  • The new locator and decimal parameters are documented in the command specs and the assistant skill. The docs and the crates/ui-egui changes were not in the part I read, so I could not check whether any new interface text uses tl!.
  • A new utm_of_code in rustgis_data is called from the engine. Layering is fine, and the code is wasm-safe.

Change size

Compared: the whole PR against main (merge base 60ae3e9 to PR head f2942b3).

Metric Value
Files changed 8 (0 added, 8 modified, 0 removed, 0 renamed)
Size before 1.08 MB
Size after 1.12 MB
Total size change +39.4 KB
Path Before After Change
crates/engine/src/tests.rs 758.2 KB 773.9 KB +15.7 KB
crates/engine/src/cmd/layout.rs 100.2 KB 115.7 KB +15.4 KB
crates/render/src/layout.rs 96.7 KB 100.8 KB +4.2 KB
docs/user-guide/layouts.md 15.2 KB 17.0 KB +1.8 KB
crates/data/src/raster/wkt.rs 69.4 KB 70.8 KB +1.4 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.5 KB +353 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

elpidiofilho and others added 2 commits October 23, 2026 00:15
…ap is said

The legend's width keeps its old 10 mm floor, so a figure or a sheet without
a locator lays its legend out as before; the legend is left out only when a
locator leaves it under 10 mm of height. Reusing a locator map no layout
showed now adds a warning naming it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dden meanwhile is gone)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff and posted three inline comments. I couldn't build or run anything here, so none of this was run against the code or its tests.

Bugs

  • Web tiles count as data in placement (medium): frame_coverage renders the live map with only the basemap and graticule set aside. A visible web tile layer is then drawn and counted as data across the whole frame. Every corner looks equally covered, so placement falls back to the default corners. Inline comment on crates/engine/src/cmd/layout.rs:927.

Performance

  • Globe locator simplifies every polygon synchronously (medium): it clones and simplifies every feature of every visible polygon layer. A layer with hundreds of thousands of polygons will stall layout.publication, and the UI with it. A feature-count cap or a warning would help. Inline comment on crates/engine/src/cmd/layout.rs:852.
  • Rendering the user's map (low): frame_coverage renders the user's own map, not a copy. That may touch render caches, though Aside does restore the basemap, graticule and label lock, including on a panic.

Quality

  • Brittle test (low, nit): the loosened warnings assertion in publication_layouts_fit_their_pages accepts only warnings containing "on what the map shows". It depends on the sample world's data layout and no longer proves a sheet is otherwise warning-free. Inline comment on crates/engine/src/tests.rs:2404.

Security

Nothing found. The new parameters (decimal, locator) are validated and return errors on junk input. The ? early returns all come before the first mutation, so a refused call changes no state. I did not look at the hostile_params_never_panic test itself.

AGENTS.md

  • I found no unwrap, expect or panic! in the non-test code I read. The new ones are in tests.
  • The utm_of_code ranges checked out against the EPSG zone limits. NAD 83 stops at zone 23 and ETRS 89 covers zones 28–38.
  • The new decimal and locator parameters are documented in the command specs, docs/user-guide/layouts.md and the skill file.

Change size

Compared: the whole PR against main (merge base 60ae3e9 to PR head 14580c8).

Metric Value
Files changed 8 (added 0, modified 8, removed 0, renamed 0)
Size before 1.08 MB
Size after 1.13 MB
Total size change +47.8 KB
File Before After Change
crates/engine/src/tests.rs 758.2 KB 777.8 KB +19.7 KB
crates/engine/src/cmd/layout.rs 100.2 KB 119.0 KB +18.7 KB
crates/render/src/layout.rs 96.7 KB 101.5 KB +4.8 KB
crates/data/src/raster/wkt.rs 69.4 KB 71.2 KB +1.8 KB
docs/user-guide/layouts.md 15.2 KB 17.0 KB +1.8 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.5 KB +353 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

… placed; the sheet test pins its one placement warning

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the whole diff and the surrounding code in crates/engine/src/cmd/layout.rs. I found no definite bugs. I could not build or run anything here, so the review is by reading only. I posted no inline comments, because none of the points below was solid enough to anchor to a line.

Bugs

  • None found. I checked these:
    • wkt::utm_of_code against the utm table. The zone arithmetic (31965..=31976 → 11..22, 31977..=31985 → 17..25, 6210, 6211, 5396, the NAD83 and ETRS89 ranges) is right.
    • The corner search. The n ≤ 4 loop is bounded at 256 picks and always has a valid pick, so best is always set. The legend shortening in the search matches legend_at placement. Ties go to the home corners because the off-home penalty is greater than the 1e-9 tolerance.
    • covered(). Clamped indices and .get() mean no panic. A rectangle that falls outside the grid returns 0.0.
    • frame_coverage. The Aside guard restores the basemap, tiles, graticule and label lock on every path, including a panic. It runs after the legend's map sync, so streamed layers have features.
    • Decimal comma. {scale} is replaced first in expand, so it can't be re-read from a layout or page name. The field is skipped in serialization when false, so existing layout files don't change.

Quality (low confidence, optional)

  • Legend dropped without a cost in the search (about 40%). legend_at can drop the legend when the locator leaves less than 10 mm. The corner search never sees that. It prices such a pick only as a 10 mm legend overlapping the locator. A pick that would leave the legend out can therefore still win over one that keeps it, with a warning as the only result. Having the search reject those picks, or add a dropped-legend cost, would be more predictable.
  • Overlap warning only covers placed surrounds (about 30%). The "overlap" warning compares only the surrounds that were placed. A legend dropped as "no room" gets its own warning, so this is fine.
  • Duplicated layout logic (about 50%). The neighbour-room calculation (room_w/room_h) is written twice, once in the search and once in legend_at. They agree today. A shared closure would keep them from drifting apart.
  • Corner count in the PR text (about 90%). The PR text says at most 24 corner assignments are tried, but the code loops over 4ⁿ picks (up to 256) and skips repeats, which leaves 24 distinct ones. The behaviour is correct. Only the comment and description numbers differ.
  • Cost of the coverage render (about 25%). frame_coverage renders the real map, with all features, once per publication call. The grid is about 96 cells across, which is cheap for typical maps. It could be slow for a very large vector layer, but it runs once per command.

Security

  • No issues. The locator and decimal parameters are validated strictly and refused when bad. All the indexing is bounds-safe (get, clamps).

Performance

  • No concerns beyond the coverage render above.

AGENTS.md

  • No unwrap, expect or panic! in non-test code. The panic! calls are inside tests.
  • Wasm-safe: no std::time and no file access.
  • Engine messages are not UI text, so tl! is not needed.
  • The docs and the assistant skill are updated.
  • Tests were added: surrounds vs data, the raster colorbar, the decimal comma, and utm_of_code round trips. The PR description says fmt, clippy and layers are clean. CI still needs to confirm it, including the hostile_params_never_panic test with the new decimal and locator params.

Change size

Compared: the whole PR against main (merge base 60ae3e9 to PR head c3b7a4f)

Metric Value
Files changed 8 (added 0, modified 8, removed 0, renamed 0)
Size before 1.08 MB (1,136,923 B)
Size after 1.13 MB (1,186,383 B)
Total size change +48.3 KB (+49,460 B)
File Before After Change
crates/engine/src/tests.rs 758.2 KB 778.2 KB +20.0 KB
crates/engine/src/cmd/layout.rs 100.2 KB 119.0 KB +18.7 KB
crates/render/src/layout.rs 96.7 KB 101.7 KB +5.0 KB
crates/data/src/raster/wkt.rs 69.4 KB 71.2 KB +1.8 KB
docs/user-guide/layouts.md 15.2 KB 17.0 KB +1.8 KB
crates/map/src/layout.rs 59.4 KB 59.8 KB +0.5 KB
crates/assistant/skills/print-layout/SKILL.md 2.2 KB 2.5 KB +353 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

opengeos#706 went in as one commit; its content is this branch's already, so each
conflict keeps this side (part 3's corner placement, decimal comma and the
review fixes since), and main's other changes in those files stay.
frame_coverage's set-aside label lock takes main's LabelKey, as Map's now
holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elpidioassinaturas
elpidioassinaturas marked this pull request as ready for review October 23, 2026 15:02
Comment thread crates/engine/src/cmd/layout.rs Resolved
Comment thread crates/engine/src/cmd/layout.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no blocking problems in this PR. I read the diff and the surrounding source only, and did not build or run anything. The concerns below are minor.

Bugs

  • None found. I checked the following and they hold up:
    • UTM table: the arithmetic in utm_of_code is right (SIRGAS 31965→zone 11N, 31983→23S), and the round-trip test covers it.
    • frame_coverage: a Drop guard restores the basemap, tiles, graticule and label lock even on a panic.
    • covered(): it clamps its grid indices, so out-of-range rectangles score 0 instead of panicking.
    • layout.page: a bad decimal returns an error before anything is changed.
    • expand: it replaces {scale} before the other tokens, so layout or page names can't spoof the token.
  • The legend is clamped to at least 10 mm beside the arrow or scale bar. It can therefore still overlap them in very small frames. The overlap warning reports this, so I count it as intended (confidence: medium that it's by design).

Security

  • None. All new parameters are validated: decimal accepts only . or ,, and there is no new file or network access.

Performance

  • frame_coverage renders the real map once at about 96 cells wide per publication layout. That is acceptable. covered() is recomputed for each of the 256 picks, and the search is cheap, but caching it per (surround, corner) would be tidier (confidence: low, inline comment posted).

Quality

  • The doc comment on OVER_DATA doesn't parse. The PR text says "at most 24" combinations while the code comment says 256 picks with duplicates skipped (confidence: high, nit, inline comment posted).
  • publication in cmd/layout.rs keeps growing past 500 lines. Moving the placement search into a helper would make it testable without a full Session (confidence: low).
  • The test publication_layouts_fit_their_pages now accepts one "on what the map shows" warning on the sample world. That is a reasonable loosening, but it makes the test less strict about warnings (confidence: low).

AGENTS.md

  • No unwrap, expect or unsafe in the non-test code I reviewed. Indexing is done with get().
  • Interface text: the new warnings are command output rather than UI literals, consistent with the existing warnings.
  • layers and wasm: frame_coverage uses only the render crate and the map crate, with no std::time.
  • Hostile parameters: decimal is handled in both commands. The PR doesn't say whether hostile_params_never_panic still passes, but the new code paths reject junk values with an error.

Change size

Compared: the whole PR against main (merge base 575b21f to PR head 571832d).

Metric Value
Files changed 8 (0 added, 8 modified, 0 removed, 0 renamed)
Size before 1.15 MB (1,207,774 B)
Size after 1.18 MB (1,237,131 B)
Total size change +28.7 KB (+29,357 B)
File Before After Change
crates/engine/src/cmd/layout.rs 108.3 KB 119.0 KB +10.7 KB
crates/engine/src/tests.rs 818.0 KB 827.6 KB +9.5 KB
crates/render/src/layout.rs 96.8 KB 101.8 KB +5.0 KB
crates/data/src/raster/wkt.rs 69.4 KB 71.2 KB +1.8 KB
docs/user-guide/layouts.md 16.1 KB 17.0 KB +939 B
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.4 KB 2.5 KB +153 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread crates/engine/src/cmd/layout.rs Resolved
Comment thread crates/engine/src/tests.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the whole diff and posted two inline comments. I didn't build the code or run the tests. I found no definite bugs.

Bugs

  • None found. I checked these:
    • the utm_of_code ranges and their round-trip against utm();
    • the corner search, which always has a valid pick, since 4ⁿ with n ≤ 4 includes distinct corners;
    • decimal_mark, which rejects bad input before layout.page changes anything;
    • the {scale} handling in expand.

Performance

  • frame_coverage renders the live map once more on every layout.publication call (crates/engine/src/cmd/layout.rs:927). It swaps out the basemap, tiles, graticule and label lock, and a Drop guard restores them. Large vector layers could make it slow, and in the browser it runs synchronously. Other render side effects, such as caches, aren't restored. Confidence: medium-low.
  • The 256-pick search over corner assignments is cheap.

Quality

  • The left_out assertion in publication_layouts_locate_their_area was removed (crates/engine/src/tests.rs:2808). The "no room beside the locator" path is no longer guaranteed to be exercised. Confidence: medium.
  • The sample-world publication test now allows one "on what the map shows" warning instead of none. That is reasonable, but it is a weaker check than before.
  • The decimal() helper swaps . and , in whole strings. This is fine for numeric labels. Confidence: low that it matters.

Security

  • None found. The new decimal parameter is validated, and nothing in the change reads external input in a new way.

AGENTS.md

  • No unwrap or panic in the non-test code I read. The new code uses get, .max and clamps, and layout.rs stays wasm-compatible.
  • Tests use unwrap, which is allowed.
  • The user-guide docs and the assistant skill text are updated for the new parameter.
  • I did not check hostile_params_never_panic coverage of decimal. Confidence: low.

Change size

Compared: the whole PR against main (merge base 575b21f to PR head 5d93ecc).

Metric Value
Files changed 8 (0 added, 8 modified, 0 removed, 0 renamed)
Size before 1.15 MB
Size after 1.18 MB
Total size change +28.7 KB
File Before After Change
crates/engine/src/cmd/layout.rs 108.3 KB 119.0 KB +10.7 KB
crates/engine/src/tests.rs 818.0 KB 827.6 KB +9.5 KB
crates/render/src/layout.rs 96.8 KB 101.9 KB +5.0 KB
crates/data/src/raster/wkt.rs 69.4 KB 71.2 KB +1.8 KB
docs/user-guide/layouts.md 16.1 KB 17.0 KB +939 B
crates/map/src/layout.rs 59.4 KB 59.8 KB +483 B
crates/assistant/skills/print-layout/SKILL.md 2.4 KB 2.5 KB +153 B
crates/map/src/graphics.rs 9.1 KB 9.2 KB +68 B

@giswqs
giswqs merged commit 3ec3d9c into opengeos:main Oct 23, 2026
20 checks passed
elpidioassinaturas pushed a commit to elpidioassinaturas/RustGIS that referenced this pull request Oct 23, 2026
Conflicts were all between opengeos#709's squash (identical to 5d93ecc in these files)
and this branch, which holds 5d93ecc plus part 4: each hunk kept ours. The
block git placed twice (Surround, COLORBAR_MM, OVER_DATA, decimal_mark, at
opengeos#709's position as well as ours) is kept once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants