Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 16 additions & 3 deletions crates/analysis/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5447,10 +5447,11 @@ fn idw_interpolation(inp: &dyn Inputs, p: &Json) -> Result<ToolResult, String> {
losses: left_out
.losses("IDW Interpolation", total, field, "a coordinate is not a finite number")
.into_iter()
.chain(beyond_note.map(projection_point_loss))
.chain(raster_losses(&r))
.collect(),
output: Output::Layers(vec![OutputLayer::Raster { file_name: format!("{name}.tif"), name, bytes }]),
messages: std::iter::once(msg).chain(beyond_note).chain(crs_note).collect(),
messages: std::iter::once(msg).chain(crs_note).collect(),
})
}

Expand Down Expand Up @@ -5607,16 +5608,22 @@ fn kriging_interpolation(inp: &dyn Inputs, p: &Json) -> Result<ToolResult, Strin
losses: left_out
.losses("Ordinary Kriging", total, field, "a coordinate (or, for a line or polygon, its centre) is not a finite number")
.into_iter()
.chain(beyond_note.map(projection_point_loss))
.chain(raster_losses(&r))
.collect(),
output: Output::Layers(vec![
OutputLayer::Raster { file_name: format!("{name}.tif"), name, bytes: pred_bytes },
OutputLayer::Raster { file_name: format!("{var_name}.tif"), name: var_name, bytes: var_bytes },
]),
messages: std::iter::once(msg).chain(beyond_note).chain(crs_note).collect(),
messages: std::iter::once(msg).chain(crs_note).collect(),
})
}

/// A point can be one member of a multipoint feature that still contributes other points.
fn projection_point_loss(text: String) -> rustgis_data::loss::LossMessage {
rustgis_data::loss::LossMessage { code: rustgis_data::loss::LossCode::DroppedGeometry, text }
}

/// How many points or rows Kriging's preparation goes through between two looks at Cancel.
const LOOK_EVERY: usize = 4096;

