From ef4352e3d3ab4026b6ed69d6ea56702600c20214 Mon Sep 17 00:00:00 2001 From: mavrick Date: Fri, 27 Nov 2026 09:34:27 -0600 Subject: [PATCH 1/2] feat(docs): an entry in the guide for each loss code, linked from the notices that give it A new guide page, Data loss codes, has an entry for each code, anchored by its id: what happened, where it is said and what to do. It replaces the command line guide's table, and a test keeps it in step with the codes. The Messages pane shows a notice's code with a link to its entry, and Copy diagnostics gives both. A strict run gives each code's address, Python's DataLossWarning has it as `url`, and the Assistant can read the page. Part of #2371. --- apps/rustgis-cli/src/main.rs | 8 +- apps/rustgis-cli/tests/integration/strict.rs | 1 + .../rustgis-python/python/rustgis/__init__.py | 8 +- apps/rustgis-python/tests/test_session.py | 2 + crates/assistant/src/docs.rs | 1 + crates/data/src/diagnostics.rs | 27 ++- crates/data/src/loss.rs | 33 ++- crates/engine/src/lib.rs | 2 +- crates/ui-egui/src/diagnosticlog.rs | 16 +- docs/cli.md | 27 +-- docs/mcp.md | 2 +- docs/python.md | 4 +- docs/user-guide/index.md | 1 + docs/user-guide/loss-codes.md | 215 ++++++++++++++++++ zensical.toml | 1 + 15 files changed, 301 insertions(+), 47 deletions(-) create mode 100644 docs/user-guide/loss-codes.md diff --git a/apps/rustgis-cli/src/main.rs b/apps/rustgis-cli/src/main.rs index 8587a9e391..81268dc88a 100644 --- a/apps/rustgis-cli/src/main.rs +++ b/apps/rustgis-cli/src/main.rs @@ -144,7 +144,11 @@ impl Strict { }; if LossKind::from_id(v).is_none() && LossCode::from_id(v).is_none() { let kinds: Vec<&str> = LossKind::ALL.iter().map(|k| k.id()).collect(); - return Err(format!("--allow {v}: not a loss kind ({}) or code (listed in the command line guide)", kinds.join(", "))); + return Err(format!( + "--allow {v}: not a loss kind ({}) or code (listed at {})", + kinds.join(", "), + rustgis_engine::data::loss::GUIDE + )); } allow.push(v.to_string()); } @@ -184,7 +188,7 @@ impl Strict { let spec = code.spec(); // A counted notice says how many it lost in its text; this counts the notices. let notices = if n == 1 { "1 notice".to_string() } else { format!("{n} notices") }; - said.push_str(&format!("\n {} ({notices}): {}", spec.id, spec.action)); + said.push_str(&format!("\n {} ({notices}): {}\n {}", spec.id, spec.action, code.doc_url())); } Err(said) } diff --git a/apps/rustgis-cli/tests/integration/strict.rs b/apps/rustgis-cli/tests/integration/strict.rs index a19e85985e..66a624e3a6 100644 --- a/apps/rustgis-cli/tests/integration/strict.rs +++ b/apps/rustgis-cli/tests/integration/strict.rs @@ -47,6 +47,7 @@ fn a_strict_run_stops_at_a_loss_it_does_not_allow() { let (code, err, printed, wrote) = run(lossy, &["--strict"]); assert_eq!((code, printed, wrote), (Some(3), false, false), "{err}"); assert!(err.contains("stopped after layer.addData") && err.contains("dropped.ring (1 notice): Correct the unreadable"), "{err}"); + assert!(err.contains("https://rustgis.app/user-guide/loss-codes/#dropped.ring"), "the code's entry in the guide: {err}"); // Allowed by its code or its kind, it runs to the end; another kind doesn't allow it. for allow in [&["--allow", "dropped.ring"][..], &["--allow", "dropped"], &["--allow=dropped.ring"]] { let (code, err, _, wrote) = run(lossy, &[&["--strict"][..], allow].concat()); diff --git a/apps/rustgis-python/python/rustgis/__init__.py b/apps/rustgis-python/python/rustgis/__init__.py index 4f77dd6f66..ed8b4e7545 100644 --- a/apps/rustgis-python/python/rustgis/__init__.py +++ b/apps/rustgis-python/python/rustgis/__init__.py @@ -44,6 +44,10 @@ PathLike = Union[str, "os.PathLike[str]"] +# The guide's page of loss codes (rustgis_data::loss::GUIDE), an entry for each code. +_LOSS_GUIDE = "https://rustgis.app/user-guide/loss-codes/" + + class DataLossWarning(UserWarning): """A command lost data: it dropped, changed, approximated or assumed something. @@ -53,8 +57,9 @@ class DataLossWarning(UserWarning): Attributes: code: The loss code, such as ``"dropped.ring"``: never translated, renamed or reused. - The command line guide lists every code with what to do about it. + The guide has an entry for each code, with what to do about it (``url``). kind: The code's kind: ``"dropped"``, ``"changed"``, ``"approximated"`` or ``"assumed"``. + url: The code's entry in the guide: what it means and what to do about it. """ def __init__(self, message: str, code: str) -> None: @@ -67,6 +72,7 @@ def __init__(self, message: str, code: str) -> None: super().__init__(message) self.code = code self.kind = code.split(".", 1)[0] + self.url = _LOSS_GUIDE + "#" + code def __reduce__(self) -> Tuple[Any, ...]: """Pickles with the code and what was added to it (notes), so a warning turned into an diff --git a/apps/rustgis-python/tests/test_session.py b/apps/rustgis-python/tests/test_session.py index 8414ec7db4..e335a8b55b 100644 --- a/apps/rustgis-python/tests/test_session.py +++ b/apps/rustgis-python/tests/test_session.py @@ -159,6 +159,8 @@ def test_losses_are_warnings_with_their_code(tmp_path): with pytest.warns(rustgis.ChangedWarning) as seen: s.run("edit.calculateField", table="records", field="n", expression="n + 1.5") assert [w.message.code for w in seen if issubclass(w.category, rustgis.DataLossWarning)] == ["changed.truncated"] + [url] = [w.message.url for w in seen if issubclass(w.category, rustgis.DataLossWarning)] + assert url == "https://rustgis.app/user-guide/loss-codes/#changed.truncated" s.notices() with warnings.catch_warnings(record=True) as seen: warnings.simplefilter("always") diff --git a/crates/assistant/src/docs.rs b/crates/assistant/src/docs.rs index aecca40932..f926beb4fe 100644 --- a/crates/assistant/src/docs.rs +++ b/crates/assistant/src/docs.rs @@ -34,6 +34,7 @@ pub const PAGES: &[Page] = pages![ "user-guide/editing.md", "user-guide/analysis.md", "user-guide/expressions.md", + "user-guide/loss-codes.md", "user-guide/layouts.md", "user-guide/sharing.md", "user-guide/workspace.md", diff --git a/crates/data/src/diagnostics.rs b/crates/data/src/diagnostics.rs index c7b27a2b1b..4af2891c7d 100644 --- a/crates/data/src/diagnostics.rs +++ b/crates/data/src/diagnostics.rs @@ -98,6 +98,8 @@ pub struct Record { pub message: String, pub details: String, pub network: Option, + /// The loss the message reports, if any: the pane links to its entry in the guide. + pub loss: Option, } #[derive(Default)] @@ -204,13 +206,14 @@ impl History { message: bounded(message, MAX_MESSAGE_BYTES), details: bounded(details, MAX_DETAILS_BYTES), network: None, + loss: None, }); } /// [`History::push`] for a message already through [`redact`] (a notice the session redacted /// for its status bar): it is only bounded, so a notice isn't redacted again for each copy. /// Only a [`Redacted`], which `redact` alone makes, gets this path. - pub fn push_redacted(&self, severity: Severity, source: &str, message: &Redacted) { + pub fn push_redacted(&self, severity: Severity, source: &str, message: &Redacted, loss: Option) { self.retain(Record { id: 0, timestamp_ms: timestamp_ms(), @@ -219,6 +222,7 @@ impl History { message: truncated(message.as_str(), MAX_MESSAGE_BYTES), details: String::new(), network: None, + loss, }); } @@ -261,6 +265,9 @@ impl History { record.source, record.message ); + if let Some(code) = record.loss { + let _ = writeln!(report, "Loss: {} ({})", code.spec().id, code.doc_url()); + } if !record.details.is_empty() { let _ = writeln!(report, "{}", record.details); } @@ -318,6 +325,7 @@ impl Capture { message, details: String::new(), network: None, + loss: None, }, ); guard.absences_overflow_said = Some(id); @@ -335,6 +343,7 @@ impl Capture { ), details: String::new(), network: Some(Network { url, method: known_method(method), status: Some(status), duration_ms: None, kind: NetworkKind::Http }), + loss: None, }; let id = store(&mut guard, record); guard.absences_said.push((server, id)); @@ -374,6 +383,7 @@ impl Capture { message: bounded(message, MAX_MESSAGE_BYTES), details: bounded(details, MAX_DETAILS_BYTES), network: Some(network), + loss: None, }; let mut state = lock(&state); if once @@ -1818,7 +1828,7 @@ mod tests { fn text_already_redacted_is_only_bounded() { let history = History::default(); let long = "word ".repeat(1000); - history.push_redacted(Severity::Info, "Application", &Redacted::new(&long)); + history.push_redacted(Severity::Info, "Application", &Redacted::new(&long), None); history.push(Severity::Info, "Application", &long, ""); let records = history.records(); assert_eq!(records[0].message, records[1].message); @@ -1827,6 +1837,19 @@ mod tests { assert_eq!(Redacted::new("Authorization: Bearer hidden").as_str(), "[REDACTED]"); } + #[test] + fn a_loss_keeps_its_code_and_the_report_gives_its_guide_entry() { + let history = History::default(); + let code = crate::loss::LossCode::DroppedRing; + history.push_redacted(Severity::Warning, "layer.addData", &Redacted::new("1 ring left out"), Some(code)); + history.push_redacted(Severity::Info, "layer.addData", &Redacted::new("added"), None); + let records = history.records(); + assert_eq!(records.iter().map(|r| r.loss).collect::>(), [Some(code), None]); + let report = history.report(Filter::All); + assert!(report.contains("Loss: dropped.ring (https://rustgis.app/user-guide/loss-codes/#dropped.ring)"), "{report}"); + assert_eq!(report.matches("Loss: ").count(), 1, "{report}"); + } + #[test] fn absence_notes_name_the_method_and_bound_oversized_addresses() { let history = History::default(); diff --git a/crates/data/src/loss.rs b/crates/data/src/loss.rs index d77a2a97a3..6947cc2722 100644 --- a/crates/data/src/loss.rs +++ b/crates/data/src/loss.rs @@ -1,7 +1,7 @@ //! Shared classification for data-loss notices, independent of their wording. //! //! A code's identifier is public: scripts match on it (`rustgis-cli run --strict --allow`), so it -//! is never translated, renamed or reused. The command line guide lists every code, checked by +//! is never translated, renamed or reused. The guide has an entry for each code ([`GUIDE`]), checked by //! `the_guide_lists_every_code`. /// What happened to the data. @@ -152,7 +152,16 @@ loss_codes! { ), } +/// The guide's page of loss codes, which has an entry for each, anchored by its identifier. +pub const GUIDE: &str = "https://rustgis.app/user-guide/loss-codes/"; + impl LossCode { + /// The address of this code's entry in the guide: what it means, where it is said and what to + /// do about it. + pub fn doc_url(self) -> String { + format!("{GUIDE}#{}", self.spec().id) + } + /// The code this identifier names. pub fn from_id(id: &str) -> Option { Self::ALL.iter().copied().find(|code| code.spec().id == id) @@ -437,18 +446,22 @@ mod tests { #[test] fn the_guide_lists_every_code() { - let guide = include_str!("../../../docs/cli.md").replace("\r\n", "\n"); - let section = guide.split("\n### Loss codes\n").nth(1).unwrap_or_default(); - let section = section.split("\n#").next().unwrap_or_default(); - let rows: Vec<&str> = section.lines().filter(|l| l.starts_with("| `")).collect(); + let guide = include_str!("../../../docs/user-guide/loss-codes.md").replace("\r\n", "\n"); + let headings: Vec<&str> = guide.lines().filter(|l| l.starts_with("### `")).collect(); for code in LossCode::ALL { let spec = code.spec(); - let row = format!("| `{}` | {} |", spec.id, spec.action); - assert!(rows.contains(&row.as_str()), "docs/cli.md: the loss codes should list\n{row}"); + // The anchor each notice links to ([`LossCode::doc_url`]), and what to do under it. + let heading = format!("### `{0}` {{ #{0} }}", spec.id); + let entry = guide.split(&format!("\n{heading}\n")).nth(1).unwrap_or_default(); + let entry = entry.split("\n### ").next().unwrap_or_default().split("\n## ").next().unwrap_or_default(); + assert!(!entry.is_empty(), "docs/user-guide/loss-codes.md should have the entry\n{heading}"); + let action = format!("**What to do:** {}", spec.action); + assert!(entry.replace('\n', " ").contains(&action), "docs/user-guide/loss-codes.md: `{}` should say\n{action}", spec.id); + assert!(code.doc_url().ends_with(&format!("/user-guide/loss-codes/#{}", spec.id))); } - for row in rows { - let id = row.trim_start_matches("| `").split('`').next().unwrap_or_default(); - assert!(LossCode::from_id(id).is_some(), "docs/cli.md lists `{id}`, which is not a loss code"); + for heading in headings { + let id = heading.trim_start_matches("### `").split('`').next().unwrap_or_default(); + assert!(LossCode::from_id(id).is_some(), "docs/user-guide/loss-codes.md lists `{id}`, which is not a loss code"); } } } diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 8317b20c80..1e3f3d3dd9 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -3599,7 +3599,7 @@ impl Session { if severity == rustgis_data::diagnostics::Severity::Error && self.rerun_said.iter().any(|said| said == text.as_str()) { return; } - self.diagnostics.push_redacted(severity, source.unwrap_or("Application"), &text); + self.diagnostics.push_redacted(severity, source.unwrap_or("Application"), &text, loss); self.notices.push(Notice { text: text.into_string(), error: severity == rustgis_data::diagnostics::Severity::Error, diff --git a/crates/ui-egui/src/diagnosticlog.rs b/crates/ui-egui/src/diagnosticlog.rs index 1e91639745..496edc9114 100644 --- a/crates/ui-egui/src/diagnosticlog.rs +++ b/crates/ui-egui/src/diagnosticlog.rs @@ -57,9 +57,10 @@ pub(crate) fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { egui::ScrollArea::vertical().id_salt("diagnostic_log_entries").auto_shrink([false, false]).show(ui, |ui| { egui::Frame::NONE.inner_margin(egui::Margin::symmetric(12, 8)).show(ui, |ui| { let mut shown = false; - for record in records.iter().rev().filter(|r| app.ui.diagnostic_filter.matches(r)) { + let filter = app.ui.diagnostic_filter; + for record in records.iter().rev().filter(|r| filter.matches(r)) { shown = true; - ui.push_id(record.id, |ui| entry(ui, record, t)); + ui.push_id(record.id, |ui| entry(ui, record, t, &mut app.ui.open_url)); ui.separator(); } if !shown { @@ -70,7 +71,7 @@ pub(crate) fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { app.ui.diagnostic_snapshot = Some((generation, records)); } -fn entry(ui: &mut Ui, record: &Record, t: &Tokens) { +fn entry(ui: &mut Ui, record: &Record, t: &Tokens, open_url: &mut Option) { // Literal labels, so each is found and translated with the interface's other strings. let (severity, color) = match record.severity { Severity::Error => (tl!("Error"), t.red), @@ -90,6 +91,15 @@ fn entry(ui: &mut Ui, record: &Record, t: &Tokens) { ui.label(RichText::new(source).small().color(t.text_dim)); }); ui.add(egui::Label::new(&record.message).wrap().selectable(true)); + if let Some(code) = record.loss { + // The code is an identifier, never translated; its guide entry says what to do. + ui.horizontal_wrapped(|ui| { + ui.label(RichText::new(code.spec().id).small().monospace().color(t.text_dim)); + if ui.link(RichText::new(tl!("What this means")).small()).on_hover_text(code.doc_url()).clicked() { + *open_url = Some(code.doc_url()); + } + }); + } if !record.details.is_empty() || record.network.is_some() { egui::CollapsingHeader::new(tl!("Technical details")).show(ui, |ui| { if let Some(network) = &record.network { diff --git a/docs/cli.md b/docs/cli.md index 13f1edf69f..d8cb5425cc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -154,31 +154,8 @@ An `--allow` that names no kind or code is refused with status 2, as is `--allow ### Loss codes -| Code | What to do | -|---|---| -| `dropped.legend` | Use a service with short HTTP or HTTPS addresses for its legend pictures. | -| `dropped.ring` | Correct the unreadable polygon ring in the source, or write to a format that holds holes, such as GeoPackage. | -| `dropped.extra-attributes` | Add fields for the extra attribute values or remove those values from the input. | -| `dropped.time` | Write to a date-time field to keep the time of day. | -| `dropped.value` | Correct the value or use a destination field that can hold it. | -| `dropped.calculation-result` | Correct the expression or check the input rows named in the notice. | -| `dropped.zm` | Keep the source file where heights or measures matter: RustGIS keeps x and y only. | -| `dropped.crs-name` | Keep the source file's coordinate system definition with the export, or export in WGS 84, which every format can name. | -| `dropped.feature` | Correct those features in the source, or read the source in the way the notice suggests. | -| `dropped.geometry` | Correct the geometry in the source, or give the coordinate system its coordinates are in. | -| `dropped.over-limit` | Read less at once, such as by filtering or clipping the source first. | -| `changed.truncated` | Use a decimal field to keep the fractional part. | -| `changed.field-name` | Use field names the format holds: at most 10 bytes and unique ignoring case for a Shapefile, unique ignoring case for a GeoPackage. | -| `changed.cut` | Shorten the text to what the format holds (254 bytes for a Shapefile; nothing past a NUL character), or write to a format without the limit, such as GeoPackage. | -| `changed.body` | Export in the layer's own coordinate system, which keeps its body. | -| `changed.encoding` | Put a .cpg file naming the file's own encoding beside it. | -| `changed.rounded` | Keep the source file where finer values matter, or write to a format that holds them (times finer than the format keeps, numbers past a dBase field's precision, or whole numbers past 2^53 in a decimal field). | -| `changed.position` | Export in a coordinate system that holds the positions, such as WGS 84. | -| `approximated.datum` | Export in the layer's own coordinate system, or give that system with a known transformation to WGS 84. | -| `approximated.curve` | Keep the source file where exact curves matter: RustGIS draws curves as straight segments. | -| `assumed.null-marker` | Write the value another way if the text Null is meant as text, not as an empty value. | -| `assumed.crs` | Give the coordinate system the coordinates are in ("crs" when adding the data, or Define Projection). | -| `assumed.encoding` | Give the file's encoding in a form RustGIS reads: a .cpg beside a Shapefile or dBASE file naming UTF-8 or its Windows code page, or a DXF saved as UTF-8. | +Each code has an entry in [Data loss codes](user-guide/loss-codes.md): what it means, where it is +said and what to do about it. A strict run's message gives the address of each code's entry. Not every loss has a code yet: losses still reported without one don't stop a strict run. diff --git a/docs/mcp.md b/docs/mcp.md index aeceae4893..3e2a9973b8 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -344,7 +344,7 @@ These behavioral tests in `crates/assistant/src/relay.rs` check the requirements | `view_map` | The map as a PNG image at the current view; `width` and `height` default to 1024 × 640, each clamped to 64–2048 pixels. A picture over 3.75 MiB (a satellite basemap near 2048 pixels) is drawn again smaller, and its caption gives the size drawn and the size asked. `layout` (a layout's name) draws its page instead, fitted to `width` (and `height` when given); `region` draws part of either at full detail: `[x, y, w, h]` in mm on a layout (up to 600 dpi), `[west, south, east, north]` in degrees on the map. What drawing it said (texts cut off, layers without their cast shadows) follows the caption | | `snapshot` | The map as a PNG with JSON metadata: `mode`, `width`, `height`, `extent` (longitude/latitude), `center`, `scale`, `projection`, `render_settled`, `saved` and `note`. `mode: "screen"` captures the RustGIS window through the relay, once the map has finished drawing or after `wait_s` seconds (default 5, clamped to 0–30); `overlays: false` leaves out the map's controls, scale bar, north arrow and sketches. `mode: "render"` draws offscreen at `max_width` (default 1024, clamped to 64–2048 pixels); height follows the view's shape, with each side capped at 2048. It works while the window is hidden. `mode: "auto"` (default) takes the screen when the map is on it. Unavailable screen captures fall back to render. `save_path` also writes the PNG to a file, which needs file access | | `search_commands` | Finds RustGIS commands by words: their ids, ribbon locations and parameters | -| `run_command` | Runs a command by id with JSON parameters; each run that changes the project is one undo step. The result names the layers it added (`layersAdded`) and what the command said beside it (`notices`), including any parameters it ignored (`layer.moveDown ignores 'steps' (it reads layer)`). A notice that reports lost data with a [loss code](cli.md#loss-codes) is also in `losses`, as `{code, kind, text, action}`, so an agent can match the code: for an `assumed.*` code it can ask instead of guessing. A loss that has no code yet is only in `notices`. When the list doesn't fit the output budget beside the result, it is shortened (each entry's `code` and `kind`, then one entry per code with its `count`, then the codes alone) and `lossesTrimmed` is `true`; with the tightest budgets `losses` is left out and only `lossesTrimmed` says so. A failed command's error ends with a `losses:` line of JSON: one entry per code with its `action` and `count`, then the counts alone, then the codes alone, or `lossesTrimmed: true` | +| `run_command` | Runs a command by id with JSON parameters; each run that changes the project is one undo step. The result names the layers it added (`layersAdded`) and what the command said beside it (`notices`), including any parameters it ignored (`layer.moveDown ignores 'steps' (it reads layer)`). A notice that reports lost data with a [loss code](user-guide/loss-codes.md) is also in `losses`, as `{code, kind, text, action}`, so an agent can match the code: for an `assumed.*` code it can ask instead of guessing. A loss that has no code yet is only in `notices`. When the list doesn't fit the output budget beside the result, it is shortened (each entry's `code` and `kind`, then one entry per code with its `count`, then the codes alone) and `lossesTrimmed` is `true`; with the tightest budgets `losses` is left out and only `lossesTrimmed` says so. A failed command's error ends with a `losses:` line of JSON: one entry per code with its `action` and `count`, then the counts alone, then the codes alone, or `lossesTrimmed: true` | | `run` | Runs several commands in one call, as one undo step (none when its lines only read the project, moved the view, exported, left a request, or ran a command that reports it changed nothing, such as a move to where the layers already are; a line that sets a value to the one it has still counts): a script in the `script.run` format (one `command-id {json}` per line, `#` comments). A failing line stops it, nothing it did to the project is kept, and the error names the line; files an earlier line wrote (an export) stay written. Answers `{success, result, lines, layersAdded, notices, losses, error, duration_s}`, where `result` is the last command's. Each line follows `run_command`'s rules, checked before any line runs | | `search_tools` | Finds geoprocessing tools by words | | `describe_tool` | A geoprocessing tool's parameters | diff --git a/docs/python.md b/docs/python.md index fd11c781ce..03311095d4 100644 --- a/docs/python.md +++ b/docs/python.md @@ -212,10 +212,10 @@ s.undo() s.redo() ``` -A notice that says a command lost data, and has a [loss code](cli.md#loss-codes), is also raised +A notice that says a command lost data, and has a [loss code](user-guide/loss-codes.md), is also raised as a Python warning: `rustgis.DroppedWarning`, `ChangedWarning`, `ApproximatedWarning` or `AssumedWarning`, all subclasses of `rustgis.DataLossWarning`. The warning's `code` (such as -`"dropped.ring"`) and `kind` say which, and its message is the notice's text with the code. The +`"dropped.ring"`) and `kind` say which, `url` is the code's entry in the guide, and its message is the notice's text with the code. The notice stays in `s.notices()`. Python's warning filters decide what happens, so a script can turn losses into errors and allow the ones it expects: diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index 611fe73ceb..d65091d653 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -12,6 +12,7 @@ This guide walks through RustGIS by task. Each page covers one part of the app: | [Editing](editing.md) | Creating and modifying features, data design, the clipboard and pop-ups | | [Analysis](analysis.md) | Selection and SQL queries, geoprocessing, the GeoLibre tools, guided workflows, imagery, data cubes and time series | | [Expressions](expressions.md) | The expression language of queries, filters and Calculate Field: grammar, operators, functions | +| [Data Loss Codes](loss-codes.md) | What each data loss code means, where it is said and what to do about it | | [Layouts and Reports](layouts.md) | Page layouts, map series, reports, presentations and notebooks | | [Sharing](sharing.md) | Exports, packages and open-format web maps, layers, styles and scenes | | [Workspace](workspace.md) | Linked views, the Browser view, animation, profiles, offline areas, customizing the ribbon | diff --git a/docs/user-guide/loss-codes.md b/docs/user-guide/loss-codes.md new file mode 100644 index 0000000000..8ddd61f195 --- /dev/null +++ b/docs/user-guide/loss-codes.md @@ -0,0 +1,215 @@ +# Data loss codes + +RustGIS never drops or changes data silently. A notice says what happened, how much and where. +A notice that reports a loss also carries one of the codes on this page. Each notice links to its +entry here, which says what the code means and what to do about it. + +A code is never translated, renamed or reused, so a script can match on it. +[`rustgis-cli run --strict`](../cli.md#strict-runs) stops at a code that no `--allow` accepts, +Python raises it as [`rustgis.DataLossWarning`](../python.md), and the [MCP server](../mcp.md) +returns it under `losses`. + +Not every loss has a code yet. Losses said without one are only notices, and don't stop a strict +run. + +## Dropped + +Dropped means data was left out and is not in the result. + +### `dropped.legend` { #dropped.legend } + +A map service offered legend pictures that RustGIS does not show, so they were left out. These are pictures with addresses that fail RustGIS's checks, are in another format, or past the limit on legends per layer. + +**Where you see it:** adding a map service layer (WMS or similar) that offers legends. + +**What to do:** Use a service with short HTTP or HTTPS addresses for its legend pictures. + +### `dropped.ring` { #dropped.ring } + +A polygon ring was left out. Rings that could not be read, or that have no area, are skipped, and a format with no holes keeps only the outer edge of each polygon. + +**Where you see it:** reading GeoRSS, GML, MapInfo or Esri PBF data; exporting polygons to GPX (their holes are left out). + +**What to do:** Correct the unreadable polygon ring in the source, or write to a format that holds holes, such as GeoPackage. + +### `dropped.extra-attributes` { #dropped.extra-attributes } + +A row had more attribute values than the layer has fields, and the extra values were not kept. + +**Where you see it:** reading a CSV file with rows longer than its header; the Repair Geometry and Check Geometry tools. + +**What to do:** Add fields for the extra attribute values or remove those values from the input. + +### `dropped.time` { #dropped.time } + +A date-time was written to a date field, which keeps only the day, so the time of day was lost. + +**Where you see it:** Calculate Field; editing or pasting table values into a date field; the Update tool. + +**What to do:** Write to a date-time field to keep the time of day. + +### `dropped.value` { #dropped.value } + +A value could not be kept and was read or written as empty (null). Examples are spreadsheet error cells, text in a date or yes/no column, and a result that is not a number. + +**Where you see it:** reading a spreadsheet, Parquet, PostGIS or table-based source; reading DTED or GRIB rasters; Calculate Field. + +**What to do:** Correct the value or use a destination field that can hold it. + +### `dropped.calculation-result` { #dropped.calculation-result } + +A calculation gave no result for some rows, so the field was left empty there. The input may have no place that can be given in longitude and latitude, or the result may be too large to hold. + +**Where you see it:** Calculate Field; Calculate Geometry Attributes; table statistics; Profile Along Selected Lines. + +**What to do:** Correct the expression or check the input rows named in the notice. + +### `dropped.zm` { #dropped.zm } + +Z (height) or M (measure) values were not kept. RustGIS keeps x and y only. + +**Where you see it:** reading KML, CSV or WKT, or a table read through DuckDB or GDAL; exporting a layer whose Z or M values were dropped when it was read. + +**What to do:** Keep the source file where heights or measures matter: RustGIS keeps x and y only. + +### `dropped.crs-name` { #dropped.crs-name } + +A coordinate system's name or definition could not be written with the data, so the file holds the coordinates without it. + +**Where you see it:** exporting to a Shapefile (no .prj file) or to CSV; exporting layers on another body than the Earth; reading Zarr stores. + +**What to do:** Keep the source file's coordinate system definition with the export, or export in WGS 84, which every format can name. + +### `dropped.feature` { #dropped.feature } + +Whole features, rows or items were left out because they could not be read or are not supported. + +**Where you see it:** reading GeoRSS, OpenStreetMap, spreadsheet, GRIB or point-cloud (LAS and LAZ) files. + +**What to do:** Correct those features in the source, or read the source in the way the notice suggests. + +### `dropped.geometry` { #dropped.geometry } + +A feature's geometry could not be read or written. The feature was kept without its place, or the place was left out. + +**Where you see it:** reading CSV with WKT, GPX, TopoJSON or MapInfo data; exporting layers with a place the target coordinate system cannot hold; Repair Geometry. + +**What to do:** Correct the geometry in the source, or give the coordinate system its coordinates are in. + +### `dropped.over-limit` { #dropped.over-limit } + +RustGIS read only part of the data because it is past a size limit. + +**Where you see it:** reading point-cloud (LAS and LAZ), DXF, KML or photo data, or a raster with a very long list of class names. + +**What to do:** Read less at once, such as by filtering or clipping the source first. + +## Changed + +Changed means data is still there but was altered, such as cut short or rounded. + +### `changed.truncated` { #changed.truncated } + +A number lost its fractional part because the field holds whole numbers. + +**Where you see it:** Calculate Field; editing table values; the Update tool. + +**What to do:** Use a decimal field to keep the fractional part. + +### `changed.field-name` { #changed.field-name } + +A field name was changed to fit the format it was written to. + +**Where you see it:** exporting to Shapefile or GeoPackage. + +**What to do:** Use field names the format holds: at most 10 bytes and unique ignoring case for a Shapefile, unique ignoring case for a GeoPackage. + +### `changed.cut` { #changed.cut } + +Text was cut short to fit a format or a limit. + +**Where you see it:** exporting to Shapefile (254 bytes per value); labels and annotations; reading raster band or class names. + +**What to do:** Shorten the text to what the format holds (254 bytes for a Shapefile; nothing past a NUL character), or write to a format without the limit, such as GeoPackage. + +### `changed.body` { #changed.body } + +Longitude and latitude on a body other than the Earth were written as Earth coordinates, because the format cannot say which body they are on. + +**Where you see it:** exporting layers in a planetary coordinate system. + +**What to do:** Export in the layer's own coordinate system, which keeps its body. + +### `changed.encoding` { #changed.encoding } + +Text that is not valid in the encoding it was read with was read with a replacement character in its place. + +**Where you see it:** reading a Shapefile or dBASE file, a DXF drawing, or Esri PBF data. + +**What to do:** Put a .cpg file naming the file's own encoding beside it. + +### `changed.rounded` { #changed.rounded } + +A number or time was rounded to what the format or the field holds. + +**Where you see it:** exporting to Shapefile or GeoPackage; reading spreadsheets or File Geodatabases; Calculate Field and table statistics. + +**What to do:** Keep the source file where finer values matter, or write to a format that holds them (times finer than the format keeps, numbers past a dBase field's precision, or whole numbers past 2^53 in a decimal field). + +### `changed.position` { #changed.position } + +Positions were moved to fit the coordinate system they were written in, for example vertices beyond 85.05 degrees north or south in Web Mercator. + +**Where you see it:** exporting in Web Mercator. + +**What to do:** Export in a coordinate system that holds the positions, such as WGS 84. + +## Approximated + +Approximated means data was kept as a close stand-in for the original. + +### `approximated.datum` { #approximated.datum } + +A datum RustGIS does not shift was treated as WGS 84, so places may be a little off. + +**Where you see it:** reading DTED rasters; exporting a layer that is not in WGS 84 to a format that holds only longitude and latitude. + +**What to do:** Export in the layer's own coordinate system, or give that system with a known transformation to WGS 84. + +### `approximated.curve` { #approximated.curve } + +Curves, circles or rotated boxes were drawn or written as straight segments. + +**Where you see it:** reading GML or File Geodatabase data; the Buffer tool; exporting circles and rotated boxes drawn in the session. + +**What to do:** Keep the source file where exact curves matter: RustGIS draws curves as straight segments. + +## Assumed + +Assumed means RustGIS had to guess something the data did not say, so the result may be wrong if the guess is. + +### `assumed.null-marker` { #assumed.null-marker } + +A value written as the text ``, which some programs write for a missing value, was read as +empty (null). + +**Where you see it:** reading a Shapefile, GeoPackage, GeoJSON, CSV or Parquet file, or point-cloud +data. + +**What to do:** Write the value another way if the text Null is meant as text, not as an empty value. + +### `assumed.crs` { #assumed.crs } + +The file does not say which coordinate system its coordinates are in, or says one RustGIS cannot use, so RustGIS read them as longitude and latitude (WGS 84). + +**Where you see it:** reading a Shapefile with an unusable .prj file, GeoPackage, PostGIS or SQL Server data, Zarr stores and point-cloud files. + +**What to do:** Give the coordinate system the coordinates are in ("crs" when adding the data, or Define Projection). + +### `assumed.encoding` { #assumed.encoding } + +The file does not name its text encoding, or names one RustGIS does not read, so RustGIS assumed one (UTF-8, or Latin-1 for a DXF). + +**Where you see it:** reading a Shapefile or dBASE file without a usable .cpg file, or a DXF drawing without a known code page. + +**What to do:** Give the file's encoding in a form RustGIS reads: a .cpg beside a Shapefile or dBASE file naming UTF-8 or its Windows code page, or a DXF saved as UTF-8. diff --git a/zensical.toml b/zensical.toml index 59b51178bf..bd4e44c0f1 100644 --- a/zensical.toml +++ b/zensical.toml @@ -25,6 +25,7 @@ nav = [ "user-guide/editing.md", "user-guide/analysis.md", "user-guide/expressions.md", + "user-guide/loss-codes.md", "user-guide/layouts.md", "user-guide/sharing.md", "user-guide/workspace.md", From a7cc28b44c0b6d91055507581855ca3d0bd44b5a Mon Sep 17 00:00:00 2001 From: mavrick Date: Fri, 27 Nov 2026 11:59:46 -0600 Subject: [PATCH 2/2] docs(ui): say what the Messages pane's functions draw, and name feature service answers as the data guide does --- crates/ui-egui/src/diagnosticlog.rs | 3 +++ docs/user-guide/loss-codes.md | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/diagnosticlog.rs b/crates/ui-egui/src/diagnosticlog.rs index 496edc9114..3eea4e9ffb 100644 --- a/crates/ui-egui/src/diagnosticlog.rs +++ b/crates/ui-egui/src/diagnosticlog.rs @@ -5,6 +5,7 @@ use rustgis_engine::data::diagnostics::{Filter, NetworkKind, Record, Severity}; use crate::{RustGisApp, theme::Tokens}; +/// The Messages pane: its filters, Copy diagnostics and Clear, then the entries, newest first. pub(crate) fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { // Background requests may finish without another UI action (including HEAD probes). ui.ctx().request_repaint_after(std::time::Duration::from_millis(500)); @@ -71,6 +72,8 @@ pub(crate) fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { app.ui.diagnostic_snapshot = Some((generation, records)); } +/// One entry: its time, severity and source, the message, the loss code with a link to its entry +/// in the guide (set in `open_url` when clicked), and any technical details. fn entry(ui: &mut Ui, record: &Record, t: &Tokens, open_url: &mut Option) { // Literal labels, so each is found and translated with the interface's other strings. let (severity, color) = match record.severity { diff --git a/docs/user-guide/loss-codes.md b/docs/user-guide/loss-codes.md index 8ddd61f195..76a65b6ed2 100644 --- a/docs/user-guide/loss-codes.md +++ b/docs/user-guide/loss-codes.md @@ -28,7 +28,7 @@ A map service offered legend pictures that RustGIS does not show, so they were l A polygon ring was left out. Rings that could not be read, or that have no area, are skipped, and a format with no holes keeps only the outer edge of each polygon. -**Where you see it:** reading GeoRSS, GML, MapInfo or Esri PBF data; exporting polygons to GPX (their holes are left out). +**Where you see it:** reading GeoRSS, GML or MapInfo data, or feature service answers in PBF; exporting polygons to GPX (their holes are left out). **What to do:** Correct the unreadable polygon ring in the source, or write to a format that holds holes, such as GeoPackage. @@ -144,7 +144,7 @@ Longitude and latitude on a body other than the Earth were written as Earth coor Text that is not valid in the encoding it was read with was read with a replacement character in its place. -**Where you see it:** reading a Shapefile or dBASE file, a DXF drawing, or Esri PBF data. +**Where you see it:** reading a Shapefile or dBASE file, a DXF drawing, or feature service answers in PBF. **What to do:** Put a .cpg file naming the file's own encoding beside it.