Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
60b782b
feat(data): dropped Z/M values and an export's geometry notes say the…
Mavrick-F Nov 23, 2026
da37a04
fix(engine): a file-wide read leaves out the layer's Z/M note by its …
Mavrick-F Nov 23, 2026
63295ca
test(engine): a batch says a Z/M loss as one coded notice
Mavrick-F Nov 23, 2026
7b98a83
chore(engine): drop conversions export notes no longer need
Mavrick-F Nov 23, 2026
dd9c51c
test(engine): the reading corpus asserts dropped.zm on every reader t…
Mavrick-F Nov 23, 2026
1adadd4
fix(data): a GDAL conversion counts its Z/M losses per part; extent-o…
Mavrick-F Nov 23, 2026
fc43039
fix(engine): a batch counts every coded loss through one method, whic…
Mavrick-F Nov 23, 2026
915a5f3
fix(data): a GDAL layer's Z/M count is kept with its conversion and a…
Mavrick-F Nov 23, 2026
8109079
fix(engine): a GDAL file says its parts' Z/M losses once for each kin…
Mavrick-F Nov 23, 2026
04c4a97
fix(data): only a Z/M count GDAL refuses is kept as unknown; a missin…
Mavrick-F Nov 23, 2026
18d339b
fix(data): a kept Z/M count longer than any count is not taken
Mavrick-F Nov 23, 2026
e534c8d
fix(data): only a Z/M count taken is kept; a failed count is said and…
Mavrick-F Nov 23, 2026
a039075
fix(data): a kept Z/M count read is touched with its conversion; Pyth…
Mavrick-F Nov 23, 2026
a76ff50
fix(python): GeoJSON leaves out the generic Z/M note when the layer's…
Mavrick-F Nov 23, 2026
c5b8540
fix(python): GeoJSON says a Z/M loss said only when the layer opened,…
Mavrick-F Nov 23, 2026
48efdd8
fix(data): a declared Z/M layer whose count fails is still marked as …
Mavrick-F Nov 23, 2026
cb402dd
fix(engine): Add Data takes a declared Z/M layer whose count failed a…
Mavrick-F Nov 23, 2026
4bddfe0
Merge main into feat/zm-loss-codes
Mavrick-F Nov 23, 2026
10eb362
test(engine): the reading corpus checks a coded loss's words beside i…
Mavrick-F Nov 23, 2026
116b0cb
Merge upstream main into feat/zm-loss-codes
Mavrick-F Nov 23, 2026
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
28 changes: 21 additions & 7 deletions apps/rustgis-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,26 @@ impl Engine {
for message in report.messages.into_iter().filter(|message| !opened_notes.contains(message)) {
session.say(message);
}
if let Some(note) = rustgis_engine::data::zm_export_note([&ds], &format!("{name} as GeoJSON")) {
session.notify(note, false);
// What GeoJSON, in WGS 84, lacks of it, as an export to GeoJSON says it.
for note in rustgis_engine::data::export_notes(
Comment thread
Mavrick-F marked this conversation as resolved.
Resolved
[(&ds, ds.lonlat_extent())],
&format!("{name} as GeoJSON"),
rustgis_engine::data::raster::Crs::LonLat,
) {
session.say(note);
Comment thread
Mavrick-F marked this conversation as resolved.
Resolved
}
// GeoJSON is longitude/latitude, whatever system the source holds its coordinates in.
return Ok(rustgis_engine::data::io::to_geojson(&*ds.in_lonlat()?).to_string());
}
if !selected {
let text = rustgis_engine::data::io::to_geojson(&*found.dataset.in_lonlat()?).to_string();
let note = rustgis_engine::data::zm_export_note([&found.dataset], &format!("{} as GeoJSON", found.name));
if let Some(note) = note {
session.notify(note, false);
let target = format!("{} as GeoJSON", found.name);
for note in rustgis_engine::data::export_notes(
[(&found.dataset, found.dataset.lonlat_extent())],
&target,
rustgis_engine::data::raster::Crs::LonLat,
) {
session.say(note);
}
return Ok(text);
}
Expand All @@ -221,8 +230,13 @@ impl Engine {
ds.push(g, r.values().cloned().collect());
}
let text = rustgis_engine::data::io::to_geojson(&ds).to_string();
if let Some(note) = rustgis_engine::data::zm_export_note([&ds], &format!("{} as GeoJSON", ds.name)) {
session.notify(note, false);
// The selected rows lack what the layer's do: said of the layer, whose system and body
// the copy in longitude/latitude no longer holds, at the selected rows' places.
let target = format!("{} as GeoJSON", ds.name);
for note in
rustgis_engine::data::export_notes([(&found.dataset, ds.extent())], &target, rustgis_engine::data::raster::Crs::LonLat)
{
session.say(note);
}
Ok::<String, String>(text)
});
Expand Down
32 changes: 24 additions & 8 deletions crates/data/src/dxf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,10 @@ pub fn read(file_name: &str, bytes: &[u8], opts: &Options) -> Result<Vec<(Datase
&& let Some((_, report)) = layers.first_mut()
{
let subject = if varying_count == 1 { "feature" } else { "features" };
report.messages.push(format!("{varying_count} {subject} lost varying Z coordinates; only the elevation attribute is kept"));
report.messages.push(crate::loss::Note::loss(
crate::loss::LossCode::DroppedZm,
format!("{varying_count} {subject} lost varying Z coordinates; only the elevation attribute is kept"),
));
}
if recovered.unreadable_vertices > 0
&& let Some((_, report)) = layers.first_mut()
Expand Down Expand Up @@ -2650,8 +2653,11 @@ mod tests {
assert_eq!(l[0].0.features.len(), MAX_TOTAL_VERTICES / 200_000);
assert!(l[0].0.zm_dropped);
assert_eq!(
l[0].1.messages.iter().filter(|m| m.contains("varying Z")).collect::<Vec<_>>(),
[&format!("{} features lost varying Z coordinates; only the elevation attribute is kept", l[0].0.features.len())]
l[0].1.messages.iter().filter(|m| m.contains("varying Z")).map(|m| (m.as_str(), m.loss)).collect::<Vec<_>>(),
[(
&*format!("{} features lost varying Z coordinates; only the elevation attribute is kept", l[0].0.features.len()),
Some(crate::loss::LossCode::DroppedZm)
)]
);
assert!(l[0].1.messages.iter().any(|m| m.contains("coordinates")), "{:?}", l[0].1.messages);
}
Expand Down Expand Up @@ -3066,7 +3072,10 @@ mod tests {
} else {
vec![]
};
assert_eq!(report.messages, expected);
assert_eq!(report.messages.texts().collect::<Vec<_>>(), expected);
assert!(
report.messages.iter().filter(|m| m.contains("varying Z")).all(|m| m.loss == Some(crate::loss::LossCode::DroppedZm))
);
let Some(Geometry::Line(parts)) = &ds.features[0].geometry else { panic!("spline line") };
let (start_xy, end_xy) = if tilted {
(Coord::new(0.1, 0.0), Coord::new(end.parse().unwrap(), 3.0))
Expand Down Expand Up @@ -3139,7 +3148,8 @@ mod tests {
assert_eq!(ds.zm_dropped, tilted);
assert_eq!(report.skipped, 0);
let expected = if tilted { vec!["1 feature lost varying Z coordinates; only the elevation attribute is kept"] } else { vec![] };
assert_eq!(report.messages, expected);
assert_eq!(report.messages.texts().collect::<Vec<_>>(), expected);
assert!(report.messages.iter().filter(|m| m.contains("varying Z")).all(|m| m.loss == Some(crate::loss::LossCode::DroppedZm)));
}
}

Expand Down Expand Up @@ -3190,7 +3200,8 @@ mod tests {
assert_eq!(ds.zm_dropped, varying, "rotation={rotation}: {:?}", report.messages);
let expected =
if varying { vec!["1 feature lost varying Z coordinates; only the elevation attribute is kept"] } else { vec![] };
assert_eq!(report.messages, expected);
assert_eq!(report.messages.texts().collect::<Vec<_>>(), expected);
assert!(report.messages.iter().filter(|m| m.contains("varying Z")).all(|m| m.loss == Some(crate::loss::LossCode::DroppedZm)));
assert_eq!(report.skipped, 0);
let Some(Geometry::Line(parts)) = &ds.features[0].geometry else { panic!("rotated line") };
assert_eq!(parts[0].first(), Some(&Coord::new(0.0, 0.0)));
Expand Down Expand Up @@ -3240,7 +3251,11 @@ mod tests {
assert_eq!(ds.value(0, 8), &Value::Float(0.0));
assert!(ds.zm_dropped, "start={start}, offset={offset}");
assert_eq!(report.skipped, 0);
assert_eq!(report.messages, ["1 feature lost varying Z coordinates; only the elevation attribute is kept"]);
assert_eq!(
report.messages.texts().collect::<Vec<_>>(),
["1 feature lost varying Z coordinates; only the elevation attribute is kept"]
);
assert_eq!(report.messages[0].loss, Some(crate::loss::LossCode::DroppedZm));
}
}

Expand Down Expand Up @@ -3289,7 +3304,8 @@ mod tests {
);
assert_eq!(report.messages.len(), if end == "9" { 2 } else { 1 });
if end == "9" {
assert_eq!(report.messages[1], "1 feature lost varying Z coordinates; only the elevation attribute is kept");
assert_eq!(report.messages[1].as_str(), "1 feature lost varying Z coordinates; only the elevation attribute is kept");
assert_eq!(report.messages[1].loss, Some(crate::loss::LossCode::DroppedZm));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/data/src/esripbf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ impl Losses {
}

/// What they say, one message per kind (as [`read`] says them).
pub fn messages(&self) -> Vec<String> {
let mut out = Vec::new();
pub fn messages(&self) -> crate::loss::Notes {
let mut out = crate::loss::Notes::new();
if self.no_crs {
out.push("the answer names no coordinate system; coordinates are read as longitude/latitude".into());
out.push("the answer names no coordinate system; coordinates are read as longitude/latitude");
}
if self.unreadable > 0 {
out.push(format!("{} values don't fit their field's type and are left empty", self.unreadable));
Expand All @@ -171,7 +171,7 @@ impl Losses {
));
}
if self.with_zm > 0 {
out.push(crate::zm_note(Some(self.with_zm as u64)));
out.push(crate::loss::Note::loss(crate::loss::LossCode::DroppedZm, crate::zm_note(Some(self.with_zm as u64))));
}
out
}
Expand Down
4 changes: 2 additions & 2 deletions crates/data/src/esripbf/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn z_and_m_are_dropped_and_said_even_when_they_are_all_alike() {
let (ds, report) = read(&bytes, "t").unwrap();
assert_eq!(ds.features[0].geometry, Some(Geometry::Point(c(4.0, 6.0))));
assert!(ds.zm_dropped);
assert_eq!(report.messages, [crate::zm_note(Some(2))]);
assert_eq!(report.messages, [crate::loss::Note::loss(crate::loss::LossCode::DroppedZm, crate::zm_note(Some(2)))]);
}

#[test]
Expand Down Expand Up @@ -203,7 +203,7 @@ fn a_page_read_within_a_limit_counts_what_the_features_kept_lost() {
]);
let page = read_page_within(&bytes, "t", 1).unwrap();
assert_eq!((page.dataset.features.len(), page.left_out, page.losses.with_zm), (1, 2, 1));
assert_eq!(page.losses.messages(), [crate::zm_note(Some(1))]);
assert_eq!(page.losses.messages(), [crate::loss::Note::loss(crate::loss::LossCode::DroppedZm, crate::zm_note(Some(1)))]);
assert!(page.report.messages.is_empty(), "the losses are said apart: {:?}", page.report.messages);
// Within a limit it doesn't reach, the whole page.
let page = read_page_within(&bytes, "t", 3).unwrap();
Expand Down
7 changes: 5 additions & 2 deletions crates/data/src/export/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ fn a_streamed_web_mercator_export_counts_what_it_writes_at_85_degrees() {
}
}
assert_eq!(
crate::web_mercator_moved_note("polar.gpkg", "polar", 3).as_deref(),
Some("polar.gpkg: 3 vertices of polar are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends")
crate::web_mercator_moved_note("polar.gpkg", "polar", 3),
Some(crate::loss::Note::loss(
crate::loss::LossCode::ChangedPosition,
"polar.gpkg: 3 vertices of polar are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"
))
);
assert_eq!(crate::web_mercator_moved_note("polar.gpkg", "polar", 0), None);
let _ = std::fs::remove_dir_all(d);
Expand Down
5 changes: 4 additions & 1 deletion crates/data/src/gml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,10 @@ pub fn read(file_name: &str, bytes: &[u8]) -> Result<Vec<(Dataset, ReadReport)>>
}
if zm > 0 {
ds.zm_dropped = true;
rep.messages.push(format!("{}: {}", ds.name, crate::zm_note(Some(zm as u64))));
rep.messages.push(crate::loss::Note::loss(
crate::loss::LossCode::DroppedZm,
format!("{}: {}", ds.name, crate::zm_note(Some(zm as u64))),
));
}
if let Some(n) = crate::source::null_text_note(&ds.fields, &null_text) {
rep.messages.push(format!("{}: {n}", ds.name));
Expand Down
57 changes: 38 additions & 19 deletions crates/data/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6386,9 +6386,9 @@ mod tests {
assert_eq!(
rep.messages,
[
crate::zm_note(Some(1)).as_str(),
"1 rows had geometry that isn't readable WKT",
"1 rows have another kind of geometry than the layer's polyline"
crate::loss::Note::loss(crate::loss::LossCode::DroppedZm, crate::zm_note(Some(1))),
"1 rows had geometry that isn't readable WKT".into(),
"1 rows have another kind of geometry than the layer's polyline".into()
]
);
// A named WKT column with a given system.
Expand Down Expand Up @@ -6437,7 +6437,7 @@ mod tests {
assert_eq!(
report.messages,
[
crate::zm_note(Some(1)),
crate::loss::Note::loss(crate::loss::LossCode::DroppedZm, crate::zm_note(Some(1))),
"1 WKT value in 'wkt' lost later non-empty geometry-collection members; only the first non-empty member is kept".into()
]
);
Expand Down Expand Up @@ -6554,8 +6554,11 @@ mod tests {
other.name = "wells".into();
let flat = Dataset::new("roads", GeometryType::Polyline, vec![]);
assert_eq!(
crate::zm_export_note([&ds, &flat, &other], "site.zip").as_deref(),
Some("site.zip: its geometry has no Z or M values for 2 layers (pts, wells), which were dropped when they were read")
crate::zm_export_note([&ds, &flat, &other], "site.zip"),
Some(crate::loss::Note::loss(
crate::loss::LossCode::DroppedZm,
"site.zip: its geometry has no Z or M values for 2 layers (pts, wells), which were dropped when they were read"
))
);
assert_eq!(crate::zm_export_note([&flat], "roads.zip"), None);

Expand All @@ -6578,6 +6581,7 @@ mod tests {
assert!(rep.messages.is_empty(), "{:?}", rep.messages);
assert_eq!(
crate::export_notes([(&utm, ext(&utm)), (&lonlat, ext(&lonlat))], "out.geojson", Crs::LonLat),
// Told by the extent alone: said without a code.
[
"out.geojson: the coordinates of utm aren't longitude/latitude, so they're out of place: define its projection and export again"
]
Expand All @@ -6596,9 +6600,12 @@ mod tests {
let saved: Dataset = serde_json::from_value(serde_json::to_value(&parcels).unwrap()).unwrap();
assert_eq!(
crate::export_notes([(&saved, ext(&saved))], "parcels.geojson", Crs::LonLat),
[format!(
"parcels.geojson: the positions of parcels are approximate, possibly a few hundred metres off: its coordinate system ({}) has no shift to WGS 84",
nad27.label()
[crate::loss::Note::loss(
crate::loss::LossCode::ApproximatedDatum,
format!(
"parcels.geojson: the positions of parcels are approximate, possibly a few hundred metres off: its coordinate system ({}) has no shift to WGS 84",
nad27.label()
)
)]
);
// Written back in NAD 27, the positions come back as they were read.
Expand All @@ -6610,9 +6617,10 @@ mod tests {
shifted.crs = Some(Crs::Epsg(26716));
assert_eq!(
crate::export_notes([&parcels, &roads, &shifted].map(|ds| (ds, ext(ds))), "map.json", Crs::LonLat),
[
[crate::loss::Note::loss(
crate::loss::LossCode::ApproximatedDatum,
"map.json: the positions of 2 layers (parcels, roads) are approximate, possibly a few hundred metres off: their coordinate systems have no shift to WGS 84"
]
)]
);
}

Expand Down Expand Up @@ -6649,7 +6657,10 @@ mod tests {
assert_eq!(merc.features[0].geometry, Some(Geometry::Point(lonlat_to_merc(c(10.0, MAX_LAT)))));
assert_eq!(
crate::export_notes([(&polar, ext(&polar))], "polar.shp", Crs::WebMercator),
["polar.shp: 3 vertices of polar are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"]
[crate::loss::Note::loss(
crate::loss::LossCode::ChangedPosition,
"polar.shp: 3 vertices of polar are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"
)]
);
// In another system, or within 85.05°: nothing.
for crs in [Crs::LonLat, Crs::Epsg(32631)] {
Expand All @@ -6661,13 +6672,17 @@ mod tests {
let one = layer("one", &[c(0.0, 86.0)]);
assert_eq!(
crate::export_notes([(&one, ext(&one))], "one.gpkg", Crs::WebMercator),
["one.gpkg: 1 vertex of one is beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"]
[crate::loss::Note::loss(
crate::loss::LossCode::ChangedPosition,
"one.gpkg: 1 vertex of one is beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"
)]
);
assert_eq!(
crate::export_notes([(&polar, ext(&polar)), (&within, ext(&within)), (&one, ext(&one))], "map.gpkg", Crs::WebMercator),
[
[crate::loss::Note::loss(
crate::loss::LossCode::ChangedPosition,
"map.gpkg: 4 vertices of 2 layers (polar, one) are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"
]
)]
);
// A streamed layer's features are only those in view: its source's extent tells, without
// a count, and only that it reaches beyond, as a source can declare a wider one than its
Expand All @@ -6684,9 +6699,10 @@ mod tests {
// A layer counted and a window told by its extent: one notice, saying both.
assert_eq!(
crate::export_notes([(&polar, ext(&polar)), (&window, Extent::new(-180.0, -90.0, 180.0, 84.0))], "map.gpkg", Crs::WebMercator),
[
[crate::loss::Note::loss(
crate::loss::LossCode::ChangedPosition,
"map.gpkg: 3 vertices of polar are beyond 85.05° north or south, and written at 85.05°; the extent of tiles reaches beyond 85.05° north or south, and what lies beyond is written at 85.05°, where Web Mercator ends"
]
)]
);
// A layer without features that isn't a window (a raster layer's, or a streamed layer's
// written a chunk at a time, whose export counts as it writes) has no extent tell.
Expand Down Expand Up @@ -6725,8 +6741,11 @@ mod tests {
{
assert_eq!(
crate::export_notes([(ds, ext(ds))], &target, Crs::WebMercator),
[format!(
"{target}: {n} vertices of {name} are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"
[crate::loss::Note::loss(
crate::loss::LossCode::ChangedPosition,
format!(
"{target}: {n} vertices of {name} are beyond 85.05° north or south, and written at 85.05°, where Web Mercator ends"
)
)]
);
}
Expand Down
5 changes: 4 additions & 1 deletion crates/data/src/kml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,10 @@ impl Reader {
}
if zm_rows > 0 {
ds.zm_dropped = true;
report.messages.push(format!("{}: {}", ds.name, crate::zm_note(Some(zm_rows as u64))));
report.messages.push(crate::loss::Note::loss(
crate::loss::LossCode::DroppedZm,
format!("{}: {}", ds.name, crate::zm_note(Some(zm_rows as u64))),
));
}
let styles = used.into_iter().filter_map(|id| self.styles.get(&id).map(|s| (id, *s))).collect();
out.push(Layer { dataset: ds, report, styles });
Expand Down
Loading
Loading