Expand Down Expand Up @@ -13127,7 +13134,13 @@ mod tests {
for tool in ["idwInterpolation", "kriging"] {
let p = serde_json::json!({"input": "polar", "field": "v", "crs": "EPSG:3857"});
let r = crate::run(tool, &m, &p).unwrap_or_else(|e| panic!("{tool}: {e}"));
assert!(r.messages.iter().any(|m| m.starts_with("1 point(s) beyond what")), "{tool}: {:?}", r.messages);
assert!(
r.losses
.iter()
.any(|n| n.code == rustgis_data::loss::LossCode::DroppedGeometry && n.text.starts_with("1 point(s) beyond what")),
"{tool}: {:?}",
r.losses
);
assert!(!r.messages.iter().any(|m| m.contains("was read in")), "{tool}: {:?}", r.messages);
}
}
Expand Down
10 changes: 8 additions & 2 deletions crates/data/src/loss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,17 @@ loss_codes! {
"A feature's geometry could not be read or written. The feature was kept without its place, or the place was left out.",
"Correct the geometry in the source; when the notice names a coordinate system, give the one its coordinates are in."
),
DroppedMask => (
"dropped.mask",
Dropped,
"A layer's mask was cleared because the destination map has no compatible mask layer by that name.",
"Copy or add the mask layer with the layer it masks."
),
DroppedOverLimit => (
"dropped.over-limit",
Dropped,
"RustGIS read only part of the data because it is past a size limit.",
"Read less at once, such as by filtering or clipping the source first, or keep fewer fields (columns) in it."
"RustGIS included only part of the data because it is past a size limit.",
"Use less data at once, such as by filtering or clipping the source first, or keep fewer fields (columns) in it."
),
ChangedCsvGuard => (
"changed.csv-guard",
Expand Down
19 changes: 11 additions & 8 deletions crates/engine/src/cmd/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,9 +1375,9 @@ struct Mesh {
keep_lines: bool,
/// The estimated size it stops at, and why.
most: (usize, String),
/// Polygons left out because their outer ring has fewer than 3 vertices.
/// Polygon parts with coordinates left out because their outer ring has fewer than 3 vertices.
skipped: usize,
/// Holes left out because they have fewer than 3 vertices, so their areas stay solid.
/// Nonempty holes left out because they have fewer than 3 vertices.
holes_dropped: usize,
/// Polygons and points of zero height left out of STL, which holds solids, not flat sheets,
/// that had an area or a point to lose.
Expand Down Expand Up @@ -1588,16 +1588,15 @@ fn layer_mesh(s: &Session, p: &Value, keep_lines: bool, out: Output<'_>) -> Resu
// A degenerate outer ring drops the polygon (a hole mustn't become solid);
// degenerate holes are left out.
if open.first().is_none_or(|r| r.len() < 3) {
mesh.skipped += 1;
mesh.skipped += usize::from(open.iter().any(|r| !r.is_empty()));
continue;
}
let rings_before = open.len();
mesh.holes_dropped += open.iter().skip(1).filter(|r| !r.is_empty() && r.len() < 3).count();
let mut k = 0;
open.retain(|r| {
k += 1;
k == 1 || r.len() >= 3
});
mesh.holes_dropped += rings_before - open.len();
let Some(outer) = open.first() else { continue };
let n: usize = open.iter().map(Vec::len).sum();
let v = mesh.vertices;
Expand Down Expand Up @@ -1767,14 +1766,18 @@ pub(crate) fn stl_with_cap(s: &Session, p: &Value, cap: usize) -> Result<usize,

/// Says what a layer's mesh left out, or used in place of a feature's own value.
fn mesh_notices(s: &mut Session, mesh: &Mesh) {
use rustgis_data::loss::LossCode;
if mesh.skipped > 0 {
s.notify(format!("Skipped {} polygon(s) whose outer ring has fewer than 3 vertices", mesh.skipped), false);
s.notify_loss(
LossCode::DroppedGeometry,
format!("Skipped {} polygon(s) whose outer ring has fewer than 3 vertices", mesh.skipped).into(),
);
}
if mesh.holes_dropped > 0 {
s.notify(format!("Dropped {} hole(s) with fewer than 3 vertices: their areas are filled in", mesh.holes_dropped), false);
s.notify_loss(LossCode::DroppedRing, format!("Dropped {} hole(s) with fewer than 3 vertices", mesh.holes_dropped).into());
}
if mesh.short_lines > 0 {
s.notify(format!("Skipped {} line part(s) with a single vertex", mesh.short_lines), false);
s.notify_loss(LossCode::DroppedGeometry, format!("Skipped {} line part(s) with a single vertex", mesh.short_lines).into());
}
if let Some(note) = rustgis_data::unplaced_note("The 3D model", &mesh.layer, mesh.unplaced) {
s.say(note);
Expand Down
23 changes: 11 additions & 12 deletions crates/engine/src/cmd/layer_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,22 @@ impl Placed {
/// Says the names cut and the masks lost, after the notice of what was added (`what`: the
/// command).
pub(crate) fn say(&self, s: &mut Session, what: &str) {
use rustgis_data::loss::LossCode;
let (map, names_cut) = (&self.map, self.names_cut);
if names_cut > 0 {
s.notify(
format!("{what}: {names_cut} copied name(s) cut so \" copy\" and a number fit in {} characters", super::MAX_NAME),
false,
s.notify_loss(
LossCode::ChangedCut,
format!("{what}: {names_cut} copied name(s) cut so \" copy\" and a number fit in {} characters", super::MAX_NAME).into(),
);
}
let (polygons, rasters) = self.unmasked.split_at(self.unmasked.len().saturating_sub(self.raster_unmasked));
match polygons {
[] => {}
[one] => s.notify(format!("{one} lost its mask: {map} has no polygon layer by that name"), false),
many => s.notify(format!("{} lost their masks: {map} has no polygon layers by those names", many.join(", ")), false),
}
match rasters {
[] => {}
[one] => s.notify(format!("{one} lost its mask: {map} has no raster layer by that name"), false),
many => s.notify(format!("{} lost their masks: {map} has no raster layers by those names", many.join(", ")), false),
for (kind, layers) in [("polygon", polygons), ("raster", rasters)] {
let text = match layers {
[] => continue,
[one] => format!("{one} lost its mask: {map} has no {kind} layer by that name"),
many => format!("{} lost their masks: {map} has no {kind} layers by those names", many.join(", ")),
};
s.notify_loss(LossCode::DroppedMask, text.into());
}
}
}
Expand Down
Loading
Loading