From 5e630e5f495c47007d2689a6b070fc0d136b15de Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:45:24 -0500 Subject: [PATCH 1/7] docs(analysis): qualify Points Along Lines, Unsplit Line, Check Geometry Say that a closed line's shared start and end gets one point in Points Along Lines; that Unsplit Line writes each joined chain as its own feature, joins among the selected features only and joins two equal parts sharing both ends into a closed line; and that Check Geometry skips a ring's other point checks when it has non-finite coordinates. --- docs/user-guide/analysis.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/analysis.md b/docs/user-guide/analysis.md index 1e1b33c218..dc289a5e2c 100644 --- a/docs/user-guide/analysis.md +++ b/docs/user-guide/analysis.md @@ -455,7 +455,9 @@ gap between two parts never counts; a line's parts that cross the antimeridian, where the next begins on its other side, as a GeoJSON file splits a line that crosses it, are one line. A ring ends where it starts, so a point there is made once, and a line that ends where it starts (a contour) is walked as a ring too; a part shorter than its offsets gets none. A line that -passes through one place twice gets a point there each time the distance lands on it. Each point +passes through one place twice gets a point there each time the distance lands on it, except at a +closed line's shared start and end, which gets one point (a line through A, B and back to A gets +one at A). Each point has its feature's attributes and three fields: `orig_fid`, the feature's OID, as Feature Vertices To Points writes it, and, named as in QGIS's Points along geometry, `distance` (how far along its part, in `units`, the start offset included) and `angle` (the line's direction there, in degrees @@ -936,7 +938,11 @@ CRS metadata. Coordinates are used directly, without projection or snapping. - **Unsplit Line** (`unsplitLine`) joins line parts at exactly equal endpoints where precisely two part ends meet and all attribute values agree. Reversed parts and closed cycles are supported. Branches, attribute changes, and intersections away from endpoints stay separate. - Every output chain retains its common attributes; no field values are discarded. + Every output chain retains its common attributes; no field values are discarded. Each chain of + joined parts is its own output feature, so a multipart input can become several features. + Joins are decided among the selected features only, when there is a selection: an unselected + part meeting an endpoint neither joins it nor stops a join there. Two parts with equal + attributes that share both endpoints join into one closed line. Missing geometries and empty or too-short parts are skipped with a count. If skipping leaves no usable output, the tool returns an error. Non-finite coordinates and malformed rows with @@ -975,7 +981,7 @@ features were checked. | `rings_intersect` | Two rings of one polygon overlap or touch along a line | | `disconnected_interior` | Rings of one polygon touch at points so that they cut its interior into pieces, such as a hole touching the exterior ring at two points, or three holes each touching the next | | `parts_overlap` | Two polygons of one multipart feature overlap or touch along a line | -| `too_complex` | Some of the feature's checks were left out: it needs more work than the tool spends on one feature, there wasn't enough memory to check it, or the geo library's relate operation failed on some of its rings or parts (`detail` says which of the three, not which rings or parts). The checks of each ring's points still run. The tool says how many features each reason left out | +| `too_complex` | Some of the feature's checks were left out: it needs more work than the tool spends on one feature, there wasn't enough memory to check it, or the geo library's relate operation failed on some of its rings or parts (`detail` says which of the three, not which rings or parts). The checks of each ring's points still run, except in a ring with non-finite coordinates, which is reported for those and skips its other point checks. The tool says how many features each reason left out | Codes are listed in this order, and are never translated. The checks work in stored coordinates, without projection. Lines may cross themselves, so only polygon rings are checked From 83a6a0f2d231539d143cb3071d2f27e75d2a1d57 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:45:29 -0500 Subject: [PATCH 2/7] fix(engine): state the pole search's limits from their constants The radius search's warning repeated 250,000 steps and 512 degrees by hand. Make the analysis constants public and format the warning from them, so the text follows if they change. --- crates/analysis/src/network.rs | 6 +++--- crates/engine/src/cmd/select.rs | 34 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/crates/analysis/src/network.rs b/crates/analysis/src/network.rs index 2cd672a794..47ac1012b5 100644 --- a/crates/analysis/src/network.rs +++ b/crates/analysis/src/network.rs @@ -537,15 +537,15 @@ impl Steps { } /// The longest step, in degrees of longitude or latitude, that [`polar_reach`] follows an edge by. -const REACH_STEP_DEG: f64 = 0.5; +pub const REACH_STEP_DEG: f64 = 0.5; /// The most steps it takes along one edge; one needing more (over 512° long, as only a hostile /// edge is) counts as near as its box. -const REACH_STEPS_MAX: f64 = 1024.0; +pub const REACH_STEPS_MAX: f64 = 1024.0; /// The most steps one search ([`within`]) takes along all its shapes' edges, a point measured /// counting as one; past them, a point or edge counts as near as its box /// ([`least_distance_to_box`]), so a shape may be counted in that's farther than the radius, never /// left out for want of steps. -const REACH_STEPS_TOTAL: usize = 250_000; +pub const REACH_STEPS_TOTAL: usize = 250_000; /// More than a degree of longitude or latitude is long anywhere on the ground (meters): a step's /// length is at most this times the degrees it spans in each. const DEGREE_M_MAX: f64 = 111_700.0; diff --git a/crates/engine/src/cmd/select.rs b/crates/engine/src/cmd/select.rs index 0b91338efc..d488850521 100644 --- a/crates/engine/src/cmd/select.rs +++ b/crates/engine/src/cmd/select.rs @@ -269,12 +269,27 @@ pub(crate) fn warn_bounded(s: &mut Session, bounded: &[(String, usize)]) { } let total: usize = bounded.iter().map(|(_, n)| n).sum(); let layers: Vec = bounded.iter().map(|(layer, n)| format!("{layer} {n}")).collect(); + let steps = grouped(network::REACH_STEPS_TOTAL); + let longest = network::REACH_STEPS_MAX * network::REACH_STEP_DEG; s.warn(format!( - "{total} feature(s) near a pole ({}) couldn't be measured in full (past a search's 250,000 steps a layer, or along an edge over 512° long) and were counted at the least distance they could be: they may lie farther, even beyond the radius", + "{total} feature(s) near a pole ({}) couldn't be measured in full (past a search's {steps} steps a layer, or along an edge over {longest}° long) and were counted at the least distance they could be: they may lie farther, even beyond the radius", layers.join(", ") )); } +/// `n` with its digits in groups of three (`250,000`). +fn grouped(n: usize) -> String { + let digits = n.to_string(); + let mut out = String::with_capacity(digits.len() + digits.len() / 3); + for (i, c) in digits.chars().enumerate() { + if i > 0 && (digits.len() - i).is_multiple_of(3) { + out.push(','); + } + out.push(c); + } + out +} + /// The hit count describes the query, regardless of whether its rows are added or removed. fn apply_hits(s: &mut Session, hits: Vec<(u32, Vec)>, m: Mode) -> CmdResult { if m == Mode::New { @@ -512,6 +527,23 @@ mod tests { use rustgis_data::{Dataset, Field, FieldType, Geometry, GeometryType, Value as DataValue}; use rustgis_geom::{lonlat_to_merc, merc_to_lonlat}; + /// The pole warning states the search's limits from the constants that set them. + #[test] + fn bounded_warning_states_the_search_limits() { + assert_eq!( + [grouped(0), grouped(999), grouped(1000), grouped(250_000), grouped(1_234_567)], + ["0", "999", "1,000", "250,000", "1,234,567"] + ); + let mut s = Session::new(Project::default()); + let mark = s.notices_given(); + warn_bounded(&mut s, &[("Cities".into(), 2)]); + let text = s.notices_since(mark).first().map(|n| n.text.as_str()).unwrap_or_default(); + assert!( + text.contains("2 feature(s) near a pole (Cities 2)") && text.contains("250,000 steps") && text.contains("over 512° long"), + "{text}" + ); + } + fn fixture() -> (Session, u32, u32) { let mut s = Session::new(Project::default()); let mut ds = From 8f29f153417b0fe4c52a69a01a9cde336e3765e5 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:45:35 -0500 Subject: [PATCH 3/7] fix(analysis): count a multipoint's non-finite members in Kernel Density Kernel Density dropped a multipoint's non-finite members silently when its other members were used. Count them and say so in one notice. Also: Repair Geometry's summary and assistant skill entry say that features it can't repair are written unchanged and those left with no area or usable points without geometry; the Buffer and Select By Location notices say outline edges were left unsplit; and a comment no longer says a project can restore a repeated selection row. --- crates/analysis/src/tools.rs | 59 +++++++++++++++---- .../assistant/skills/geoprocessing/SKILL.md | 4 +- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index 10186fdc8f..5521b39b13 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -98,7 +98,7 @@ pub static TOOLS: &[ToolSpec] = &[ id: "repairGeometry", name: "Repair Geometry", toolbox: "Data Management › Features", - summary: "Writes every feature with its geometry made valid: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Says what was repaired in each.", + summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features it cannot repair are written unchanged, and those left with no area or usable points without geometry. Says what was repaired in each.", params: &[ P { name: "input", label: "Input Features", kind: K::VectorLayer, required: true, default: "", help: "" }, P { name: "output", label: "Output Name", kind: K::Text, required: false, default: "", help: "" }, @@ -1512,7 +1512,7 @@ fn buffer_with_limits(inp: &dyn Inputs, p: &Json, limit: usize, bytes: usize) -> } if coarse > 0 { r.messages.push(format!( - "{coarse} of {} features' buffers have edges left longer than their outline allows (a ring of thousands of long edges uses up the points added to it): their sides there can stray from the distance by more than a buffer otherwise keeps to (0.012%, 0.05% along a line or outline buffered in stretches, or 1 cm)", + "{coarse} of {} features' buffers have outline edges left unsplit, with no points added along them (a ring of thousands of long edges uses up the points it may add): their sides there can stray from the distance by more than a buffer otherwise keeps to (0.012%, 0.05% along a line or outline buffered in stretches, or 1 cm)", picked.len() )); } @@ -2342,8 +2342,9 @@ fn size_output_points<'a>( for f in feats { let Some(g) = &f.geometry else { continue }; let k = count(g); - // Saturating, as sizes from input are. A row repeated in the selection (a project can - // restore one) is counted again, and its points are written twice. + // Saturating, as sizes from input are. A row repeated in the selection (only a custom + // `Inputs` can give one: a project's selection is normalized on load) is counted again, + // and its points are written twice. n = n.saturating_add(k); if estimate { let own = f.attrs.get(..kept).unwrap_or(&f.attrs); @@ -3321,7 +3322,7 @@ fn select_by_location_with_work_limit(inp: &dyn Inputs, p: &Json, limit: usize, let coarse = coarse.into_inner(); if coarse > 0 { messages.push(format!( - "{coarse} selecting features' buffers have edges left longer than their outline allows (a ring of thousands of long edges uses up the points added to it): features near their edges there may be selected or not by more than a buffer otherwise keeps to (0.012% of the distance, 0.05% along a line or outline buffered in stretches, or 1 cm)" + "{coarse} selecting features' buffers have outline edges left unsplit, with no points added along them (a ring of thousands of long edges uses up the points it may add): features near their edges there may be selected or not by more than a buffer otherwise keeps to (0.012% of the distance, 0.05% along a line or outline buffered in stretches, or 1 cm)" )); } Ok(ToolResult { output: Output::Selection { layer: ds.name.clone(), rows: hits }, messages }) @@ -3630,6 +3631,9 @@ fn kernel_density_tool(inp: &dyn Inputs, p: &Json) -> Result // which would land on the map's edge rather than where it is (#1033): its latitude doesn't // come back. let mut beyond: usize = 0; + // A multipoint's members with non-finite coordinates, in the features whose other members + // were used (a feature with none usable is counted in `skipped`). + let (mut non_finite, mut non_finite_features) = (0usize, 0usize); let project = |c: Coord, beyond: &mut usize| { // Web Mercator's limit is known exactly: the round trip alone would let a latitude a hair // past it through, onto the edge. @@ -3666,17 +3670,20 @@ fn kernel_density_tool(inp: &dyn Inputs, p: &Json) -> Result } } Geometry::MultiPoint(cs) => { - let mut any = false; + let (mut any, mut bad) = (false, 0usize); for c in cs { - if c.is_finite() - && let Some(p_proj) = project(*c, &mut beyond) - { + if !c.is_finite() { + bad += 1; + } else if let Some(p_proj) = project(*c, &mut beyond) { pts.push((p_proj, w)); any = true; } } if !any { skipped += 1; + } else if bad > 0 { + non_finite = non_finite.saturating_add(bad); + non_finite_features += 1; } } _ => { @@ -3688,6 +3695,9 @@ fn kernel_density_tool(inp: &dyn Inputs, p: &Json) -> Result // Only Web Mercator's limit is known to be a latitude. let why = if crs == Crs::WebMercator { " (past 85.05° of latitude)" } else { "" }; let beyond_note = (beyond > 0).then(|| format!("{beyond} point(s) beyond what {} can hold{why} were left out", crs.label())); + let non_finite_note = (non_finite > 0).then(|| { + format!("{non_finite} point(s) with non-finite coordinates were left out of {non_finite_features} multipoint feature(s) whose other points were used") + }); if pts.is_empty() { let none = "input layer has no valid points with positive weights to analyze"; return Err(beyond_note.map_or_else(|| none.to_string(), |note| format!("{none}: {note}"))); @@ -3753,7 +3763,7 @@ fn kernel_density_tool(inp: &dyn Inputs, p: &Json) -> Result }; Ok(ToolResult { output: Output::Layers(vec![OutputLayer::Raster { file_name: format!("{name}.tif"), name, bytes }]), - messages: std::iter::once(msg).chain(beyond_note).collect(), + messages: std::iter::once(msg).chain(beyond_note).chain(non_finite_note).collect(), }) } @@ -8491,7 +8501,7 @@ mod tests { for dissolve in ["None", "All"] { let params = serde_json::json!({"input": "l", "distance": 1, "units": "Meters", "dissolve": dissolve}); let res = crate::run("buffer", &m, ¶ms).unwrap_or_else(|e| panic!("{e}")); - let said = res.messages.iter().any(|m| m.starts_with("1 of 1 features' buffers have edges left longer")); + let said = res.messages.iter().any(|m| m.starts_with("1 of 1 features' buffers have outline edges left unsplit")); assert_eq!(said, coarse, "dissolve {dissolve}: {:?}", res.messages); } } @@ -8744,6 +8754,33 @@ mod tests { assert!(note.starts_with("1 point(s) beyond what") && !note.contains("85.05°"), "{:?}", res.messages); } + /// A multipoint's non-finite members are left out and counted when its other members are + /// used; a clean multipoint says nothing of the kind. + #[test] + fn kernel_density_counts_a_multipoints_non_finite_members() { + let run = |members: Vec| { + let mut pts = Dataset::new("pts", GeometryType::Point, vec![]); + pts.push(Some(Geometry::Point(Coord::new(0.0, 60.0))), vec![]); + pts.push(Some(Geometry::MultiPoint(members)), vec![]); + let m = Map(HashMap::from([("pts".to_string(), pts)])); + let params = serde_json::json!({"input": "pts", "crs": "EPSG:3857", "radius": 5000.0, "pixelSize": 1000.0}); + crate::run("kernelDensity", &m, ¶ms).map(|r| r.messages).unwrap_or_else(|e| vec![e]) + }; + let lossy = run(vec![Coord::new(0.01, 60.0), Coord::new(f64::NAN, 60.0), Coord::new(0.0, f64::INFINITY)]); + assert!(lossy.iter().any(|m| m.contains("from 2 points (bandwidth")), "{lossy:?}"); + let notes: Vec<_> = lossy.iter().filter(|m| m.contains("non-finite")).collect(); + assert!( + notes.len() == 1 + && notes.iter().all(|m| m.starts_with("2 point(s) with non-finite coordinates were left out of 1 multipoint feature(s)")), + "{lossy:?}" + ); + let clean = run(vec![Coord::new(0.01, 60.0), Coord::new(0.02, 60.0)]); + assert!( + clean.iter().any(|m| m.contains("from 3 points (bandwidth")) && clean.iter().all(|m| !m.contains("non-finite")), + "{clean:?}" + ); + } + #[test] fn kernel_density_analysis_tool_tests() { // Create point dataset with UTM projection diff --git a/crates/assistant/skills/geoprocessing/SKILL.md b/crates/assistant/skills/geoprocessing/SKILL.md index f9d1987b6a..aa10fcbf18 100644 --- a/crates/assistant/skills/geoprocessing/SKILL.md +++ b/crates/assistant/skills/geoprocessing/SKILL.md @@ -27,7 +27,9 @@ Based on the RustGIS user guide, Analysis › Geoprocessing tools `featureEnvelopeToPolygon`, `unsplitLine` (`input`, optional `output`; see the user guide for envelope axes and endpoint-joining rules); `checkGeometry` (`input`: a layer of the features with invalid geometry, saying what is wrong with each); `repairGeometry` (`input`: - every feature with its geometry made valid, and a field saying what was repaired) + every feature with its geometry made valid where it can be, and a field saying what was + repaired; features it cannot repair are written unchanged, those left with no area or + usable points without geometry) - selection: `selectByLocation` (`input`, `select`, `distance`, `invert`), `selectByAttributes` (`input`, `where`) - statistics: `countPoints` (Summarize Within: `polygons`, `points`, `statistics`: summary From 7ac78404d3111c545c48696c4ade3dc6efef325b Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 03:05:59 -0500 Subject: [PATCH 4/7] Address review feedback - Repair Geometry's summary and the geoprocessing skill say that a non-finite coordinate anywhere, even in a hole, writes the feature without geometry, and that the area condition applies to polygons. - The user guide says two parts sharing both endpoints join into one closed line only when no other considered part ends there. - The pole warning uses rustgis_map::graphics::thousands instead of a duplicate grouping helper, and its test derives the limits from the reach constants. - The kernel density multipoint test checks the skipped count of an all-non-finite multipoint and that no projection-limit note appears. --- crates/analysis/src/tools.rs | 5 +++- .../assistant/skills/geoprocessing/SKILL.md | 5 ++-- crates/engine/src/cmd/select.rs | 26 +++++-------------- docs/user-guide/analysis.md | 3 ++- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index 5521b39b13..8617a2fad5 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -98,7 +98,7 @@ pub static TOOLS: &[ToolSpec] = &[ id: "repairGeometry", name: "Repair Geometry", toolbox: "Data Management › Features", - summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features it cannot repair are written unchanged, and those left with no area or usable points without geometry. Says what was repaired in each.", + summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features with a missing or non-finite coordinate anywhere, even in a hole, or left with no usable points or, for polygons, no area, are written without geometry; those it cannot repair are written unchanged. Says what was repaired in each.", params: &[ P { name: "input", label: "Input Features", kind: K::VectorLayer, required: true, default: "", help: "" }, P { name: "output", label: "Output Name", kind: K::Text, required: false, default: "", help: "" }, @@ -8768,12 +8768,15 @@ mod tests { }; let lossy = run(vec![Coord::new(0.01, 60.0), Coord::new(f64::NAN, 60.0), Coord::new(0.0, f64::INFINITY)]); assert!(lossy.iter().any(|m| m.contains("from 2 points (bandwidth")), "{lossy:?}"); + assert!(lossy.iter().all(|m| !m.contains("beyond what")), "{lossy:?}"); let notes: Vec<_> = lossy.iter().filter(|m| m.contains("non-finite")).collect(); assert!( notes.len() == 1 && notes.iter().all(|m| m.starts_with("2 point(s) with non-finite coordinates were left out of 1 multipoint feature(s)")), "{lossy:?}" ); + let unusable = run(vec![Coord::new(f64::NAN, 60.0), Coord::new(0.0, f64::INFINITY)]); + assert!(unusable.iter().any(|m| m.contains("from 1 points (1 skipped, bandwidth")), "{unusable:?}"); let clean = run(vec![Coord::new(0.01, 60.0), Coord::new(0.02, 60.0)]); assert!( clean.iter().any(|m| m.contains("from 3 points (bandwidth")) && clean.iter().all(|m| !m.contains("non-finite")), diff --git a/crates/assistant/skills/geoprocessing/SKILL.md b/crates/assistant/skills/geoprocessing/SKILL.md index aa10fcbf18..dcbe531ace 100644 --- a/crates/assistant/skills/geoprocessing/SKILL.md +++ b/crates/assistant/skills/geoprocessing/SKILL.md @@ -28,8 +28,9 @@ Based on the RustGIS user guide, Analysis › Geoprocessing tools for envelope axes and endpoint-joining rules); `checkGeometry` (`input`: a layer of the features with invalid geometry, saying what is wrong with each); `repairGeometry` (`input`: every feature with its geometry made valid where it can be, and a field saying what was - repaired; features it cannot repair are written unchanged, those left with no area or - usable points without geometry) + repaired; features with a missing or non-finite coordinate, even in a hole, or left with no + usable points or, for polygons, no area are written without geometry; valid points and + lines are kept; features it cannot repair are written unchanged) - selection: `selectByLocation` (`input`, `select`, `distance`, `invert`), `selectByAttributes` (`input`, `where`) - statistics: `countPoints` (Summarize Within: `polygons`, `points`, `statistics`: summary diff --git a/crates/engine/src/cmd/select.rs b/crates/engine/src/cmd/select.rs index d488850521..aa858210d2 100644 --- a/crates/engine/src/cmd/select.rs +++ b/crates/engine/src/cmd/select.rs @@ -269,7 +269,7 @@ pub(crate) fn warn_bounded(s: &mut Session, bounded: &[(String, usize)]) { } let total: usize = bounded.iter().map(|(_, n)| n).sum(); let layers: Vec = bounded.iter().map(|(layer, n)| format!("{layer} {n}")).collect(); - let steps = grouped(network::REACH_STEPS_TOTAL); + let steps = rustgis_map::graphics::thousands(network::REACH_STEPS_TOTAL as f64); let longest = network::REACH_STEPS_MAX * network::REACH_STEP_DEG; s.warn(format!( "{total} feature(s) near a pole ({}) couldn't be measured in full (past a search's {steps} steps a layer, or along an edge over {longest}° long) and were counted at the least distance they could be: they may lie farther, even beyond the radius", @@ -277,19 +277,6 @@ pub(crate) fn warn_bounded(s: &mut Session, bounded: &[(String, usize)]) { )); } -/// `n` with its digits in groups of three (`250,000`). -fn grouped(n: usize) -> String { - let digits = n.to_string(); - let mut out = String::with_capacity(digits.len() + digits.len() / 3); - for (i, c) in digits.chars().enumerate() { - if i > 0 && (digits.len() - i).is_multiple_of(3) { - out.push(','); - } - out.push(c); - } - out -} - /// The hit count describes the query, regardless of whether its rows are added or removed. fn apply_hits(s: &mut Session, hits: Vec<(u32, Vec)>, m: Mode) -> CmdResult { if m == Mode::New { @@ -530,16 +517,17 @@ mod tests { /// The pole warning states the search's limits from the constants that set them. #[test] fn bounded_warning_states_the_search_limits() { - assert_eq!( - [grouped(0), grouped(999), grouped(1000), grouped(250_000), grouped(1_234_567)], - ["0", "999", "1,000", "250,000", "1,234,567"] - ); let mut s = Session::new(Project::default()); let mark = s.notices_given(); warn_bounded(&mut s, &[("Cities".into(), 2)]); let text = s.notices_since(mark).first().map(|n| n.text.as_str()).unwrap_or_default(); assert!( - text.contains("2 feature(s) near a pole (Cities 2)") && text.contains("250,000 steps") && text.contains("over 512° long"), + text.contains("2 feature(s) near a pole (Cities 2)") + && text.contains(&format!( + "past a search's {} steps a layer", + rustgis_map::graphics::thousands(network::REACH_STEPS_TOTAL as f64) + )) + && text.contains(&format!("along an edge over {}° long", network::REACH_STEPS_MAX * network::REACH_STEP_DEG)), "{text}" ); } diff --git a/docs/user-guide/analysis.md b/docs/user-guide/analysis.md index dc289a5e2c..34e3a172a6 100644 --- a/docs/user-guide/analysis.md +++ b/docs/user-guide/analysis.md @@ -942,7 +942,8 @@ CRS metadata. Coordinates are used directly, without projection or snapping. joined parts is its own output feature, so a multipart input can become several features. Joins are decided among the selected features only, when there is a selection: an unselected part meeting an endpoint neither joins it nor stops a join there. Two parts with equal - attributes that share both endpoints join into one closed line. + attributes that share both endpoints join into one closed line when no other considered part + ends there. Missing geometries and empty or too-short parts are skipped with a count. If skipping leaves no usable output, the tool returns an error. Non-finite coordinates and malformed rows with From 5a148d19198ccd37fc11caf9ce8075f8bd369007 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 03:27:27 -0500 Subject: [PATCH 5/7] Address review feedback - Repair Geometry's summary and the geoprocessing skill say that only features too complex to check, or whose repair fails, are written unchanged, and that no area means once repaired. - Check Geometry's guide says a ring with a non-finite coordinate is left out of every other check, in the non_finite_coordinate row rather than the too_complex one. - Unsplit Line's guide limits the closed-line join to open parts. - The kernel density test checks that an unusable multipoint gives no partial-use note. --- crates/analysis/src/tools.rs | 3 ++- crates/assistant/skills/geoprocessing/SKILL.md | 5 +++-- docs/user-guide/analysis.md | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index 8617a2fad5..dd69779cfc 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -98,7 +98,7 @@ pub static TOOLS: &[ToolSpec] = &[ id: "repairGeometry", name: "Repair Geometry", toolbox: "Data Management › Features", - summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features with a missing or non-finite coordinate anywhere, even in a hole, or left with no usable points or, for polygons, no area, are written without geometry; those it cannot repair are written unchanged. Says what was repaired in each.", + summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features with a missing or non-finite coordinate anywhere, even in a hole, or left with no usable points or, for polygons, no area once repaired, are written without geometry; features too complex to check, or whose repair fails, are written unchanged. Says what was repaired in each.", params: &[ P { name: "input", label: "Input Features", kind: K::VectorLayer, required: true, default: "", help: "" }, P { name: "output", label: "Output Name", kind: K::Text, required: false, default: "", help: "" }, @@ -8777,6 +8777,7 @@ mod tests { ); let unusable = run(vec![Coord::new(f64::NAN, 60.0), Coord::new(0.0, f64::INFINITY)]); assert!(unusable.iter().any(|m| m.contains("from 1 points (1 skipped, bandwidth")), "{unusable:?}"); + assert!(unusable.iter().all(|m| !m.contains("were left out of")), "{unusable:?}"); let clean = run(vec![Coord::new(0.01, 60.0), Coord::new(0.02, 60.0)]); assert!( clean.iter().any(|m| m.contains("from 3 points (bandwidth")) && clean.iter().all(|m| !m.contains("non-finite")), diff --git a/crates/assistant/skills/geoprocessing/SKILL.md b/crates/assistant/skills/geoprocessing/SKILL.md index dcbe531ace..1b5996ad50 100644 --- a/crates/assistant/skills/geoprocessing/SKILL.md +++ b/crates/assistant/skills/geoprocessing/SKILL.md @@ -29,8 +29,9 @@ Based on the RustGIS user guide, Analysis › Geoprocessing tools features with invalid geometry, saying what is wrong with each); `repairGeometry` (`input`: every feature with its geometry made valid where it can be, and a field saying what was repaired; features with a missing or non-finite coordinate, even in a hole, or left with no - usable points or, for polygons, no area are written without geometry; valid points and - lines are kept; features it cannot repair are written unchanged) + usable points or, for polygons, no area once repaired are written without geometry; valid + points and lines are kept; features too complex to check, or whose repair fails, are + written unchanged) - selection: `selectByLocation` (`input`, `select`, `distance`, `invert`), `selectByAttributes` (`input`, `where`) - statistics: `countPoints` (Summarize Within: `polygons`, `points`, `statistics`: summary diff --git a/docs/user-guide/analysis.md b/docs/user-guide/analysis.md index 34e3a172a6..74b3dc3ae6 100644 --- a/docs/user-guide/analysis.md +++ b/docs/user-guide/analysis.md @@ -941,9 +941,10 @@ CRS metadata. Coordinates are used directly, without projection or snapping. Every output chain retains its common attributes; no field values are discarded. Each chain of joined parts is its own output feature, so a multipart input can become several features. Joins are decided among the selected features only, when there is a selection: an unselected - part meeting an endpoint neither joins it nor stops a join there. Two parts with equal - attributes that share both endpoints join into one closed line when no other considered part - ends there. + part meeting an endpoint neither joins it nor stops a join there. Two open parts with + equal attributes that share both endpoints join into one closed line when no other considered + part ends there; a part that is already closed has two ends at its endpoint, so it joins + nothing there. Missing geometries and empty or too-short parts are skipped with a count. If skipping leaves no usable output, the tool returns an error. Non-finite coordinates and malformed rows with @@ -973,7 +974,7 @@ features were checked. | Code | What is wrong | | --- | --- | | `null_geometry` | No geometry, or one without coordinates | -| `non_finite_coordinate` | A coordinate is not a number or infinite. The row is written without geometry, so it can't spoil the layer's extent | +| `non_finite_coordinate` | A coordinate is not a number or infinite. The row is written without geometry, so it can't spoil the layer's extent. A ring with one is reported for those coordinates and left out of every other check: its points, its edges' crossings and its containment in other rings | | `too_few_points` | A line part with fewer than 2 distinct points, a ring with fewer than 3, or a polygon part without rings | | `ring_not_closed` | A ring's last point is not its first | | `repeated_vertex` | The same vertex twice in a row (a closed ring's last point doesn't count) | @@ -982,7 +983,7 @@ features were checked. | `rings_intersect` | Two rings of one polygon overlap or touch along a line | | `disconnected_interior` | Rings of one polygon touch at points so that they cut its interior into pieces, such as a hole touching the exterior ring at two points, or three holes each touching the next | | `parts_overlap` | Two polygons of one multipart feature overlap or touch along a line | -| `too_complex` | Some of the feature's checks were left out: it needs more work than the tool spends on one feature, there wasn't enough memory to check it, or the geo library's relate operation failed on some of its rings or parts (`detail` says which of the three, not which rings or parts). The checks of each ring's points still run, except in a ring with non-finite coordinates, which is reported for those and skips its other point checks. The tool says how many features each reason left out | +| `too_complex` | Some of the feature's checks were left out: it needs more work than the tool spends on one feature, there wasn't enough memory to check it, or the geo library's relate operation failed on some of its rings or parts (`detail` says which of the three, not which rings or parts). The checks of each ring's points still run. The tool says how many features each reason left out | Codes are listed in this order, and are never translated. The checks work in stored coordinates, without projection. Lines may cross themselves, so only polygon rings are checked From f7cc6a1f4c00308112d11adcf7bf473f55241a2f Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 03:49:13 -0500 Subject: [PATCH 6/7] Address Claude review feedback - The Buffer and Select By Location notes for coarse outlines name both causes, the points a ring may add running out and a very long edge reaching its halving limit, instead of saying the edges were left unsplit with no points added. --- crates/analysis/src/tools.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index dd69779cfc..cdc3772a2c 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -1512,7 +1512,7 @@ fn buffer_with_limits(inp: &dyn Inputs, p: &Json, limit: usize, bytes: usize) -> } if coarse > 0 { r.messages.push(format!( - "{coarse} of {} features' buffers have outline edges left unsplit, with no points added along them (a ring of thousands of long edges uses up the points it may add): their sides there can stray from the distance by more than a buffer otherwise keeps to (0.012%, 0.05% along a line or outline buffered in stretches, or 1 cm)", + "{coarse} of {} features' buffers have outline edges left with fewer points along them than they need (the points a ring may add ran out, as on a ring of thousands of long edges, or a very long edge was halved as many times as it may be): their sides there can stray from the distance by more than a buffer otherwise keeps to (0.012%, 0.05% along a line or outline buffered in stretches, or 1 cm)", picked.len() )); } @@ -3322,7 +3322,7 @@ fn select_by_location_with_work_limit(inp: &dyn Inputs, p: &Json, limit: usize, let coarse = coarse.into_inner(); if coarse > 0 { messages.push(format!( - "{coarse} selecting features' buffers have outline edges left unsplit, with no points added along them (a ring of thousands of long edges uses up the points it may add): features near their edges there may be selected or not by more than a buffer otherwise keeps to (0.012% of the distance, 0.05% along a line or outline buffered in stretches, or 1 cm)" + "{coarse} selecting features' buffers have outline edges left with fewer points along them than they need (the points a ring may add ran out, as on a ring of thousands of long edges, or a very long edge was halved as many times as it may be): features near their edges there may be selected or not by more than a buffer otherwise keeps to (0.012% of the distance, 0.05% along a line or outline buffered in stretches, or 1 cm)" )); } Ok(ToolResult { output: Output::Selection { layer: ds.name.clone(), rows: hits }, messages }) @@ -8501,7 +8501,7 @@ mod tests { for dissolve in ["None", "All"] { let params = serde_json::json!({"input": "l", "distance": 1, "units": "Meters", "dissolve": dissolve}); let res = crate::run("buffer", &m, ¶ms).unwrap_or_else(|e| panic!("{e}")); - let said = res.messages.iter().any(|m| m.starts_with("1 of 1 features' buffers have outline edges left unsplit")); + let said = res.messages.iter().any(|m| m.starts_with("1 of 1 features' buffers have outline edges left with fewer points")); assert_eq!(said, coarse, "dissolve {dissolve}: {:?}", res.messages); } } From ea8dc97bf6b6ff26fdf9c2edf00d4cb00d274775 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 04:17:03 -0500 Subject: [PATCH 7/7] Address CodeRabbit review feedback - Repair Geometry's summary and the geoprocessing skill say that being written without geometry takes precedence: only other features too complex to check, or whose repair fails, are written unchanged. - The Buffer coarse-outline test checks that the note names both reasons an edge can be left coarse. --- crates/analysis/src/tools.rs | 12 +++++++++--- crates/assistant/skills/geoprocessing/SKILL.md | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index cdc3772a2c..d8a7d3ab9c 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -98,7 +98,7 @@ pub static TOOLS: &[ToolSpec] = &[ id: "repairGeometry", name: "Repair Geometry", toolbox: "Data Management › Features", - summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features with a missing or non-finite coordinate anywhere, even in a hole, or left with no usable points or, for polygons, no area once repaired, are written without geometry; features too complex to check, or whose repair fails, are written unchanged. Says what was repaired in each.", + summary: "Writes every feature with its geometry made valid where it can be: rings closed, repeated vertices and degenerate parts dropped, self-intersections, overlapping parts and holes outside their shell resolved. Features with a missing or non-finite coordinate anywhere, even in a hole, or left with no usable points or, for polygons, no area once repaired, are written without geometry. Other features too complex to check, or whose repair fails, are written unchanged. Says what was repaired in each.", params: &[ P { name: "input", label: "Input Features", kind: K::VectorLayer, required: true, default: "", help: "" }, P { name: "output", label: "Output Name", kind: K::Text, required: false, default: "", help: "" }, @@ -8501,8 +8501,14 @@ mod tests { for dissolve in ["None", "All"] { let params = serde_json::json!({"input": "l", "distance": 1, "units": "Meters", "dissolve": dissolve}); let res = crate::run("buffer", &m, ¶ms).unwrap_or_else(|e| panic!("{e}")); - let said = res.messages.iter().any(|m| m.starts_with("1 of 1 features' buffers have outline edges left with fewer points")); - assert_eq!(said, coarse, "dissolve {dissolve}: {:?}", res.messages); + let note = + res.messages.iter().find(|m| m.starts_with("1 of 1 features' buffers have outline edges left with fewer points")); + assert_eq!(note.is_some(), coarse, "dissolve {dissolve}: {:?}", res.messages); + // The note names both reasons an edge can be left coarse. + assert!( + note.is_none_or(|m| m.contains("the points a ring may add ran out") && m.contains("halved as many times as it may be")), + "{note:?}" + ); } } } diff --git a/crates/assistant/skills/geoprocessing/SKILL.md b/crates/assistant/skills/geoprocessing/SKILL.md index 1b5996ad50..8f3886a362 100644 --- a/crates/assistant/skills/geoprocessing/SKILL.md +++ b/crates/assistant/skills/geoprocessing/SKILL.md @@ -30,8 +30,8 @@ Based on the RustGIS user guide, Analysis › Geoprocessing tools every feature with its geometry made valid where it can be, and a field saying what was repaired; features with a missing or non-finite coordinate, even in a hole, or left with no usable points or, for polygons, no area once repaired are written without geometry; valid - points and lines are kept; features too complex to check, or whose repair fails, are - written unchanged) + points and lines are kept; other features too complex to check, or whose repair fails, + are written unchanged) - selection: `selectByLocation` (`input`, `select`, `distance`, `invert`), `selectByAttributes` (`input`, `where`) - statistics: `countPoints` (Summarize Within: `polygons`, `points`, `statistics`: summary