From faf0a041f03e1459fe577521c5980442e34ddde8 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:22:18 -0500 Subject: [PATCH 1/9] fix(engine): say when Copy Path or a new GeoPackage changes a name Copy Path left a service address's keys, tokens or password out without a word, so a pasted address failed with no explanation; it now says so once. A new GeoPackage whose requested tableName is reserved is written under a prefixed name that only the JSON result gave; it now says what the table is called instead. Both are tested both ways: the changed result gives the notice, an unchanged one none. --- crates/engine/src/cmd/clipboard.rs | 7 +++++- crates/engine/src/cmd/share.rs | 10 +++++++++ crates/engine/src/tests.rs | 36 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/clipboard.rs b/crates/engine/src/cmd/clipboard.rs index d9e4c1b08b..1011f4c00c 100644 --- a/crates/engine/src/cmd/clipboard.rs +++ b/crates/engine/src/cmd/clipboard.rs @@ -192,7 +192,12 @@ fn copy_path(s: &mut Session, p: &Value) -> CmdResult { let l = s.map().layer(id).ok_or("no such layer")?; let path = l.raster.as_ref().and_then(|r| r.path.clone()).or_else(|| l.dataset.source.clone()); let path = path.ok_or_else(|| format!("{} isn't stored in a file", l.name))?; + let name = l.name.clone(); // A service layer's address is its source: copied without keys, tokens or its password, as // the details pane shows it and a saved project keeps a web address. - Ok(json!({"text": crate::sources::redact(&path)})) + let text = crate::sources::redact(&path); + if text != path { + s.notify(format!("The copied address of {name} leaves out its keys, tokens or password: add them back to use it"), false); + } + Ok(json!({"text": text})) } diff --git a/crates/engine/src/cmd/share.rs b/crates/engine/src/cmd/share.rs index 9f347ef027..0482a78ef8 100644 --- a/crates/engine/src/cmd/share.rs +++ b/crates/engine/src/cmd/share.rs @@ -93,6 +93,16 @@ pub fn gpkg_table(p: &Value, ext: &str) -> Result { /// it again. fn report_table(s: &mut Session, path: &str, gpkg: &GpkgTable, table: Option, out: &mut Value) { let Some(table) = table else { return }; + // A new file's table is said only when it isn't the name asked for (a reserved name is + // prefixed); one added to or replaced in a file is always named below. + if gpkg.mode == GpkgMode::NewFile + && let Some(asked) = gpkg.name.as_deref().filter(|n| *n != table.table) + { + s.notify( + format!("{path}: wrote the table {} instead of '{asked}', a name GeoPackage reserves or leaves empty", table.table), + false, + ); + } if gpkg.mode != GpkgMode::NewFile { let (reread, failed) = if table.replaced { super::gpkg::reset_sources(s, Path::new(path), &table.table, true) } else { (0, Vec::new()) }; diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index c488a4749c..24a5082791 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -13098,9 +13098,22 @@ fn a_service_layers_address_is_copied_without_its_key() { let r = s.run("layer.addDownload", &json!({"id": id, "url": url, "name": "Api", "service": true})).unwrap(); let layer = r["layer"].as_u64().or_else(|| r["layers"][0].as_u64()).unwrap() as u32; assert_eq!(s.map().layer(layer).and_then(|l| l.dataset.source.as_deref()), Some(url)); + let mark = s.notice_mark(); let copied = s.run("layer.copyPath", &json!({"layer": layer})).unwrap(); let text = copied["text"].as_str().unwrap(); assert!(text.starts_with("https://x.org/collections/a/items?") && !text.contains("SECRET"), "{text}"); + let said = |s: &Session| s.notices_since(mark).iter().filter(|n| n.text.contains("leaves out its keys")).count(); + assert_eq!(said(&s), 1, "the copied address says what it left out"); + // An address with nothing secret in it is copied as it is, with no notice. + let id = s.download_started(); + assert!(s.download_landed(id, br#"{"type": "Point", "coordinates": [1, 2]}"#.to_vec())); + let plain = "https://x.org/collections/b/items?f=json"; + let r = s.run("layer.addDownload", &json!({"id": id, "url": plain, "name": "Plain", "service": true})).unwrap(); + let layer = r["layer"].as_u64().or_else(|| r["layers"][0].as_u64()).unwrap() as u32; + let mark = s.notice_mark(); + let copied = s.run("layer.copyPath", &json!({"layer": layer})).unwrap(); + assert_eq!(copied["text"], plain); + assert!(s.notices_since(mark).iter().all(|n| !n.text.contains("leaves out")), "{:?}", s.notices_since(mark)); } /// The app's downloads land in the project they were started for, as bytes (no base64); one @@ -15428,6 +15441,29 @@ fn exporting_features_refuses_to_replace_an_existing_geopackage() { std::fs::remove_dir_all(dir).unwrap(); } +/// A new GeoPackage whose asked-for table name is reserved says what the table is called +/// instead; one written under the name asked for says nothing of it. +#[test] +fn a_new_geopackage_says_when_its_table_name_was_changed() { + let dir = std::env::temp_dir().join(format!("rustgis-engine-gpkg-rename-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let mut s = world(); + let said = |s: &Session, mark: u64| s.notices_since(mark).iter().filter(|n| n.text.contains("instead of")).count(); + let mark = s.notice_mark(); + let path = dir.join("reserved.gpkg"); + let out = s.run("share.exportLayer", &json!({"layer": "Cities", "path": path, "tableName": "gpkg_cities"})).unwrap(); + assert_eq!(out["table"].as_str(), Some("layer_gpkg_cities"), "{out}"); + assert_eq!(said(&s, mark), 1, "{:?}", s.notices_since(mark)); + let mark = s.notice_mark(); + let path = dir.join("plain.gpkg"); + let out = s.run("share.exportLayer", &json!({"layer": "Cities", "path": path, "tableName": "towns"})).unwrap(); + assert_eq!(out["table"].as_str(), Some("towns"), "{out}"); + assert_eq!(said(&s, mark), 0, "{:?}", s.notices_since(mark)); + drop(s); + std::fs::remove_dir_all(dir).unwrap(); +} + /// Export Features adds a layer to an existing GeoPackage as one more table, or replaces one of /// its tables, saying which; a layer read in place from that GeoPackage can go back into it (its /// filtered copy as another table). `mode` and `tableName` are for GeoPackages only. From 4ff7baecc734d719e71a4a1205105e1c90ebd519 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:22:20 -0500 Subject: [PATCH 2/9] fix(engine): lend the sole web login when the session's choice is stale A session choice naming a connection no longer among an origin's candidates made the request read anonymously, with no notice, even when one connection with a login was left. Such a choice now counts as no choice, so the single-candidate fallback runs. --- crates/engine/src/service_logins.rs | 6 ++++-- crates/engine/src/tests/permission_policy.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/service_logins.rs b/crates/engine/src/service_logins.rs index 6a86ede41f..1a746e157c 100644 --- a/crates/engine/src/service_logins.rs +++ b/crates/engine/src/service_logins.rs @@ -319,8 +319,10 @@ pub fn request(s: &mut Session, connection: Option<&str>, url: &str) -> Result Date: Sun, 8 Nov 2026 00:22:28 -0500 Subject: [PATCH 3/9] fix(ui-egui): read a poisoned result slot The writers fill a result slot even when its lock is poisoned, so the pane doesn't wait forever, but take() read it with lock().ok() and never saw the result. It now reads through the poison. --- crates/ui-egui/src/panes.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index 6f30d91a25..eec05e108e 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -2877,8 +2877,9 @@ pub fn start_geolibre_load(app: &mut RustGisApp) { app.gp.web_load = Some(slot); } +/// What a slot holds, taken out; a poisoned slot is still read, as its writer fills it anyway. fn take(slot: &crate::Slot) -> Option { - slot.lock().ok().and_then(|mut s| s.take()) + slot.lock().unwrap_or_else(std::sync::PoisonError::into_inner).take() } /// Picks up what the browser's GeoLibre runner finished: the tool list, or a tool run. @@ -6928,6 +6929,24 @@ pub(crate) fn layout_menu(app: &mut RustGisApp, ui: &mut Ui, n: &str) { mod tests { use super::*; + /// A slot poisoned by a panicking writer that filled it anyway is still read, or the pane + /// waiting on it would wait forever. + #[cfg(not(target_arch = "wasm32"))] + #[test] + fn a_poisoned_slot_is_still_taken() { + let slot: crate::Slot = crate::Slot::default(); + let writer = slot.clone(); + let _ = std::thread::spawn(move || { + let mut held = writer.lock().unwrap(); + *held = Some(7); + panic!("the writer fails after filling the slot"); + }) + .join(); + assert!(slot.is_poisoned()); + assert_eq!(take(&slot), Some(7)); + assert_eq!(take(&slot), None, "taken once"); + } + /// Run starts a built-in tool on a thread of its own: the pane shows it running, with Cancel, /// and its result lands as gp.run's would, with its layer and history. #[cfg(not(target_arch = "wasm32"))] From 9f3161e8ff89b0f6b63e09d7dc8b06aca9feb92e Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:22:37 -0500 Subject: [PATCH 4/9] test(engine): check plugin download expiry on freshly booted hosts The expiry test backdated its waits with Instant::checked_sub and returned early when the host had been up less than the wait, so on fresh CI machines its assertions never ran. Expiry now takes the time to check at, and the test passes a later time instead. The rerun error it matches now says the layer was removed or undone. --- crates/engine/src/cmd/plugin_fetch.rs | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/plugin_fetch.rs b/crates/engine/src/cmd/plugin_fetch.rs index e93caa077d..39541c1871 100644 --- a/crates/engine/src/cmd/plugin_fetch.rs +++ b/crates/engine/src/cmd/plugin_fetch.rs @@ -520,11 +520,16 @@ impl UrlWaits { } } - /// Downloads waited for past [`REQUEST_WAIT`] land as failed, and are remembered as given up: - /// their addresses, redacted, to be said (a notice with a key in it loses what follows it). - fn expire(&mut self) -> Vec { - let late: Vec<(u64, Value)> = - self.in_flight.iter().filter(|(.., at)| at.elapsed() >= REQUEST_WAIT).map(|(n, q, _)| (*n, q.clone())).collect(); + /// Downloads waited for past [`REQUEST_WAIT`] by `now` land as failed, and are remembered as + /// given up: their addresses, redacted, to be said (a notice with a key in it loses what + /// follows it). + fn expire_at(&mut self, now: Instant) -> Vec { + let late: Vec<(u64, Value)> = self + .in_flight + .iter() + .filter(|(.., at)| now.saturating_duration_since(*at) >= REQUEST_WAIT) + .map(|(n, q, _)| (*n, q.clone())) + .collect(); let mut addresses = Vec::new(); for (n, asked) in late { self.land(n, Err(format!("no download in {} minutes", REQUEST_WAIT.as_secs() / 60)), Added::default()); @@ -867,13 +872,19 @@ impl Session { /// what it answered this time. Its `layer.addUrl` calls answer what adding each download /// answered. Errors are also given as notices, as for any command. pub fn poll_plugin_retries(&mut self) -> Vec<(String, CmdResult)> { + self.poll_plugin_retries_at(Instant::now()) + } + + /// [`Session::poll_plugin_retries`] as at `now`: downloads waited for past [`REQUEST_WAIT`] + /// by then are given up (a test passes a later time instead of backdating the waits). + fn poll_plugin_retries_at(&mut self, now: Instant) -> Vec<(String, CmdResult)> { self.url_waits.documents_in(); if self.plugin_retries.is_empty() { return Vec::new(); } // Said here too: the command may go on without it, and what it answers goes nowhere. let minutes = REQUEST_WAIT.as_secs() / 60; - match self.url_waits.expire().as_slice() { + match self.url_waits.expire_at(now).as_slice() { [] => {} [url] => self.notify(format!("{url}: no download in {minutes} minutes, so its plugin command stopped waiting for it"), true), many => self.notify( @@ -1114,7 +1125,7 @@ mod tests { s.map_mut().layers[at] = other; s.rerun_landed = vec![(asked.clone(), answer, added)]; let e = s.run("layer.addUrl", &asked).unwrap_err(); - assert!(e.contains("taken away (undone)"), "{e}"); + assert!(e.contains("removed or undone"), "{e}"); // A tile layer (a GeoTIFF read in place answers its place in the list), then taken away. let tiles = json!({"url": "https://x.org/{z}/{x}/{y}.png", "name": "T"}); let answer = s.run("map.addTiles", &tiles); @@ -1135,7 +1146,7 @@ mod tests { s.run("map.removeTiles", &json!({"index": moved})).unwrap(); assert!(s.map().tiles.iter().any(|t| t.name == "T2")); let e = s.run("layer.addUrl", &asked).unwrap_err(); - assert!(e.contains("taken away (undone)"), "{e}"); + assert!(e.contains("removed or undone"), "{e}"); // A standalone table (a file with no geometry), then taken away. let answer = s.run("layer.addDataText", &json!({"fileName": "sites.csv", "text": "id,street\n1,Champ de Mars\n"})); assert!(answer.as_ref().unwrap()["table"].is_string(), "{answer:?}"); @@ -1143,7 +1154,7 @@ mod tests { assert_eq!(s.run("layer.addUrl", &asked), answer); s.run("table.remove", &json!({"table": "sites"})).unwrap(); let e = s.run("layer.addUrl", &asked).unwrap_err(); - assert!(e.contains("the table its download added was taken away (undone)"), "{e}"); + assert!(e.contains("the table its download added was removed or undone"), "{e}"); } /// A number lands only the read it was given for: a plugin's has no login, and a read that @@ -1173,7 +1184,6 @@ mod tests { /// Timeouts are one counted, redacted notice, and a real pinned command receives the failure. #[test] fn a_download_given_up_is_said_with_its_address() { - let Some(long_ago) = Instant::now().checked_sub(REQUEST_WAIT + Duration::from_secs(1)) else { return }; let mut s = Session::new(crate::project::Project::default()); let first = load_test_plugin("eng-slow-real"); let other = load_test_plugin("eng-slow-other"); @@ -1182,8 +1192,7 @@ mod tests { let mark = s.notice_mark(); s.poll_plugin_retries(); assert!(s.notices_since(mark).is_empty(), "it still has time"); - s.url_waits.in_flight[0].2 = long_ago; - let ran = s.poll_plugin_retries(); + let ran = s.poll_plugin_retries_at(Instant::now() + REQUEST_WAIT); assert!(ran[0].1.is_err(), "{ran:?}"); s.poll_plugin_retries(); let said: Vec<_> = s.notices_since(mark).iter().filter(|n| n.error && n.text.contains("stopped waiting")).collect(); @@ -1199,9 +1208,8 @@ mod tests { ask(&mut s, &first, json!({"url":"https://x.org/a.csv?token=hunter2"})).unwrap(); ask(&mut s, &other, json!({"url":"https://x.org/b.csv"})).unwrap(); let _taken = s.take_url_requests(); - s.url_waits.in_flight.iter_mut().for_each(|w| w.2 = long_ago); let mark = s.notice_mark(); - s.poll_plugin_retries(); + s.poll_plugin_retries_at(Instant::now() + REQUEST_WAIT); let said: Vec<_> = s.notices_since(mark).iter().filter(|n| n.error && n.text.contains("stopped waiting")).collect(); assert_eq!(said.len(), 1, "{said:?}"); assert!( From ef9d36d5d25a1171b518c185b9636366e708e3a6 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:22:56 -0500 Subject: [PATCH 5/9] fix(engine): clearer messages, and corner names in any case - A rerun whose download's layer is gone says it was removed or undone, not only undone. - The shared-DEM-name refusal says to try again and that Terrain stays as it was, since it also fires with Terrain already on. - The move, rotate and scale notice names infinite coordinates too. - The crowded-surrounds warning speaks of freer places, not corners. - An arrangement's corner names are read whatever their case, as arrangement names are. - layer.addDataText's fileName description lists .city.json. --- crates/engine/src/cmd/design.rs | 6 +++--- crates/engine/src/cmd/layer.rs | 6 +++--- crates/engine/src/cmd/layout.rs | 4 ++-- crates/engine/src/cmd/plugins.rs | 2 +- crates/engine/src/cmd/view.rs | 2 +- crates/engine/src/tests.rs | 4 ++++ crates/engine/tests/polar_edits.rs | 7 +++++-- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/cmd/design.rs b/crates/engine/src/cmd/design.rs index 7b11b318a4..0d1e37152f 100644 --- a/crates/engine/src/cmd/design.rs +++ b/crates/engine/src/cmd/design.rs @@ -939,8 +939,8 @@ fn polar_transform( }) } -/// [`modify`] for a move, turn or scale, which leaves a vertex missing a coordinate where it was: -/// says how many of the features it changed have one. +/// [`modify`] for a move, turn or scale, which leaves a vertex missing a coordinate (or with an +/// infinite one) where it was: says how many of the features it changed have one. fn move_features(s: &mut Session, mut change: impl FnMut((u32, usize), &Geometry) -> Result, String>) -> CmdResult { let mut missing = 0usize; let done = modify(s, |key, g| { @@ -953,7 +953,7 @@ fn move_features(s: &mut Session, mut change: impl FnMut((u32, usize), &Geometry Ok(moved) })?; if missing > 0 { - s.warn(format!("{missing} feature(s) have a vertex missing a coordinate, which was left where it was")); + s.warn(format!("{missing} feature(s) have a vertex missing a coordinate or with an infinite one, which was left where it was")); } Ok(done) } diff --git a/crates/engine/src/cmd/layer.rs b/crates/engine/src/cmd/layer.rs index f6bc99da35..939c624031 100644 --- a/crates/engine/src/cmd/layer.rs +++ b/crates/engine/src/cmd/layer.rs @@ -47,7 +47,7 @@ pub fn commands() -> Vec { C::new("layer.addEncodedPolyline", "Add Encoded Polyline", "Home › Add", add_encoded_polyline).roles(&[]).effects(crate::policy::Effects::NONE).params( r#"{"polyline": "encoded polyline text" | [texts] (one line each), "precision"?: 5 (Google) | 6 (OSRM, Valhalla), "name"?: text}"#, ), - C::new("layer.addDataText", "Add Data (from text)", "Home › Add", add_data_text).roles(&[]).effects(crate::policy::Effects::NONE).params(r#"{"fileName": "name.geojson|.csv|.tsv", "text": string, "name"?: text, "x"?, "y"?, "wkt"?, "crs"?, "delimiter"? (as layer.addData, for delimited text), "layer"?, "paperSpace"? (as layer.addData, for a file of several layers)}"#), + C::new("layer.addDataText", "Add Data (from text)", "Home › Add", add_data_text).roles(&[]).effects(crate::policy::Effects::NONE).params(r#"{"fileName": "name.geojson|.csv|.tsv|.city.json (CityJSON: all its layers)", "text": string, "name"?: text, "x"?, "y"?, "wkt"?, "crs"?, "delimiter"? (as layer.addData, for delimited text; crs also for a CityJSON model that doesn't say), "layer"?, "paperSpace"? (as layer.addData, for a file of several layers)}"#), C::new("layer.addSample", "Add Sample Data", "Home › Add › Add Data", add_sample).roles(&[]).effects(crate::policy::Effects::NONE).params(r#"{"name": "countries"|"cities"|"rivers"|"lakes"}"#), C::new("layer.remove", "Remove", "Layers", remove).roles(&[]).effects(crate::policy::Effects::NONE) .key("Delete") @@ -3226,10 +3226,10 @@ fn add_url_as_given(s: &mut Session, p: &Value) -> CmdResult { .and_then(Value::as_u64) .is_some_and(|id| u32::try_from(id).ok().and_then(|id| s.map().layer(id)).is_none()); if missing || added.gone(s.map()) { - return Err(format!("{url}: the layer its download added was taken away (undone) before the command ran again")); + return Err(format!("{url}: the layer its download added was removed or undone before the command ran again")); } if super::plugins::fetch::table_gone(&answer, &s.project) { - return Err(format!("{url}: the table its download added was taken away (undone) before the command ran again")); + return Err(format!("{url}: the table its download added was removed or undone before the command ran again")); } return added.answer_now(s.map(), &answer); } diff --git a/crates/engine/src/cmd/layout.rs b/crates/engine/src/cmd/layout.rs index 2ed0c0afa3..f7fc9b8796 100644 --- a/crates/engine/src/cmd/layout.rs +++ b/crates/engine/src/cmd/layout.rs @@ -786,7 +786,7 @@ pub fn parse_arrangement(v: &Value) -> Result { let corner = o.get(*key).and_then(Value::as_str).map(str::trim).unwrap_or(""); homes[i] = CORNER_NAMES .iter() - .position(|c| *c == corner) + .position(|c| c.eq_ignore_ascii_case(corner)) .ok_or_else(|| format!("arrangement: \"{key}\" is \"top-left\", \"top-right\", \"bottom-left\" or \"bottom-right\""))?; } if (0..4).any(|i| homes[..i].contains(&homes[i])) { @@ -2062,7 +2062,7 @@ fn publication(s: &mut Session, p: &Value) -> CmdResult { _ => (format!("the {} and the {last}", rest.join(", the ")), "sit"), }; warnings - .push(format!("{names} {verb} on what the map shows, the freer corners having gone to the others: move by hand what matters")); + .push(format!("{names} {verb} on what the map shows, the freer places having gone to the others: move by hand what matters")); } for (i, (a, ra)) in placed.iter().enumerate() { for (b, rb) in placed.iter().skip(i + 1) { diff --git a/crates/engine/src/cmd/plugins.rs b/crates/engine/src/cmd/plugins.rs index 48b4c8a846..da786e3190 100644 --- a/crates/engine/src/cmd/plugins.rs +++ b/crates/engine/src/cmd/plugins.rs @@ -680,6 +680,6 @@ mod tests { // A layer undone while the command waited: said, not named. s.rerun_landed = vec![(asked.clone(), Ok(json!({"layer": 4_000_000})), Default::default())]; let e = s.run("layer.addUrl", &asked).unwrap_err(); - assert!(e.contains("taken away (undone)"), "{e}"); + assert!(e.contains("removed or undone"), "{e}"); } } diff --git a/crates/engine/src/cmd/view.rs b/crates/engine/src/cmd/view.rs index 4af97f16fb..80139e4a88 100644 --- a/crates/engine/src/cmd/view.rs +++ b/crates/engine/src/cmd/view.rs @@ -270,7 +270,7 @@ fn terrain(s: &mut Session, p: &Value) -> CmdResult { if let TerrainSource::Layer(n) = &t.source && m.layers.iter().filter(|l| l.name.eq_ignore_ascii_case(n)).count() > 1 { - let e = format!("two layers are called '{n}': rename one, then turn Terrain on"); + let e = format!("two layers are called '{n}': rename one, then try again (Terrain stays as it was)"); // A terrain that was on stays as it was. if let Some(old) = old_terrain { m.view.terrain = Some(old); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 24a5082791..a0287f0a45 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -6859,6 +6859,10 @@ fn publication_arrangements_and_the_favourite() { let custom = json!({"locator": "bottom-left", "northArrow": "top-left", "legend": "top-right", "scaleBar": "bottom-right"}); let r = s.run("layout.publication", &json!({"extent": extent, "author": "", "arrangement": custom})).unwrap(); assert_eq!((r["arrangement"].as_str(), corners(&s)), (Some("custom"), ["bottom left", "top left", "top right", "bottom right"]), "{r}"); + // Corner names, like arrangement names, are read whatever their case. + let shouted = json!({"locator": "Bottom-Left", "northArrow": "TOP-LEFT", "legend": "top-Right", "scaleBar": "bottom-right"}); + let r = s.run("layout.publication", &json!({"extent": extent, "author": "", "arrangement": shouted})).unwrap(); + assert_eq!(corners(&s), ["bottom left", "top left", "top right", "bottom right"], "{r}"); // The favourite: shown, set, then the one the default and "favourite" take. let shown = s.run("layout.arrangement", &json!({})).unwrap(); assert_eq!((shown["favourite"].as_str(), shown["corners"]["legend"].as_str()), (Some("classic"), Some("bottom-left"))); diff --git a/crates/engine/tests/polar_edits.rs b/crates/engine/tests/polar_edits.rs index bb964f3ed5..c276253845 100644 --- a/crates/engine/tests/polar_edits.rs +++ b/crates/engine/tests/polar_edits.rs @@ -624,7 +624,7 @@ fn a_vertex_missing_a_coordinate_left_where_it_was_is_counted() { s.notices_since(mark).iter().filter(|n| n.text.contains("missing a coordinate")).map(|n| n.text.clone()).collect::>(); (ran.is_ok(), said) }; - let one = ["1 feature(s) have a vertex missing a coordinate, which was left where it was"]; + let one = ["1 feature(s) have a vertex missing a coordinate or with an infinite one, which was left where it was"]; let edits = [("edit.move", json!({"dx": 1000.0})), ("edit.rotate", json!({"angle": 10.0})), ("edit.scale", json!({"factor": 1.5}))]; let near_equator = boxed(10.0, 10.0, 11.0, 11.0); for ring in [polar_ring(), near_equator] { @@ -656,7 +656,10 @@ fn a_vertex_missing_a_coordinate_left_where_it_was_is_counted() { let features = vec![polygon(two), polygon(once), polygon(boxed(30.0, 10.0, 31.0, 11.0)), Geometry::Point(Coord::new(f64::NAN, 10.0))]; let (mut s, _) = layer(GeometryType::Polygon, features); let (ran, text) = said(&mut s, "edit.rotate", &json!({"angle": 10.0})); - assert!(ran && text == ["2 feature(s) have a vertex missing a coordinate, which was left where it was"], "{text:?}"); + assert!( + ran && text == ["2 feature(s) have a vertex missing a coordinate or with an infinite one, which was left where it was"], + "{text:?}" + ); // A refused edit (a polygon reaching a pole can't be turned yet) says nothing of the kind. let mut cap = polar_ring(); cap[0].y = -90.0; From 73245404e2c3f005c4927553da24b06c9ac1856f Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 05:27:30 -0500 Subject: [PATCH 6/9] Address review feedback - Copy Path's notice no longer names the layer (a name may hold an address with a key) and its wording holds for every part redaction can leave out, a fragment or web login included. - A new GeoPackage's table is said when it differs from the default name (the layer's) as well as from tableName, and the notice says what GeoPackage changes in a name instead of calling it reserved. - The rename test asserts both names in one notice and covers the default name. --- crates/engine/src/cmd/clipboard.rs | 4 ++-- crates/engine/src/cmd/share.rs | 31 ++++++++++++++++++------------ crates/engine/src/tests.rs | 14 +++++++++++++- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd/clipboard.rs b/crates/engine/src/cmd/clipboard.rs index 1011f4c00c..ef95b78e95 100644 --- a/crates/engine/src/cmd/clipboard.rs +++ b/crates/engine/src/cmd/clipboard.rs @@ -192,12 +192,12 @@ fn copy_path(s: &mut Session, p: &Value) -> CmdResult { let l = s.map().layer(id).ok_or("no such layer")?; let path = l.raster.as_ref().and_then(|r| r.path.clone()).or_else(|| l.dataset.source.clone()); let path = path.ok_or_else(|| format!("{} isn't stored in a file", l.name))?; - let name = l.name.clone(); // A service layer's address is its source: copied without keys, tokens or its password, as // the details pane shows it and a saved project keeps a web address. let text = crate::sources::redact(&path); if text != path { - s.notify(format!("The copied address of {name} leaves out its keys, tokens or password: add them back to use it"), false); + // Not the layer's name: it may hold an address with a key of its own. + s.notify("The copied address leaves out part of the layer's address (keys, tokens, a password, a login or a fragment), so it may not work as it is", false); } Ok(json!({"text": text})) } diff --git a/crates/engine/src/cmd/share.rs b/crates/engine/src/cmd/share.rs index 0482a78ef8..40c6ff62f7 100644 --- a/crates/engine/src/cmd/share.rs +++ b/crates/engine/src/cmd/share.rs @@ -39,6 +39,7 @@ pub fn commands() -> Vec { let ext = Path::new(path).extension().and_then(|e| e.to_str()).unwrap_or("").to_ascii_lowercase(); let gpkg = gpkg_table(p, &ext)?; let t = s.project.tables.get(s.table_index(p)?).ok_or("no such table")?; + let default = t.dataset.name.clone(); // Tables may retain geometry and its import losses, just as feature layers do. let notes = rustgis_data::export_notes([(&t.dataset, t.dataset.extent())], path, Crs::LonLat); let mut dbf_notes = Vec::new(); @@ -56,7 +57,7 @@ pub fn commands() -> Vec { s.notify(note, false); } let mut out = json!({"path": path}); - report_table(s, path, &gpkg, table, &mut out); + report_table(s, path, &gpkg, &default, table, &mut out); Ok(out) }).roles(&[]).effects(crate::policy::Effects::NONE.with(crate::policy::Effect::Files)) .params( @@ -91,17 +92,22 @@ pub fn gpkg_table(p: &Value, ext: &str) -> Result { /// an export into an existing GeoPackage also says so, what went with a replaced table, and /// which views and triggers elsewhere name it. Layers read in place from a replaced table read /// it again. -fn report_table(s: &mut Session, path: &str, gpkg: &GpkgTable, table: Option, out: &mut Value) { +fn report_table(s: &mut Session, path: &str, gpkg: &GpkgTable, default: &str, table: Option, out: &mut Value) { let Some(table) = table else { return }; - // A new file's table is said only when it isn't the name asked for (a reserved name is - // prefixed); one added to or replaced in a file is always named below. - if gpkg.mode == GpkgMode::NewFile - && let Some(asked) = gpkg.name.as_deref().filter(|n| *n != table.table) - { - s.notify( - format!("{path}: wrote the table {} instead of '{asked}', a name GeoPackage reserves or leaves empty", table.table), - false, - ); + // A new file's table is said only when it isn't the name asked for, or by default the + // layer's (a reserved name is prefixed, control characters and edge spaces dropped); one + // added to or replaced in a file is always named below. + let asked = gpkg.name.as_deref().unwrap_or(default); + if gpkg.mode == GpkgMode::NewFile && asked != table.table { + let note = if asked.trim().is_empty() { + format!("{path}: wrote the table {}, as the layer has no name", table.table) + } else { + format!( + "{path}: wrote the table {} instead of '{asked}' (GeoPackage table names can't start with gpkg_, sqlite_ or rtree_, and lose control characters and edge spaces)", + table.table + ) + }; + s.notify(note, false); } if gpkg.mode != GpkgMode::NewFile { let (reread, failed) = @@ -305,9 +311,10 @@ fn write_layer(l: &rustgis_map::Layer, path: &str, asked: Option, gpkg: Gpk // (layers reading a replaced table) is at hand. let written_path = Some(path.to_string()); let path = path.to_string(); + let default = ds.name.clone(); let then: Option = table.map(|t| { Box::new(move |s: &mut Session, out: &mut Value| { - report_table(s, &path, &gpkg, Some(t), out); + report_table(s, &path, &gpkg, &default, Some(t), out); Ok(()) }) as super::exports::Then }); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index a0287f0a45..0ac3721b5a 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -13106,7 +13106,7 @@ fn a_service_layers_address_is_copied_without_its_key() { let copied = s.run("layer.copyPath", &json!({"layer": layer})).unwrap(); let text = copied["text"].as_str().unwrap(); assert!(text.starts_with("https://x.org/collections/a/items?") && !text.contains("SECRET"), "{text}"); - let said = |s: &Session| s.notices_since(mark).iter().filter(|n| n.text.contains("leaves out its keys")).count(); + let said = |s: &Session| s.notices_since(mark).iter().filter(|n| n.text.contains("leaves out part")).count(); assert_eq!(said(&s), 1, "the copied address says what it left out"); // An address with nothing secret in it is copied as it is, with no notice. let id = s.download_started(); @@ -15459,6 +15459,18 @@ fn a_new_geopackage_says_when_its_table_name_was_changed() { let out = s.run("share.exportLayer", &json!({"layer": "Cities", "path": path, "tableName": "gpkg_cities"})).unwrap(); assert_eq!(out["table"].as_str(), Some("layer_gpkg_cities"), "{out}"); assert_eq!(said(&s, mark), 1, "{:?}", s.notices_since(mark)); + let both = |s: &Session, mark: u64| { + s.notices_since(mark).iter().any(|n| n.text.contains("wrote the table layer_gpkg_cities instead of 'gpkg_cities'")) + }; + assert!(both(&s, mark), "{:?}", s.notices_since(mark)); + // The default name, the layer's, is said the same way when it is changed. + s.run("layer.rename", &json!({"layer": "Cities", "name": "gpkg_cities"})).unwrap(); + let mark = s.notice_mark(); + let path = dir.join("default.gpkg"); + let out = s.run("share.exportLayer", &json!({"layer": "gpkg_cities", "path": path})).unwrap(); + assert_eq!(out["table"].as_str(), Some("layer_gpkg_cities"), "{out}"); + assert!(both(&s, mark), "{:?}", s.notices_since(mark)); + s.run("layer.rename", &json!({"layer": "gpkg_cities", "name": "Cities"})).unwrap(); let mark = s.notice_mark(); let path = dir.join("plain.gpkg"); let out = s.run("share.exportLayer", &json!({"layer": "Cities", "path": path, "tableName": "towns"})).unwrap(); From 72a0f39d6b3a8ae39cb06dfe24c2ff81b22fc2a1 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 05:48:30 -0500 Subject: [PATCH 7/9] Address review feedback - The GeoPackage table notice shows control characters in the name asked for escaped, so a newline can't pass for another message. - An empty default name is said without calling it a layer's, as a standalone table takes the same path. --- crates/engine/src/cmd/share.rs | 5 ++++- crates/engine/src/tests.rs | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/share.rs b/crates/engine/src/cmd/share.rs index 40c6ff62f7..d2fcd3db9d 100644 --- a/crates/engine/src/cmd/share.rs +++ b/crates/engine/src/cmd/share.rs @@ -100,8 +100,11 @@ fn report_table(s: &mut Session, path: &str, gpkg: &GpkgTable, default: &str, ta let asked = gpkg.name.as_deref().unwrap_or(default); if gpkg.mode == GpkgMode::NewFile && asked != table.table { let note = if asked.trim().is_empty() { - format!("{path}: wrote the table {}, as the layer has no name", table.table) + format!("{path}: wrote the table {}, as there was no name to give it", table.table) } else { + // Escaped: a control character in the name would otherwise reach the terminal. + let asked: String = + asked.chars().map(|c| if c.is_control() { c.escape_default().to_string() } else { c.to_string() }).collect(); format!( "{path}: wrote the table {} instead of '{asked}' (GeoPackage table names can't start with gpkg_, sqlite_ or rtree_, and lose control characters and edge spaces)", table.table diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 0ac3721b5a..23ac7c7129 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -15471,6 +15471,12 @@ fn a_new_geopackage_says_when_its_table_name_was_changed() { assert_eq!(out["table"].as_str(), Some("layer_gpkg_cities"), "{out}"); assert!(both(&s, mark), "{:?}", s.notices_since(mark)); s.run("layer.rename", &json!({"layer": "gpkg_cities", "name": "Cities"})).unwrap(); + // A control character in the name asked for is dropped, and shown escaped in the notice. + let mark = s.notice_mark(); + let path = dir.join("control.gpkg"); + let out = s.run("share.exportLayer", &json!({"layer": "Cities", "path": path, "tableName": "road\nnetwork"})).unwrap(); + assert_eq!(out["table"].as_str(), Some("roadnetwork"), "{out}"); + assert!(s.notices_since(mark).iter().any(|n| n.text.contains("instead of 'road\\nnetwork'")), "{:?}", s.notices_since(mark)); let mark = s.notice_mark(); let path = dir.join("plain.gpkg"); let out = s.run("share.exportLayer", &json!({"layer": "Cities", "path": path, "tableName": "towns"})).unwrap(); From 8bd375aa6acc631271f25d2757611bf6cd3fef5a Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 06:09:27 -0500 Subject: [PATCH 8/9] Address review feedback - The terrain error for two same-named DEMs says to name the DEM or make it the active layer when trying again, since a retry with Terrain off otherwise takes whichever raster is active. --- crates/engine/src/cmd/view.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/view.rs b/crates/engine/src/cmd/view.rs index 80139e4a88..c3e796cb1b 100644 --- a/crates/engine/src/cmd/view.rs +++ b/crates/engine/src/cmd/view.rs @@ -270,7 +270,9 @@ fn terrain(s: &mut Session, p: &Value) -> CmdResult { if let TerrainSource::Layer(n) = &t.source && m.layers.iter().filter(|l| l.name.eq_ignore_ascii_case(n)).count() > 1 { - let e = format!("two layers are called '{n}': rename one, then try again (Terrain stays as it was)"); + let e = format!( + "two layers are called '{n}': rename one, then try again with the DEM named or made the active layer (Terrain stays as it was)" + ); // A terrain that was on stays as it was. if let Some(old) = old_terrain { m.view.terrain = Some(old); From 9d60244f7a066387c273a092b0949e119d11f674 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 06:29:56 -0500 Subject: [PATCH 9/9] Address review feedback - The same-named DEM error says to give the DEM a name of its own and name it when trying again: renaming another layer can leave a third of that name, and a retry with Terrain on keeps its old source. --- crates/engine/src/cmd/view.rs | 2 +- crates/engine/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/view.rs b/crates/engine/src/cmd/view.rs index c3e796cb1b..75aa418d58 100644 --- a/crates/engine/src/cmd/view.rs +++ b/crates/engine/src/cmd/view.rs @@ -271,7 +271,7 @@ fn terrain(s: &mut Session, p: &Value) -> CmdResult { && m.layers.iter().filter(|l| l.name.eq_ignore_ascii_case(n)).count() > 1 { let e = format!( - "two layers are called '{n}': rename one, then try again with the DEM named or made the active layer (Terrain stays as it was)" + "more than one layer is called '{n}': give the DEM a name of its own, then try again naming it (Terrain stays as it was)" ); // A terrain that was on stays as it was. if let Some(old) = old_terrain { diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 23ac7c7129..bbf9678f9b 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -5342,7 +5342,7 @@ fn terrain_is_set_from_a_dem_or_tiles() { s.active_layer = Some(second); s.run("layer.rename", &json!({"name": name})).unwrap(); let e = s.run("map.terrain", &json!({})).unwrap_err(); - assert!(e.contains("two layers are called"), "{e}"); + assert!(e.contains("more than one layer is called"), "{e}"); s.run("layer.rename", &json!({"name": "dem 2"})).unwrap(); s.active_layer = Some(id); s.run("map.terrain", &json!({})).unwrap();