You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(layout): read each layer once for the statistics of all of a publication's texts - #3634
layout.publication read a layer once for each text holding one of its statistics ({count:Layer}, {sum:Layer:field}…), twice over: to measure the texts and to say which figures they miss. Both now gather the tokens of all the texts first, so each of the two reads a layer once, however many texts name it.
statistic_figures works out the figures of all the texts together.
statistic_notices_each (new) gives each text's notices from one set of figures; say_layout_text_statistics calls it, so importing a layout and changing the first frame's map read once too. The notices and their order are unchanged.
Tokens are deduplicated and grouped by layer through hashed lookups, as the list now spans every text of a layout.
The change is in the engine and the renderer, so the desktop app, the browser, the command line, Python, the phone, the Assistant and MCP all get it through the same commands; no command, parameter or saved data changes, so there is nothing new to undo.
Measuring and the notices remain two separate passes. Drawing a layout still reads text by text; that is outside this command.
Testing
New tests in crates/render/src/layout/tests/statistic_passes.rs count the passes over a layer; three of them failed before the change (5 and 4 passes where 1 and 2 are expected).
Counted layer_statistics calls under a debugger for rustgis-cli run --sample --cmd layout.publication=…: on main, 2 with one text holding {count:Countries} and 10 with five; with this change, 2 in both.
checks.sh: fmt, clippy, doctests, layers and schema --check pass. nextest: 12353 of 12365 pass. The 12 failures are in rustgis-geolibre (7), rustgis-ui-egui's smoke test (1), and four map frame tests of rustgis-ui-egui; those four fail the same way on main (c4cc3d9) on this machine, and none touches the code changed here.
No actionable comments were generated in the recent review.
Walkthrough
Layout text statistics now calculate figures across multiple texts and avoid repeating calculations for tokens that reference the same layer. The layout command requests per-text notices in one call, and tests verify pass counts and notice results.
Changes: Layout text statistics
Layer / File(s)
Summary
Batch token and figure calculation crates/render/src/layout/dynamic_text.rs
The notice API accepts multiple texts, deduplicates statistic tokens, and calculates figures once per referenced layer. It returns notices for each text.
Layout command integration and validation crates/engine/src/cmd/layout/text.rs, crates/render/src/layout/dynamic_text.rs, crates/render/src/layout/tests.rs, crates/render/src/layout/tests/statistic_passes.rs
The layout command collects text contents and warns on returned notices. Tests check layer pass counts, token order, per-text notices, and cases with no usable map.
opengeos/RustGIS#2853 — Defines the layer-statistic tokens that this change processes across layout texts.
Possibly related PRs
opengeos/RustGIS#2980: Introduced the layer-statistic tokens and figure computation that this change updates.
opengeos/RustGIS#3073: Established the layout module structure used by the added statistic-pass tests.
Suggested reviewers:giswqs, mavrick-f
Merge Risk: Minimal · up to ea1c3
This change reduces repeated layer reads when computing layout text statistics. Commands, parameters, and saved data are unchanged. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: layout.publication now reads each layer once for the statistics of all of a publication's texts. It matches the summary, the objectives, and the linked issue #3132. Th…
Description check
The description follows the template. It has a Summary that explains the change and why. It has a Testing section with new tests, debugger counts, and checks.sh and nextest results. The UI evidence se…
Linked Issues check
[#3132] The issue requires one layer pass across all texts that name the same layer, for layout.publication. The reviewed head changes distinct_stat_tokens in `crates/render/src/layout/dynamic_tex…
Out of Scope Changes check
All changed code serves the fix for #3132. The changes are: (1) figures_of and distinct_stat_tokens now work across texts, which is the core fix; (2) statistic_notices_each is a new public funct…
Full details: Title check
Explanation
The title names the main change: layout.publication now reads each layer once for the statistics of all of a publication's texts. It matches the summary, the objectives, and the linked issue #3132. The fix(layout) prefix fits a bug fix. The title is 84 characters, a little long, but it is specific and clear.
Full details: Description check
Explanation
The description follows the template. It has a Summary that explains the change and why. It has a Testing section with new tests, debugger counts, and checks.sh and nextest results. The UI evidence section states 'No visible UI change.', which the template allows. It has a Related issue section that closes #3132. The description is complete and specific.
Full details: Linked Issues check
Explanation
[#3132] The issue requires one layer pass across all texts that name the same layer, for layout.publication. The reviewed head changes distinct_stat_tokens in crates/render/src/layout/dynamic_text.rs to take all texts at once and deduplicate tokens across them. statistic_figures now calls figures_of once over that combined token list. figures_of groups tokens by lowercased layer name and calls rustgis_map::layout::layer_statistics once per group, with the PASSES test counter recording each group pass. Because one call covers every text, each layer is read once per publication measurement. The notice path (notices_over) gathers tokens across texts too, computes one figures_of call, and then reuses the figures per text through statistic_notices_each, so the notices pass also reads each layer once. Evidence limits: the diff for crates/engine/src/cmd/layout/text.rs could not be read, so the wiring of say_layout_text_statistics is not verified from source. The new tests and the debugger pass counts are author-reported and were not re-run here. The render-level change alone covers the acceptance criterion.
Full details: Out of Scope Changes check
Explanation
All changed code serves the fix for #3132. The changes are: (1) figures_of and distinct_stat_tokens now work across texts, which is the core fix; (2) statistic_notices_each is a new public function that shares one figure set across texts, which the PR summary and the say_layout_text_statistics change in crates/engine/src/cmd/layout/text.rs use for the notice pass, a second read of the same layers; (3) statistic_notices, map_statistic_notices and statistics delegate to the shared logic with unchanged behavior for one text; (4) #[cfg(test)] pass counter and the statistic_passes test module support verification of the fix. No unrelated feature or behavior change was found in the reviewed render diff. The engine diff could not be read, so its exact content is unverified, but its described purpose is the same notice-pass consolidation.
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.
A rabbit gathers tokens from each page, One layer pass replaces many a gauge. The notices return to text in line, While title, note, and source align. The rabbit thumps: “Each figure’s fine!”
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: 0cb8f953-03b8-4e5d-9018-9d10db96bdd1
Commits
Reviewing files that changed from the base of the PR and between c4cc3d9 and ea1c3ef.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
layout.publicationread a layer once for each text holding one of its statistics ({count:Layer},{sum:Layer:field}…), twice over: to measure the texts and to say which figures they miss. Both now gather the tokens of all the texts first, so each of the two reads a layer once, however many texts name it.statistic_figuresworks out the figures of all the texts together.statistic_notices_each(new) gives each text's notices from one set of figures;say_layout_text_statisticscalls it, so importing a layout and changing the first frame's map read once too. The notices and their order are unchanged.The change is in the engine and the renderer, so the desktop app, the browser, the command line, Python, the phone, the Assistant and MCP all get it through the same commands; no command, parameter or saved data changes, so there is nothing new to undo.
Measuring and the notices remain two separate passes. Drawing a layout still reads text by text; that is outside this command.
Testing
crates/render/src/layout/tests/statistic_passes.rscount the passes over a layer; three of them failed before the change (5 and 4 passes where 1 and 2 are expected).layer_statisticscalls under a debugger forrustgis-cli run --sample --cmd layout.publication=…: onmain, 2 with one text holding{count:Countries}and 10 with five; with this change, 2 in both.checks.sh: fmt, clippy, doctests, layers andschema --checkpass. nextest: 12353 of 12365 pass. The 12 failures are inrustgis-geolibre(7),rustgis-ui-egui's smoke test (1), and four map frame tests ofrustgis-ui-egui; those four fail the same way onmain(c4cc3d9) on this machine, and none touches the code changed here.UI evidence
No visible UI change.
Related issue
Closes #3132
Summary by CodeRabbit