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/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? layerOrder? columns? textSize? classLabels? 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? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? 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? layerOrder? columns? textSize? classLabels? 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? 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 Down
26 changes: 19 additions & 7 deletions crates/engine/src/cmd/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ use legend::*;
pub(crate) use legend::{legend_columns_param, legend_counts_param, legend_fit_param, legend_names_param};
mod page;
use page::*;
mod profile;
use profile::*;
mod publication;
pub use publication::*;
mod series;
Expand Down Expand Up @@ -183,12 +185,12 @@ pub fn commands() -> Vec<C> {
C::new("layout.addElement", "Add Element", "Publish › Map Surrounds", add_element).inputs(element_inputs).roles(&[]).effects(crate::policy::Effects::NONE.with(crate::policy::Effect::Files)).params(
concat!(
r##"{"layout"?, "##,
r##""kind": "northArrow"|"scaleBar"|"legend"|"colorbar"|"text"|"dynamicText"|"picture"|"table"|"chart"|"rectangle" (a neatline framing the page unless any of x, y, w, h is given)|"ellipse"|"circle"|"line"|"arrow"|"extentIndicator"|"grid"|"section" (a section line over a map frame, named at both ends, A and A', up to 26 a frame; as a grid or an extentIndicator, it adds no element: the reply's "element" is its frame, the one layout.update changes it on with "section", and "section" its name), "##,
r##""kind": "northArrow"|"scaleBar"|"legend"|"colorbar"|"text"|"dynamicText"|"picture"|"table"|"chart"|"rectangle" (a neatline framing the page unless any of x, y, w, h is given)|"ellipse"|"circle"|"line"|"arrow"|"extentIndicator"|"grid"|"section" (a section line over a map frame, named at both ends, A and A', up to 26 a frame; as a grid or an extentIndicator, it adds no element: the reply's "element" is its frame, the one layout.update changes it on with "section", and "section" its name)|"profile" (a raster's profile along a section line of the frame, beside the frame on the side the line runs along, lined up with it: each sample is read at its point of the page line, through the frame's projection, so the curve is straight across from the place it comes from; its box is the frame's side, which it follows when the frame is moved or resized; a tilted frame, one on the globe, or a raster read in place draws none, which a notice and exports say), "##,
r##""frame"?: element id (default: the first map frame), "##,
r##""of"?: frame id (extentIndicator, which also takes "color" and "width" in points, default red and 2), "##,
r##""text"? (a text's words; {count:Layer}, {sum:Layer:field}, {mean:Layer:field}, {min:Layer:field} and {max:Layer:field} show the layer's figure, as {scale} shows the scale: of the first map frame's map, over the features the layer's definition query keeps, with the layout's decimal mark; one with no figure shows as written and says why), "##,
r##""size"?, "##,
r##""color"?: "#RRGGBB"|"#RRGGBBAA" (text, dynamicText, line, arrow, rectangle, ellipse, circle: its outline; extentIndicator; grid; section, default #A8431F; scaleBar; legend, colorbar, table, chart: the ink of its text and lines, default #222222, a chart's bars and a colorbar's colours keeping theirs, and a table drawn without its white cells; refused for other kinds), "##,
r##""color"?: "#RRGGBB"|"#RRGGBBAA" (text, dynamicText, line, arrow, rectangle, ellipse, circle: its outline; extentIndicator; grid; section, default #A8431F; scaleBar; legend, colorbar, table, chart, profile: the ink of its text and lines, default #222222, a chart's bars and a colorbar's colours keeping theirs, and a table drawn without its white cells; refused for other kinds), "##,
r##""bold"?: bool (text), "##,
r##""italic"?: bool, "##,
r##""align"?: "left"|"center"|"right", "##,
Expand All @@ -200,7 +202,7 @@ pub fn commands() -> Vec<C> {
r##""case"?: "none"|"upper"|"lower" (text, dynamicText: drawn in upper or lower case once its dynamic text is filled in, its text kept as typed; default none; refused for other kinds), "##,
r##""font"?: "sans"|"serif"|an installed font family's name, as labels.fonts lists them (text, dynamicText; a family not installed here is drawn in its fallback, and a serif where none is installed in the sans, with a warning; refused for other kinds), "##,
r##""fallback"?: "sans"|"serif" (a named font's, where it isn't installed; default its own class, else sans), "##,
r##""title"?: legend title (default "Legend"); chart: its own title ("" for none; default: its field, or the statistic of its field by the group), "##,
r##""title"?: legend title (default "Legend"); chart: its own title ("" for none; default: its field, or the statistic of its field by the group); profile: written over its curve ("" for none; default its layer's name), "##,
r##""allClasses"?: bool (legend: every class, not only those the frame draws), "##,
r##""hideOther"?: bool (legend: leave out <all other values>), "##,
r##""showNoData"?: bool (legend: include Graduated Colors’ missing-value symbol; default false), "##,
Expand All @@ -215,7 +217,7 @@ pub fn commands() -> Vec<C> {
r##""ticks"?: 2..21 (colorbar: labelled values, ends included), "##,
r##""tickSide"?: "below"|"above"|"right"|"left" (colorbar), "##,
r##""reverse"?: bool (colorbar: high values first), "##,
r##""fill"?: "#RRGGBBAA" (rectangle, ellipse, circle, northArrow; scaleBar: the alternating bar's light divisions, default white; refused for other kinds), "##,
r##""fill"?: "#RRGGBBAA" (rectangle, ellipse, circle, northArrow; scaleBar: the alternating bar's light divisions, default white; profile: under its curve, default #D8C8A8, null for none; refused for other kinds), "##,
r##""width"?: outline width in points (rectangle, ellipse, circle; 0 for none) or line width in points (line, grid; section, 0.1 to 20, default 1.5), "##,
r##""radius"?: mm, 0 to 50 (rectangle: rounded corners), "##,
r##""dash"?: [points, …] (line, arrow, section, and a rectangle's, ellipse's or circle's outline: dash, gap, … in turn, as layer.lineStrokes takes it, at most 8, each 0 to 500; an arrow's heads stay solid; [] or null for solid; refused, null too, for other kinds), "##,
Expand All @@ -225,7 +227,7 @@ pub fn commands() -> Vec<C> {
r##""length"?: mm (line, arrow), "##,
r##""image"?: base64, "##,
r##""path"?: picture file, "##,
r##""layer"?: (table, chart; colorbar: a raster layer, default the top visible raster with a colour scale, not drawn by classes, which a legend lists), "##,
r##""layer"?: (table, chart; colorbar: a raster layer, default the top visible raster with a colour scale, not drawn by classes, which a legend lists; profile: a raster layer held whole, not read in place, default the top one shown), "##,
r##""field"?: (chart: a numeric field, default the layer's first; any field when it groups and counts, default then the field it groups by), "##,
r##""label"?: a field (chart: each bar's label when not grouped), "##,
r##""group"?: a field (chart: a bar per value of this field, its statistic of field over that value's features; blank values make one "(blank)" bar; default none, a bar per feature), "##,
Expand All @@ -240,7 +242,7 @@ pub fn commands() -> Vec<C> {
r##""classes"?: bool (chart: each bar in the colour its features have on the map, by the layer's symbology classes: a bar per feature its feature's, a grouped bar the colour its features share; a bar whose features have several, which a warning counts, and an Other bar keep barColor; default false), "##,
r##""labelAlign"?: "left" (the default)|"right" (chart: bars running across have their labels at the left of their column, or at its right against the bars), "##,
r##""mirror"?: bool (chart: drawn as its mirror image, its text reading as ever: bars running across from the right, their labels at the right, or columns hanging from the top, their labels over them; beside a chart drawn the usual way the two face each other; default false), "##,
r##""max"?: a number above 0|"auto" (chart: the value at the far end of its bars' room, so charts given the same one share a scale; a bar past it runs to that end, which a warning counts; default "auto", its bars' own), "##,
r##""max"?: a number above 0|"auto" (chart: the value at the far end of its bars' room, so charts given the same one share a scale; a bar past it runs to that end, which a warning counts; default "auto", its bars' own; profile: any number, the value at its top, above "min"; default the samples' most, rounded up), "##,
r##""hideLabels"?: bool (chart: its labels left out, their room given to the bars; default false), "##,
r##""barOutline"?: {"color"?: "#RRGGBB"|"#RRGGBBAA" (default #222222), "width"?: points, 0 to 5 (default 0.5; 0 for none)} (chart: a line round each bar, or each stretch of a stacked one; default none) (label, group, statistic, order, bars, other, stack, values, decimals, barColor, classes, labelAlign, mirror, max, hideLabels and barOutline refused for other kinds unless null, as showNoData is, a scaleBar's decimals aside), "##,
r##""rows"?, "##,
Expand All @@ -261,8 +263,18 @@ pub fn commands() -> Vec<C> {
r##""name"?: a section's name, up to 20 characters, its frame's only one of that name (section, default the first free letter; a grid and an extent indicator refuse it, other kinds say they ignore it), "##,
r##""direction"?: "horizontal" (the default)|"vertical" (section: across the whole frame, straight on the page, named at its left and right ends or its top and bottom ones; refused for other kinds), "##,
r##""at"?: [longitude, latitude] (section: the place the line runs through and keeps to when the frame is moved, turned or rescaled, default the frame's centre; a line whose place is outside the frame isn't drawn, which a notice and exports say; refused for other kinds), "##,
r##""section"?: a section line's name (profile: the line it follows, default the frame's first; refused for other kinds), "##,
r##""band"?: 1-based (profile: the band read, default 1, its value whatever the raster holds), "##,
r##""side"?: "bottom"|"top" (profile of a horizontal section line, default bottom)|"left"|"right" (of a vertical one, default right), "##,
r##""gap"?: mm, 0 to 100 (profile: between the frame and it, default 3), "##,
r##""thickness"?: mm, 10 to 300 (profile: across it, default 30), "##,
r##""unit"?: text, one line, up to 100 characters (profile: after its value axis' numbers, such as "m"; default none), "##,
r##""lineColor"?: "#RRGGBB"|"#RRGGBBAA" (profile: its curve, default #3C3228), "##,
r##""lineWidth"?: points, 0.1 to 10 (profile: its curve, default 1), "##,
r##""min"?: number (profile: the value at its base; with "max", which must be above it, two profiles share a scale; default the samples' least, rounded down), "##,
r##""guides"?: bool (profile: lines at its value axis' numbers, default true), "##,
r##""outline"?: "#RRGGBB" (northArrow, or a rectangle's, ellipse's or circle's outline instead of color; refused for other kinds), "##,
r##""units"?: "auto"|"kilometers"|"meters"|"miles"|"feet", "##,
r##""units"?: "auto"|"kilometers"|"meters"|"miles"|"feet" (scaleBar; profile: its distance axis, from the section line's A end along the ground), "##,
r##""divisions"?: 1..10, at most 10 with divisionsBeforeZero together, more refused (scaleBar, whose "color" is its lines, dark divisions and labels, default #222222), "##,
r##""subdivisions"?: 0..10 (scaleBar: parts the first division after zero is cut into, not labelled; 0 or 1 leaves it whole), "##,
r##""divisionsBeforeZero"?: 0..2 (scaleBar: whole divisions left of zero, labelled with negatives, counted toward the ten in all with "divisions", more refused), "##,
Expand Down
4 changes: 4 additions & 0 deletions crates/engine/src/cmd/layout/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ pub(crate) fn color(p: &Value, k: &str, d: Rgba) -> Result<Rgba, String> {

pub(in crate::cmd::layout) fn add_element(s: &mut Session, p: &Value) -> CmdResult {
let kind = ps(p, "kind").ok_or("kind is required")?;
// A profile reads its own keys (#2863 part 2), several of them other kinds' too.
if kind == "profile" {
return add_profile(s, p);
}
if kind != "legend" && kind != "scaleBar" && p.get("textSize").is_some_and(|v| !v.is_null()) {
return Err(ONLY_LAYOUT_TEXT_SIZE.into());
}
Expand Down
11 changes: 11 additions & 0 deletions crates/engine/src/cmd/layout/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ pub(in crate::cmd::layout) fn series_page_inputs(input: &crate::cmd::InputContex
pub(in crate::cmd::layout) fn element_inputs(input: &crate::cmd::InputContext<'_>, p: &Value) -> Result<crate::cmd::Inputs, String> {
let s = input;
let kind = ps(p, "kind").ok_or("kind is required")?;
// A profile reads the raster it draws (#2863 part 2).
if kind == "profile" {
let layout = s.project.layouts.get(index(input, p)?).ok_or("no layout")?;
let frame = frame_of(layout, p)?;
let map = frame_map(input, layout, frame)?;
let name = added_profile_layer(map, p)?;
let mut inputs = crate::cmd::Inputs::named(map, [name.as_str()])?;
inputs.maps.push(map.instance_id());
inputs.state = json!({"layout":index(input,p)?,"frame":frame});
Comment thread
elpidioassinaturas marked this conversation as resolved.
Resolved
return Ok(inputs);
}
if !matches!(kind, "table" | "chart" | "colorbar" | "legend") {
let mut inputs = object_inputs(input, p)?;
if matches!(kind, "northArrow" | "scaleBar" | "extentIndicator" | "grid" | "section") {
Expand Down
Loading
Loading