Skip to content

QGIS import: print layouts' atlases as map series (piece 12c of #882, second part) - #3674

Open
pick2510 wants to merge 1 commit into
opengeos:mainfrom
pick2510:qgis-layouts-f
Open

pick2510 wants to merge 1 commit into
opengeos:mainfrom
pick2510:qgis-layouts-f

Conversation

@pick2510

@pick2510 pick2510 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Piece 12c of #882, second part, which completes piece 12. project.importQgis now brings in a QGIS print layout's atlas as a map series. Until now an atlas was only noted.

  • Which frame: on each page with a map item following the atlas (AtlasMap atlasDriven="1"), the first such map in QGIS's drawing order becomes the frame of that page's map series. Each page of a QGIS layout is a RustGIS layout, so an atlas over several pages gives each of them a series.
  • Its layer: the coverage layer, as it came in and as it is drawn (the topmost of its name), as attribute tables find theirs. The frame is shown on the series' first page, as layout.seriesPage shows it.
  • Page names: the field the page name expression names, written raw, in double quotes or in another case. An atlas without an expression prints an empty name, as QGIS does.
  • Margin: in Auto mode, QGIS grows the feature's box by its margin in total (checked with PyQGIS: 0.1 makes a 1,000 m feature 1,100 m wide). A series pads each side and then fits 10% over (FIT_MARGIN), so the margin is converted: QGIS's default 10% becomes a series margin of 0.
  • Tokens:
    • @atlas_pagename, @atlas_featurenumber and @atlas_totalfeatures become {pageName}, {page} and {pages} on a page with the series.
    • @layout_page and @layout_numpages there print the layout's own page, as QGIS does (1 of 1 on a one-page layout), since {page} counts the series' features.
  • Noted (approximated):
    • its filter (a page for each feature) and sort order (the layer's order);
    • a hidden coverage layer (shown);
    • a file name pattern other than QGIS's default;
    • a fixed or predefined scale, and an atlas of points, zoomed to each feature (QGIS keeps a point atlas's map scale);
    • a margin a series can't take (under 10% or over 1,110%, or one that doesn't read);
    • clipping to the feature;
    • further maps following it on a page (kept at their own extent);
    • atlas tokens on a page without its map (kept as written);
    • page names by an expression or a field the layer hasn't (named by their numbers).
  • Left out, noted:
    • an atlas whose coverage layer isn't the project's, didn't come in as a feature layer, has no features or is read in place;
    • an atlas with no map following it, or none that came in;
    • texts printing the page of a series left out, which print a first page of one, unnamed, said with their count.
    • Each atlas is counted once, on its first page, however many pages it covers.

A change to map series

layout.seriesPage (and the series' pages in an export) padded every feature by at least 0.01° on each side, about 1 km. Any feature much smaller than that, such as a parcel or the corpus's 150 m polygons, was lost in the middle of its frame. The floor now applies only to a lone point, which has no size to take a margin of. Every other feature is padded by its margin alone (rustgis_map::layout::series_extent, used by both paths). Saved frames don't move until a page is stepped or exported, but a re-exported series of small features is framed more tightly. The user guide's map series section says so.

Reach

  • Desktop: inline and through the background import, whose layouts land unchanged with their series.
  • Browser, command line, Python, Assistant and MCP: they all run project.importQgis. Its parameters and answer are unchanged. The series commands are unchanged apart from the padding above.
  • Phone: as the desktop.
  • The way back: Undo removes the map and its layouts together. An imported series is changed or switched off with layout.series like any other.

No code from other projects was followed. QGIS's file format was read from files QGIS wrote, and its behaviour from its exports and from PyQGIS probes, not from its source.

Known, not handled

  • A RustGIS table can't follow a series' page, so tables of the atlas's feature stay left out (noted, as before).
  • RustGIS draws a page's feature about 4% smaller than QGIS's export of the corpus project (see the screenshots).
  • A point atlas at a fixed scale gets two notes for one approximation. When the engine leaves a series out, the approximation notes the reader made for its atlas are still said.

Testing

  • crates/map/src/qgis/layout_atlas_tests.rs, 8 tests, both ways: the corpus atlas with nothing said; an unnamed atlas and the layout's own page; every setting a series has no place for, said once; atlases left out (unknown layer, no map following, switched off); atlas tokens on a page without its map; the margin conversion; a margin that doesn't read; the first page of an atlas over two pages.
  • crates/engine/src/tests/qgis_atlas.rs, 6 tests:
    • the corpus atlas lands as a series of the polygons named by "name", its frame on page 1 as layout.seriesPage frames it, stepping and exporting;
    • page names by an expression and by a field in another case or in quotes;
    • a point atlas;
    • a coverage layer that doesn't come in, or comes in empty, with its texts said;
    • an atlas over two pages, a series each and said once;
    • layout.seriesPage framing a small polygon by its margin alone and a point with 0.01°.
  • crates/map/src/layout/tests.rs: series_extent, both cases.
  • Updated: the every-item corpus project's atlas now comes in (no note); the corpus count (44 projects).
  • New corpus project layout-atlas.qgs, written by QGIS 4.4.0 from generate.py.
  • Checks run:
    • cargo fmt;
    • clippy with -D warnings on map and engine;
    • the map crate suite and the engine suite (3,412). The only failure was cog_windows_stand_in_the_level_kept_until_their_tiles_arrive, which is flaky and fails without this change too;
    • the render suite: six font, scale bar and text tests fail on this machine with or without this change;
    • test-hygiene, rows;
    • the wasm build as CI runs it.
  • A read-only review ran before this PR, then re-checked the fixes. What it found is fixed here, except the points under "Known, not handled".

UI evidence

New UI (after only). The corpus's atlas layout as RustGIS exports it after the import, page 1:

rustgis-atlas-1.png

Page 5, after layout.seriesPage:

rustgis-atlas-5.png

QGIS 4.4.0's own export of page 1, for comparison:

qgis-atlas-1.png

Related issue

Part of #882 (piece 12c, second part; completes piece 12).

Summary by CodeRabbit

  • New Features
    • QGIS atlas layouts can now be imported as map series, with coverage-layer navigation, page names, and supported page expressions.
  • Improvements
    • Map-series pages now frame small features with margins based on their extent, while point features receive a small fixed extent.
    • Import reports identify atlas settings or content that could not be represented.
  • Documentation
    • Updated the layout and workspace guides with atlas import behavior and map-series margin details.

…eos#882, second part)

A QGIS layout's atlas becomes a map series on each page with a map
following it: that page's first such map steps through the coverage
layer as it came in, at the atlas map's margin, its pages named by the
field the page name expression names. Atlas tokens print the series'
page there. Filters, sorts, a hidden coverage layer, file name patterns,
fixed or predefined scales, points, margins a series can't take,
clipping and further maps are noted; an atlas a series can't be made of
is left out, noted, with the texts printing its page.

A map series' page now pads a feature by its margin alone; the 0.01°
floor stays for a lone point (small features were lost in a kilometre
around them). A 44th generated project in the corpus.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

QGIS atlas definitions are imported as layout map series with coverage layers, page naming, margins, and atlas label handling. The engine attaches series to supported feature layers and frames pages from feature extents. Unsupported or omitted atlas settings produce report notes.

Changes: QGIS atlas parsing and association

Layer / File(s) Summary
Atlas series metadata and map association
crates/map/src/qgis/layout.rs, crates/map/src/qgis/layout/atlas.rs, crates/map/src/qgis/layout_atlas_tests.rs
The parser records atlas metadata and associates the first qualifying following map with a series. It converts margins and reports unsupported settings. Tests cover atlas selection, margins, and omitted series cases.
Atlas labels and import reporting
crates/map/src/qgis/layout.rs, crates/map/src/qgis/layout/atlas.rs, crates/map/src/qgis/layout_atlas_tests.rs, crates/map/src/qgis/layout_tests.rs, crates/map/src/qgis/mod.rs, crates/map/src/qgis/tests.rs, docs/user-guide/workspace.md
Atlas page expressions are translated when a series is available and retained when it is not. Atlas-specific report notes and public helpers are added. Tests and documentation cover label handling and reporting.

Engine series attachment and page framing

Layer / File(s) Summary
Engine series attachment and page framing
crates/engine/src/cmd/qgis.rs, crates/engine/src/cmd/layout/series.rs, crates/engine/src/tests.rs, crates/engine/src/tests/qgis_atlas.rs, crates/map/src/layout.rs, crates/map/src/layout/tests.rs, docs/user-guide/layouts.md
The engine attaches a series when its coverage layer supports series and has features. It resolves page-name fields, sets the initial frame, and reports omitted or approximated behavior. Series-page framing uses feature-relative margins and a fixed padding for point extents.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant QGISLayoutParser
  participant ProjectLayout
  participant land_series
  participant FeatureLayer
  participant series_page
  QGISLayoutParser->>ProjectLayout: Record atlas series metadata
  land_series->>FeatureLayer: Resolve coverage layer and read features
  FeatureLayer-->>land_series: Return first feature extent
  land_series->>ProjectLayout: Attach supported map series
  series_page->>FeatureLayer: Read feature for selected page
  FeatureLayer-->>series_page: Return feature extent
Loading

Possibly related issues

  • opengeos/RustGIS issue 882 — The tracking issue lists atlas map-series import as remaining QGIS import parity work, which this change implements.

Suggested reviewers: jgregoriorincon, mavrick-f

Merge Risk: Minimal · up to b3b86 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: QGIS print layout atlases are now imported as RustGIS map series. The raw summary and PR objectives confirm that land_series, the atlas reader, and the tests implement…
Description check Passed The description follows the template's Summary, Testing, UI evidence, and Related issue sections. Summary explains the atlas-to-series import, the frame and layer choice, page names, margin conversion…
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.
Full details: Title check

Explanation

The title names the main change: QGIS print layout atlases are now imported as RustGIS map series. The raw summary and PR objectives confirm that land_series, the atlas reader, and the tests implement this. The title also names the piece-12c scope, which fits the changeset. It is specific and concise, and a teammate scanning history would understand the primary change.

Full details: Description check

Explanation

The description follows the template's Summary, Testing, UI evidence, and Related issue sections. Summary explains the atlas-to-series import, the frame and layer choice, page names, margin conversion, token translation, the approximated and left-out cases, and the series framing change. Testing lists the new test files, the checks run, and one known failing test. UI evidence contains before-and-after style screenshots, which fit the template's requirement for visible UI changes. Related issue cites Part of #882. The template's UI evidence section requires screenshots, and the description supplies them, so the section is complete.

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 maps the pages bright,
Through atlas fields and frames of light.
A margin keeps each feature near,
While page names hop from far to here.
The map turns pages, neat and clear,
And leaves a note when maps disappear.

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: c038771d-2abe-4155-8fc6-b058d538db16
Commits

Reviewing files that changed from the base of the PR and between ea3413c and b3b8693.

Files ignored due to path filters: 2

  • crates/map/testdata/qgis/generated/generate.py is excluded by !**/generated/**
  • crates/map/testdata/qgis/generated/qgs/layout-atlas.qgs is excluded by !**/generated/**
Files selected for processing: 14

  • crates/engine/src/cmd/layout/series.rs
  • crates/engine/src/cmd/qgis.rs
  • crates/engine/src/tests.rs
  • crates/engine/src/tests/qgis_atlas.rs
  • crates/map/src/layout.rs
  • crates/map/src/layout/tests.rs
  • crates/map/src/qgis/layout.rs
  • crates/map/src/qgis/layout/atlas.rs
  • crates/map/src/qgis/layout_atlas_tests.rs
  • crates/map/src/qgis/layout_tests.rs
  • crates/map/src/qgis/mod.rs
  • crates/map/src/qgis/tests.rs
  • docs/user-guide/layouts.md
  • docs/user-guide/workspace.md

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

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Code review

I reviewed the diff statically. I could not build or run the tests here, so the claims in the PR's testing section are unverified. There were no earlier review threads on this PR, so I left no earlier concerns out.

Bugs

  • None confirmed. I checked the layout-index mapping (Placed.page against layouts in finish), the per-label atlas_here reset in label_item, the once-per-atlas counting via read.first, the series removal and report in Layout::clamp, and margin clamping (series_margin, layout.series, both 0 to 5). I found no unwrap, expect, panic! or indexing in new non-test code.

Security

  • None found.

Performance

  • None found. The work per atlas is one pass over the layout's items plus one rows_extent([0]). The series stores names and margins, not layer data, so it adds no second copy.

Quality

  • crates/map/src/qgis/layout/atlas.rs:165: the margin note also fires for fixed-scale and predefined maps, where QGIS ignores the margin. Confidence medium, based on the PR's own description rather than QGIS source. (Inline.)
  • crates/engine/src/cmd/qgis.rs:1695: fit_scale clamps the series scale to MIN_FRAME_SCALE (0.5) with no notice. Features under roughly 9 cm across are zoomed out silently, while the frame loop reports the same case as scaled. Confidence medium-low. (Inline.)
  • crates/map/src/qgis/layout/atlas.rs:172: nits (missing doc on the pub const, a spelled-out HashSet, a test-only shim). For the release quality pass. (Inline.)

AGENTS.md

  • None found. No command was added or renamed, so command-surface.txt is unchanged. No saved format changed, so no schema step is needed. The docs match the behaviour. Nothing platform-specific was added, so the wasm build is unaffected.

Twins checked

  • layout.seriesPage and the series export in export.rs both use series_extent, so they agree.
  • project.importQgis runs inline, through the background import, and through the ahead-on-copy path. All three reach add_layouts, so the series lands on each.
  • No other QGIS read route builds ProjectLayouts. layout.import is native and unaffected.

Unverified question (not posted)

  • The atlas note covers only filename patterns and says the import exports one PDF. QGIS's single-file export setting is not read. The corpus XML has no such attribute, so I could not confirm how QGIS writes it. Confidence low.

Change size

Compared with the base branch: the whole PR against main (merge base 97d2279 to PR head b3b8693).

Files changed Added Modified Removed Renamed Size before Size after Total change
16 4 12 0 0 5.17 MB 5.30 MB +131.1 KB
Path Size before Size after Size change
crates/map/testdata/qgis/generated/qgs/layout-atlas.qgs 0 B 86.3 KB +86.3 KB
crates/map/src/qgis/layout_atlas_tests.rs 0 B 10.9 KB +10.9 KB
crates/engine/src/tests/qgis_atlas.rs 0 B 10.2 KB +10.2 KB
crates/map/src/qgis/layout/atlas.rs 0 B 10.0 KB +10.0 KB
crates/engine/src/cmd/qgis.rs 168.3 KB 173.9 KB +5.6 KB
crates/map/src/qgis/layout.rs 83.5 KB 86.6 KB +3.1 KB
crates/map/testdata/qgis/generated/generate.py 75.9 KB 78.0 KB +2.1 KB
docs/user-guide/workspace.md 65.0 KB 66.1 KB +1.1 KB
crates/map/src/layout/tests.rs 139.5 KB 140.3 KB +708 B
crates/map/src/qgis/layout_tests.rs 62.2 KB 62.7 KB +510 B
crates/map/src/layout.rs 41.5 KB 42.0 KB +494 B
crates/map/src/qgis/mod.rs 75.9 KB 76.0 KB +93 B
docs/user-guide/layouts.md 112.0 KB 112.0 KB +69 B
crates/engine/src/cmd/layout/series.rs 4.3 KB 4.3 KB +24 B
crates/engine/src/tests.rs 4.09 MB 4.09 MB +16 B
crates/map/src/qgis/tests.rs 250.1 KB 250.1 KB 0 B

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3674/
Web app https://preview.rustgis.app/pr-3674/app/
Commit b3b8693

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 branch has not been deployed

No deployments
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.

1 participant