From f67e49c829b8d63698ba66ce829baba179c1a964 Mon Sep 17 00:00:00 2001 From: mavrick Date: Fri, 27 Nov 2026 08:16:30 -0600 Subject: [PATCH 1/4] fix(engine): repair and the opening summary read what a note counts, not its words Repair Data Source refused an empty DuckDB replacement by matching the words of a note, and the summary of losses said on opening grouped notes by six English phrases and read providers and counts out of the text. Rewording or translating a note changed what they decided and added up. A note can now carry a tally: who found the loss (GDAL, DuckDB or RustGIS), what was counted and how many, or that the number isn't known. The GDAL and DuckDB conversions and the replacement check give one with their notes. Repair finds the left-out rows by their tally, and the summary groups by tally and code and says a total from the tally. A note without one is grouped only with the same note. Part of #2371. --- crates/data/src/loss.rs | 107 +++++++++++- crates/data/src/source/gdal.rs | 56 ++++-- crates/engine/src/cmd/exports.rs | 2 +- crates/engine/src/cmd/field.rs | 2 +- crates/engine/src/cmd/project.rs | 259 ++++++++++++++-------------- crates/engine/src/cmd/raster.rs | 4 +- crates/engine/src/cmd/repair.rs | 29 +++- crates/engine/src/cmd/stac_bands.rs | 3 +- crates/map/src/source.rs | 23 ++- 9 files changed, 323 insertions(+), 162 deletions(-) diff --git a/crates/data/src/loss.rs b/crates/data/src/loss.rs index d77a2a97a3..4fac3eede1 100644 --- a/crates/data/src/loss.rs +++ b/crates/data/src/loss.rs @@ -184,27 +184,40 @@ pub struct LossMessage { pub struct Note { pub text: String, pub loss: Option, + /// What the note counts, for code that groups or adds up notes: it reads this, never the + /// words, which may be reworded or translated. Boxed, so a note without one stays small. + pub tally: Option>, } impl Note { /// A note that reports a loss. pub fn loss(code: LossCode, text: impl Into) -> Self { - Self { text: text.into(), loss: Some(code) } + Self { text: text.into(), loss: Some(code), tally: None } } /// A note that reports no loss. pub fn plain(text: impl Into) -> Self { - Self { text: text.into(), loss: None } + Self { text: text.into(), loss: None, tally: None } + } + + /// A note that says `tally` in its own words ([`Tally::text`]), with the loss it reports, if any. + pub fn tallied(loss: Option, tally: Tally) -> Self { + Self { text: tally.text(), loss, tally: Some(Box::new(tally)) } + } + + /// The same note, counting `tally`. + pub fn with_tally(self, tally: Tally) -> Self { + Self { tally: Some(Box::new(tally)), ..self } } /// The same note, its text after `prefix: ` (the layer or file it is about). pub fn prefixed(self, prefix: &str) -> Self { - Self { text: format!("{prefix}: {}", self.text), loss: self.loss } + Self { text: format!("{prefix}: {}", self.text), ..self } } /// The same note, its text changed by `f` (a qualifier added). pub fn map_text(self, f: impl FnOnce(String) -> String) -> Self { - Self { text: f(self.text), loss: self.loss } + Self { text: f(self.text), ..self } } pub fn as_str(&self) -> &str { @@ -267,6 +280,92 @@ impl PartialEq for Note { } } +/// Who found what a [`Tally`] counts. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum Finder { + /// GDAL's conversion of a file RustGIS doesn't read itself. + Gdal, + /// DuckDB's conversion of a table. + Duckdb, + /// RustGIS's own check. + Rustgis, +} + +impl Finder { + fn prefix(self) -> &'static str { + match self { + Self::Gdal => "GDAL: ", + Self::Duckdb => "DuckDB: ", + Self::Rustgis => "", + } + } +} + +/// What a [`Tally`] counts. +#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum Counted { + /// Features or rows of another geometry type than the layer's, left out. + OtherGeometryType, + /// Rows without a geometry, left out. + RowsWithoutGeometry, + /// Features whose Z or M values were dropped. + ZmDropped, + /// Rows that couldn't be read while checking a replacement. + UnreadableRows, + /// A layer with no declared coordinate system, left unprojected: its count is 1. + NoDeclaredCrs, + /// Integer overflow warnings, whatever value overflowed. + IntegerOverflow, + /// Times a converting program gave this warning, in its own words. + Warning(String), +} + +/// What a note counts, how many and who found it: what notes from several layers are grouped and +/// added up by, so that rewording a note changes no decision or total. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct Tally { + pub by: Finder, + pub counted: Counted, + /// How many, or `None` where the number isn't known. + pub count: Option, +} + +impl Tally { + pub fn new(by: Finder, counted: Counted, count: Option) -> Self { + Self { by, counted, count } + } + + /// What this count says, naming no layer, so that it also says a total over several. + pub fn text(&self) -> String { + let n = self.count.map_or_else(|| "an unknown number of".to_string(), |n| n.to_string()); + let what = match (&self.counted, self.by) { + (Counted::OtherGeometryType, Finder::Duckdb) => match self.count { + Some(_) => format!("{n} rows of another geometry type were left out"), + None => format!("{n} rows of another geometry type may have been left out"), + }, + (Counted::OtherGeometryType, _) => match self.count { + Some(_) => format!("{n} features of another geometry type were left out"), + None => format!("{n} features of another geometry type may have been left out"), + }, + (Counted::RowsWithoutGeometry, _) => match self.count { + Some(_) => format!("{n} rows without a geometry were left out"), + None => format!("{n} rows without a geometry may have been left out"), + }, + (Counted::ZmDropped, Finder::Gdal) => match self.count { + Some(_) => format!("{n} source feature(s) had Z or M coordinates; conversion keeps only XY coordinates"), + None => format!("{n} source feature(s) may have had Z or M coordinates dropped; conversion keeps only XY coordinates"), + }, + (Counted::ZmDropped, _) => crate::zm_note(self.count), + (Counted::UnreadableRows, _) => format!("{n} rows could not be read while checking the replacement"), + // Said of each layer that has none, so with no count. + (Counted::NoDeclaredCrs, _) => "no declared coordinate system; the coordinates were left unprojected".to_string(), + (Counted::IntegerOverflow, _) => format!("{n} integer overflow warning(s)"), + (Counted::Warning(line), _) => format!("{line} ({n} occurrence(s))"), + }; + format!("{}{what}", self.by.prefix()) + } +} + /// What a reader, a source or a write says, in order: plain text pushed onto it stays plain, and /// a [`Note::loss`] keeps its code. #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/crates/data/src/source/gdal.rs b/crates/data/src/source/gdal.rs index b3f307e7b6..3fe5b155e2 100644 --- a/crates/data/src/source/gdal.rs +++ b/crates/data/src/source/gdal.rs @@ -479,10 +479,13 @@ fn convert_one_fresh_in(dir: &Path, src: &Path, layer: &str, family: Option {} Some(count) => { zm_dropped = true; - zm_note = Some(crate::loss::Note::loss( - crate::loss::LossCode::DroppedZm, - format!( - "GDAL: '{layer}' contains Z or M coordinates on {count} source feature(s); conversion keeps only XY coordinates" - ), - )); + zm_note = Some( + crate::loss::Note::loss( + crate::loss::LossCode::DroppedZm, + format!( + "GDAL: '{layer}' contains Z or M coordinates on {count} source feature(s); conversion keeps only XY coordinates" + ), + ) + .with_tally(crate::loss::Tally::new( + crate::loss::Finder::Gdal, + crate::loss::Counted::ZmDropped, + Some(count), + )), + ); } None => { // A layer that declares them may still hold only x and y: said without a code, as @@ -524,7 +534,8 @@ fn convert_one_fresh_in(dir: &Path, src: &Path, layer: &str, family: Option {} - Ok(other) => notes.push(crate::loss::Note::loss( - crate::loss::LossCode::DroppedFeature, - format!("GDAL: {other} features of another geometry type were left out"), + Ok(other) => notes.push(crate::loss::Note::tallied( + Some(crate::loss::LossCode::DroppedFeature), + crate::loss::Tally::new(crate::loss::Finder::Gdal, crate::loss::Counted::OtherGeometryType, Some(other)), + )), + Err(_) => notes.push(crate::loss::Note::tallied( + None, + crate::loss::Tally::new(crate::loss::Finder::Gdal, crate::loss::Counted::OtherGeometryType, None), )), - Err(_) => notes.push("GDAL: an unknown number of features of another geometry type may have been left out"), } } notes @@ -793,6 +806,15 @@ fn placement(fgb: &Path) -> Placement { } /// The notice for a layer converted to longitude/latitude because its system can't be read. +/// A warning GDAL gave `count` times while converting, in its words. Its integer overflows, +/// whatever the value, are counted as one kind, so several layers' are said once. +fn gdal_warning(line: String, count: u64) -> crate::loss::Note { + use crate::loss::{Counted, Finder, Note, Tally}; + let text = format!("GDAL: {line} ({count} occurrence(s))"); + let counted = if line.to_ascii_lowercase().contains("integer overflow") { Counted::IntegerOverflow } else { Counted::Warning(line) }; + Note::plain(text).with_tally(Tally::new(Finder::Gdal, counted, Some(count))) +} + pub fn in_lonlat_note(layer: &str) -> String { in_lonlat_notes(&[layer]) } diff --git a/crates/engine/src/cmd/exports.rs b/crates/engine/src/cmd/exports.rs index 8ddaa0b775..fcad71be6b 100644 --- a/crates/engine/src/cmd/exports.rs +++ b/crates/engine/src/cmd/exports.rs @@ -302,7 +302,7 @@ pub(crate) fn copy_notices_coded(copy: &mut Session, path: &str) -> Vec<(rustgis rustgis_data::loss::Note::plain(format!("{path}: {earlier} earlier notices from drawing it aren't shown")), )); } - said.extend(kept.into_iter().map(|n| (n.severity, rustgis_data::loss::Note { loss: n.loss(), text: n.text }))); + said.extend(kept.into_iter().map(|n| (n.severity, rustgis_data::loss::Note { loss: n.loss(), text: n.text, tally: None }))); said } diff --git a/crates/engine/src/cmd/field.rs b/crates/engine/src/cmd/field.rs index 4a29ba7bd7..52ac809cd6 100644 --- a/crates/engine/src/cmd/field.rs +++ b/crates/engine/src/cmd/field.rs @@ -654,7 +654,7 @@ pub(crate) fn export_work(s: &Session, p: &Value) -> Result Option<(&str, Option, &str)> { - note.split_once(": ").and_then(|(provider, body)| counted_body(provider, body)).or_else(|| counted_body("", note)) -} - -fn counted_body<'a>(provider: &'a str, body: &'a str) -> Option<(&'a str, Option, &'a str)> { - if let Some(tail) = body.strip_prefix("an unknown number of ") { - return Some((provider, None, tail)); - } - let (count, tail) = body.split_once(' ')?; - if count.is_empty() || !count.bytes().all(|b| b.is_ascii_digit()) { - return None; - } - Some((provider, Some(count.parse().ok()?), tail)) -} - -/// Whether a note states an amount: a leading count, "on N source feature(s)", or a GDAL -/// "(N occurrence(s))" suffix. A note with none needs no per-layer qualifier. -fn shows_count(note: &str) -> bool { - let digits_before = |marker: &str| { - note.split(marker) - .next() - .and_then(|head| head.rsplit([' ', '(']).next()) - .is_some_and(|n| !n.is_empty() && n.bytes().all(|b| b.is_ascii_digit())) - && note.contains(marker) - }; - note.split_whitespace().next().is_some_and(|w| w.bytes().all(|b| b.is_ascii_digit())) - || counted_conversion_loss(note).is_some() - || digits_before(" source feature") - || digits_before(" occurrence(s))") -} - +/// One kind of loss on opening, gathered over the layers that said it. struct ConversionLoss { layers: usize, first: String, - note: String, - total: Option, - unknown: bool, - /// The note whose wording the grouped notice uses: the first unknown one once any count is - /// unknown, so a definite "were left out" isn't claimed for layers that may have lost none. - wording: String, + /// The first layer's note, said as it is when no other layer says the same. + note: rustgis_data::loss::Note, + /// The notes' total, or `None` once any count is unknown; for notes without a tally, unused. + total: Option, } impl ConversionLoss { - fn new(first: &str, note: String) -> Self { - let total = counted_conversion_loss(¬e).and_then(|(_, count, _)| count); - let unknown = note.contains("an unknown number of"); - Self { layers: 1, first: first.into(), wording: note.clone(), note, total, unknown } + fn new(first: &str, note: rustgis_data::loss::Note) -> Self { + let total = note.tally.as_ref().and_then(|t| t.count); + Self { layers: 1, first: first.into(), note, total } } - fn add(&mut self, note: &str) { + fn add(&mut self, note: &rustgis_data::loss::Note) { self.layers += 1; - let amount = counted_conversion_loss(note).and_then(|(_, count, _)| count); - self.total = self.total.zip(amount).and_then(|(total, amount)| total.checked_add(amount)); - if note.contains("an unknown number of") && !self.unknown { - self.unknown = true; - self.wording = note.into(); - } + let amount = note.tally.as_ref().and_then(|t| t.count); + self.total = self.total.zip(amount).map(|(total, amount)| total.saturating_add(amount)); } - fn notice(self) -> String { - let Self { layers, first, note, total, unknown, wording } = self; + /// What is said: the first layer's note for one layer; for several, the tally's words with the + /// total, or, for notes that count nothing, the note they all said. + fn notice(self) -> rustgis_data::loss::Note { + let Self { layers, first, note, total } = self; if layers == 1 { - return format!("{first}: {note}"); + return note.prefixed(&first); } - let note = if let Some((provider, _, tail)) = counted_conversion_loss(if unknown { &wording } else { ¬e }) - && (total.is_some() || unknown) - { - let count = total.filter(|_| !unknown).map_or_else(|| "an unknown number of".into(), |n| n.to_string()); - if provider.is_empty() { format!("{count} {tail}") } else { format!("{provider}: {count} {tail}") } - } else if unknown { - format!("{note} (count shown is {first}'s; the total is unknown)") - } else if shows_count(¬e) { - format!("{note} (count shown is {first}'s)") - } else { - note - }; - format!("{layers} layers: {note}; first: {first}") + let tally = note.tally.map(|tally| Box::new(rustgis_data::loss::Tally { count: total, ..*tally })); + let text = tally.as_deref().map_or(note.text, rustgis_data::loss::Tally::text); + rustgis_data::loss::Note { text: format!("{layers} layers: {text}; first: {first}"), loss: note.loss, tally } } } -/// Says fresh opening losses once per kind, summing leading provider counts only when all are -/// known, and saved-conversion fallbacks once with the layer count and first failure. Ordinary -/// source notes are not opening conversion diagnostics. +/// Says fresh opening losses once per kind, adding up their counts only when all are known, and +/// saved-conversion fallbacks once with the layer count and first failure. Notes are grouped by +/// what they count ([`rustgis_data::loss::Tally`]) and their code, never by their words; notes +/// that count nothing are grouped only with the same note. Ordinary source notes are not opening +/// conversion diagnostics. pub(crate) fn say_conversion_fallbacks(s: &mut Session) { - use rustgis_data::loss::LossCode; let mut fallback: Option<(usize, String, String)> = None; - // By provider and kind, and by the loss code the notes carry, which the summary keeps. - let mut losses = std::collections::BTreeMap::<(String, String, Option<&'static str>), (ConversionLoss, Option)>::new(); + let mut said = Vec::new(); for l in s.project.maps.iter_mut().flat_map(|m| &mut m.layers) { let Some(source) = l.source.as_mut() else { continue }; if let Some(note) = source.take_conversion_fallback() { @@ -249,29 +202,9 @@ pub(crate) fn say_conversion_fallbacks(s: &mut Session) { None => fallback = Some((1, l.name.clone(), note)), } } - let mut seen = std::collections::BTreeSet::new(); - for note in source.take_conversion_notes() { - let code = note.loss; - let note = note.text; - // Source layer names and feature counts vary within a loss kind. Count affected - // layers once each and total leading feature/row counts across those layers. - let kind = [ - "Z or M coordinates", - "another geometry type", - "rows without a geometry", - "no declared coordinate system", - "rows could not be read while checking the replacement", - "Integer overflow", - ] - .into_iter() - .find(|kind| note.contains(*kind)) - // An unlisted GDAL warning, without its per-layer occurrence count. - .unwrap_or_else(|| note.rsplit_once(" (").filter(|(_, tail)| tail.ends_with("occurrence(s))")).map_or(¬e, |(base, _)| base)); - let provider = note.split_once(": ").map_or("", |(provider, _)| provider); - let key = (provider.to_owned(), kind.to_owned(), code.map(|c| c.spec().id)); - if seen.insert(key.clone()) { - losses.entry(key).and_modify(|(loss, _)| loss.add(¬e)).or_insert_with(|| (ConversionLoss::new(&l.name, note), code)); - } + let notes = source.take_conversion_notes(); + if !notes.is_empty() { + said.push((l.name.clone(), notes)); } } if let Some((count, name, note)) = fallback { @@ -282,9 +215,35 @@ pub(crate) fn say_conversion_fallbacks(s: &mut Session) { }; s.notify(text, false); } - for (loss, code) in losses.into_values() { - s.say(rustgis_data::loss::Note { text: loss.notice(), loss: code }); + for note in conversion_notices(said) { + s.say(note); + } +} + +/// The notices for each layer's opening notes: one per kind of loss, a layer counted once for +/// each. +fn conversion_notices(layers: Vec<(String, rustgis_data::loss::Notes)>) -> Vec { + use rustgis_data::loss::{Counted, Finder}; + type Key = (Option<(Finder, Counted)>, Option, Option<&'static str>); + let mut losses = std::collections::BTreeMap::::new(); + for (name, notes) in layers { + let mut seen = std::collections::BTreeSet::new(); + for note in notes { + let key: Key = match ¬e.tally { + Some(t) => (Some((t.by, t.counted.clone())), None, note.loss.map(|c| c.spec().id)), + None => (None, Some(note.text.clone()), note.loss.map(|c| c.spec().id)), + }; + if seen.insert(key.clone()) { + match losses.get_mut(&key) { + Some(loss) => loss.add(¬e), + None => { + losses.insert(key, ConversionLoss::new(&name, note)); + } + } + } + } } + losses.into_values().map(ConversionLoss::notice).collect() } /// Why a block with `extent` can't be drawn on the DEM `dem` (its name, its box and its footprint, @@ -1212,46 +1171,96 @@ fn save_as_inputs(input: &super::InputContext<'_>, p: &Value) -> Result) -> Note { + let code = count.map(|_| LossCode::DroppedFeature); + Note::tallied(code, Tally::new(Finder::Gdal, Counted::OtherGeometryType, count)) + } + + fn zm(layer: &str, count: u64) -> Note { + Note::loss(LossCode::DroppedZm, format!("GDAL: '{layer}' contains Z or M coordinates on {count} source feature(s)")) + .with_tally(Tally::new(Finder::Gdal, Counted::ZmDropped, Some(count))) + } + + fn texts(notes: &[Note]) -> Vec<&str> { + notes.iter().map(|n| n.text.as_str()).collect() + } #[test] - fn grouped_counts_sum_without_a_provider_and_uncounted_notes_take_no_qualifier() { - let mut loss = ConversionLoss::new("First", "3 rows could not be read while checking the replacement".into()); - loss.add("4 rows could not be read while checking the replacement"); - assert_eq!(loss.notice(), "2 layers: 7 rows could not be read while checking the replacement; first: First"); + fn grouped_counts_sum_and_a_single_layer_keeps_its_note() { + let unread = |n| Note::tallied(None, Tally::new(Finder::Rustgis, Counted::UnreadableRows, Some(n))); + let mut loss = ConversionLoss::new("First", unread(3)); + loss.add(&unread(4)); + assert_eq!(loss.notice().text, "2 layers: 7 rows could not be read while checking the replacement; first: First"); - let note = "GDAL: 'a' has no declared coordinate system; its coordinates were left unprojected"; - let mut loss = ConversionLoss::new("First", note.into()); - loss.add("GDAL: 'b' has no declared coordinate system; its coordinates were left unprojected"); - assert_eq!(loss.notice(), format!("2 layers: {note}; first: First")); + let mut loss = ConversionLoss::new("First", other(Some(3))); + loss.add(&other(Some(4))); + let notice = loss.notice(); + assert_eq!(notice.text, "2 layers: GDAL: 7 features of another geometry type were left out; first: First"); + assert_eq!(notice.loss, Some(LossCode::DroppedFeature)); + assert_eq!( + ConversionLoss::new("First", other(Some(3))).notice().text, + "First: GDAL: 3 features of another geometry type were left out" + ); - let note = "GDAL: 'a' declares Z or M coordinates on 3 source feature(s); conversion keeps only XY coordinates"; - let mut loss = ConversionLoss::new("First", note.into()); - loss.add("GDAL: 'b' declares Z or M coordinates on 5 source feature(s); conversion keeps only XY coordinates"); - assert_eq!(loss.notice(), format!("2 layers: {note} (count shown is First's); first: First")); + let mut loss = ConversionLoss::new("First", zm("a", 3)); + loss.add(&zm("b", 5)); + assert_eq!( + loss.notice().text, + "2 layers: GDAL: 8 source feature(s) had Z or M coordinates; conversion keeps only XY coordinates; first: First" + ); } #[test] fn grouped_conversion_losses_keep_unknown_totals_in_either_order() { - let definite = "GDAL: 3 features of another geometry type were left out"; - let unknown = "GDAL: an unknown number of features of another geometry type may have been left out"; - for notes in [[definite, unknown], [unknown, definite]] { - let mut loss = ConversionLoss::new("First", notes[0].into()); - loss.add(notes[1]); - let notice = loss.notice(); - assert!(notice.starts_with("2 layers: GDAL: an unknown number of features of another geometry type"), "{notice}"); - assert!(!notice.contains("GDAL: 3 "), "{notice}"); - assert!(notice.contains("may have been left out") && !notice.contains("were left out"), "{notice}"); + for notes in [[other(Some(3)), other(None)], [other(None), other(Some(3))]] { + let [a, b] = notes; + let mut loss = ConversionLoss::new("First", a); + loss.add(&b); + assert_eq!( + loss.notice().text, + "2 layers: GDAL: an unknown number of features of another geometry type may have been left out; first: First" + ); } } #[test] - fn grouped_known_conversion_counts_sum_and_single_layers_stay_unchanged() { - let note = "GDAL: 3 features of another geometry type were left out"; - let mut loss = ConversionLoss::new("First", note.into()); - loss.add("GDAL: 4 features of another geometry type were left out"); - assert_eq!(loss.notice(), "2 layers: GDAL: 7 features of another geometry type were left out; first: First"); + fn notes_that_count_nothing_group_only_with_the_same_note() { + let notices = conversion_notices(vec![ + ("A".into(), Notes::from(vec!["the same note", "only A's"])), + ("B".into(), Notes::from(vec!["the same note"])), + ]); + assert_eq!(texts(¬ices), ["2 layers: the same note; first: A", "A: only A's"]); + } - let single = ConversionLoss::new("First", note.into()); - assert_eq!(single.notice(), format!("First: {note}")); + /// The acceptance test of #2371: rewording or translating a note changes how many notices are + /// said, their codes and their totals not at all. + #[test] + fn rewording_the_notes_changes_no_grouping_code_or_total() { + let layers = + |reword: bool| { + let reworded = |n: Note| if reword { n.map_text(|t| format!("reworded: {}", t.len())) } else { n }; + let crs = + |layer: &str| { + Note::loss(LossCode::AssumedCrs, format!("GDAL: '{layer}' has no declared coordinate system")) + .with_tally(Tally::new(Finder::Gdal, Counted::NoDeclaredCrs, Some(1))) + }; + let duckdb = |n| Note::tallied(None, Tally::new(Finder::Duckdb, Counted::OtherGeometryType, Some(n))); + ["A", "B", "C"] + .into_iter() + .zip(1u64..) + .map(|(name, n)| { + let notes: Notes = [other(Some(n)), zm(name, n * 10), crs(name), duckdb(n)].into_iter().map(reworded).collect(); + (name.to_string(), notes) + }) + .collect::>() + }; + let said = conversion_notices(layers(false)); + let reworded = conversion_notices(layers(true)); + assert_eq!(said.len(), 4, "{:?}", texts(&said)); + assert_eq!(said, reworded, "grouped notices are said from their tallies"); + assert!(texts(&said).contains(&"3 layers: GDAL: 6 features of another geometry type were left out; first: A")); + assert!(texts(&said).contains(&"3 layers: DuckDB: 6 rows of another geometry type were left out; first: A")); } } diff --git a/crates/engine/src/cmd/raster.rs b/crates/engine/src/cmd/raster.rs index 26d92e8c19..de03019725 100644 --- a/crates/engine/src/cmd/raster.rs +++ b/crates/engine/src/cmd/raster.rs @@ -562,7 +562,7 @@ pub(crate) fn loss_lines(losses: Vec<(String, rustgis_data::loss::Note)>) -> Vec } let mut lines = Vec::new(); for (code, parts, ranges, named) in kinds { - let line = |text: String| rustgis_data::loss::Note { loss: code, text }; + let line = |text: String| rustgis_data::loss::Note { loss: code, text, tally: None }; let differ = ranges.iter().any(|(lo, hi)| lo != hi); // A few rasters whose numbers differ: each its own, so none is lost in a range. if differ && named.len() <= 3 { @@ -585,7 +585,7 @@ pub(crate) fn loss_lines(losses: Vec<(String, rustgis_data::loss::Note)>) -> Vec } }; let each = if differ { ", each" } else { "" }; - lines.push(rustgis_data::loss::Note { loss: code, text: format!("{who}{each}: {line}") }); + lines.push(rustgis_data::loss::Note { loss: code, text: format!("{who}{each}: {line}"), tally: None }); } lines } diff --git a/crates/engine/src/cmd/repair.rs b/crates/engine/src/cmd/repair.rs index cd6d8c998e..6dfe494e97 100644 --- a/crates/engine/src/cmd/repair.rs +++ b/crates/engine/src/cmd/repair.rs @@ -269,8 +269,7 @@ fn replace_linked( && let Some(origin) = &new.duckdb && let Some(info) = new.info() && info.count == Some(0) - && let Some(note) = - info.notes.iter().find(|note| note.starts_with("DuckDB: ") && note.ends_with(" rows of another geometry type were left out")) + && let Some(note) = other_family_only(&info.notes) { return Err(format!( "{path}: the replacement table contains no {}; {}. The layer was not changed", @@ -281,6 +280,16 @@ fn replace_linked( install(s, prepared) } +/// The note saying DuckDB left out rows of another geometry type, found by what it counts, not +/// its words: for a replacement that holds none of the layer's own, it is why Repair refuses. +#[cfg(not(target_arch = "wasm32"))] +fn other_family_only(notes: &rustgis_data::loss::Notes) -> Option<&rustgis_data::loss::Note> { + use rustgis_data::loss::{Counted, Finder}; + notes.iter().find(|note| { + note.tally.as_ref().is_some_and(|t| t.by == Finder::Duckdb && t.counted == Counted::OtherGeometryType && t.count != Some(0)) + }) +} + #[cfg(not(target_arch = "wasm32"))] fn install(s: &mut Session, prepared: Prepared) -> Result<(), String> { let Prepared { input, candidate } = prepared; @@ -683,3 +692,19 @@ fn reload_tiles(s: &mut Session, p: &Value) -> CmdResult { Ok(json!({"index": i, "path": path})) } } + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tests { + use rustgis_data::loss::{Counted, Finder, Note, Notes, Tally}; + + #[test] + fn a_replacement_of_another_geometry_type_is_found_by_its_tally_not_its_words() { + let left_out = |n| Note::tallied(None, Tally::new(Finder::Duckdb, Counted::OtherGeometryType, Some(n))); + let notes: Notes = [Note::plain("a plain note"), left_out(2).map_text(|_| "reworded".into())].into_iter().collect(); + assert_eq!(super::other_family_only(¬es).map(|n| n.text.as_str()), Some("reworded")); + let words_only: Notes = ["DuckDB: 2 rows of another geometry type were left out"].into_iter().collect(); + assert!(super::other_family_only(&words_only).is_none(), "the words alone decide nothing"); + let gdal: Notes = [Note::tallied(None, Tally::new(Finder::Gdal, Counted::OtherGeometryType, Some(2)))].into_iter().collect(); + assert!(super::other_family_only(&gdal).is_none()); + } +} diff --git a/crates/engine/src/cmd/stac_bands.rs b/crates/engine/src/cmd/stac_bands.rs index 7ff7d6f0a6..7cd5c1421f 100644 --- a/crates/engine/src/cmd/stac_bands.rs +++ b/crates/engine/src/cmd/stac_bands.rs @@ -460,6 +460,7 @@ mod desktop { .map(|((_, loss), texts, bands, files)| Note { text: format!("{} ({files} file{}): {}", bands.join(", "), if files == 1 { "" } else { "s" }, texts.join("; ")), loss, + tally: None, }) .collect() } @@ -1206,7 +1207,7 @@ mod tests { assert_eq!(merge_notes(&[(w(&["red"]), vec![edges("north"), pieces])]).len(), 2); assert!(merge_notes(&[(w(&["red"]), Vec::new()), (w(&["green"]), Vec::new())]).is_empty()); // The same words as a coded and as a plain note are two notices, each keeping its code. - let rounded = |code: Option| Note { text: "values rounded to 32-bit floats".into(), loss: code }; + let rounded = |code: Option| Note { text: "values rounded to 32-bit floats".into(), loss: code, tally: None }; let split = merge_notes(&[ (w(&["red"]), vec![rounded(Some(LossCode::ChangedRounded))]), (w(&["green"]), vec![rounded(None)]), diff --git a/crates/map/src/source.rs b/crates/map/src/source.rs index 061c8367cc..cada6bf33c 100644 --- a/crates/map/src/source.rs +++ b/crates/map/src/source.rs @@ -1071,6 +1071,7 @@ impl SourceLayer { } let mut new = SourceLayer { shapefile_crs: self.shapefile_crs, limit: self.limit, byte_budget: self.byte_budget, ..Default::default() }; + use rustgis_data::loss::{Counted, Finder, LossCode, Note, Tally}; let mut conversion_notes = rustgis_data::loss::Notes::new(); let declared_empty; let conversion_zm_dropped; @@ -1118,20 +1119,24 @@ impl SourceLayer { let out = fresh.output; if out.skipped > 0 { // 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), + conversion_notes.push(Note::tallied( + Some(LossCode::DroppedFeature), + Tally::new(Finder::Duckdb, Counted::RowsWithoutGeometry, Some(out.skipped)), )); } if out.other_family > 0 { - conversion_notes.push(format!("DuckDB: {} rows of another geometry type were left out", out.other_family)); + conversion_notes + .push(Note::tallied(None, Tally::new(Finder::Duckdb, Counted::OtherGeometryType, Some(out.other_family)))); } let part = out.parts.first().ok_or_else(|| format!("{path}: the table returns no {}", d.family.label()))?; if part.zm_dropped > 0 { - conversion_notes.push(rustgis_data::loss::Note::loss( - rustgis_data::loss::LossCode::DroppedZm, - rustgis_data::zm_note(Some(part.zm_dropped)), - )); + conversion_notes.push( + Note::loss(LossCode::DroppedZm, rustgis_data::zm_note(Some(part.zm_dropped))).with_tally(Tally::new( + Finder::Duckdb, + Counted::ZmDropped, + Some(part.zm_dropped), + )), + ); } declared_empty = part.count == 0; new.path = Some(part.path.display().to_string()); @@ -1189,7 +1194,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)); + conversion_notes.push(Note::tallied(None, Tally::new(Finder::Rustgis, Counted::UnreadableRows, probe.skipped.try_into().ok()))); } if let Some(info) = new.info() { let mut info = info.clone(); From 08e99277769041da36c3173911d25d3480e41c50 Mon Sep 17 00:00:00 2001 From: mavrick Date: Fri, 27 Nov 2026 08:44:55 -0600 Subject: [PATCH 2/4] fix(engine): expect a total over layers, and build the browser without an unused import --- crates/engine/src/cmd/project.rs | 2 +- .../tests/integration/portable_projects/reload.rs | 3 ++- crates/map/src/source.rs | 11 ++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/cmd/project.rs b/crates/engine/src/cmd/project.rs index 7a070ab3cb..3b63d83bfd 100644 --- a/crates/engine/src/cmd/project.rs +++ b/crates/engine/src/cmd/project.rs @@ -1231,7 +1231,7 @@ mod conversion_loss_tests { ("A".into(), Notes::from(vec!["the same note", "only A's"])), ("B".into(), Notes::from(vec!["the same note"])), ]); - assert_eq!(texts(¬ices), ["2 layers: the same note; first: A", "A: only A's"]); + assert_eq!(texts(¬ices), ["A: only A's", "2 layers: the same note; first: A"]); } /// The acceptance test of #2371: rewording or translating a note changes how many notices are diff --git a/crates/engine/tests/integration/portable_projects/reload.rs b/crates/engine/tests/integration/portable_projects/reload.rs index 565a7153a5..0fac94d6cc 100644 --- a/crates/engine/tests/integration/portable_projects/reload.rs +++ b/crates/engine/tests/integration/portable_projects/reload.rs @@ -1439,7 +1439,8 @@ fn project_open_reports_fresh_conversion_losses_once_per_kind_but_not_clean_conv assert!(losses[0].text.starts_with("2 layers: "), "{}", losses[0].text); assert!(losses[0].text.ends_with(&format!("first: {first}")), "{}", losses[0].text); } - assert!(losses[0].text.contains("1 source feature(s)"), "{}", losses[0].text); + // One feature each: several layers' notice gives their total. + assert!(losses[0].text.contains(&format!("{layer_count} source feature(s)")), "{}", losses[0].text); assert!(!losses[0].error); } else { assert!(losses.is_empty(), "{notices:?}"); diff --git a/crates/map/src/source.rs b/crates/map/src/source.rs index cada6bf33c..3892563546 100644 --- a/crates/map/src/source.rs +++ b/crates/map/src/source.rs @@ -1071,7 +1071,7 @@ impl SourceLayer { } let mut new = SourceLayer { shapefile_crs: self.shapefile_crs, limit: self.limit, byte_budget: self.byte_budget, ..Default::default() }; - use rustgis_data::loss::{Counted, Finder, LossCode, Note, Tally}; + use rustgis_data::loss::{Counted, Finder, Note, Tally}; let mut conversion_notes = rustgis_data::loss::Notes::new(); let declared_empty; let conversion_zm_dropped; @@ -1120,7 +1120,7 @@ impl SourceLayer { if out.skipped > 0 { // A row is a feature: one without geometry isn't added, and its values go with it. conversion_notes.push(Note::tallied( - Some(LossCode::DroppedFeature), + Some(rustgis_data::loss::LossCode::DroppedFeature), Tally::new(Finder::Duckdb, Counted::RowsWithoutGeometry, Some(out.skipped)), )); } @@ -1131,11 +1131,8 @@ impl SourceLayer { let part = out.parts.first().ok_or_else(|| format!("{path}: the table returns no {}", d.family.label()))?; if part.zm_dropped > 0 { conversion_notes.push( - Note::loss(LossCode::DroppedZm, rustgis_data::zm_note(Some(part.zm_dropped))).with_tally(Tally::new( - Finder::Duckdb, - Counted::ZmDropped, - Some(part.zm_dropped), - )), + Note::loss(rustgis_data::loss::LossCode::DroppedZm, rustgis_data::zm_note(Some(part.zm_dropped))) + .with_tally(Tally::new(Finder::Duckdb, Counted::ZmDropped, Some(part.zm_dropped))), ); } declared_empty = part.count == 0; From eec79bb190e5c76b250e18c5334436e8b3dadc7e Mon Sep 17 00:00:00 2001 From: mavrick Date: Fri, 27 Nov 2026 09:16:06 -0600 Subject: [PATCH 3/4] fix(engine): an overflowing total is unknown, Repair reads a definite count, and a doc comment is back on its function --- crates/data/src/source/gdal.rs | 2 +- crates/engine/src/cmd/project.rs | 5 +++-- crates/engine/src/cmd/repair.rs | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/data/src/source/gdal.rs b/crates/data/src/source/gdal.rs index 3fe5b155e2..f779a53d01 100644 --- a/crates/data/src/source/gdal.rs +++ b/crates/data/src/source/gdal.rs @@ -805,7 +805,6 @@ fn placement(fgb: &Path) -> Placement { }) } -/// The notice for a layer converted to longitude/latitude because its system can't be read. /// A warning GDAL gave `count` times while converting, in its words. Its integer overflows, /// whatever the value, are counted as one kind, so several layers' are said once. fn gdal_warning(line: String, count: u64) -> crate::loss::Note { @@ -815,6 +814,7 @@ fn gdal_warning(line: String, count: u64) -> crate::loss::Note { Note::plain(text).with_tally(Tally::new(Finder::Gdal, counted, Some(count))) } +/// The notice for a layer converted to longitude/latitude because its system can't be read. pub fn in_lonlat_note(layer: &str) -> String { in_lonlat_notes(&[layer]) } diff --git a/crates/engine/src/cmd/project.rs b/crates/engine/src/cmd/project.rs index 3b63d83bfd..4767fcad71 100644 --- a/crates/engine/src/cmd/project.rs +++ b/crates/engine/src/cmd/project.rs @@ -157,7 +157,8 @@ struct ConversionLoss { first: String, /// The first layer's note, said as it is when no other layer says the same. note: rustgis_data::loss::Note, - /// The notes' total, or `None` once any count is unknown; for notes without a tally, unused. + /// The notes' total, or `None` once any count is unknown or the total too large to hold; for + /// notes without a tally, unused. total: Option, } @@ -170,7 +171,7 @@ impl ConversionLoss { fn add(&mut self, note: &rustgis_data::loss::Note) { self.layers += 1; let amount = note.tally.as_ref().and_then(|t| t.count); - self.total = self.total.zip(amount).map(|(total, amount)| total.saturating_add(amount)); + self.total = self.total.zip(amount).and_then(|(total, amount)| total.checked_add(amount)); } /// What is said: the first layer's note for one layer; for several, the tally's words with the diff --git a/crates/engine/src/cmd/repair.rs b/crates/engine/src/cmd/repair.rs index 6dfe494e97..64d80bfb00 100644 --- a/crates/engine/src/cmd/repair.rs +++ b/crates/engine/src/cmd/repair.rs @@ -286,7 +286,10 @@ fn replace_linked( fn other_family_only(notes: &rustgis_data::loss::Notes) -> Option<&rustgis_data::loss::Note> { use rustgis_data::loss::{Counted, Finder}; notes.iter().find(|note| { - note.tally.as_ref().is_some_and(|t| t.by == Finder::Duckdb && t.counted == Counted::OtherGeometryType && t.count != Some(0)) + // A definite count: one that is unknown says only that rows may have been left out. + note.tally + .as_ref() + .is_some_and(|t| t.by == Finder::Duckdb && t.counted == Counted::OtherGeometryType && t.count.is_some_and(|n| n > 0)) }) } From 05ebd18fe0ee4522bca453a88017d505ede98570 Mon Sep 17 00:00:00 2001 From: mavrick Date: Fri, 27 Nov 2026 09:46:32 -0600 Subject: [PATCH 4/4] fix(engine): one notice for a kind of loss whether its counts are known, and a layer's notes of a kind added up first --- crates/engine/src/cmd/project.rs | 108 +++++++++++++++++++++---------- crates/map/src/source.rs | 2 +- 2 files changed, 76 insertions(+), 34 deletions(-) diff --git a/crates/engine/src/cmd/project.rs b/crates/engine/src/cmd/project.rs index 4767fcad71..9992f6c347 100644 --- a/crates/engine/src/cmd/project.rs +++ b/crates/engine/src/cmd/project.rs @@ -155,35 +155,43 @@ pub(crate) fn reset_to(s: &mut Session, p: Project) { struct ConversionLoss { layers: usize, first: String, - /// The first layer's note, said as it is when no other layer says the same. + /// The first layer's note, said as it is when no other note joins it. note: rustgis_data::loss::Note, /// The notes' total, or `None` once any count is unknown or the total too large to hold; for /// notes without a tally, unused. total: Option, + /// Whether the first layer gave several notes of this kind (GDAL's integer overflows, one + /// per value), so its note alone doesn't say its count. + merged: bool, + /// The code the group says: any of its notes' (a definite count is coded where an unknown + /// one of the same kind isn't, and the group still holds that loss). + loss: Option, } impl ConversionLoss { - fn new(first: &str, note: rustgis_data::loss::Note) -> Self { - let total = note.tally.as_ref().and_then(|t| t.count); - Self { layers: 1, first: first.into(), note, total } + fn new(first: &str, note: rustgis_data::loss::Note, total: Option, merged: bool) -> Self { + let loss = note.loss; + Self { layers: 1, first: first.into(), note, total, merged, loss } } - fn add(&mut self, note: &rustgis_data::loss::Note) { + fn add(&mut self, amount: Option, loss: Option) { self.layers += 1; - let amount = note.tally.as_ref().and_then(|t| t.count); + self.loss = self.loss.or(loss); self.total = self.total.zip(amount).and_then(|(total, amount)| total.checked_add(amount)); } - /// What is said: the first layer's note for one layer; for several, the tally's words with the - /// total, or, for notes that count nothing, the note they all said. + /// What is said: the first layer's note for one layer; for several, or for one whose notes of + /// the kind were joined, the tally's words with the total, or, for notes that count nothing, + /// the note they all said. fn notice(self) -> rustgis_data::loss::Note { - let Self { layers, first, note, total } = self; - if layers == 1 { + let Self { layers, first, note, total, merged, loss } = self; + if layers == 1 && !merged { return note.prefixed(&first); } let tally = note.tally.map(|tally| Box::new(rustgis_data::loss::Tally { count: total, ..*tally })); let text = tally.as_deref().map_or(note.text, rustgis_data::loss::Tally::text); - rustgis_data::loss::Note { text: format!("{layers} layers: {text}; first: {first}"), loss: note.loss, tally } + let text = if layers == 1 { format!("{first}: {text}") } else { format!("{layers} layers: {text}; first: {first}") }; + rustgis_data::loss::Note { text, loss, tally } } } @@ -228,18 +236,34 @@ fn conversion_notices(layers: Vec<(String, rustgis_data::loss::Notes)>) -> Vec, Option, Option<&'static str>); let mut losses = std::collections::BTreeMap::::new(); for (name, notes) in layers { - let mut seen = std::collections::BTreeSet::new(); + // A layer's notes of one kind are added up first, so the layer joins its kind once. + let mut mine = std::collections::BTreeMap::, bool)>::new(); for note in notes { + // A tallied note by what it counts alone: a known count and an unknown one of the + // same kind are one loss, its total unknown. let key: Key = match ¬e.tally { - Some(t) => (Some((t.by, t.counted.clone())), None, note.loss.map(|c| c.spec().id)), + Some(t) => (Some((t.by, t.counted.clone())), None, None), None => (None, Some(note.text.clone()), note.loss.map(|c| c.spec().id)), }; - if seen.insert(key.clone()) { - match losses.get_mut(&key) { - Some(loss) => loss.add(¬e), - None => { - losses.insert(key, ConversionLoss::new(&name, note)); - } + let amount = note.tally.as_ref().and_then(|t| t.count); + match mine.get_mut(&key) { + // The same words, said twice, are one note. + Some(_) if key.1.is_some() => {} + Some((first, total, merged)) => { + *total = total.zip(amount).and_then(|(total, amount)| total.checked_add(amount)); + *merged = true; + first.loss = first.loss.or(note.loss); + } + None => { + mine.insert(key, (note, amount, false)); + } + } + } + for (key, (note, amount, merged)) in mine { + match losses.get_mut(&key) { + Some(loss) => loss.add(amount, note.loss), + None => { + losses.insert(key, ConversionLoss::new(&name, note, amount, merged)); } } } @@ -1191,22 +1215,22 @@ mod conversion_loss_tests { #[test] fn grouped_counts_sum_and_a_single_layer_keeps_its_note() { let unread = |n| Note::tallied(None, Tally::new(Finder::Rustgis, Counted::UnreadableRows, Some(n))); - let mut loss = ConversionLoss::new("First", unread(3)); - loss.add(&unread(4)); + let mut loss = ConversionLoss::new("First", unread(3), Some(3), false); + loss.add(Some(4), None); assert_eq!(loss.notice().text, "2 layers: 7 rows could not be read while checking the replacement; first: First"); - let mut loss = ConversionLoss::new("First", other(Some(3))); - loss.add(&other(Some(4))); + let mut loss = ConversionLoss::new("First", other(Some(3)), Some(3), false); + loss.add(Some(4), Some(LossCode::DroppedFeature)); let notice = loss.notice(); assert_eq!(notice.text, "2 layers: GDAL: 7 features of another geometry type were left out; first: First"); assert_eq!(notice.loss, Some(LossCode::DroppedFeature)); assert_eq!( - ConversionLoss::new("First", other(Some(3))).notice().text, + ConversionLoss::new("First", other(Some(3)), Some(3), false).notice().text, "First: GDAL: 3 features of another geometry type were left out" ); - let mut loss = ConversionLoss::new("First", zm("a", 3)); - loss.add(&zm("b", 5)); + let mut loss = ConversionLoss::new("First", zm("a", 3), Some(3), false); + loss.add(Some(5), Some(LossCode::DroppedZm)); assert_eq!( loss.notice().text, "2 layers: GDAL: 8 source feature(s) had Z or M coordinates; conversion keeps only XY coordinates; first: First" @@ -1214,15 +1238,18 @@ mod conversion_loss_tests { } #[test] - fn grouped_conversion_losses_keep_unknown_totals_in_either_order() { - for notes in [[other(Some(3)), other(None)], [other(None), other(Some(3))]] { - let [a, b] = notes; - let mut loss = ConversionLoss::new("First", a); - loss.add(&b); + fn a_known_and_an_unknown_count_of_one_kind_are_one_notice_in_either_order() { + for counts in [[Some(3), None], [None, Some(3)]] { + let notices = conversion_notices(vec![ + ("First".into(), Notes::from(vec![other(counts[0])])), + ("Second".into(), Notes::from(vec![other(counts[1])])), + ]); assert_eq!( - loss.notice().text, - "2 layers: GDAL: an unknown number of features of another geometry type may have been left out; first: First" + texts(¬ices), + ["2 layers: GDAL: an unknown number of features of another geometry type may have been left out; first: First"] ); + // The known count's loss is still in the group, so it keeps its code. + assert_eq!(notices[0].loss, Some(LossCode::DroppedFeature)); } } @@ -1235,6 +1262,21 @@ mod conversion_loss_tests { assert_eq!(texts(¬ices), ["A: only A's", "2 layers: the same note; first: A"]); } + #[test] + fn a_layers_notes_of_one_kind_add_up_before_it_joins_the_others() { + let overflow = |line: &str, n| { + Note::plain(format!("GDAL: {line} ({n} occurrence(s))")).with_tally(Tally::new(Finder::Gdal, Counted::IntegerOverflow, Some(n))) + }; + let a = || Notes::from(vec![overflow("Integer overflow on 3000000000", 2), overflow("Integer overflow on 4000000000", 3)]); + assert_eq!(texts(&conversion_notices(vec![("A".into(), a())])), ["A: GDAL: 5 integer overflow warning(s)"]); + let notices = + conversion_notices(vec![("A".into(), a()), ("B".into(), Notes::from(vec![overflow("Integer overflow on 5000000000", 4)]))]); + assert_eq!(texts(¬ices), ["2 layers: GDAL: 9 integer overflow warning(s); first: A"]); + // One line alone is said in GDAL's words. + let one = conversion_notices(vec![("B".into(), Notes::from(vec![overflow("Integer overflow on 5000000000", 4)]))]); + assert_eq!(texts(&one), ["B: GDAL: Integer overflow on 5000000000 (4 occurrence(s))"]); + } + /// The acceptance test of #2371: rewording or translating a note changes how many notices are /// said, their codes and their totals not at all. #[test] diff --git a/crates/map/src/source.rs b/crates/map/src/source.rs index 3892563546..e7616dac87 100644 --- a/crates/map/src/source.rs +++ b/crates/map/src/source.rs @@ -1066,12 +1066,12 @@ impl SourceLayer { /// Opens a replacement with fresh handles, windows, caches and selection. pub fn relinked(&self, path: &str, table: Option<&str>) -> Result { + use rustgis_data::loss::{Counted, Finder, Note, Tally}; if self.embedded.is_some() || self.postgis.is_some() || self.mysql.is_some() || self.sqlserver.is_some() { return Err("the layer reads a database or data kept in the project: there's no file to repair".into()); } let mut new = SourceLayer { shapefile_crs: self.shapefile_crs, limit: self.limit, byte_budget: self.byte_budget, ..Default::default() }; - use rustgis_data::loss::{Counted, Finder, Note, Tally}; let mut conversion_notes = rustgis_data::loss::Notes::new(); let declared_empty; let conversion_zm_dropped;