Skip to content
2 changes: 1 addition & 1 deletion crates/assistant/skills/print-layout/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Make a printable page layout — map frame, title, legend, north ar
1. Get the map right first: symbology, labels and extent. A layout's map frame shows the map's current view.
2. For a finished sheet or a figure for a paper in one step, use `layout.publication` with a `"profile"`
(a page size alone, `"a4"`, `"letter"`, `"legal"`, `"tabloid"`, `"a5"` to `"a0"`, for a sheet turned to the area's shape, or with its orientation, `"a4-portrait"`, `"letter-landscape"`, … to choose; `"figure-1col"`, `"thesis-full"`, … for a figure), the `"extent"`
to fit, and the texts: `"title"`, `"subtitle"`, `"sources"`, `"note"`, a `"locator"` (`"globe"`: the visible polygon layers held in the project, not streamed ones, over the basemap; `"inset"`; `["inset", "globe"]`, both, the globe outlining the inset; or `"none"`; when omitted, `"globe"` on a sheet and `"none"` on a figure), and `"decimal": ","` for a map in a language with a decimal comma. A sheet's `"style"` arranges it: `"classic"` (the default), `"banner"`, `"panel"`, `"editorial"`, `"modular"`, `"poster"` (for a poster-like sheet), `"edge"` (the map from side to side of the page; it also takes `"paper"`, the page colour as `"#RRGGBB"`, `"kicker"`, a short line over the title, and `"figures"`, up to three `{"value", "label"}` under the map, whose texts may hold layer statistics such as `{count:Layer}`; `"panel"` takes `"figures"` too, stacked in its panel) or `"mosaic"` (a key map and 1 to 6 detail maps numbered on it, listed in `"panels"` as `[west, south, east, north]` in degrees; without `"extent"` the key map holds them all), with an `"accent"` colour as `"#RRGGBB"`. Its
to fit, and the texts: `"title"`, `"subtitle"`, `"sources"`, `"note"`, a `"locator"` (`"globe"`: the visible polygon layers held in the project, not streamed ones, over the basemap; `"inset"`; `["inset", "globe"]`, both, the globe outlining the inset; or `"none"`; when omitted, `"globe"` on a sheet and `"none"` on a figure), and `"decimal": ","` for a map in a language with a decimal comma. A sheet's `"style"` arranges it: `"classic"` (the default), `"banner"`, `"panel"`, `"editorial"`, `"modular"`, `"poster"` (for a poster-like sheet), `"edge"` (the map from side to side of the page; it also takes `"paper"`, the page colour as `"#RRGGBB"`, `"kicker"`, a short line over the title, and `"figures"`, up to three `{"value", "label"}` under the map, whose texts may hold layer statistics such as `{count:Layer}`; `"panel"` takes `"figures"` too, stacked in its panel) or `"mosaic"` (a key map and 1 to 6 detail maps numbered on it, listed in `"panels"` as `[west, south, east, north]` in degrees, or as `{"extent": …}` or `{"bookmark": "name"}` of the map, with a `"label"` on its number and a `"scale"` (1:N) if wanted; without `"extent"` the key map holds them all), with an `"accent"` colour as `"#RRGGBB"`. Its
surrounds (locator, north arrow, legend, scale bar) start from an `"arrangement"` (`"classic"`, `"mirrored"`, `"legendRight"`, `"legendTop"`, or a corner for each; `"best"`, the default, tries the user's favourite, set with `layout.arrangement`, and the others), and one over the data moves to the freest place in the frame, the largest first (the legend, as a rule); read its `"arrangement"`, `"moved"` and `"warnings"`. It places the frame at a round scale, the
graticule, legend (a long one in up to three columns: its own choice, though a legend takes up to six), scale bar and north arrow, and wraps the footer. `"grid"`, `"scaleBar"` and `"northArrow"` take `"none"` to leave that part out, or an object of its options (the grid's `"step"` or `"type"`, the bar's `"units"` or `"style"`, the arrow's `"style"`, `"fill"`, `"outline"` and `"show"`). Its result lists every element's id and name
(`"elements"`), so skip to step 5 to adjust them. Otherwise,
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/cmd/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn commands() -> Vec<C> {
r#""legend"?: "none" (no legend; a colorbar keeps its box, and the answer's "legendColumns" is null) | {"title"?: text, "columns"?: 1 to 6 (that many; the placement picks 1 to 3 otherwise), "exclude"?: [layer names] (left out besides the context ones)}, "#,
r#""legendBox"?: "auto" (the default: over the map, the legend has no box where the map shows nothing under it but its light plain paper or water, with no layer, context, basemap shape or graticule line there and no veil; the answer's "legendBox" says whether it has one) | "always", "#,
r#""style"?: "classic" (the default: the title over the map, the footer under it) | "banner" (the title and subtitle in a band of the accent colour across the top) | "panel" (the map at the left, a panel at the right with the title, locator, legend, sources and reference) | "editorial" (the title large in serif, a column at the right with the note, the locator and the legend) | "modular" (cards on a light page: the map, the locator and the legend each in one, the sources and reference in tinted ones) | "poster" (the page in the accent colour, the title in light text, the map in a light card, the footer in darker blocks) | "edge" (the map from one side of the page to the other with no border, a kicker and the title over it, the footer with no boxes under a thin rule) | "mosaic" (the classic sheet with its map area split into a key map, which takes the legend, scale bar, north arrow and locator, and a grid of detail maps that "panels" lists, each numbered as the key map numbers its outline) (a sheet's arrangement; figures leave it to the caption), "#,
r#""panels"?: 1 to 6 [west, south, east, north] in degrees (a mosaic sheet's detail maps, each fitted at a round scale; without "extent" the key map holds them all; "crs" doesn't apply to them), "#,
r#""panels"?: 1 to 6 [west, south, east, north] in degrees, or {"extent": [w, s, e, n] | "bookmark": a bookmark's name, "label"?: text (on the number's plate), "scale"?: N (1:N, centred on the extent)} (a mosaic sheet's detail maps, each fitted at a round scale unless given one; without "extent" the key map holds them all; "crs" doesn't apply to them), "#,
r##""paper"?: "#RRGGBB" (an edge sheet's page colour, as layout.page's "color"; white by default; on a dark one its texts are light), "##,
r#""kicker"?: text (an edge sheet's short line in spaced capitals over the title, in the accent colour), "#,
r#""figures"?: up to three {"value": text, "label"?: text} (a sheet's headline figures: an edge sheet's in columns under the map, a panel sheet's stacked in its panel; a value may hold layer statistics such as {count:Layer}), "#,
Expand Down
42 changes: 31 additions & 11 deletions crates/engine/src/cmd/layout/publication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ pub(in crate::cmd::layout) fn publication(s: &mut Session, p: &Value) -> CmdResu
let (sheet, page_w, page_h) = (profile.sheet, profile.width, profile.height);
let whole_globe = shows_whole_globe(s.map(), p);
// Its error is raised once the style is known: another style is told panels isn't for it.
let panels = publication_panels(p);
let panels = publication_panels(s, p);
let globe = s.map().projection.is_globe();
let around_panels = panels.as_ref().ok().and_then(|p| p.as_deref()).map(|p| panels_extent(p, globe));
let around_panels = panels
.as_ref()
.ok()
.and_then(|p| p.as_deref())
.map(|p| panels_extent(&p.iter().map(|panel| panel.extent).collect::<Vec<_>>(), globe));
// An extent in the map's own system (#3322): `plane` is that rectangle, framed as it is, and
// `extent` only says how large it is in degrees.
let in_own = match crate::cmd::imagery::crs_param(s, p, "crs")? {
Expand Down Expand Up @@ -246,6 +250,7 @@ pub(in crate::cmd::layout) fn publication(s: &mut Session, p: &Value) -> CmdResu
.filter_map(|t| t.as_deref())
.chain(sources.iter().chain(&reference).chain(&headings).map(String::as_str))
.chain(headlines.iter().flat_map(|(value, label)| [Some(value), label.as_ref()]).flatten().map(String::as_str))
.chain(panels.iter().filter_map(|panel| panel.label.as_deref()))
.collect();
crate::render::layout::statistic_figures(s.map(), comma, &texts)
};
Expand Down Expand Up @@ -1099,14 +1104,28 @@ pub(in crate::cmd::layout) fn publication(s: &mut Session, p: &Value) -> CmdResu
let (inner_w, inner_h) = inner_frame((fw, fh), (room_side, room_end));
let (center, scale) = fit_frame(s.map(), &extent, rectangle.as_ref(), whole_globe, (inner_w, inner_h))
.ok_or("the extent can't be drawn on the map's projection")?;
let panel_views = panels
.iter()
.zip(&cells)
.enumerate()
.map(|(i, (e, &(.., w, h)))| {
fit_frame(s.map(), e, None, false, (w, h)).ok_or_else(|| format!("panels[{i}] can't be drawn on the map's projection"))
})
.collect::<Result<Vec<_>, _>>()?;
let mut panel_views = Vec::with_capacity(panels.len());
let mut too_small = Vec::new();
for (i, (panel, &(.., w, h))) in panels.iter().zip(&cells).enumerate() {
let (panel_center, fitted) = fit_frame(s.map(), &panel.extent, None, false, (w, h))
.ok_or_else(|| format!("panels[{i}] can't be drawn on the map's projection"))?;
// A scale given is kept, and said where it shows less than the panel's extent: nothing is
// cut without a word (#3579).
if let Some(scale) = panel.scale {
// `fit_scale` keeps a tenth of spare: a scale that shows the extent edge to edge holds it.
let holds = fit_scale(s.map(), &panel.extent, w, h)
.is_none_or(|(_, whole)| scale >= whole / rustgis_map::layout::FIT_MARGIN * (1.0 - 1e-9));
if !holds {
too_small.push(format!("panels[{i}] at 1:{scale} (1:{fitted:.0} does)"));
}
}
panel_views.push((panel_center, panel.scale.unwrap_or(fitted)));
}
warnings.extend(panels_warning(
&too_small,
"is at a scale that doesn't show its whole extent",
"are at scales that don't show their whole extents",
));
// A name given past the limit is refused, as layout.new refuses it, not cut (#2639).
let given = crate::cmd::within("name", "a layout's name", ps(p, "name").unwrap_or(PUBLICATION_NAME).trim(), crate::cmd::MAX_NAME)?;
let (name, name_cut) = unique_name(s, "New Publication Layout", "the name given", &given);
Expand Down Expand Up @@ -1142,7 +1161,8 @@ pub(in crate::cmd::layout) fn publication(s: &mut Session, p: &Value) -> CmdResu
},
);
if mosaic {
add_panels(&mut l, &s.map().name, frame, &cells, &panel_views, k, ink);
let labels: Vec<Option<String>> = panels.iter().map(|panel| panel.label.clone()).collect();
warnings.extend(add_panels(&mut l, &s.map().name, frame, &cells, &panel_views, &labels, &drawn, k, ink));
}
// Over the map, clear of the grid's labels (drawn inside the frame along its labelled
// edges): the north arrow, the legend sized to what it lists, the scale bar with the numeric
Expand Down
Loading
Loading