Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ The shared pieces the everyday workflow stands on.
### Correct results
A result is right, or RustGIS says what it lost or assumed
([AGENTS.md](AGENTS.md#never-silent)).
- Known silent losses: DXF polyface faces with missing vertices and unreadable supplied Z outside 3D POLYLINE vertices; and the text
reader loss listed as `Silent` in `crates/engine/tests/integration/never_silent_reading.rs`:
attribute fields/values in XLSB short-cell workbooks (the original SheetJS 0.18.5 clean
workbook retains its point but no attributes, without a notice). A fix makes
its case `Said` or `Imported` _(open)_.
- Known silent losses still to cover: DXF unreadable extrusion Z (group 230); XLSB cached formula errors (`BrtFmlaError`) and
rich inline strings (`BrtCellRString`) skipped by the workbook reader _(open)_.
- Lossy sample files in `never_silent_reading.rs` for the readers it doesn't cover yet:
remaining distinct loss families and parser paths (see the finite
[coverage inventory](crates/engine/testdata/reading-losses/README.md#coverage-boundaries)). It covers GeoJSON, TopoJSON, CSV,
Expand Down
27 changes: 27 additions & 0 deletions apps/rustgis-cli/tests/integration/strict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,30 @@ fn explain_says_what_a_code_means_and_what_to_do_offline() {
assert!(!unknown.status.success());
assert!(String::from_utf8_lossy(&unknown.stderr).contains("not a loss code"));
}

/// Previously plain notices must now stop a strict run and accept only their matching allowance.
#[test]
fn strict_classifies_csv_protection_and_xy_crs_assumptions() {
for (property, value, command, code) in [
("=label", "safe", r#"data.convert={"format":"csv","layer":"points"}"#, "changed.field-name"),
("label", "=SUM(A1)", r#"data.convert={"format":"csv","layer":"points"}"#, "changed.csv-guard"),
("label", "safe", r#"gp.run={"tool":"xyTableToPoint","params":{"input":"points","x":"x","y":"y"}}"#, "assumed.crs"),
] {
let mut properties = serde_json::json!({"x": 1, "y": 2});
properties[property] = serde_json::json!(value);
let geojson = serde_json::json!({"type":"FeatureCollection", "features":[{"type":"Feature", "geometry":{"type":"Point","coordinates":[1,2]}, "properties":properties}]});
let add = format!("layer.addDataText={}", serde_json::json!({"fileName":"points.geojson", "text":geojson.to_string()}));
for allow in [false, true] {
let mut args = vec!["--strict", "--cmd", &add, "--cmd", command];
if allow {
args.extend(["--allow", code]);
}
let out = cli(&args);
let error = String::from_utf8_lossy(&out.stderr);
assert_eq!(out.status.code(), Some(if allow { 0 } else { 3 }), "{code}: {error}");
if !allow {
assert!(error.contains(code), "{error}");
}
}
}
}
21 changes: 17 additions & 4 deletions crates/analysis/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4691,10 +4691,13 @@ fn xy_table_to_point(inp: &dyn Inputs, p: &Json) -> Result<ToolResult, String> {
});
}
let mut messages = vec![format!("XY Table To Point: {placed} points")];
let mut losses: Vec<rustgis_data::loss::LossMessage> = Vec::new();
if crs_text.is_empty() {
messages.push("XY Table To Point: WGS 84 (EPSG:4326) was assumed because no coordinate system was given".into());
losses.push(rustgis_data::loss::LossMessage {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the assumed-CRS message into losses is the right fix (it now has a code, and the other readers already code AssumedCrs). But it also changes behaviour: a run of xyTableToPoint without a crs now counts as a loss, so rustgis-cli --strict exits 3 unless the script adds --allow assumed.crs. Before this, it passed silently. The PR description says strict-mode timing is unchanged and doesn't mention this exit-code change. Please say so in the PR description (and in the release notes, if they list CLI behaviour changes) so scripts that use --strict with this tool can be updated.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description now explicitly states that XY Table To Point without an explicit CRS exits 3 under --strict unless --allow assumed.crs is given. It also calls out the newly classified CSV, column and copyright cases. The strict/allow regression covers both outcomes; only the check timing and rollback behavior remain unchanged.

code: rustgis_data::loss::LossCode::AssumedCrs,
text: "XY Table To Point: WGS 84 (EPSG:4326) was assumed because no coordinate system was given".into(),
});
}
let mut losses: Vec<rustgis_data::loss::LossMessage> = Vec::new();
messages.extend(crs_note.map(|note| format!("XY Table To Point: its coordinate system: {note}")));
// A row without numbers had no place to lose; one whose numbers have no place in the system
// has lost it.
Expand Down Expand Up @@ -13967,12 +13970,15 @@ mod tests {
assert_eq!(run(serde_json::json!({"input": "stops", "x": "lon", "y": "lat", "crs": 3857})).unwrap_err(), "crs must be text");

let r = run(serde_json::json!({"input": "stops", "x": "lon", "y": "lat"})).unwrap();
assert_eq!(r.losses[0].code, rustgis_data::loss::LossCode::AssumedCrs);
let explicit = run(serde_json::json!({"input": "stops", "x": "lon", "y": "lat", "crs": "EPSG:4326"})).unwrap();
assert!(!explicit.losses.iter().any(|n| n.code == rustgis_data::loss::LossCode::AssumedCrs));
// Rows without numbers lose nothing; the one off the globe loses its place.
assert_eq!(
said(&r)[1..],
[
"XY Table To Point: WGS 84 (EPSG:4326) was assumed because no coordinate system was given",
"3 of 7 rows have no numbers in both fields; they are in the table without a point",
"AssumedCrs: XY Table To Point: WGS 84 (EPSG:4326) was assumed because no coordinate system was given",
"DroppedGeometry: 1 of 7 rows have coordinates with no place in EPSG:4326; they are in the table without a point"
]
);
Expand Down Expand Up @@ -14015,7 +14021,14 @@ mod tests {
// Points in longitude/latitude are held there, with no system of their own, as before.
for (crs, assumed) in [("", true), (" ", true), ("EPSG:4326", false)] {
let r = run(serde_json::json!({"input": "stops", "x": "lon", "y": "lat", "crs": crs})).unwrap();
assert_eq!(r.messages.iter().filter(|m| m.contains("WGS 84 (EPSG:4326) was assumed")).count(), usize::from(assumed), "{crs:?}");
assert_eq!(
r.losses
.iter()
.filter(|m| m.code == rustgis_data::loss::LossCode::AssumedCrs && m.text.contains("WGS 84 (EPSG:4326) was assumed"))
.count(),
usize::from(assumed),
"{crs:?}"
);
let lonlat = layer(r);
assert_eq!((lonlat.coord_crs(), lonlat.crs), (Crs::LonLat, None));
}
Expand Down
Loading
Loading