Repository navigation
feat(layout): write layout files with a format header (#2277) - #2805
Conversation
Layout files (.rgislayout) are now written as map and layer files are:
{"format": 2, "requires": [...], ...layout}, requiring what the layout's
elements use that an older reader would draw without and save again
without. The reader shipped in v0.8.0 (opengeos#2527), so a released RustGIS
refuses such a file by name instead of losing what it can't keep.
The layout element checks move from Project::required_capabilities into
layout_capabilities, which the project and layout_file_bytes both call;
the project's requires is unchanged. layout.save and the browser download
of Save Layout File write through layout_file_bytes.
Closes opengeos#2277
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewOverall the change is sound. I found no bugs, security problems or AGENTS.md breaks. I did not build or run the tests (no shell in this review), so the test results below are from reading the code. Bugs
Security
Performance
Quality
AGENTS.md
Prior concerns
Change sizeCompared with main (merge base 3119075 to PR head d3f91fa).
|
📖 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 |
Code reviewI found no bugs, security issues, or AGENTS.md violations in this PR. I did not post any inline comments. There were no earlier review threads, so no concerns were skipped. BugsNone found. Confidence: high. Checked:
SecurityNone found. Confidence: high. PerformanceNone found. Confidence: high. QualityNone worth an inline comment. Two notes for the maintainers:
AGENTS.mdNone found. Confidence: high. The PR updates the docs that said layout files were not covered, covers the browser and desktop paths through one function, and adds tests in both directions (headed and unheaded, one layout and several). It needs no schema regeneration, since layout files are not project saves and no layout-file schema exists. Change sizeCompared: the whole PR against main (merge base 3119075 to PR head d3f91fa).
|
Summary
Layout files (
.rgislayout) are now written with a format header, as map and layer files are:"format": 2and, when the layout's elements use something an older reader would draw without and save again without,"requires"naming it. This is the writer half of #2277; the reader went out in v0.8.0 with #2527, so a released RustGIS already refuses such a file by name instead of opening it and losing the element's background, ink, wrap, chart settings, frame border or text size.layout_capabilities(crates/engine/src/project_capabilities.rs) holds the layout element checks thatProject::required_capabilitiesmade inline. The project and the layout file both call it, so a layout element capability added later is required in both places. The project'srequiresis unchanged, in the same order.layout_file_byteswrites{format, requires, ...layout}with the sameItemheader asmap_file_bytes. It stays indented, as layout files have always been, so the header is the only change to the file. It never requirescrs-wkt: a layout holds no coordinate system, only a measured grid's as text.layout.save(desktop, CLI, Python, scripts, tasks: every caller of the command) and the browser download of Save Layout File (ui.saveLayout) both write through it, so the two give the same bytes. The phone (ui-touch) has no layout save. No command, parameter or help text changes.docs/maintaining.md: the "Layout files are not covered ([Feature]: Layout files (.rgislayout): a checked format header, so an older RustGIS refuses what it can't keep #2277)" sentences are gone, and the backgrounds paragraph says what layout files now carry. Theimported_layout_usesdoc comment says a layout file read from a path brings its own header.Releases before v0.8.0 still read a headed file as before, ignoring the header. That limit is why the writer waited for a release carrying the reader.
#2666 (open) adds a layout capability,
layout-scale-bar-details, inline inProject::required_capabilities. Whichever of the two merges second moves it intolayout_capabilities, so layout files require it too.Testing
crates/engine/src/tests/layout_files.rs:a_saved_layout_file_requires_what_its_elements_use_and_reads_back_the_same: for eleven layout fixtures inschema/fixtures/, which cover the nine capabilities (layout_chart_lookandlayout_chart_stackneed two at once, withlayout-chart-data) plus one fixture that needs none, the file'srequiresequals therequireswritten in the fixture, not one worked out again by the code under test. Imported into that project without its layout, the layout is the same, and saved again the file is byte for byte the same.a_layout_file_requires_nothing_for_other_layouts_or_saved_commands: a second, plain layout of a project with a background and a savedwrapcommand writes norequires. The layout with the background requires only that.crates/ui-egui/src/lib.rs:layout_download_is_the_saved_layout_file. The browser download gives the same bytes aslayout.save, header included.formatin the file) and passes after.cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo nextest run --workspace(9189 passed; the two DuckDB tests that need a local DuckDB left out), doctests,cargo xtask layersandcargo xtask schema --check: all pass.UI evidence
No visible UI change.
Related issue
Closes #2277
Summary by CodeRabbit