From b67203d1ddf6742c5da1f71591fbfec288080eb5 Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 03:20:41 -0600 Subject: [PATCH 1/6] feat(engine): search areas, geocoding, profiles, routes, services, rasters, constructions and label conversion give loss codes (#2371) --- crates/data/src/ogc.rs | 10 +++++++ crates/engine/src/circle_edit.rs | 8 +++++- crates/engine/src/cmd/field.rs | 2 +- crates/engine/src/cmd/geocode.rs | 11 ++++--- crates/engine/src/cmd/gp.rs | 38 +++++++++++++++++-------- crates/engine/src/cmd/items.rs | 8 +++--- crates/engine/src/cmd/labels.rs | 8 ++++-- crates/engine/src/cmd/layer.rs | 6 +++- crates/engine/src/cmd/project.rs | 2 +- crates/engine/src/cmd/raster.rs | 11 +++++-- crates/engine/src/cmd/service.rs | 5 ++-- crates/engine/src/cmd/sharing.rs | 8 ++++-- crates/engine/src/cmd/stac_area.rs | 33 ++++++++++++++------- crates/engine/src/cmd/workflows.rs | 17 ++++++----- crates/engine/src/cmd/workspace.rs | 7 +++-- crates/engine/src/construction.rs | 18 ++++++++---- crates/engine/src/geometry_calc.rs | 5 ++-- crates/engine/src/tests.rs | 6 ++++ crates/engine/src/tests/services_own.rs | 4 +++ crates/engine/src/tests/unplaced_gp.rs | 18 +++++++++--- crates/ui-egui/src/lib.rs | 8 ++---- crates/ui-egui/src/saveprompt.rs | 2 +- 22 files changed, 165 insertions(+), 70 deletions(-) diff --git a/crates/data/src/ogc.rs b/crates/data/src/ogc.rs index 3ba9322baa..7411733e1f 100644 --- a/crates/data/src/ogc.rs +++ b/crates/data/src/ogc.rs @@ -5210,6 +5210,16 @@ pub enum Assumed { } impl Assumed { + /// Its loss code: `assumed.crs` when the answer is read in a system it didn't name or named + /// otherwise. An answer that named none, read in the one asked for, and one read as it named, + /// assume nothing past the request. + pub fn loss(self) -> Option { + match self { + Assumed::Unnamed | Assumed::NotDegrees => None, + Assumed::Unread | Assumed::InDegrees | Assumed::InAsked | Assumed::DegreesUnnamed => Some(crate::loss::LossCode::AssumedCrs), + } + } + /// Its notice, `{n}` the number of answers. pub fn template(self) -> &'static str { match self { diff --git a/crates/engine/src/circle_edit.rs b/crates/engine/src/circle_edit.rs index d3ab22472c..e545aa9e2e 100644 --- a/crates/engine/src/circle_edit.rs +++ b/crates/engine/src/circle_edit.rs @@ -533,7 +533,13 @@ mod tests { s.notices.clear(); s.run("share.exportLayer", &json!({"layer":id,"path":path})).unwrap(); assert_eq!(s.notices.iter().filter(|n| n.text.starts_with("2 circle")).count(), 1); - assert_eq!(s.notices.iter().filter(|n| n.text.starts_with("1 rotated box")).count(), 1); + assert_eq!( + s.notices + .iter() + .filter(|n| n.text.starts_with("1 rotated box") && n.loss() == Some(rustgis_data::loss::LossCode::ApproximatedCurve)) + .count(), + 1 + ); if ext == "geojson" { let text = std::fs::read_to_string(&path).unwrap(); let j: Value = serde_json::from_str(&text).unwrap(); diff --git a/crates/engine/src/cmd/field.rs b/crates/engine/src/cmd/field.rs index cbb1680421..4a29ba7bd7 100644 --- a/crates/engine/src/cmd/field.rs +++ b/crates/engine/src/cmd/field.rs @@ -656,7 +656,7 @@ pub(crate) fn export_work(s: &Session, p: &Value) -> Result CmdResult { { let found = crate::render::rustgis_tiles::geocode::search_blocking(&g, query, limit)?; if found.skipped > 0 { - s.warn(skipped_notice(found.skipped)); + s.say(skipped_notice(found.skipped)); } if found.limited > 0 { s.notify(format!("Search candidates not shown: {} (limit {limit}).", found.limited), false); @@ -137,8 +137,11 @@ pub fn addresses(s: &Session, p: &Value) -> Result<(Vec, Vec), S /// What a run says of the places the geocoder answered with but gave no usable position for /// (they are left out, so an address may be "not found" because of them). -pub fn skipped_notice(n: usize) -> String { - format!("{n} of the geocoder's places had no usable position (no coordinate, or an unreadable one) and were left out") +pub fn skipped_notice(n: usize) -> rustgis_data::loss::Note { + rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedFeature, + format!("{n} of the geocoder's places had no usable position (no coordinate, or an unreadable one) and were left out"), + ) } /// The addresses past what a run may send. @@ -200,7 +203,7 @@ fn geocode(s: &mut Session, p: &Value) -> CmdResult { check_batch(&g, distinct.len())?; let l = lookup(&g, &distinct)?; if l.skipped > 0 { - s.warn(skipped_notice(l.skipped)); + s.say(skipped_notice(l.skipped)); } if l.limited > 0 { s.notify( diff --git a/crates/engine/src/cmd/gp.rs b/crates/engine/src/cmd/gp.rs index 75e90a93ed..f716516a22 100644 --- a/crates/engine/src/cmd/gp.rs +++ b/crates/engine/src/cmd/gp.rs @@ -534,19 +534,22 @@ pub fn plugin_start(s: &mut Session, tool: &str, params: &Value) -> Result( } } let mut left_out_whole = std::collections::HashSet::new(); - let work = work_inputs(&snap.map, &snap.tables, spec, params, &mut full, &mut messages, &mut left_out_whole)?; + let work = work_inputs(&snap.map, &snap.tables, spec, params, &mut full, &mut messages, &mut losses, &mut left_out_whole)?; let mut rows = env_inputs(&snap.map, &full, &snap.env, params)?; narrow_to_queries(&snap.map, spec, params, &full, &mut rows, &mut messages)?; let unread = if work == Crs::LonLat { std::collections::HashSet::new() } else { attributes_only(spec, params) }; @@ -2056,27 +2059,37 @@ fn work_inputs( params: &Value, full: &mut std::collections::HashMap, messages: &mut Vec, + losses: &mut Vec, left_out_whole: &mut std::collections::HashSet, ) -> Result { + // A loss with its code; the rest as messages. + let mut say = |said: Vec| { + for note in said { + match note.loss { + Some(code) => losses.push(LossMessage { code, text: note.text }), + None => messages.push(note.text), + } + } + }; let work = work_system(map, spec, params, full); if work != Crs::LonLat { match inputs_in(map, tables, spec, params, full, work, left_out_whole) { Ok((converted, said)) => { full.extend(converted); - messages.extend(said); + say(said); return Ok(work); } Err(e) => { // A Cancel isn't a place that can't be held. rustgis_data::progress::check().map_err(|e| e.to_string())?; let name = spec.map_or("The tool", |t| t.name); - messages.push(format!("{name} worked in longitude/latitude, not {}: {e}", work.label())); + say(vec![rustgis_data::loss::Note::plain(format!("{name} worked in longitude/latitude, not {}: {e}", work.label()))]); } } } let (converted, said) = inputs_in(map, tables, spec, params, full, Crs::LonLat, left_out_whole)?; full.extend(converted); - messages.extend(said); + say(said); Ok(Crs::LonLat) } @@ -2093,7 +2106,7 @@ fn inputs_in( full: &std::collections::HashMap, work: Crs, left_out_whole: &mut std::collections::HashSet, -) -> Result<(std::collections::HashMap, Vec), String> { +) -> Result<(std::collections::HashMap, Vec), String> { let mut converted = std::collections::HashMap::new(); // The converted inputs with edges that bend ([`bent_edges`]): name, how many, how far. let mut bent: Vec<(String, usize, f64)> = Vec::new(); @@ -2212,8 +2225,9 @@ fn inputs_in( let name = spec.map_or("The tool", |t| t.name); let n: usize = unplaced.iter().map(|(_, n)| n).sum(); let layers = unplaced.iter().map(|(layer, n)| format!("'{layer}' ({n})")).collect::>().join(", "); - said.push(format!( - "{name}: {n} feature(s) of {layers} have a place that can't be given in longitude/latitude, so the tool reads them without their geometry" + said.push(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedGeometry, + format!("{name}: {n} feature(s) of {layers} have a place that can't be given in longitude/latitude, so the tool reads them without their geometry"), )); } if !bent.is_empty() { @@ -2221,10 +2235,10 @@ fn inputs_in( let n: usize = bent.iter().map(|(_, n, _)| n).sum(); let far = bent.iter().map(|(.., far)| *far).fold(0.0, f64::max); let layers = bent.iter().map(|(layer, n, _)| format!("'{layer}' ({n})")).collect::>().join(", "); - said.push(format!( + said.push(rustgis_data::loss::Note::plain(format!( "{name}: {n} edge(s) of {layers}, converted into {}, are taken straight there, up to {far:.0} m from where a run in longitude/latitude takes them (straight on a Web Mercator map); their vertices are where they were", work.label() - )); + ))); } Ok((converted, said)) } diff --git a/crates/engine/src/cmd/items.rs b/crates/engine/src/cmd/items.rs index 2e234508a0..b405bb84bb 100644 --- a/crates/engine/src/cmd/items.rs +++ b/crates/engine/src/cmd/items.rs @@ -1230,7 +1230,7 @@ fn export_3d(s: &mut Session, p: &Value) -> CmdResult { let (bytes, report, construction_notes) = stl_bytes(s, p)?; rustgis_data::io::write_atomic(Path::new(&path), &bytes).map_err(|e| format!("{path}: {e}"))?; for note in construction_notes { - s.notify(note, false); + s.say(note); } s.retain_written_notices(written); s.notify_written(format!("Exported {path}")); @@ -1242,7 +1242,7 @@ fn export_3d(s: &mut Session, p: &Value) -> CmdResult { let (obj, construction_notes) = obj_text(s, p)?; rustgis_data::io::write_atomic(Path::new(&path), obj.as_bytes()).map_err(|e| format!("{path}: {e}"))?; for note in construction_notes { - s.notify(note, false); + s.say(note); } s.retain_written_notices(written); s.notify_written(format!("Exported {path}")); @@ -1616,7 +1616,7 @@ fn ring_area(r: &[(f64, f64)]) -> f64 { } /// A feature layer as Wavefront OBJ text. -fn obj_text(s: &mut Session, p: &Value) -> Result<(String, Vec), String> { +fn obj_text(s: &mut Session, p: &Value) -> Result<(String, Vec), String> { let mesh = layer_mesh(s, p, true)?; mesh_notices(s, &mesh); let mut obj = String::new(); @@ -1709,7 +1709,7 @@ pub(crate) fn fanned_caps_note(n: usize) -> String { } /// A feature layer as binary STL, noting what it leaves out. -fn stl_bytes(s: &mut Session, p: &Value) -> Result<(Vec, StlReport, Vec), String> { +fn stl_bytes(s: &mut Session, p: &Value) -> Result<(Vec, StlReport, Vec), String> { let mesh = layer_mesh(s, p, false)?; let (bytes, report) = mesh_stl(&mesh, MAX_STL_TRIANGLES)?; mesh_notices(s, &mesh); diff --git a/crates/engine/src/cmd/labels.rs b/crates/engine/src/cmd/labels.rs index e561bbbca6..3442a0bbd2 100644 --- a/crates/engine/src/cmd/labels.rs +++ b/crates/engine/src/cmd/labels.rs @@ -1231,12 +1231,16 @@ fn convert(s: &mut Session, p: &Value) -> CmdResult { a.min_scale = min_scale; a.max_scale = max_scale; } + // Text cut, and labels of features it can't place, are lost from the annotation. if let Some(note) = cut_note { - s.notify(note, false); + s.say(rustgis_data::loss::Note::loss(rustgis_data::loss::LossCode::ChangedCut, note)); } - for note in [flattened_note, repeated_note, astray_note, unplaced_note, unplaced_features_note].into_iter().flatten() { + for note in [flattened_note, repeated_note, astray_note, unplaced_note].into_iter().flatten() { s.notify_text(note, false); } + if let Some(note) = unplaced_features_note { + s.notify_loss(rustgis_data::loss::LossCode::DroppedFeature, note); + } if let Some((_, unread)) = &whole { unread.say(s); } diff --git a/crates/engine/src/cmd/layer.rs b/crates/engine/src/cmd/layer.rs index 6d9aef6559..17f561c12e 100644 --- a/crates/engine/src/cmd/layer.rs +++ b/crates/engine/src/cmd/layer.rs @@ -4504,7 +4504,11 @@ pub(crate) fn duckdb_parts( origin: impl Fn(rustgis_data::source::Family) -> rustgis_map::source::DuckdbOrigin, ) -> Vec { if out.skipped > 0 { - s.notify(format!("{name}: {} rows without a geometry were left out", out.skipped), false); + // A row is a layer's feature: one without geometry isn't added, and its values go with it. + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedFeature, + format!("{name}: {} rows without a geometry were left out", out.skipped), + )); } // Z and M values are dropped as DuckDB writes the result: one notice for all its parts. let zm = out.parts.iter().fold(0u64, |n, p| n.saturating_add(p.zm_dropped)); diff --git a/crates/engine/src/cmd/project.rs b/crates/engine/src/cmd/project.rs index 2eb42d30ed..02f00f24df 100644 --- a/crates/engine/src/cmd/project.rs +++ b/crates/engine/src/cmd/project.rs @@ -807,7 +807,7 @@ fn write(s: &mut Session, path: PathBuf) -> CmdResult { s.notify_written(format!("Saved {}", path.display())); crate::durable::notify(s, &report); for note in construction_notes { - s.notify(note, false); + s.say(note); } s.retain_written_notices(written); s.path = Some(destination); diff --git a/crates/engine/src/cmd/raster.rs b/crates/engine/src/cmd/raster.rs index d1250b9b27..aeca1683fe 100644 --- a/crates/engine/src/cmd/raster.rs +++ b/crates/engine/src/cmd/raster.rs @@ -426,7 +426,11 @@ pub(super) fn read_notices(s: &mut Session, name: &str, layer: &mut RasterLayer) false, ); } else { - s.notify(format!("{name}: {count} rounded as the file was read: {held}, so an export writes the rounded values"), false); + // Read whole, the count is of every value rounded. + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::ChangedRounded, + format!("{name}: {count} rounded as the file was read: {held}, so an export writes the rounded values"), + )); } } } @@ -792,7 +796,10 @@ fn add_jpeg2000_bytes(s: &mut Session, p: &Value, name: &str, bytes: Vec, zo // The GeoTIFF GDAL made names the WGS 84 it assumed, as if the file had. r.crs_assumed |= c.assumed_lonlat; if c.assumed_lonlat { - s.notify(format!("{name} doesn't say its coordinate system; its coordinates look like longitude/latitude, so it's read as WGS 84 (give \"crs\" if not)"), false); + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::AssumedCrs, + format!("{name} doesn't say its coordinate system; its coordinates look like longitude/latitude, so it's read as WGS 84 (give \"crs\" if not)"), + )); } let title = ps(p, "name").map(str::trim).filter(|n| !n.is_empty()).map(str::to_string).unwrap_or_else(|| r.name.clone()); add_raster_after(s, &title, RasterLayer::from_bytes(r, file_name, c.tif), zoom) diff --git a/crates/engine/src/cmd/service.rs b/crates/engine/src/cmd/service.rs index eaf466db26..308286ecfc 100644 --- a/crates/engine/src/cmd/service.rs +++ b/crates/engine/src/cmd/service.rs @@ -529,13 +529,14 @@ fn vet(mut svc: Service, reach: Reach, completing: bool, read: &std::collections /// [`place_answer`](rustgis_data::ogc::place_answer); none: left as they come), and a cut-off /// answer and a system assumed pointed out. pub fn features_answer(s: &mut Session, name: &str, url: &str, bytes: Vec, bounds: Option<[f64; 4]>) -> Vec { + // The rest of the features, past the server's limit or its first page, aren't read. if let Some(note) = rustgis_data::ogc::partial_note(&bytes) { - s.notify(format!("{name}: {note}"), false); + s.say(rustgis_data::loss::Note::loss(rustgis_data::loss::LossCode::DroppedOverLimit, format!("{name}: {note}"))); } let (bytes, assumed) = rustgis_data::ogc::place_answer(bytes, url, bounds); // Once per kind with a count over the command (a service group reads many answers). if let Some(assumed) = assumed { - s.notify_counted(None, assumed.template(), 1); + s.notify_counted(assumed.loss(), assumed.template(), 1); } bytes } diff --git a/crates/engine/src/cmd/sharing.rs b/crates/engine/src/cmd/sharing.rs index d5be1833bf..b7305e2a8e 100644 --- a/crates/engine/src/cmd/sharing.rs +++ b/crates/engine/src/cmd/sharing.rs @@ -208,13 +208,17 @@ pub fn commands() -> Vec { pub fn share_bytes(s: &mut Session, kind: &str, p: &Value) -> Result<(String, Vec, String), String> { let (name, bytes, source, notes) = share_output(s, kind, p)?; for note in notes { - s.notify(note, false); + s.say(note); } Ok((name, bytes, source)) } /// Shared-item construction notes are deferred when a front end still needs to deliver bytes. -pub(crate) fn share_output(s: &mut Session, kind: &str, p: &Value) -> Result<(String, Vec, String, Vec), String> { +pub(crate) fn share_output( + s: &mut Session, + kind: &str, + p: &Value, +) -> Result<(String, Vec, String, Vec), String> { let what = match kind { "webMap" => "The web map", "webLayer" => "The web layer", diff --git a/crates/engine/src/cmd/stac_area.rs b/crates/engine/src/cmd/stac_area.rs index d43999e14a..0d09f31065 100644 --- a/crates/engine/src/cmd/stac_area.rs +++ b/crates/engine/src/cmd/stac_area.rs @@ -58,8 +58,11 @@ fn read_geometries(path: &str) -> Result<(Vec, rustgis_data::loss::Not messages.push(format!("{path}: {} feature(s) have no geometry and are left out of the search area", ds.features.len() - had)); } if unplaced > 0 { - messages.push(format!( - "{path}: {unplaced} feature(s) have a place that can't be given in longitude/latitude and are left out of the search area" + messages.push(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedFeature, + format!( + "{path}: {unplaced} feature(s) have a place that can't be given in longitude/latitude and are left out of the search area" + ), )); } Ok((geometries, messages)) @@ -96,7 +99,7 @@ pub fn merge_loaded(geometries: &[Geometry], mut notices: rustgis_data::loss::No /// The geometries of the selected features of the layer `p` names (`layer`, default the active /// layer): a copy, so the merge can run off the session's thread, with what was left out of it. -pub fn selected_geometries(s: &Session, p: &Value) -> Result<(Vec, Vec), String> { +pub fn selected_geometries(s: &Session, p: &Value) -> Result<(Vec, Vec), String> { selected(s, p) } @@ -150,14 +153,18 @@ fn notes(area: &Area) -> Vec { fn selected_noted(s: &mut Session, p: &Value) -> Result, String> { let (geometries, notes) = selected(s, p)?; for n in notes { - s.warn(n); + if n.loss.is_some() { + s.say(n); + } else { + s.warn(n.text); + } } Ok(geometries) } /// The selected features' geometries of the layer `p` names, and a notice for the selected rows /// that have none (a feature without geometry, or a row the layer no longer has). -fn selected(s: &Session, p: &Value) -> Result<(Vec, Vec), String> { +fn selected(s: &Session, p: &Value) -> Result<(Vec, Vec), String> { let id = s.layer_id(p)?; let layer = s.map().layer(id).ok_or("no such layer")?; if layer.selection.is_empty() { @@ -179,18 +186,24 @@ fn selected(s: &Session, p: &Value) -> Result<(Vec, Vec), Stri } } } + use rustgis_data::loss::{LossCode, Note}; let mut notes = Vec::new(); + // A feature without geometry had no area to give the search; one with a place it can't give + // has lost it. if geometries.len() + unplaced < layer.selection.len() { - notes.push(format!( + notes.push(Note::plain(format!( "{}: {} selected feature(s) have no geometry and are left out of the search area", layer.name, layer.selection.len() - geometries.len() - unplaced - )); + ))); } if unplaced > 0 { - notes.push(format!( - "{}: {unplaced} selected feature(s) have a place that can't be given in longitude/latitude and are left out of the search area", - layer.name + notes.push(Note::loss( + LossCode::DroppedFeature, + format!( + "{}: {unplaced} selected feature(s) have a place that can't be given in longitude/latitude and are left out of the search area", + layer.name + ), )); } Ok((geometries, notes)) diff --git a/crates/engine/src/cmd/workflows.rs b/crates/engine/src/cmd/workflows.rs index 267dde6367..529d6a4e38 100644 --- a/crates/engine/src/cmd/workflows.rs +++ b/crates/engine/src/cmd/workflows.rs @@ -2322,10 +2322,10 @@ fn route(s: &mut Session, p: &Value) -> CmdResult { s.notify_text(notice, false); } if r.skipped_segments > 0 { - s.notify( + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedGeometry, format!("{source_name}: {} segments with invalid coordinates were omitted from the route network", r.skipped_segments), - false, - ); + )); } if r.overflowing > 0 { s.notify( @@ -2497,9 +2497,12 @@ fn simulate(s: &mut Session, p: &Value) -> CmdResult { s.notify_text(notice, false); } if unplaced > 0 { - s.warn(format!( - "{}: {unplaced} polygon(s) of {source} have a place that can't be given in longitude/latitude, so no points are simulated in them", - ds.name + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedFeature, + format!( + "{}: {unplaced} polygon(s) of {source} have a place that can't be given in longitude/latitude, so no points are simulated in them", + ds.name + ), )); } let nid = super::layer::add_dataset(s, ds); @@ -2626,7 +2629,7 @@ fn convert(s: &mut Session, p: &Value) -> CmdResult { let target = ds.name.clone(); let query_note = super::share::query_export_note(&target, &layer.name, &report); drop(ds); - for note in notes.into_iter().chain(construction_notes.into_iter().map(rustgis_data::loss::Note::plain)) { + for note in notes.into_iter().chain(construction_notes) { s.say(note); } super::share::notify_null_numbers(s, &target, null_numbers); diff --git a/crates/engine/src/cmd/workspace.rs b/crates/engine/src/cmd/workspace.rs index df68884e7e..6dfbdcf6c9 100644 --- a/crates/engine/src/cmd/workspace.rs +++ b/crates/engine/src/cmd/workspace.rs @@ -233,8 +233,11 @@ pub fn commands() -> Vec { } let out: Vec = lines.iter().take(MAX_PROFILED_LINES).map(|l| profile(s, p, l)).collect::>()?; if unplaced > 0 { - s.warn(format!( - "Profile Along Selected Lines: {unplaced} line(s) have a place that can't be given in longitude/latitude, so they get no profile" + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedCalculationResult, + format!( + "Profile Along Selected Lines: {unplaced} line(s) have a place that can't be given in longitude/latitude, so they get no profile" + ), )); } Ok(Value::Array(out)) diff --git a/crates/engine/src/construction.rs b/crates/engine/src/construction.rs index afbd363a4a..40ca5762eb 100644 --- a/crates/engine/src/construction.rs +++ b/crates/engine/src/construction.rs @@ -94,10 +94,13 @@ pub(crate) struct Counts { circles: usize, } impl Counts { - pub(crate) fn notes(self) -> Vec { + /// What an output loses of the constructions it writes: their curved edges are straight in + /// the polygons written, which keep no construction to draw them again. + pub(crate) fn notes(self) -> Vec { + use rustgis_data::loss::{LossCode, Note}; let boxes = (self.boxes > 0).then(|| format!("{} rotated box(es): session-only construction is not included in this output and will not survive reimport; the source polygons use four transformed corners, with curved grid edges approximated by straight edges", self.boxes)); let circles = (self.circles > 0).then(|| format!("{} circle(s): session-only centre/radius construction is not included in this output and will not survive reimport; source polygons approximate circles with straight edges (tolerance in each construction grid, before projection)", self.circles)); - boxes.into_iter().chain(circles).collect() + boxes.into_iter().chain(circles).map(|text| Note::loss(LossCode::ApproximatedCurve, text)).collect() } } @@ -174,13 +177,16 @@ impl Cache { } } } - pub(crate) fn export_notes(&self, map: u64, layer: &rustgis_map::Layer) -> Result, String> { + pub(crate) fn export_notes(&self, map: u64, layer: &rustgis_map::Layer) -> Result, String> { self.output_notes(std::iter::once((map, layer))) } /// Count only unchanged, live constructions from the output's source layers. Exports call /// this on their worker. Document writers call it in their existing synchronous durable /// transaction, before output, with the same cancellation context as serialization. - pub(crate) fn output_notes<'a>(&self, layers: impl IntoIterator) -> Result, String> { + pub(crate) fn output_notes<'a>( + &self, + layers: impl IntoIterator, + ) -> Result, String> { if self.len == 0 { return Ok(Vec::new()); } @@ -210,7 +216,7 @@ pub(crate) fn forget_feature(s: &mut Session, layer: u32, feature: u64) { impl Session { /// Counted losses for a layer output, including browser downloads. Call before encoding /// and present the notes only after the output has been accepted or written. - pub fn layer_construction_output_notes(&self, layer: u32) -> Result, String> { + pub fn layer_construction_output_notes(&self, layer: u32) -> Result, String> { let l = self.map().layer(layer).ok_or("no such layer")?; self.constructions.export_notes(self.map().instance_id(), l) } @@ -218,7 +224,7 @@ impl Session { /// public `Project` directly should present these notes too: `Project` owns no session cache. /// Explicit save/download paths call this inside their existing durable output transaction; /// unlike the live session, the serialized document contains only polygon geometry. - pub fn construction_output_notes(&self) -> Result, String> { + pub fn construction_output_notes(&self) -> Result, String> { self.constructions.output_notes(self.project.maps.iter().flat_map(|m| m.layers.iter().map(move |l| (m.instance_id(), l)))) } } diff --git a/crates/engine/src/geometry_calc.rs b/crates/engine/src/geometry_calc.rs index 1a498bfa3d..8fa17f7fd2 100644 --- a/crates/engine/src/geometry_calc.rs +++ b/crates/engine/src/geometry_calc.rs @@ -184,8 +184,9 @@ pub fn run(s: &mut Session, p: &Json) -> CmdResult { crate::cmd::design::apply(s, id, changes)?; if unplaced > 0 { let name = s.map().layer(id).map(|l| l.name.clone()).unwrap_or_default(); - s.warn(format!( - "{name}: {unplaced} feature(s) have a place that can't be given in longitude/latitude, so their {property} is left empty in {field}" + s.say(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedCalculationResult, + format!("{name}: {unplaced} feature(s) have a place that can't be given in longitude/latitude, so their {property} is left empty in {field}"), )); } Ok(json!({"rows": rows.len(), "nulls": nulls, "unplaced": unplaced, "field": field})) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 30306c3417..1239a72bf9 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -51243,6 +51243,12 @@ fn a_cog_window_comes_in_as_a_raster() { s.run("layer.addUrl", &json!({"url": format!("{wide}/ids.tif"), "bbox": [10.0, 45.0, 10.5, 45.5], "name": "Ids"})).unwrap(); let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); assert!(said.iter().any(|n| n.starts_with("Ids: 32768 values were rounded as the file was read")), "{said:?}"); + assert!( + s.notices_since(mark) + .iter() + .any(|n| n.text.starts_with("Ids: 32768 values were rounded") && n.loss() == Some(rustgis_data::loss::LossCode::ChangedRounded)), + "{said:?}" + ); // Across tiles, only the window's own cells are counted (the four tiles hold 131,072 odd // values; the 256 × 256 window, half of its own). let mark = s.notice_mark(); diff --git a/crates/engine/src/tests/services_own.rs b/crates/engine/src/tests/services_own.rs index d74bf18acf..79183ce12e 100644 --- a/crates/engine/src/tests/services_own.rs +++ b/crates/engine/src/tests/services_own.rs @@ -58,6 +58,8 @@ fn a_wfs_type_is_asked_for_in_its_own_system() { said.len() == 1 && said[0].starts_with("1 service answer(s) named no coordinate system, and their positions are in degrees"), "{said:?}" ); + // Read in a system other than the one asked for: an assumption, coded. + assert_eq!(s.notices.iter().map(|n| n.loss()).collect::>(), [Some(rustgis_data::loss::LossCode::AssumedCrs)]); // A system RustGIS doesn't read: in CRS84, as before. let text = caps("/lonlat", "urn:ogc:def:crs:EPSG::999999"); s.run("service.add", &json!({"url": format!("{}/lonlat", server.base), "layer": "towns", "text": text, "name": "Unread"})).unwrap(); @@ -161,6 +163,8 @@ fn an_arcgis_layer_is_asked_for_in_its_services_system() { assert_eq!(first_point(&s, "Unbounded"), (Crs::from_epsg(2056).unwrap(), 2_600_000.0, 1_200_000.0)); let said = notices(&s); assert!(said.len() == 1 && said[0].contains("1 service answer(s) named no coordinate system"), "{said:?}"); + // Read in the system asked for: nothing assumed past the request. + assert_eq!(s.notices.iter().map(|n| n.loss()).collect::>(), [None]); } /// A WCS coverage in LV95 is asked for in it, with no conversion by the server, and comes in as a diff --git a/crates/engine/src/tests/unplaced_gp.rs b/crates/engine/src/tests/unplaced_gp.rs index 745eaf625e..e41e4abbbe 100644 --- a/crates/engine/src/tests/unplaced_gp.rs +++ b/crates/engine/src/tests/unplaced_gp.rs @@ -67,7 +67,9 @@ fn session(far: bool) -> Session { fn run(s: &mut Session, cmd: &str, p: serde_json::Value) -> (serde_json::Value, Vec) { let mark = s.notice_mark(); let out = s.run(cmd, &p).unwrap_or_else(|e| panic!("{cmd}: {e}")); - let said = s.notices_since(mark).iter().map(|n| n.text.clone()).filter(|t| t.contains("can't be given in")).collect(); + let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).filter(|t| t.contains("can't be given in")).collect(); + // Each such notice says a loss, with its code. + assert!(s.notices_since(mark).iter().filter(|n| n.text.contains("can't be given in")).all(|n| n.loss().is_some()), "{cmd}: {said:?}"); (out, said) } @@ -184,8 +186,13 @@ fn a_route_and_a_simulation_leave_out_what_they_cant_place() { let mark = s.notice_mark(); let r = s.run("analysis.route", &json!({"layer": "lines", "from": [10.002, 45.002], "to": [10.038, 45.038]})).unwrap(); assert!(r["lengthKm"].as_f64().unwrap() > 4.0, "{r}"); - let omitted: Vec<_> = - s.notices_since(mark).iter().map(|n| n.text.clone()).filter(|t| t.contains("segments with invalid coordinates")).collect(); + let omitted: Vec<_> = s + .notices_since(mark) + .iter() + .filter(|n| { + n.text.contains("segments with invalid coordinates") && n.loss() == Some(rustgis_data::loss::LossCode::DroppedGeometry) + }) + .collect(); assert_eq!(omitted.len(), usize::from(far), "{omitted:?}"); // Points in the square only. let (out, said) = run(&mut s, "analysis.simulate", json!({"layer": "areas", "count": 5})); @@ -208,7 +215,10 @@ fn profiles_and_a_search_area_leave_out_what_they_cant_place() { assert_eq!(said.len(), usize::from(far), "{said:?}"); let (geometries, notes) = crate::cmd::stac_area::selected_geometries(&s, &json!({"layer": "lines"})).unwrap(); assert_eq!(geometries.len(), 1); - let unplaced: Vec<_> = notes.iter().filter(|n| n.contains("can't be given in")).collect(); + let unplaced: Vec<_> = notes + .iter() + .filter(|n| n.contains("can't be given in") && n.loss == Some(rustgis_data::loss::LossCode::DroppedFeature)) + .collect(); assert_eq!(unplaced.len(), usize::from(far), "{notes:?}"); assert!(notes.iter().all(|n| !n.contains("have no geometry")), "{notes:?}"); if far { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4feca3651a..47c33d56f4 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2763,7 +2763,7 @@ impl RustGisApp { self.session.notify(offered, false); report.notify(&mut self.session); for note in construction_notes { - self.session.notify(note, false); + self.session.say(note); } self.ui.web_file = Some(file); Ok(()) @@ -5662,11 +5662,7 @@ impl RustGisApp { if self.download(&name, bytes) { rustgis_engine::cmd::share::notify_export_query(&mut self.session, &name, &layer_name, &query_report); rustgis_engine::cmd::share::notify_null_numbers(&mut self.session, &name, null_numbers); - for note in notes - .into_iter() - .chain(dbf_notes) - .chain(construction_notes.into_iter().map(rustgis_engine::data::loss::Note::plain)) - { + for note in notes.into_iter().chain(dbf_notes).chain(construction_notes) { self.session.say(note); } } diff --git a/crates/ui-egui/src/saveprompt.rs b/crates/ui-egui/src/saveprompt.rs index 0863650cd2..ae37b81549 100644 --- a/crates/ui-egui/src/saveprompt.rs +++ b/crates/ui-egui/src/saveprompt.rs @@ -122,7 +122,7 @@ pub(crate) fn start_project_save(app: &mut RustGisApp, in_place: bool) -> Result }); report.notify(&mut app.session); for note in notes { - app.session.notify(note, false); + app.session.say(note); } Ok(()) } From 8c7adbcce19bf7283990a2025c5a1481534d36f2 Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 03:31:00 -0600 Subject: [PATCH 2/6] fix(engine): the geocoding pane and a DuckDB reload code what they leave out, and the geocoder and label tests check the codes (#2371) --- crates/engine/src/tests.rs | 17 ++++++++++++++--- crates/map/src/source.rs | 7 ++++++- crates/ui-egui/src/geocodeui.rs | 7 +++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 1239a72bf9..af5180eb7a 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -5408,7 +5408,11 @@ fn label_expressions_say_what_they_lose() { s.run("labels.by", &json!({"layer": "Cities", "text": long})).unwrap(); let n = s.run("labels.convert", &json!({"layer": "Cities"})).unwrap()["annotations"].as_u64().unwrap(); let said = format!("Cities Annotation: {n} label texts cut to {} characters", rustgis_map::label_by::MAX_LABEL_TEXT); - assert!(s.notices.iter().any(|x| x.text == said), "{:?}", s.notices.last()); + assert!( + s.notices.iter().any(|x| x.text == said && x.loss() == Some(rustgis_data::loss::LossCode::ChangedCut)), + "{:?}", + s.notices.last() + ); s.undo(); // Project Info names the text expression the labels draw by, and the field once it doesn't read. s.map_mut().layer_mut(cities).unwrap().labels.default.field = "name".into(); @@ -31464,8 +31468,15 @@ fn geocoding_with_the_locatieserver() { (path("Kapot", 5), br#"{"response":{"docs":[{"weergavenaam":"x","centroide_ll":"POINT(x y)"}]}}"#.to_vec()), ]); let url = format!("{base}/free"); - let left_out = - |s: &Session| s.notices.iter().filter(|n| n.text.contains("no usable position")).map(|n| n.text.clone()).collect::>(); + // Each with its code: the places are left out of what the geocoder found. + let left_out = |s: &Session| { + s.notices + .iter() + .filter(|n| n.text.contains("no usable position")) + .inspect(|n| assert_eq!(n.loss(), Some(rustgis_data::loss::LossCode::DroppedFeature), "{}", n.text)) + .map(|n| n.text.clone()) + .collect::>() + }; let mut s = Session::new(Project::default()); let r = s.run("map.findPlace", &json!({"query": "Damrak 1, Amsterdam", "provider": "locatieserver", "url": url})).unwrap(); assert_eq!(r["count"], 2, "{r}"); diff --git a/crates/map/src/source.rs b/crates/map/src/source.rs index 1626beab33..061c8367cc 100644 --- a/crates/map/src/source.rs +++ b/crates/map/src/source.rs @@ -1117,7 +1117,11 @@ impl SourceLayer { .map_err(|e| format!("{path}: {e}"))?; let out = fresh.output; if out.skipped > 0 { - conversion_notes.push(format!("DuckDB: {} rows without a geometry were left out", out.skipped)); + // A row is a feature: one without geometry isn't added, and its values go with it. + conversion_notes.push(rustgis_data::loss::Note::loss( + rustgis_data::loss::LossCode::DroppedFeature, + format!("DuckDB: {} rows without a geometry were left out", out.skipped), + )); } if out.other_family > 0 { conversion_notes.push(format!("DuckDB: {} rows of another geometry type were left out", out.other_family)); @@ -1184,6 +1188,7 @@ impl SourceLayer { ))); } if probe.skipped > 0 { + // A probe of one feature: the reads that follow count these rows as they say them. conversion_notes.push(format!("{} rows could not be read while checking the replacement", probe.skipped)); } if let Some(info) = new.info() { diff --git a/crates/ui-egui/src/geocodeui.rs b/crates/ui-egui/src/geocodeui.rs index a6470d961b..d457358f74 100644 --- a/crates/ui-egui/src/geocodeui.rs +++ b/crates/ui-egui/src/geocodeui.rs @@ -74,7 +74,10 @@ pub fn poll(app: &mut RustGisApp, ctx: &egui::Context) { if let Ok(found) = &r && found.skipped > 0 { - app.session.warn(skipped(found.skipped)); + app.session.say(rustgis_engine::data::loss::Note::loss( + rustgis_engine::data::loss::LossCode::DroppedFeature, + skipped(found.skipped), + )); } match r { Ok(f) if f.places.is_empty() => app.dialogs.error = Some(tl!("No place found").to_string()), @@ -156,7 +159,7 @@ pub fn poll(app: &mut RustGisApp, ctx: &egui::Context) { // Every answer is in: the layer. let Some(job) = st.job.take() else { return }; if job.skipped > 0 { - app.session.warn(skipped(job.skipped)); + app.session.say(rustgis_engine::data::loss::Note::loss(rustgis_engine::data::loss::LossCode::DroppedFeature, skipped(job.skipped))); } if job.limited > 0 { app.session.notify( From 11caee4790590270eda7997dda9037f2f4dbe0b7 Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 04:15:17 -0600 Subject: [PATCH 3/6] fix(engine): a picker save says its construction notes once written, and tool inputs, cut-off service answers and JPEG 2000 stay plain (#2371) --- crates/engine/src/cmd/gp.rs | 9 +++++---- crates/engine/src/cmd/raster.rs | 5 +---- crates/engine/src/cmd/service.rs | 3 +-- crates/engine/src/tests/unplaced_gp.rs | 11 +++++++++-- crates/ui-egui/src/saveprompt.rs | 10 +++++++--- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd/gp.rs b/crates/engine/src/cmd/gp.rs index f716516a22..e56d34c913 100644 --- a/crates/engine/src/cmd/gp.rs +++ b/crates/engine/src/cmd/gp.rs @@ -2225,10 +2225,11 @@ fn inputs_in( let name = spec.map_or("The tool", |t| t.name); let n: usize = unplaced.iter().map(|(_, n)| n).sum(); let layers = unplaced.iter().map(|(layer, n)| format!("'{layer}' ({n})")).collect::>().join(", "); - said.push(rustgis_data::loss::Note::loss( - rustgis_data::loss::LossCode::DroppedGeometry, - format!("{name}: {n} feature(s) of {layers} have a place that can't be given in longitude/latitude, so the tool reads them without their geometry"), - )); + // Counted over each whole layer, before the run's rows are narrowed to a selection: some may + // be rows the tool doesn't read, so it isn't a coded loss. + said.push(rustgis_data::loss::Note::plain(format!( + "{name}: {n} feature(s) of {layers} have a place that can't be given in longitude/latitude, so the tool reads them without their geometry" + ))); } if !bent.is_empty() { let name = spec.map_or("The tool", |t| t.name); diff --git a/crates/engine/src/cmd/raster.rs b/crates/engine/src/cmd/raster.rs index aeca1683fe..ee94cfcca8 100644 --- a/crates/engine/src/cmd/raster.rs +++ b/crates/engine/src/cmd/raster.rs @@ -796,10 +796,7 @@ fn add_jpeg2000_bytes(s: &mut Session, p: &Value, name: &str, bytes: Vec, zo // The GeoTIFF GDAL made names the WGS 84 it assumed, as if the file had. r.crs_assumed |= c.assumed_lonlat; if c.assumed_lonlat { - s.say(rustgis_data::loss::Note::loss( - rustgis_data::loss::LossCode::AssumedCrs, - format!("{name} doesn't say its coordinate system; its coordinates look like longitude/latitude, so it's read as WGS 84 (give \"crs\" if not)"), - )); + s.notify(format!("{name} doesn't say its coordinate system; its coordinates look like longitude/latitude, so it's read as WGS 84 (give \"crs\" if not)"), false); } let title = ps(p, "name").map(str::trim).filter(|n| !n.is_empty()).map(str::to_string).unwrap_or_else(|| r.name.clone()); add_raster_after(s, &title, RasterLayer::from_bytes(r, file_name, c.tif), zoom) diff --git a/crates/engine/src/cmd/service.rs b/crates/engine/src/cmd/service.rs index 308286ecfc..288d36cdf5 100644 --- a/crates/engine/src/cmd/service.rs +++ b/crates/engine/src/cmd/service.rs @@ -529,9 +529,8 @@ fn vet(mut svc: Service, reach: Reach, completing: bool, read: &std::collections /// [`place_answer`](rustgis_data::ogc::place_answer); none: left as they come), and a cut-off /// answer and a system assumed pointed out. pub fn features_answer(s: &mut Session, name: &str, url: &str, bytes: Vec, bounds: Option<[f64; 4]>) -> Vec { - // The rest of the features, past the server's limit or its first page, aren't read. if let Some(note) = rustgis_data::ogc::partial_note(&bytes) { - s.say(rustgis_data::loss::Note::loss(rustgis_data::loss::LossCode::DroppedOverLimit, format!("{name}: {note}"))); + s.notify(format!("{name}: {note}"), false); } let (bytes, assumed) = rustgis_data::ogc::place_answer(bytes, url, bounds); // Once per kind with a count over the command (a service group reads many answers). diff --git a/crates/engine/src/tests/unplaced_gp.rs b/crates/engine/src/tests/unplaced_gp.rs index e41e4abbbe..11f7de1a91 100644 --- a/crates/engine/src/tests/unplaced_gp.rs +++ b/crates/engine/src/tests/unplaced_gp.rs @@ -68,8 +68,15 @@ fn run(s: &mut Session, cmd: &str, p: serde_json::Value) -> (serde_json::Value, let mark = s.notice_mark(); let out = s.run(cmd, &p).unwrap_or_else(|e| panic!("{cmd}: {e}")); let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).filter(|t| t.contains("can't be given in")).collect(); - // Each such notice says a loss, with its code. - assert!(s.notices_since(mark).iter().filter(|n| n.text.contains("can't be given in")).all(|n| n.loss().is_some()), "{cmd}: {said:?}"); + // Each such notice says a loss, with its code; a tool's, counted over its whole inputs before + // they are narrowed to its rows, is plain. + assert!( + s.notices_since(mark) + .iter() + .filter(|n| n.text.contains("can't be given in") && !n.text.contains("so the tool reads them")) + .all(|n| n.loss().is_some()), + "{cmd}: {said:?}" + ); (out, said) } diff --git a/crates/ui-egui/src/saveprompt.rs b/crates/ui-egui/src/saveprompt.rs index ae37b81549..dd98199d71 100644 --- a/crates/ui-egui/src/saveprompt.rs +++ b/crates/ui-egui/src/saveprompt.rs @@ -61,6 +61,8 @@ struct PendingSave { document: Option, /// Whether that document is the one the project was opened from. opened_from: bool, + /// What the save loses of the project's constructions, said once it is written. + notes: Vec, } /// The document the open project is written back to on Save, and whether it is the one the project @@ -119,11 +121,9 @@ pub(crate) fn start_project_save(app: &mut RustGisApp, in_place: bool) -> Result project: app.session.file_identity(), document: target, opened_from, + notes, }); report.notify(&mut app.session); - for note in notes { - app.session.say(note); - } Ok(()) } @@ -158,6 +158,10 @@ impl RustGisApp { } } let Some(saved) = pending else { return }; + // Written: what it lost of the constructions is said now, and only now. + for note in saved.notes { + self.session.say(note); + } // Saved through the picker: Save writes back to the document it wrote from now on, or // asks again where the phone can't write it back; never to the one before. // A write-back that reports its document again (iOS made its bookmark again, the file having From bd4c26fd0d885e9176164a2c5d0aed9ea3942b36 Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 04:26:19 -0600 Subject: [PATCH 4/6] fix(analysis): the network tools code segments they leave out, and a picker save that may have reached its file says its construction notes (#2371) --- crates/analysis/src/tools/network_analysis.rs | 26 ++++++++++++------- crates/ui-egui/src/saveprompt.rs | 7 +++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/crates/analysis/src/tools/network_analysis.rs b/crates/analysis/src/tools/network_analysis.rs index 282eca4555..ef9ae7e246 100644 --- a/crates/analysis/src/tools/network_analysis.rs +++ b/crates/analysis/src/tools/network_analysis.rs @@ -21,6 +21,8 @@ struct Network<'a> { unit_m: f64, snap_m: f64, notes: Vec, + /// What building it lost, with codes: segments it couldn't read. + losses: Vec, } /// Reads the `network`, `costField`, `units` and `snapDistance` parameters and builds (or reuses) @@ -88,19 +90,25 @@ fn network<'a>(inp: &'a dyn Inputs, p: &Json, tool: &str) -> Result, ds.name )); } + // Left out of the network, as the route command leaves them out of its own. + let mut losses = Vec::new(); if graph.skipped_segments() > 0 { - notes.push(format!( - "{tool}: {} segment(s) of '{}' with invalid coordinates were left out of the network", - graph.skipped_segments(), - ds.name - )); + losses.push(rustgis_data::loss::LossMessage { + code: rustgis_data::loss::LossCode::DroppedGeometry, + text: format!( + "{tool}: {} segment(s) of '{}' with invalid coordinates were left out of the network", + graph.skipped_segments(), + ds.name + ), + }); } if graph.segments() == 0 { // What left no lines is said with it: the notes would be lost with the run. - let why = if notes.is_empty() { String::new() } else { format!(" ({})", notes.join("; ")) }; + let said: Vec<&str> = notes.iter().map(String::as_str).chain(losses.iter().map(|l| l.text.as_str())).collect(); + let why = if said.is_empty() { String::new() } else { format!(" ({})", said.join("; ")) }; return Err(format!("'{}' has no lines to search{why}", ds.name)); } - Ok(Network { ds, graph, unit_m, snap_m, notes }) + Ok(Network { ds, graph, unit_m, snap_m, notes, losses }) } /// The features of a point layer moved onto the network, in layer order, as (feature id, place), @@ -350,7 +358,7 @@ pub(super) fn service_area(inp: &dyn Inputs, p: &Json) -> Result self.session.notify(crate::i18n::fmt("Saved {name}.", &[("name", &name)]), false), Err(error) => { self.session.notify(error, true); + // A failed write-back that may have reached the document: what that loses of the + // constructions is said too, as the file may hold it. + if let Some(p) = pending.as_ref().filter(|p| p.document.is_some() && reached) { + for note in p.notes.clone() { + self.session.say(note); + } + } // A document that couldn't be written back is asked for again: the next Save // shows the picker. A picker closed with no choice changes nothing. if let Some(failed) = pending.filter(|p| p.document.is_some() && reached) { From e59daf7b4f623e0a2ecaf654ec5881688232702d Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 04:43:31 -0600 Subject: [PATCH 5/6] fix(ui): a picker save that wrote its file says its construction notes, and a test covers each ending (#2371) --- crates/ui-egui/src/saveprompt.rs | 51 ++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/saveprompt.rs b/crates/ui-egui/src/saveprompt.rs index d0ae58f17f..6819bc6a67 100644 --- a/crates/ui-egui/src/saveprompt.rs +++ b/crates/ui-egui/src/saveprompt.rs @@ -149,9 +149,10 @@ impl RustGisApp { Ok(name) => self.session.notify(crate::i18n::fmt("Saved {name}.", &[("name", &name)]), false), Err(error) => { self.session.notify(error, true); - // A failed write-back that may have reached the document: what that loses of the - // constructions is said too, as the file may hold it. - if let Some(p) = pending.as_ref().filter(|p| p.document.is_some() && reached) { + // A failed save that may have written its file (a write-back that reached its + // document, or a picker that reported where it wrote): what that loses of the + // constructions is said too, as the file may hold it. A cancelled picker wrote nothing. + if let Some(p) = pending.as_ref().filter(|p| (p.document.is_some() && reached) || reported.is_some()) { for note in p.notes.clone() { self.session.say(note); } @@ -432,6 +433,50 @@ mod tests { h.output().viewport_output.get(&egui::ViewportId::ROOT).is_some_and(|v| v.commands.contains(&egui::ViewportCommand::CancelClose)) } + /// A picker save of a project holding a circle says what the save loses of it (drawn as straight + /// edges, with the code) once the save completes, or when it failed after the picker wrote; a + /// cancelled or refused picker says nothing of it. + #[test] + fn a_picker_save_says_its_construction_losses_only_once_written() { + use rustgis_engine::data::{Dataset, Field, FieldType, GeometryType, loss::LossCode}; + let said = |h: &Harness, mark: u64| { + h.state() + .session + .notices_since(mark) + .iter() + .filter(|n| n.text.contains("circle(s)") && n.loss() == Some(LossCode::ApproximatedCurve)) + .count() + }; + for (finish, expected) in [("ok", 1), ("cancelled", 0), ("wrote, then failed", 1), ("refused", 0)] { + let mut h = launch(); + h.state_mut().services.save_project = Some(Box::new(|_, _, _| Ok(()))); + let id = h.state_mut().session.map_mut().add_dataset(Dataset::new( + "Rings", + GeometryType::Polygon, + vec![Field::new("n", FieldType::Text)], + )); + h.state_mut().session.active_layer = Some(id); + h.state_mut().run("edit.enable", json!({"on": true})).unwrap(); + h.state_mut().run("edit.addCircle", json!({"circle": {"center": [1000.0, 1000.0], "radius": 100.0}})).unwrap(); + let mark = h.state().session.notice_mark(); + // New Project asks about the unsaved circle; its Save opens the picker. + h.state_mut().run_by_user("project.new", Value::Null).unwrap(); + frames(&mut h, 2); + click(&mut h, "Save"); + assert_eq!(said(&h, mark), 0, "{finish}: nothing said before the save completes"); + match finish { + "ok" => h.state_mut().complete_project_save(Ok("World Atlas.rgis".into())), + "cancelled" => h.state_mut().complete_project_save(Err("Picker cancelled".into())), + "wrote, then failed" => { + h.state_mut().project_document("content://saved/World Atlas.rgis".into()); + h.state_mut().complete_project_save(Err("couldn't confirm the save".into())); + } + _ => h.state_mut().project_save_refused("busy".into()), + } + assert_eq!(said(&h, mark), expected, "{finish}: {:?}", h.state().session.notices_since(mark)); + } + } + #[test] fn project_save_dialogs_fit_a_narrow_viewport() { let mut h = launch(); From d61951dc5d26a42271418fca69b3835cdabf2d07 Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 04:54:17 -0600 Subject: [PATCH 6/6] revert(engine): a plugin tool's input losses are left for their own PR, with a test (#2371) --- crates/engine/src/cmd/gp.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/gp.rs b/crates/engine/src/cmd/gp.rs index e56d34c913..d30058c052 100644 --- a/crates/engine/src/cmd/gp.rs +++ b/crates/engine/src/cmd/gp.rs @@ -534,22 +534,19 @@ pub fn plugin_start(s: &mut Session, tool: &str, params: &Value) -> Result