Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2ca504e
feat(layout): a layout text shows a layer's count, sum, mean, min or …
jgregoriorincon Nov 24, 2026
dd79ea5
docs(layout): the guide, schema, fixture and help for layer statistic…
jgregoriorincon Nov 25, 2026
7066178
fix(layout): a statistic over a layer read in place says it covers on…
jgregoriorincon Nov 25, 2026
57459ac
fix(layout): a raster layer's statistic is drawn as written, and a re…
jgregoriorincon Nov 25, 2026
e51a344
docs(layout): the statistics paragraph of the guide, rewrapped and na…
jgregoriorincon Nov 25, 2026
a94d3cb
fix(layout): a layer statistic in a publication's texts needs the cap…
jgregoriorincon Nov 25, 2026
54632a9
fix(layout): a statistic says when its frame's map is missing from th…
jgregoriorincon Nov 25, 2026
b7a9181
docs(layout): rewrap the statistics paragraph of the guide (#2853)
jgregoriorincon Nov 25, 2026
b476e95
fix(layout): the statistics of an imported layout's texts are checked…
jgregoriorincon Nov 25, 2026
3af4cee
docs(layout): the guide says how a statistic is written and rewraps i…
jgregoriorincon Nov 25, 2026
e19ac97
fix(layout): a token split across a publication title's list entries …
jgregoriorincon Nov 25, 2026
2933a7d
fix(layout): a token split across a publication's source or reference…
jgregoriorincon Nov 26, 2026
e95c0b1
docs(layout): the cost of a statistic's pass is stated; the capabilit…
jgregoriorincon Nov 26, 2026
0bdc10a
fix(layout): a layer statistic in a presentation map page's title nee…
jgregoriorincon Nov 26, 2026
596e0e1
fix(layout): a statistic read through report.existingTemplate or pres…
jgregoriorincon Nov 26, 2026
9ac7e87
docs(layout): rewrap the statistics capability paragraph of maintaini…
jgregoriorincon Nov 26, 2026
2bc9b5c
fix(layout): another map for the first frame says what the layout's t…
jgregoriorincon Nov 26, 2026
1a4b92b
fix(layout): deleting or drawing over the first frame says what the l…
jgregoriorincon Nov 26, 2026
5f0bf52
fix(layout): giving the first frame the map it already has says nothi…
jgregoriorincon Nov 26, 2026
b67d2e1
fix(layout): renaming a layer renames it in the layout texts' statist…
jgregoriorincon Nov 26, 2026
cab11b2
fix(layout): the rename test passes clippy; its unit test keeps its p…
jgregoriorincon Nov 26, 2026
8a7726e
test(layout): the same-map notice test pins its messages (#2853)
jgregoriorincon Nov 26, 2026
94cddd9
docs(layout): rewrap the statistics paragraph of the guide (#2853)
jgregoriorincon Nov 26, 2026
ec45ca2
Merge remote-tracking branch 'upstream/main' into feat/2853-text-stat…
jgregoriorincon Nov 26, 2026
8f495b1
fix(layout): renaming a layer renames it in a presentation map page's…
jgregoriorincon Nov 26, 2026
23a2928
fix(layout): deleting the map of a layout's first frame says what its…
jgregoriorincon Nov 26, 2026
df3db83
fix(layout): a publication's wrapped text keeps a layer statistic who…
jgregoriorincon Nov 26, 2026
ca6ab68
fix(layout): a publication measures a layer statistic as wide as a ty…
jgregoriorincon Nov 26, 2026
cd5f4db
fix(layout): a rename leaves a statistic text that would outgrow its …
jgregoriorincon Nov 26, 2026
fc2b448
fix(layout): a rename leaves a presentation title that would outgrow …
jgregoriorincon Nov 26, 2026
b75bad4
fix(layout): adding a first frame, and a rename to a name with braces…
jgregoriorincon Nov 26, 2026
8a64a7b
refactor(layout): the rename of statistics is one function; a typical…
jgregoriorincon Nov 26, 2026
4c05ecf
fix(layout): a publication text with a layer statistic is always wrap…
jgregoriorincon Nov 26, 2026
4223c24
refactor(layout): a layout text's limit is one constant at its call s…
jgregoriorincon Nov 26, 2026
389ae99
perf(layout): the figures of one layer in a text are tallied in one p…
jgregoriorincon Nov 26, 2026
bfa5d51
fix(layout): no index that can panic in layer_statistic; the guide an…
jgregoriorincon Nov 26, 2026
95eb10d
fix(layout): a figure written without its field is said, not dropped …
jgregoriorincon Nov 26, 2026
eab9d2d
fix(layout): a publication measures a layer statistic by the figure i…
jgregoriorincon Nov 26, 2026
ce57656
fix(layout): a figure written with an empty field is said, like one w…
jgregoriorincon Nov 26, 2026
ed249d1
Merge remote-tracking branch 'upstream/main' into feat/2853-text-stat…
jgregoriorincon Nov 26, 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
84 changes: 84 additions & 0 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7199,6 +7199,34 @@ pub(crate) fn legends_follow_layer(s: &mut Session, old: &str, new: Option<&str>
}
}

/// What a layer rename does to a text's layer statistics (#2853).
enum Renamed {
/// No statistic names the layer.
Same,
/// The text with the new name written in.
To(String),
/// The new name would take the text past `limit` characters, which the file would cut.
TooLong,
/// The new name holds a brace, which ends a token early.
Braces,
}

/// `text` with the layer a rename moves (`replace` says the name that takes the old one's place)
/// written into its statistic tokens, held to `limit` characters.
fn renamed_statistics(text: &str, limit: usize, braces: bool, replace: &mut impl FnMut(&mut String)) -> Renamed {
let renamed = rustgis_map::layout::rename_stat_layers(text, |layer| {
let mut name = layer.to_string();
replace(&mut name);
(name != layer).then_some(name)
});
match renamed {
None => Renamed::Same,
Some(_) if braces => Renamed::Braces,
Some(renamed) if renamed.chars().count() <= limit => Renamed::To(renamed),
Some(_) => Renamed::TooLong,
}
}

/// Carries typed references to a renamed layer along with it. Map-local references and layout
/// frames stay in their map. A name still present there keeps its references, as legends do;
/// project-wide references without a map stay unchanged when another map still has that name.
Expand Down Expand Up @@ -7296,6 +7324,10 @@ fn references_follow_layer(s: &mut Session, old: &str, new: &str) {
if let Elevation::Surface(layer) = &mut editing.settings.elevation {
replace(layer);
}
let mut texts_too_long = 0usize;
let mut texts_with_braces = 0usize;
// A name with a brace can't be written into a token: the texts keep the old one.
let braces = new.contains(['{', '}']);
for layout in &mut s.project.layouts {
let frames: Vec<u32> = layout
.elements
Expand All @@ -7305,12 +7337,22 @@ fn references_follow_layer(s: &mut Session, old: &str, new: &str) {
_ => None,
})
.collect();
// A text's layer statistics (#2853) read the map of the layout's first frame.
let texts_read_this_map = layout.first_frame().is_some_and(|f| frames.contains(&f));
for element in &mut layout.elements {
match &mut element.kind {
ElementKind::Table { frame, layer, .. } | ElementKind::Chart { frame, layer, .. } if frames.contains(frame) => {
replace(layer)
}
ElementKind::Colorbar { frame, layer: Some(layer), .. } if frames.contains(frame) => replace(layer),
ElementKind::Text { text, .. } if texts_read_this_map => {
match renamed_statistics(text, rustgis_map::layout::MAX_TEXT_CHARS, braces, &mut replace) {
Renamed::To(renamed) => *text = renamed,
Renamed::TooLong => texts_too_long += 1,
Renamed::Braces => texts_with_braces += 1,
Renamed::Same => {}
}
}
_ => {}
}
}
Expand All @@ -7320,6 +7362,20 @@ fn references_follow_layer(s: &mut Session, old: &str, new: &str) {
replace(&mut series.layer);
}
}
// A presentation's map page draws its title over its own map, where a layer statistic is filled
// in (#2853).
let mut titles_too_long = 0usize;
let mut titles_with_braces = 0usize;
for page in s.project.presentations.iter_mut().flat_map(|p| &mut p.pages) {
if matches!(&page.kind, rustgis_map::presentation::PageKind::Map { map, .. } if map.eq_ignore_ascii_case(&map_name)) {
match renamed_statistics(&page.title, rustgis_map::presentation::MAX_TITLE, braces, &mut replace) {
Renamed::To(renamed) => page.title = renamed,
Renamed::TooLong => titles_too_long += 1,
Renamed::Braces => titles_with_braces += 1,
Renamed::Same => {}
}
}
}
// These items do not record a map; changing an ambiguous name would redirect references
// used with another map. Keep those spellings until the user chooses their intended layer.
let shared = s.project.maps.iter().enumerate().any(|(i, map)| {
Expand Down Expand Up @@ -7360,6 +7416,34 @@ fn references_follow_layer(s: &mut Session, old: &str, new: &str) {
project_reference(image);
}
}
for (count, what) in [(texts_with_braces, "layout text(s)"), (titles_with_braces, "presentation title(s)")] {
if count > 0 {
s.notify_text(crate::notice_text::NoticeText::format(
"{count} {what} keep the old layer name '{old}' in their statistics: the new name has a brace, which a token can't hold",
[("count", count.to_string().into()), ("what", what.to_string().into()), ("old", old.to_string().into())],
), false);
}
}
if titles_too_long > 0 {
s.notify_text(crate::notice_text::NoticeText::format(
"{count} presentation title(s) keep the old layer name '{old}' in their statistics: the new name would take them past the {limit} characters a title holds",
[
("count", titles_too_long.to_string().into()),
("old", old.to_string().into()),
("limit", rustgis_map::presentation::MAX_TITLE.to_string().into()),
],
), false);
}
if texts_too_long > 0 {
s.notify_text(crate::notice_text::NoticeText::format(
"{count} layout text(s) keep the old layer name '{old}' in their statistics: the new name would take them past the {limit} characters a text holds",
[
("count", texts_too_long.to_string().into()),
("old", old.to_string().into()),
("limit", rustgis_map::layout::MAX_TEXT_CHARS.to_string().into()),
],
), false);
}
if left > 0 {
s.notify_text(crate::notice_text::NoticeText::format(
"{count} project reference(s) still name '{old}': another map has a layer of the old or new name; choose the intended layer in those items",
Expand Down
127 changes: 116 additions & 11 deletions crates/engine/src/cmd/layout.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/engine/src/cmd/presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn commands() -> Vec<C> {
add_page(s, p, title, PageKind::Map { map: name, center, width_m })
}).inputs(map_page_inputs).roles(&[]).effects(crate::policy::Effects::NONE)
.when(need_presentation)
.params(r#"{"presentation"?, "map"?: name (default: the active map, at its current view), "lon"?, "lat"?, "widthM"?: ground width shown (m), "title"?, "at"?: page index}"#),
.params(r#"{"presentation"?, "map"?: name (default: the active map, at its current view), "lon"?, "lat"?, "widthM"?: ground width shown (m), "title"? (a layer's figure may be written in it: {count:Layer}, {sum:Layer:field}, {mean:…}, {min:…}, {max:…}, filled in when the page is drawn), "at"?: page index}"#),
C::new("presentation.blankPage", "Blank Page", "Publish › Page", |s, p| {
let background = super::layout::color(p, "background", Rgba::rgb(0xFF, 0xFF, 0xFF))?;
let text = super::within("text", "a page's text", ps(p, "text").unwrap_or(""), MAX_TEXT)?;
Expand Down Expand Up @@ -138,7 +138,7 @@ pub fn commands() -> Vec<C> {
.when(need_presentation)
.params(r#"{"presentation"?, "source": video file or URL, "poster"?: PNG/JPEG file, "posterImage"?: base64, "title"?, "caption"?, "at"?}"#),
C::new("presentation.updatePage", "Page Properties", "Presentation", update_page).inputs(page_inputs).roles(&[]).effects(crate::policy::Effects::NONE).when(need_presentation).params(
r##"{"presentation"?, "page": index, "title"?, "text"?, "caption"?, "notes"?, "seconds"?, "background"?: "#RRGGBB"|"#RRGGBBAA", "moveTo"?: index}"##,
r##"{"presentation"?, "page": index, "title"? (a map page's title may hold a layer's figure, as mapPage's), "text"?, "caption"?, "notes"?, "seconds"?, "background"?: "#RRGGBB"|"#RRGGBBAA", "moveTo"?: index}"##,
),
C::new("presentation.removePage", "Delete Page", "Presentation", |s, p| {
let (i, k) = page_of(s, p)?;
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub const CAPABILITIES: &[&str] = &[
"label-duplicates",
"tile-resampling",
"layout-page-color",
"layout-text-statistics",
];
/// An offline area keeping the versions that lost a sync or a Bring Back
/// (`OfflineArea::conflicts`, #2468): an older reader would save it again without them.
Expand Down
Loading
Loading