Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
54f9af0
test(render): pin how a layout legend draws, is measured and exports,…
m-hollis-1 Nov 26, 2026
2d6643c
test(render): pin each legend page, notice and publication on its own
m-hollis-1 Nov 26, 2026
53404b8
feat(layout): a legend's fit, its layer names and up to six columns i…
m-hollis-1 Nov 26, 2026
f7a887f
feat(render): a layout legend shrinks its text or adds columns to fit…
m-hollis-1 Nov 26, 2026
4155c1c
test(render): a fitted legend's SVG and PDF are those of the manual l…
m-hollis-1 Nov 26, 2026
763c16e
feat(layout): a legend's fit and layer names through layout.addElemen…
m-hollis-1 Nov 26, 2026
0fcd278
feat(ui): a legend's fit and layer names in the Format pane
m-hollis-1 Nov 26, 2026
c635c1a
docs(layout): a legend's fit, layer names and six columns in the user…
m-hollis-1 Nov 26, 2026
28f5f4e
perf(render): a legend's rows are measured once for a fit, and a manu…
m-hollis-1 Nov 27, 2026
72c8cfc
refactor(ui): the legend's fit names come from the model
m-hollis-1 Nov 27, 2026
d42e818
test(engine): a fit too wide in its own columns says so, and a refuse…
m-hollis-1 Nov 27, 2026
0ef4846
docs(layout): columns under each fit, and comments reflowed to their …
m-hollis-1 Nov 27, 2026
cdeee92
Merge upstream main into feat/layout-legend-fit
m-hollis-1 Nov 27, 2026
ee6a933
fix(layout): a fitted legend that no longer fits says so at export
m-hollis-1 Nov 27, 2026
809bad5
perf(layout): a publication measures its legend in the three column c…
m-hollis-1 Nov 27, 2026
adf9b36
Merge upstream main into feat/layout-legend-fit
m-hollis-1 Nov 27, 2026
addba4e
Merge upstream main into feat/layout-legend-fit
m-hollis-1 Nov 27, 2026
03a4655
fix(layout): an export names the fitted legends that no longer fit, a…
m-hollis-1 Nov 27, 2026
71e0767
docs(assistant): a publication's legend takes up to three columns, a …
m-hollis-1 Nov 27, 2026
f3cec58
fix(layout): a fitted legend is listed once for each way it doesn't fit
m-hollis-1 Nov 27, 2026
cfb9ca7
docs(layout): rewrap the publication legend's sentence
m-hollis-1 Nov 27, 2026
a711475
Merge upstream main into feat/layout-legend-fit
m-hollis-1 Nov 27, 2026
a07b0db
fix(report): a report's export says the fitted legends on its pages t…
m-hollis-1 Nov 27, 2026
29dbd3f
fix(layout): an export names a legend once under each reason
m-hollis-1 Nov 27, 2026
f1bed07
perf(layout): a legend's fit notice measures only the columns it reads
m-hollis-1 Nov 27, 2026
87d25a9
fix(layout): a legend's fit is measured in the columns it is drawn in
m-hollis-1 Nov 27, 2026
6e17939
fix(layout): a legend picture is measured as its column draws it
m-hollis-1 Nov 27, 2026
e4f024a
perf(render): a legend's painter reuses its measured rows
m-hollis-1 Nov 27, 2026
d126358
test(render): a legend picture test fails with a message, not unreach…
m-hollis-1 Nov 27, 2026
1b46886
Merge upstream main into feat/layout-legend-fit
m-hollis-1 Nov 27, 2026
fef6925
fix(engine): a report template with a fitted legend requires the lege…
m-hollis-1 Nov 27, 2026
cf7b538
refactor(layout): drop two helpers of a legend's fit that nothing calls
m-hollis-1 Nov 27, 2026
7f613b6
docs(render): say what the search for a legend's text size guarantees
m-hollis-1 Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/assistant/skills/print-layout/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Make a printable page layout — map frame, title, legend, north ar
(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"` 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"` or `"poster"` (for a poster-like sheet), 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), 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
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,
`layout.new` `{"name": N, "page": "letter"|"a4"|…, "orientation": "landscape"|"portrait"}` creates the layout and
opens it.
Expand All @@ -24,7 +24,9 @@ description: Make a printable page layout — map frame, title, legend, north ar
`"subdivisions"` (0–10), `"divisionsBeforeZero"` (0–2), `"labelPosition"` (`"above"`, `"below"`), `"unitLabel"`
(text; `""` for none), `"unitLabelPosition"` (`"afterLabels"`, `"afterBar"`, `"above"`, `"below"`), `"decimals"`
(`"auto"`, the default, or 0–3 fixed with the thousands set apart, as a chart's), `"textSize"` (4–100 pt, its
labels' size) and `"fit"` (`"adjustDivisionValue"`, `"adjustDivision"`, `"adjustWidth"`). A `"text"` or `"dynamicText"` can take
labels' size) and `"fit"` (`"adjustDivisionValue"`, `"adjustDivision"`, `"adjustWidth"`). A `"legend"` can take
`"columns"` (1–6), `"fit"` (`"manual"`, `"adjustSize"`, `"adjustColumns"`, `"adjustColumnsAndSize"`: shrink its
text or add columns to fit its box) and `"showLayerNames": false`. A `"text"` or `"dynamicText"` can take
`"valign"` (`"top"`, `"middle"`, `"bottom"`), `"lineSpacing"` (0.5–3, default 1) and `"case"`
(`"none"`, `"upper"`, `"lower"`; applied when drawn, the text kept as typed). `"grid"` adds a graticule to the frame
(`"style": "ticks"` for neatline ticks, `"format": "dms"`, `"edges"`).
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/command-surface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ layer.transparency layer? value
layer.visibility layer? visible?
layer.zoomTo layer?
layout.activate name layout
layout.addElement layout? kind frame? of? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? columns? textSize? orientation? ticks? tickSide? reverse? fill? width? radius? dash? dir? head? angle? length? image? path? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? hideLabels? barOutline? rows? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? outline? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? x? y? w? h? background?
layout.addElement layout? kind frame? of? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? columns? textSize? showLayerNames? orientation? ticks? tickSide? reverse? fill? width? radius? dash? dir? head? angle? length? image? path? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? hideLabels? barOutline? rows? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? outline? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? x? y? w? h? background?
layout.addFrame layout? shape? points? map? x? y? w? h?
layout.arrange layout? element to
layout.arrangement favourite? save? arrangement? remove?
Expand All @@ -304,7 +304,7 @@ layout.save layout? path
layout.series layout? layer nameField? frame? margin? off?
layout.seriesPage layout? page
layout.seriesRefresh layout?
layout.update layout? element x? y? w? h? name? visible? locked? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? labels? columns? textSize? orientation? ticks? tickSide? reverse? style? fill? outline? radius? width? dash? dir? head? angle? length? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? map? scale? center? bearing? pitch? grid? extentIndicator? border? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? barOutline? hideLabels? rows? background?
layout.update layout? element x? y? w? h? name? visible? locked? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? labels? columns? textSize? showLayerNames? orientation? ticks? tickSide? reverse? style? fill? outline? radius? width? dash? dir? head? angle? length? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? map? scale? center? bearing? pitch? grid? extentIndicator? border? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? barOutline? hideLabels? rows? background?
locator.find locator? text limit? zoom?
map.activate name
map.addTiles url kind? name? bounds? attribution? minZoom? maxZoom? tileSize? singleImage? tms? subdomains? layers? styleLayers? opacity? blend? resampling? overlay? top? replace? id? view? start? end? unit? interval? dates? legend? connection?
Expand Down
26 changes: 16 additions & 10 deletions crates/engine/src/cmd/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use std::sync::LazyLock;
use rustgis_geom::{Coord, Extent};
use rustgis_map::layout::{
Arrange, ArrowStyle, Background, CHART_BAR, CHART_BARS, CHART_OUTLINE, ChartOrder, ChartOutline, CoordFormat, ElementKind, FontFamily,
FrameShape, GRID_LABEL_PT, Grid, GridEdges, GridKind, GridStyle, Guides, LAYOUT_TEXT_SIZE, LINE_SPACING, Layout, LineDir, LineHead,
MAX_CHART_BARS, MAX_CHART_DECIMALS, MAX_CHART_OUTLINE_WIDTH, MAX_COLORBAR_TICKS, MAX_GRID_WIDTH, MAX_GUIDES, MAX_LEGEND_COLUMNS,
MAX_LEGEND_LABEL_CHARS, MAX_LEGEND_LABELS, MAX_LINE_SPACING, MAX_SCALE_BEFORE_ZERO, MAX_SCALE_DECIMALS, MAX_SCALE_DIVISIONS,
MAX_SCALE_SUBDIVISIONS, MAX_TICK_MM, MAX_UNIT_LABEL_CHARS, MIN_ELEMENT_MM, MIN_LINE_SPACING, MapSeries, Orientation, PAGES,
SCALE_BAR_TEXT_PT, ScaleBarFit, ScaleBarStyle, ScaleLabelPosition, ScaleUnits, TextAlign, TextCase, TextVAlign, TickSide,
UnitLabelPosition, fit_scale, line_angle, line_at_angle, line_length,
FrameShape, GRID_LABEL_PT, Grid, GridEdges, GridKind, GridStyle, Guides, LAYOUT_TEXT_SIZE, LINE_SPACING, LayerNames, Layout, LegendFit,
LineDir, LineHead, MAX_CHART_BARS, MAX_CHART_DECIMALS, MAX_CHART_OUTLINE_WIDTH, MAX_COLORBAR_TICKS, MAX_GRID_WIDTH, MAX_GUIDES,
MAX_LEGEND_COLUMNS, MAX_LEGEND_LABEL_CHARS, MAX_LEGEND_LABELS, MAX_LINE_SPACING, MAX_SCALE_BEFORE_ZERO, MAX_SCALE_DECIMALS,
MAX_SCALE_DIVISIONS, MAX_SCALE_SUBDIVISIONS, MAX_TICK_MM, MAX_UNIT_LABEL_CHARS, MIN_ELEMENT_MM, MIN_LINE_SPACING, MapSeries,
Orientation, PAGES, SCALE_BAR_TEXT_PT, ScaleBarFit, ScaleBarStyle, ScaleLabelPosition, ScaleUnits, TextAlign, TextCase, TextVAlign,
TickSide, UnitLabelPosition, fit_scale, line_angle, line_at_angle, line_length,
};
use rustgis_map::report::StatKind;
use rustgis_map::symbology::{Dash, MAX_DASH_STEP, MAX_DASH_STEPS};
Expand All @@ -38,7 +38,9 @@ use frame::*;
mod inputs;
pub(crate) use inputs::*;
mod legend;
pub(in crate::cmd) use legend::say_unfitted_legends_in;
use legend::*;
pub(crate) use legend::{legend_columns_param, legend_fit_param, legend_names_param};
mod page;
use page::*;
mod publication;
Expand Down Expand Up @@ -198,8 +200,9 @@ pub fn commands() -> Vec<C> {
r##""hideOther"?: bool (legend: leave out <all other values>), "##,
r##""showNoData"?: bool (legend: include Graduated Colors’ missing-value symbol; default false), "##,
r##""exclude"?: [layer names] (legend: layers it leaves out though the map draws them), "##,
r##""columns"?: 1..3 (legend: the columns its rows are laid in; default 1), "##,
r##""columns"?: 1..6 (legend: the columns its rows are laid in; default 1; with a fit that adds columns, the fewest it starts from), "##,
r##""textSize"?: points, 4 to 100 (legend: its layers' names and classes' labels, its title, rows, swatches and gaps following in proportion and a point symbol keeping the size the map draws it at; default 9; scaleBar: its labels, the room over the bar and between them following, the bar keeping its size; default 8; refused outside that range, and for other kinds unless null, as showNoData is), "##,
r##""showLayerNames"?: bool (legend: the name over each layer's classes and over a web layer's legend picture; default true; a layer drawn in one symbol keeps its name; refused for other kinds), "##,
r##""orientation"?: "horizontal"|"vertical" (colorbar; chart: bars running across, the default, or columns standing up, each label centred under its column), "##,
r##""ticks"?: 2..21 (colorbar: labelled values, ends included), "##,
r##""tickSide"?: "below"|"above"|"right"|"left" (colorbar), "##,
Expand Down Expand Up @@ -255,7 +258,7 @@ pub fn commands() -> Vec<C> {
r##""labelPosition"?: "above"|"below" (scaleBar: its division labels, default above), "##,
r##""unitLabel"?: text, one line, up to 100 characters (scaleBar: the unit's name as printed, default its abbreviation; "" prints none), "##,
r##""unitLabelPosition"?: "afterLabels"|"afterBar"|"above"|"below" (scaleBar: default afterLabels, after the last label), "##,
r##""fit"?: "adjustDivisionValue"|"adjustDivision"|"adjustWidth" (scaleBar: when round divisions don't fill the box: adjustDivisionValue, the default, divides the roundest length that fits, so a division may not be round; adjustDivision keeps a round division and adds or drops divisions, at most ten in all, the divisions before zero included, to fill the width; adjustWidth keeps the divisions and draws the bar only as wide as they need) (a value out of range or not one of the names is refused, and these are refused for other kinds), "##,
r##""fit"?: "adjustDivisionValue"|"adjustDivision"|"adjustWidth" (scaleBar: when round divisions don't fill the box: adjustDivisionValue, the default, divides the roundest length that fits, so a division may not be round; adjustDivision keeps a round division and adds or drops divisions, at most ten in all, the divisions before zero included, to fill the width; adjustWidth keeps the divisions and draws the bar only as wide as they need) or "manual"|"adjustSize"|"adjustColumns"|"adjustColumnsAndSize" (legend: manual, the default, keeps its size and columns and leaves out what its box doesn't hold; adjustSize shrinks its rows' text, down to 4 points, until they fit; adjustColumns adds columns, up to 6, until they fit, never more than fit across; adjustColumnsAndSize adds columns first, then shrinks the text; its title keeps its size; one that can't fit says so) (a value out of range or not one of the names is refused, and these are refused for other kinds, fit for any but a legend or a scale bar), "##,
r##""x"?, "##,
r##""y"?, "##,
r##""w"?, "##,
Expand Down Expand Up @@ -294,8 +297,9 @@ pub fn commands() -> Vec<C> {
r##""showNoData"?: bool (legend; default false), "##,
r##""exclude"?: [layer names] (legend; [] lists every layer again), "##,
r##""labels"?: {"<layer>": "<label>"|null} (legend: what it shows instead of a layer's name, up to 200 characters, a longer one is refused; each entry replaces that layer's label, null or "" shows its name again, {} every layer's; a layer the map hasn't is refused), "##,
r##""columns"?: 1..3 (legend), "##,
r##""columns"?: 1..6 (legend), "##,
r##""textSize"?: points, 4 to 100 (legend, scaleBar, as in layout.addElement, null giving each its default again; refused outside that range, and for other elements unless null), "##,
r##""showLayerNames"?: bool (legend, as in layout.addElement; null leaves it as it is), "##,
r##""orientation"? (colorbar, chart), "##,
r##""ticks"?, "##,
r##""tickSide"?, "##,
Expand All @@ -317,7 +321,7 @@ pub fn commands() -> Vec<C> {
r##""labelPosition"?, "##,
r##""unitLabel"? (null: the unit's abbreviation again), "##,
r##""unitLabelPosition"?, "##,
r##""fit"? (scaleBar, as in layout.addElement; refused for other elements, a null unitLabel too), "##,
r##""fit"? (scaleBar or legend, as in layout.addElement, each by its own names; refused for other elements, a null unitLabel too), "##,
r##""map"?, "##,
r##""scale"?, "##,
r##""center"?: [lon, lat], "##,
Expand Down Expand Up @@ -586,6 +590,8 @@ pub(crate) fn new_layout(s: &mut Session, p: &Value) -> CmdResult {
labels: Default::default(),
color: None,
text_size: rustgis_map::layout::LEGEND_TEXT_PT,
fit: rustgis_map::layout::LegendFit::Manual,
show_layer_names: rustgis_map::layout::LayerNames::Shown,
},
);
l.add("North Arrow", (side + sw / 2.0 - 8.0, m + 16.0 + fh * 0.62, 16.0, 24.0), ElementKind::north_arrow(frame));
Expand Down
6 changes: 4 additions & 2 deletions crates/engine/src/cmd/layout/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ pub(in crate::cmd::layout) fn changes_chart_look(p: &Value) -> bool {

/// What a scale bar's details given for another element are told.
pub(in crate::cmd::layout) const ONLY_SCALE_BAR_DETAILS: &str =
"only scale bars take subdivisions, divisionsBeforeZero, labelPosition, unitLabel, unitLabelPosition or fit";
"only scale bars take subdivisions, divisionsBeforeZero, labelPosition, unitLabel or unitLabelPosition";

/// The keys only a scale bar takes: its details beyond its units, divisions, style and colours,
/// and its `decimals`, which a chart takes too.
pub(in crate::cmd::layout) const SCALE_BAR_KEYS: [&str; 6] =
["subdivisions", "divisionsBeforeZero", "labelPosition", "unitLabel", "unitLabelPosition", "fit"];

/// Whether `p` gives a detail only a scale bar takes: its `fit` aside, which a legend takes too, by
/// its own names ([`ONLY_FIT`]).
pub(in crate::cmd::layout) fn gives_scale_bar_details(p: &Value) -> bool {
SCALE_BAR_KEYS.iter().any(|k| gives(p, k))
SCALE_BAR_KEYS.iter().filter(|k| **k != "fit").any(|k| gives(p, k))
}

/// A whole number from 0 to `hi` given as `k`, when it's given (and not null): an error when it's
Expand Down
12 changes: 12 additions & 0 deletions crates/engine/src/cmd/layout/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
if kind != "legend" && p.get("columns").is_some_and(|v| !v.is_null()) {
return Err(ONLY_LEGEND_COLUMNS.into());
}
// A value that isn't true or false is refused on any kind first, as the legend's arm would.
if legend_names_param(p)?.is_some() && kind != "legend" {
return Err(ONLY_LEGEND_NAMES.into());
}
// A legend and a scale bar each read `fit` as their own (their names don't overlap).
if !matches!(kind, "legend" | "scaleBar") && gives(p, "fit") {
return Err(ONLY_FIT.into());
}
// A grid's "labels" is a bool and a legend's an object (read with it); on any other kind, or as
// anything else on a grid, it is refused rather than left unread.
match p.get("labels").filter(|v| !v.is_null()) {
Expand Down Expand Up @@ -352,6 +360,8 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
};
let text_size =
text_size_param(p, "textSize", rustgis_map::layout::LEGEND_TEXT_PT)?.unwrap_or(rustgis_map::layout::LEGEND_TEXT_PT);
let fit = legend_fit_param(p)?.unwrap_or_default();
let show_layer_names = legend_names_param(p)?.map_or(LayerNames::Shown, LayerNames::from_shown);
(
"Legend",
place(p, l, (pw - 70.0, 45.0, 60.0, 80.0))?,
Expand All @@ -366,6 +376,8 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
labels,
color: ink,
text_size,
fit,
show_layer_names,
},
)
}
Expand Down
Loading
Loading