Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -27,7 +27,7 @@ description: Make a printable page layout — map frame, title, legend, north ar
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), `"subtitle"` (one line under its title), `"sizes": "nested"` (a point layer's marker sizes one inside another on a common base), `"showCounts": true` (each class row ends in its number of features; none for a layer read from a database, over the web or a view at a time from other files),
`"showLayerNames": false`, `"layerOrder": ["<layer>"]` (those layers first, the map unchanged) and `"classLabels"` (`{"<layer>": {"<class label>": "<text>"}}`: its own text for a
`"showLayerNames": false`, `"layerOrder": ["<layer>"]` (those layers first, the map unchanged), `"columnBreaks": ["<layer>"]` (each starts a column; no `"columns"` above 1 beside them) and `"classLabels"` (`{"<layer>": {"<class label>": "<text>"}}`: its own text for a
class, the layer keeping its label).
A `"picture"` takes a `"path"` (a PNG or JPEG file; it remembers the file) or an `"image"` (base64);
`layout.update` with `"path"` reads it again. A `"text"` or `"dynamicText"` can take
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 @@ -284,7 +284,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? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columns? textSize? classLabels? sizes? showCounts? 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? fields? header? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? section? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? 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? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columnBreaks? columns? textSize? classLabels? sizes? showCounts? 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? fields? header? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? section? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? 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 @@ -306,7 +306,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? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? labels? classLabels? columns? textSize? showLayerNames? sizes? showCounts? 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? section? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? barOutline? hideLabels? rows? fields? header? image? path? 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? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columnBreaks? labels? classLabels? columns? textSize? showLayerNames? sizes? showCounts? 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? section? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? barOutline? hideLabels? rows? fields? header? image? path? 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? anonymous?
Expand Down
16 changes: 10 additions & 6 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7439,7 +7439,8 @@ pub(crate) fn legends_follow_layer(s: &mut Session, old: &str, new: Option<&str>
.map(|e| e.id)
.collect();
for e in &mut layout.elements {
if let rustgis_map::layout::ElementKind::Legend { frame, exclude, layer_order, labels, class_labels, .. } = &mut e.kind
if let rustgis_map::layout::ElementKind::Legend { frame, exclude, layer_order, column_breaks, labels, class_labels, .. } =
&mut e.kind
&& frames.contains(frame)
{
// Its label (#1654), taken off the old name; onto the new one unless another layer
Expand Down Expand Up @@ -7474,11 +7475,14 @@ pub(crate) fn legends_follow_layer(s: &mut Session, old: &str, new: Option<&str>
Some(n) => rename_listed(exclude, old, n),
None => exclude.retain(|x| !x.eq_ignore_ascii_case(old)),
}
// Its place in the legend's order (#3279) goes with it; onto a name already
// there, the layers sharing it go together at the first of the two.
match new {
Some(n) => rename_listed(layer_order, old, n),
None => layer_order.retain(|x| !x.eq_ignore_ascii_case(old)),
// Its place in the legend's order (#3279) goes with it, and the column it starts
// (#3445); onto a name already there, the list keeps one entry, where the first
// of the two was.
for list in [layer_order, column_breaks] {
match new {
Some(n) => rename_listed(list, old, n),
None => list.retain(|x| !x.eq_ignore_ascii_case(old)),
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/engine/src/cmd/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ pub fn commands() -> Vec<C> {
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##""layerOrder"?: [layer names] (legend: these layers first, in this order, the others after them as the map draws them; the map is not changed), "##,
r##""columnBreaks"?: [layer names] (legend: each of these layers starts a column, 5 at most, so "columns" above 1 and the fits that add columns are refused beside them), "##,
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; table: its text, its rows and columns following; default 8; refused outside that range, and for other kinds unless null, as showNoData is), "##,
r##""classLabels"?: {"<layer>": {"<class label>": "<text>"}} (legend: its own text for a class, by the label the layer shows for it, up to 200 characters; the layer keeps its label; a layer or class it can't find is refused), "##,
Expand Down Expand Up @@ -333,6 +334,7 @@ pub fn commands() -> Vec<C> {
r##""showNoData"?: bool (legend; default false), "##,
r##""exclude"?: [layer names] (legend; [] lists every layer again), "##,
r##""layerOrder"?: [layer names] (legend, as in layout.addElement; [] returns to the map's order), "##,
r##""columnBreaks"?: [layer names] (legend, as in layout.addElement; [] takes them off), "##,
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##""classLabels"?: {"<layer>": {"<class label>": "<text>"|null}|null} (legend, as in layout.addElement; each entry replaces that class's text, null or "" shows the layer's label again, a layer's null or {} all of its classes', {} every layer's), "##,
r##""columns"?: 1..6 (legend), "##,
Expand Down Expand Up @@ -642,6 +644,7 @@ pub(crate) fn new_layout(s: &mut Session, p: &Value) -> CmdResult {
show_no_data: false,
exclude: Vec::new(),
layer_order: Vec::new(),
column_breaks: Vec::new(),
columns: 1,
labels: Default::default(),
color: None,
Expand Down
7 changes: 7 additions & 0 deletions crates/engine/src/cmd/layout/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
if kind != "legend" && gives(p, "layerOrder") {
return Err(ONLY_LEGEND_ORDER.into());
}
if kind != "legend" && gives(p, "columnBreaks") {
return Err(ONLY_LEGEND_BREAKS.into());
}
if kind != "legend" && p.get("columns").is_some_and(|v| !v.is_null()) {
return Err(ONLY_LEGEND_COLUMNS.into());
}
Expand Down Expand Up @@ -481,6 +484,7 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
let exclude = legend_exclude(s, l, frame, p)?.unwrap_or_default();
let layer_order = legend_layer_order(s, l, frame, p)?.unwrap_or_default();
let columns = legend_columns_param(p)?.unwrap_or(1);
let column_breaks = legend_column_breaks(s, l, frame, p)?.unwrap_or_default();
let labels = match legend_labels(s, l, frame, p)? {
Some(given) => with_labels(&BTreeMap::new(), given)?,
None => BTreeMap::new(),
Expand All @@ -496,6 +500,7 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
let show_counts = legend_counts_param(p)?.map_or(FeatureCounts::Hidden, FeatureCounts::from_shown);
let subtitle = legend_subtitle_param(p)?.unwrap_or_default();
let sizes = legend_sizes_param(p)?.unwrap_or_default();
columns_set_by_breaks((&column_breaks, true), (columns, true), (fit, true))?;
(
"Legend",
place(p, l, (pw - 70.0, 45.0, 60.0, 80.0))?,
Expand All @@ -507,6 +512,7 @@ pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResu
show_no_data,
exclude,
layer_order,
column_breaks,
columns,
labels,
color: ink,
Expand Down Expand Up @@ -1112,6 +1118,7 @@ const ADD_LEGEND_KEYS: &[&str] = &[
"showNoData",
"exclude",
"layerOrder",
"columnBreaks",
"columns",
"labels",
"classLabels",
Expand Down
24 changes: 13 additions & 11 deletions crates/engine/src/cmd/layout/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub(in crate::cmd::layout) fn element_inputs(input: &crate::cmd::InputContext<'_
if kind == "legend"
&& legend_exclude(input, layout, frame, p)?.is_none()
&& legend_layer_order(input, layout, frame, p)?.is_none()
&& legend_column_breaks(input, layout, frame, p)?.is_none()
&& legend_labels(input, layout, frame, p)?.is_none()
&& legend_class_labels(input, layout, frame, p)?.is_none()
{
Expand All @@ -123,8 +124,8 @@ pub(in crate::cmd::layout) fn element_inputs(input: &crate::cmd::InputContext<'_
}
} else {
let (names, labels) = (legend_exclude(input, layout, frame, p)?, legend_labels(input, layout, frame, p)?);
let order = legend_layer_order(input, layout, frame, p)?;
legend_inputs(&mut inputs, map, names, order, labels, legend_class_labels(input, layout, frame, p)?);
let (order, breaks) = (legend_layer_order(input, layout, frame, p)?, legend_column_breaks(input, layout, frame, p)?);
legend_inputs(&mut inputs, map, names, [order, breaks], labels, legend_class_labels(input, layout, frame, p)?);
}
inputs.maps.push(map.instance_id());
inputs.state = json!({"layout":index(input,p)?,"frame":frame,"selectors":inputs.state});
Expand Down Expand Up @@ -244,9 +245,9 @@ pub(in crate::cmd::layout) fn update_inputs(input: &crate::cmd::InputContext<'_>
Some(ElementKind::Legend { frame, .. }) => {
let (names, labels) = (legend_exclude(input, l, *frame, p)?, legend_labels(input, l, *frame, p)?);
let classes = legend_class_labels(input, l, *frame, p)?;
let order = legend_layer_order(input, l, *frame, p)?;
if names.is_some() || order.is_some() || labels.is_some() || classes.is_some() {
legend_inputs(&mut inputs, frame_map(input, l, *frame)?, names, order, labels, classes);
let lists = [legend_layer_order(input, l, *frame, p)?, legend_column_breaks(input, l, *frame, p)?];
if names.is_some() || lists.iter().any(Option::is_some) || labels.is_some() || classes.is_some() {
legend_inputs(&mut inputs, frame_map(input, l, *frame)?, names, lists, labels, classes);
}
}
_ => {}
Expand All @@ -255,24 +256,25 @@ pub(in crate::cmd::layout) fn update_inputs(input: &crate::cmd::InputContext<'_>
Ok(inputs)
}

/// The layers a legend's `exclude`, `layerOrder`, `labels` and `classLabels` name, as inputs. Tile layers' names are stored
/// selector text, not invented layer/table identities.
/// The layers a legend's `exclude`, `layerOrder`, `columnBreaks`, `labels` and `classLabels` name,
/// as inputs. Tile layers' names are stored selector text, not invented layer/table identities.
pub(in crate::cmd::layout) fn legend_inputs(
inputs: &mut crate::cmd::Inputs,
map: &Map,
names: Option<Vec<String>>,
order: Option<Vec<String>>,
[order, breaks]: [Option<Vec<String>>; 2],
labels: Option<Vec<(String, Option<String>)>>,
classes: Option<GivenClassLabels>,
) {
let named = names
.iter()
.flatten()
.chain(order.iter().flatten())
.chain(breaks.iter().flatten())
.chain(labels.iter().flatten().map(|(n, _)| n))
.chain(classes.iter().flatten().map(|(n, _)| n));
inputs.layers.extend(named.filter_map(|n| map.layer_by_name(n)).map(|l| (map.instance_id(), l.id)));
inputs.state = json!({"exclude": names, "layerOrder": order, "labels": labels, "classLabels": classes});
inputs.state = json!({"exclude": names, "layerOrder": order, "columnBreaks": breaks, "labels": labels, "classLabels": classes});
}

/// Reference-only operations bind the actual chosen layout, without reading its stored maps.
Expand Down Expand Up @@ -307,8 +309,8 @@ pub(in crate::cmd::layout) fn element_selectors(kind: &ElementKind) -> Option<Va
ElementKind::Chart { frame, layer, field, label, group, stack, .. } => {
json!({"frame":frame,"layer":layer,"field":field,"label":label,"group":group,"stack":stack})
}
ElementKind::Legend { frame, exclude, layer_order, labels, class_labels, .. } => {
json!({"frame":frame,"exclude":exclude,"layerOrder":layer_order,"labels":labels,"classLabels":class_labels})
ElementKind::Legend { frame, exclude, layer_order, column_breaks, labels, class_labels, .. } => {
json!({"frame":frame,"exclude":exclude,"layerOrder":layer_order,"columnBreaks":column_breaks,"labels":labels,"classLabels":class_labels})
}
ElementKind::Colorbar { frame, layer, .. } => json!({"frame":frame,"layer":layer}),
ElementKind::Profile(p) => json!({"frame":p.frame,"layer":p.layer,"section":p.section}),
Expand Down
Loading
Loading