From ca8694a52a486519282406344579a77e35d8fc57 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:28:00 -0500 Subject: [PATCH 01/11] fix(data): count ArcGIS pbf notices for what the layer keeps A repeated field of an unknown type was said both to be left out and to be read as text; it is now counted only as left out. The UTF-8 notice names aliases, which its count includes. --- crates/data/src/esripbf.rs | 8 ++++---- crates/data/src/esripbf/tests.rs | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/data/src/esripbf.rs b/crates/data/src/esripbf.rs index 617dc6a18b..c580a2109c 100644 --- a/crates/data/src/esripbf.rs +++ b/crates/data/src/esripbf.rs @@ -124,7 +124,7 @@ pub struct Losses { pub no_crs: bool, /// Values that don't fit their field's type. pub unreadable: usize, - /// Values or field names that aren't valid UTF-8. + /// Values, field names or aliases that aren't valid UTF-8. pub not_utf8: usize, /// Polygon rings without area. pub flat_rings: usize, @@ -156,7 +156,7 @@ impl Losses { } if self.not_utf8 > 0 { out.push(format!( - "{} values or field names aren't valid UTF-8; the bytes that can't be read are replaced with U+FFFD", + "{} values, field names or aliases aren't valid UTF-8; the bytes that can't be read are replaced with U+FFFD", self.not_utf8 )); } @@ -282,13 +282,13 @@ pub fn read_page_within(bytes: &[u8], name: &str, limit: usize) -> Result columns.push(None); continue; }; - unknown += usize::from(number > LAST_FIELD_TYPE); // Fields are found by name whatever its case, so the first of a name keeps it. if !names.insert(name.to_lowercase()) { repeated += 1; columns.push(None); continue; } + unknown += usize::from(number > LAST_FIELD_TYPE); if number == OID && object_id_field.is_none() { object_id_field = Some(fields.len()); } @@ -726,7 +726,7 @@ struct Tally { unreadable: usize, /// Polygon rings without area. flat_rings: usize, - /// Text values and field names that aren't valid UTF-8. + /// Text values, field names and aliases that aren't valid UTF-8. not_utf8: usize, /// Bytes left of [`MAX_GEOMETRY_BYTES`]. geometry_room: usize, diff --git a/crates/data/src/esripbf/tests.rs b/crates/data/src/esripbf/tests.rs index 3958d49d68..70816e71cc 100644 --- a/crates/data/src/esripbf/tests.rs +++ b/crates/data/src/esripbf/tests.rs @@ -271,7 +271,10 @@ fn text_that_isnt_utf8_is_read_with_replacements_and_said() { assert_eq!(ds.fields[0].name, "N\u{FFFD}AME"); assert_eq!(ds.features[0].attrs, [Value::Text("a\u{FFFD}b".into())]); assert_eq!(ds.features[1].attrs, [Value::Text("ok".into())]); - assert_eq!(report.messages, ["2 values or field names aren't valid UTF-8; the bytes that can't be read are replaced with U+FFFD"]); + assert_eq!( + report.messages, + ["2 values, field names or aliases aren't valid UTF-8; the bytes that can't be read are replaced with U+FFFD"] + ); } #[test] @@ -594,6 +597,15 @@ fn a_field_type_rustgis_doesnt_know_is_read_as_text_and_said() { assert!(report.messages.is_empty(), "{:?}", report.messages); } +#[test] +fn a_repeated_field_of_an_unknown_type_is_only_said_left_out() { + // The repeat is dropped, so it isn't also said to be read as text. + let bytes = answer(&[field("NAME", 4), field("name", 17), feature(&[text("a"), uint(5)])]); + let (ds, report) = read(&bytes, "t").unwrap(); + assert_eq!(ds.fields.len(), 1); + assert_eq!(report.messages, ["1 fields repeat an earlier field's name and are left out"]); +} + #[test] fn text_is_taken_from_the_room_at_its_size_once_read_before_it_is_made() { // Each byte that isn't UTF-8 becomes U+FFFD, three bytes. From 1efcae37b93d6bd67a94ea80a6182f1ccd9070d6 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:28:09 -0500 Subject: [PATCH 02/11] fix(data): name a zero-size FlatGeobuf feature in its error A zero size prefix failed later as an invalid size prefix; it is now refused as a zero-size feature. --- crates/data/src/source/fgb/checked.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/data/src/source/fgb/checked.rs b/crates/data/src/source/fgb/checked.rs index 585a31633e..39ccaa2701 100644 --- a/crates/data/src/source/fgb/checked.rs +++ b/crates/data/src/source/fgb/checked.rs @@ -126,6 +126,9 @@ impl Read for Guard { let size = <[u8; 4]>::try_from(&*buf) .map(u32::from_le_bytes) .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "an invalid feature size prefix"))?; + if size == 0 { + return Err(io::Error::new(io::ErrorKind::InvalidData, "a zero-size feature")); + } let size = u64::from(size); let remaining = self.end.map(|end| end.saturating_sub(self.pos)).unwrap_or(u64::MAX).min(super::remote::READ_BUDGET); if size > remaining || usize::try_from(size).ok().and_then(|n| n.checked_add(4)).is_none() { @@ -181,4 +184,20 @@ mod tests { assert!(error.to_string().contains("read budget")); assert!(guard.failure.borrow().is_some()); } + + #[test] + fn a_zero_size_prefix_is_named() { + let mut guard = Guard { + input: io::Cursor::new(0u32.to_le_bytes()), + pos: 0, + end: Some(4), + start: Rc::new(Cell::new(0)), + next: None, + failure: Failure::default(), + }; + let error = guard.read_exact(&mut [0; 4]).unwrap_err(); + assert_eq!(error.kind(), io::ErrorKind::InvalidData); + assert_eq!(error.to_string(), "a zero-size feature"); + assert!(guard.failure.borrow().is_some()); + } } From dec4e4496e08eaed967353eab2c7e2e0d9884da7 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:28:15 -0500 Subject: [PATCH 03/11] fix(data): leave other tables' spatial index triggers out of a replace Replacing a GeoPackage table named parcels listed the rtree triggers of parcels_2 as objects that may no longer work, as their SQL contains the name. A table's own rtree__ triggers are now left out. --- crates/data/src/source/gpkg/add.rs | 8 ++++++-- crates/data/src/source/tests.rs | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/data/src/source/gpkg/add.rs b/crates/data/src/source/gpkg/add.rs index 1611fcc958..b324783a5f 100644 --- a/crates/data/src/source/gpkg/add.rs +++ b/crates/data/src/source/gpkg/add.rs @@ -234,12 +234,16 @@ fn related(conn: &Connection, table: &str) -> Result { } /// The views, and triggers on other tables, whose SQL mentions `table` (by a case-blind search, -/// so a longer name containing it counts too), by name. +/// so a longer name containing it counts too), by name. Another table's own spatial index +/// triggers (`rtree__…` on ``) touch only that table and its index, so they're left +/// out: replacing `parcels` doesn't name `parcels_2`'s. fn dependents(conn: &Connection, table: &str) -> Result> { let mut st = conn .prepare( "SELECT name FROM sqlite_master WHERE type IN ('view', 'trigger') AND lower(tbl_name) != lower(?1) - AND instr(lower(sql), lower(?1)) > 0 ORDER BY name", + AND instr(lower(sql), lower(?1)) > 0 + AND NOT (type = 'trigger' AND lower(substr(name, 1, length(tbl_name) + 7)) = 'rtree_' || lower(tbl_name) || '_') + ORDER BY name", ) .map_err(err)?; let names = st.query_map([table], |r| r.get::<_, String>(0)).map_err(err)?; diff --git a/crates/data/src/source/tests.rs b/crates/data/src/source/tests.rs index 390a82ae62..b72df946b1 100644 --- a/crates/data/src/source/tests.rs +++ b/crates/data/src/source/tests.rs @@ -2754,6 +2754,10 @@ fn geopackage_export_adds_and_replaces_tables_and_keeps_the_others() { // A second table in that system reuses its entry. let more = write_path_to(&fewer, &path, Crs::WebMercator, &to(GpkgMode::AddTable, Some("permits_2027"))).unwrap(); assert_eq!(more.1, Some(GpkgWritten { table: "permits_2027".into(), replaced: false, dependents: vec![] })); + // Its spatial index triggers mention `permits` within their own table's name, but don't use + // it, so replacing `permits` again names only the view. + let again = write_path_to(&fewer, &path, Crs::WebMercator, &to(GpkgMode::ReplaceTable, Some("permits"))).unwrap(); + assert_eq!(again.1, Some(GpkgWritten { table: "permits".into(), replaced: true, dependents: vec!["recent_permits".into()] })); // Replacing a table not there (a misspelt name) is refused rather than adding one. let e = write_path_to(&fewer, &path, Crs::LonLat, &to(GpkgMode::ReplaceTable, Some("permit"))).unwrap_err().to_string(); assert!(e.contains("no table permit to replace"), "{e}"); From d62b9c78edee98de9ea57b4a478187da7335e9a3 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:28:15 -0500 Subject: [PATCH 04/11] fix(data): say which Shapefiles in a zip pass the layer limit A zip with more than 32 Shapefiles dropped the rest without a notice; each is now listed as past the limit, as other members are. --- crates/data/src/io.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/data/src/io.rs b/crates/data/src/io.rs index 24095cbcd6..c288750a7c 100644 --- a/crates/data/src/io.rs +++ b/crates/data/src/io.rs @@ -2022,7 +2022,8 @@ pub fn read_zip_in(file_name: &str, bytes: &[u8], crs: Option) -> Result = Vec::new(); for n in shps { if out.len() >= MAX_ZIP_LAYERS { - break; + skipped.push(format!("{n} (past the {MAX_ZIP_LAYERS}-layer limit)")); + continue; } let base = stem(&n); let name = Path::new(&n).file_stem().and_then(|s| s.to_str()).unwrap_or("layer").to_string(); @@ -3490,6 +3491,19 @@ mod tests { } // A .shp alone is refused with a hint to zip it. assert!(read_bytes("x.shp", &entries[0].1).is_err()); + // Shapefiles past the layer limit are named, not dropped unsaid; at the limit nothing is said. + let shapefiles = |count: usize| -> Vec<(String, Vec)> { + (0..count).flat_map(|i| entries.iter().take(3).map(move |(n, b)| (format!("s{i:02}.{}", ext(n)), b.clone()))).collect() + }; + fn ext(n: &str) -> String { + n.rsplit('.').next().unwrap_or_default().to_ascii_lowercase() + } + let layers = read_zip("x.zip", &crate::zip::write(&shapefiles(MAX_ZIP_LAYERS + 2)).unwrap()).unwrap(); + assert_eq!(layers.len(), MAX_ZIP_LAYERS); + assert_eq!(layers[0].1.messages, ["x.zip: skipped s32.shp (past the 32-layer limit); s33.shp (past the 32-layer limit)"]); + let layers = read_zip("x.zip", &crate::zip::write(&shapefiles(MAX_ZIP_LAYERS)).unwrap()).unwrap(); + assert_eq!(layers.len(), MAX_ZIP_LAYERS); + assert!(layers.iter().all(|(_, r)| r.messages.is_empty()), "{:?}", layers[0].1.messages); } /// A Shapefile's loose files picked or dropped together are zipped into one, which reads as a From dd3f95d6eeda400dcfff037b59724cebb46c0746 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:28:22 -0500 Subject: [PATCH 05/11] docs(data): correct label_point, covering, CRS and listing notes label_point lists every case it returns None, the GeoParquet covering comments allow a null box for an empty geometry, coordinate_system no longer says only EPSG systems, and the OGC API listing note says each collection can make up to three layers. --- crates/data/src/geometry.rs | 4 +++- crates/data/src/ogc.rs | 8 +++++--- crates/data/src/source/mod.rs | 4 ++-- crates/data/src/source/parquet.rs | 5 +++-- docs/user-guide/data-formats.md | 5 +++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/crates/data/src/geometry.rs b/crates/data/src/geometry.rs index 2e980d58f4..b7136b170e 100644 --- a/crates/data/src/geometry.rs +++ b/crates/data/src/geometry.rs @@ -214,7 +214,9 @@ impl Geometry { /// A point for a label or a pop-up: the point itself, the middle vertex of the longest line /// part, or the centroid of the largest valid polygon (moved inside it if the centroid falls out). /// - /// Returns `None` if the geometry is empty or if all polygon parts contain non-finite coordinates. + /// Returns `None` if the geometry is empty (no points, no line vertices), if no polygon part + /// has an outer ring that is finite and not empty, or if the chosen part's centroid isn't + /// finite. pub fn label_point(&self) -> Option { match self { Geometry::Point(c) => Some(*c), diff --git a/crates/data/src/ogc.rs b/crates/data/src/ogc.rs index 189ad0893c..4a8d098e26 100644 --- a/crates/data/src/ogc.rs +++ b/crates/data/src/ogc.rs @@ -462,9 +462,11 @@ pub struct Service { pub past_read_limit: Option, } -/// Most layers or collections `service.layers` lists from one document. The others are still read -/// ([`Service::listed`]), so that they can be added by name: which ones come first is up to the -/// server, and some change their order between answers (#1519). +/// Most layers or collections `service.layers` lists from one document. An OGC API collection +/// can make up to three layers (features, map tiles, vector tiles), so its listing can pass this +/// many layers. The others are still read ([`Service::listed`]), so that they can be added by +/// name: which ones come first is up to the server, and some change their order between answers +/// (#1519). const MAX_LISTED_LAYERS: usize = 2_000; /// Most layers or collections read from one document, which is hostile input. const MAX_READ_LAYERS: usize = if cfg!(test) { 3_000 } else { 100_000 }; diff --git a/crates/data/src/source/mod.rs b/crates/data/src/source/mod.rs index 82a92e2344..a8abc5d936 100644 --- a/crates/data/src/source/mod.rs +++ b/crates/data/src/source/mod.rs @@ -203,8 +203,8 @@ impl SourceInfo { self.notes.push(format!("{n} column{} {what}: {}{more}", if n == 1 { "" } else { "s" }, named.join(", "))); } - /// The source's coordinate system, when it isn't longitude/latitude and is known by its EPSG - /// code. + /// The source's coordinate system, when it isn't longitude/latitude: one known by its EPSG + /// code or a custom one without. pub fn coordinate_system(&self) -> Option { Crs::parse(&self.crs).ok().filter(|c| *c != Crs::LonLat) } diff --git a/crates/data/src/source/parquet.rs b/crates/data/src/source/parquet.rs index a3209c48e6..3911233083 100644 --- a/crates/data/src/source/parquet.rs +++ b/crates/data/src/source/parquet.rs @@ -43,7 +43,8 @@ pub struct ParquetSource { field_cols: Vec, /// Leaf column indices of the bbox covering's xmin, ymin, xmax, ymax. covering: Option<[usize; 4]>, - /// The metadata declares the covering, whose null boxes then imply null geometry. + /// The metadata declares the covering, whose null boxes then mean no geometry or an empty + /// one, neither of which meets an extent. declared_covering: bool, reproject: Reproject, /// The file, when it is read by its web address. @@ -343,7 +344,7 @@ impl ParquetSource { /// Whether inferred bounds may omit or count rows that only their geometry can test. /// Unknown null counts require the same fallback as known nulls; declared coverings promise - /// that a box is present if and only if geometry is present. + /// that a box is present if and only if a non-empty geometry is present. fn needs_geometry_filter(&self, md: &ParquetMetaData, g: usize) -> bool { let Some(c) = self.covering else { return true }; !self.declared_covering diff --git a/docs/user-guide/data-formats.md b/docs/user-guide/data-formats.md index 501084c1e5..230355b6b1 100644 --- a/docs/user-guide/data-formats.md +++ b/docs/user-guide/data-formats.md @@ -310,8 +310,9 @@ Scripts use `service.import {"url":"…","name":"My OGC Layer"}` and | WCS 1.0 / 2.0 (a 1.1 service is asked in 1.0) | Coverages, with their bounds | A raster: GetCoverage of the map's view within the coverage's bounds (or its whole extent: `"bbox": "full"`), as a GeoTIFF in EPSG:4326, at most 2048 pixels on a side | | ArcGIS REST | FeatureServer and MapServer layers; a MapServer's map; an ImageServer; a VectorTileServer | Layers queried as GeoJSON, or in protocol buffers (`f=pbf`, smaller and quicker to read) when the layer's description lists them and names its record limit (the description read first, or given up on after 15 seconds; a first protocol buffer page that can't be fetched or read has the layer read in GeoJSON, with a notice saying why), page by page past the server's record limit (`resultOffset`) up to 100,000 features or more on a computer with more memory (in protocol buffers, also no more than a quarter of the computer's memory once read, from 512 MB, the web app's limit, up to 3 GB; a later page past it ends the read with a notice, and the first page is always kept, within the reader's own limits for a page) (a command such as `service.add` waits a minute at most for the features), where the layer supports paging (ArcGIS Server 10.3 and later; otherwise up to the record limit); a map as its tile cache when it is Web Mercator's pyramid, else exported images; an ImageServer as exported images; a VectorTileServer as its MapLibre style | -A long list stops at its first 2,000 layers (for OGC API, collections), and a note says how many -the service has. Which ones come first is up to the service, and some change their order between +A long list stops at its first 2,000 layers, and a note says how many the service has. An OGC +API service stops at its first 2,000 collections instead, and each can make up to three layers +(features, map tiles and vector tiles), so its list can be longer. Which ones come first is up to the service, and some change their order between answers. `service.add` still takes any of them by name, up to 100,000 in one document, fewer (but at least 2,000) when the document's request address (an OGC API's, its own), which each layer's repeats, is very long. An ArcGIS service or directory is an exception: it is read up to From 37ba9960ea3ad060f740fb5fdef335f2efd73467 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:38:47 -0500 Subject: [PATCH 06/11] fix(engine): say which features an interpolation leaves out analysis.interpolate dropped features without a label point or a numeric value without a word. It now gives one notice with a count of each kind, and the answer's skipped field holds the counts. --- crates/engine/src/cmd/workflows.rs | 42 +++++++++++++++++++++++++----- crates/engine/src/tests.rs | 32 +++++++++++++++++++++++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/workflows.rs b/crates/engine/src/cmd/workflows.rs index 5f5f0f1139..a21ae427d0 100644 --- a/crates/engine/src/cmd/workflows.rs +++ b/crates/engine/src/cmd/workflows.rs @@ -1036,12 +1036,21 @@ fn interpolate_work(s: &Session, p: &Value) -> Result { let ds = feature_ds(s, p)?; let field = ps(p, "field").ok_or("field is required")?; let fi = ds.field_index(field).ok_or_else(|| format!("no field named '{field}'"))?; - let pts: Vec<(Coord, f64)> = ds - .features - .iter() - .enumerate() - .filter_map(|(r, ft)| Some((ft.geometry.as_ref()?.label_point()?, ds.value(r, fi).as_f64().filter(|v| v.is_finite())?))) - .collect(); + // Features without a place or a number are left out, and said (by kind, with a count). + let (mut no_point, mut no_value) = (0usize, 0usize); + let mut pts: Vec<(Coord, f64)> = Vec::with_capacity(ds.features.len()); + for (r, ft) in ds.features.iter().enumerate() { + let Some(c) = ft.geometry.as_ref().and_then(|g| g.label_point()) else { + no_point += 1; + continue; + }; + let Some(v) = ds.value(r, fi).as_f64().filter(|v| v.is_finite()) else { + no_value += 1; + continue; + }; + pts.push((c, v)); + } + let (layer_name, field_name) = (ds.name.clone(), field.to_string()); let e = s.project.gp_env.extent.unwrap_or_else(|| { let mut e = Extent::EMPTY; pts.iter().for_each(|(c, _)| e.expand(*c)); @@ -1051,7 +1060,26 @@ fn interpolate_work(s: &Session, p: &Value) -> Result { let name = out_name(p, format!("{}_{field}_idw", ds.name)); let power = f(p, "power").unwrap_or(2.0).clamp(0.5, 10.0); let neighbors = p.get("neighbors").and_then(Value::as_u64).unwrap_or(12).max(1) as usize; - Ok(Box::new(move || made(rasterops::idw(&pts, &e, cell, power, neighbors, &name)?, None))) + Ok(Box::new(move || { + let m = made(rasterops::idw(&pts, &e, cell, power, neighbors, &name)?, None)?; + if no_point == 0 && no_value == 0 { + return Ok(m); + } + let then: Then = Box::new(move |s: &mut Session, v: &mut Value| { + let mut why = Vec::new(); + if no_point > 0 { + why.push(format!("{no_point} with no geometry or no finite coordinates")); + } + if no_value > 0 { + why.push(format!("{no_value} whose {field_name} isn't a number")); + } + s.notify(format!("{layer_name}: features left out of the surface: {}", why.join(", ")), false); + if let Some(o) = v.as_object_mut() { + o.insert("skipped".into(), json!({"noPoint": no_point, "noValue": no_value})); + } + }); + Ok(Made { then: Some(then), ..m }) + })) } /// Creates a route layer and reports invalid source segments omitted from its network. diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index c488a4749c..356592ae0f 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -33084,3 +33084,35 @@ fn topology_refuses_latitudes_past_the_poles() { } } } + +/// `analysis.interpolate` says how many features it leaves out, and why: those with no place to +/// stand for and those whose value isn't a number. A layer it reads whole says nothing. +#[test] +fn interpolation_says_the_features_it_leaves_out() { + use rustgis_data::{Dataset, Field, FieldType, Geometry, GeometryType, Value as V}; + use rustgis_geom::Coord; + let mut s = world(); + let mut wells = Dataset::new("wells", GeometryType::Point, vec![Field::new("depth", FieldType::Double)]); + for (i, depth) in [10.0, 20.0, 30.0].into_iter().enumerate() { + wells.push(Some(Geometry::Point(Coord::new(i as f64, i as f64))), vec![V::Float(depth)]); + } + crate::cmd::layer::add_dataset(&mut s, wells.clone()); + let mark = s.notice_mark(); + let v = s.run("analysis.interpolate", &json!({"layer": "wells", "field": "depth", "cellSize": 0.5})).unwrap(); + assert!(v.get("skipped").is_none(), "{v}"); + assert!(s.notices_since(mark).iter().all(|n| !n.text.contains("left out")), "{:?}", s.notices_since(mark)); + + wells.name = "lossy wells".into(); + wells.push(None, vec![V::Float(40.0)]); + wells.push(Some(Geometry::Point(Coord::new(f64::NAN, 1.0))), vec![V::Float(50.0)]); + wells.push(Some(Geometry::Point(Coord::new(1.5, 0.5))), vec![V::Null]); + crate::cmd::layer::add_dataset(&mut s, wells); + let mark = s.notice_mark(); + let v = s.run("analysis.interpolate", &json!({"layer": "lossy wells", "field": "depth", "cellSize": 0.5})).unwrap(); + assert_eq!(v["skipped"], json!({"noPoint": 2, "noValue": 1}), "{v}"); + let said: Vec<_> = s.notices_since(mark).iter().filter(|n| n.text.contains("left out")).map(|n| n.text.clone()).collect(); + assert_eq!( + said, + ["lossy wells: features left out of the surface: 2 with no geometry or no finite coordinates, 1 whose depth isn't a number"] + ); +} From 15b7a1ab5d702db858eefdff4d4444f0881f6c34 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 01:20:27 -0500 Subject: [PATCH 07/11] test(data): give the zip limit test's Shapefiles their .prj Without it each layer also said its coordinates were assumed to be longitude/latitude, which isn't what the test checks. --- crates/data/src/io.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/data/src/io.rs b/crates/data/src/io.rs index c288750a7c..242933f18b 100644 --- a/crates/data/src/io.rs +++ b/crates/data/src/io.rs @@ -3493,7 +3493,7 @@ mod tests { assert!(read_bytes("x.shp", &entries[0].1).is_err()); // Shapefiles past the layer limit are named, not dropped unsaid; at the limit nothing is said. let shapefiles = |count: usize| -> Vec<(String, Vec)> { - (0..count).flat_map(|i| entries.iter().take(3).map(move |(n, b)| (format!("s{i:02}.{}", ext(n)), b.clone()))).collect() + (0..count).flat_map(|i| entries.iter().take(4).map(move |(n, b)| (format!("s{i:02}.{}", ext(n)), b.clone()))).collect() }; fn ext(n: &str) -> String { n.rsplit('.').next().unwrap_or_default().to_ascii_lowercase() From 1ba692ae64753e9e5e682a1dd16cd4e55b43d425 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 01:36:46 -0500 Subject: [PATCH 08/11] fix(engine): leave out interpolation points with non-finite coordinates A point's label point is the point itself, NaN or not, so such a point reached the IDW surface; it is now counted with those that have no place. --- crates/engine/src/cmd/workflows.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/workflows.rs b/crates/engine/src/cmd/workflows.rs index a21ae427d0..8e86691d60 100644 --- a/crates/engine/src/cmd/workflows.rs +++ b/crates/engine/src/cmd/workflows.rs @@ -1040,7 +1040,7 @@ fn interpolate_work(s: &Session, p: &Value) -> Result { let (mut no_point, mut no_value) = (0usize, 0usize); let mut pts: Vec<(Coord, f64)> = Vec::with_capacity(ds.features.len()); for (r, ft) in ds.features.iter().enumerate() { - let Some(c) = ft.geometry.as_ref().and_then(|g| g.label_point()) else { + let Some(c) = ft.geometry.as_ref().and_then(|g| g.label_point()).filter(|c| c.is_finite()) else { no_point += 1; continue; }; From 76b8db049e22bfd3702c01b372eb0802f46755fe Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 05:29:17 -0500 Subject: [PATCH 09/11] Address review feedback - label_point: say a polygon part with a non-finite hole is left out whole. - SourceInfo::coordinate_system: say None also covers a CRS that doesn't parse. - read_zip: name at most 20 skipped members and count the rest, so a huge archive can't grow the notice without bound; test that MapInfo files past the layer limit are named once each. - analysis.interpolate: when no surface can be made, the error says how many features were left out and why. --- crates/data/src/geometry.rs | 4 ++-- crates/data/src/io.rs | 26 ++++++++++++++++++++++++++ crates/data/src/source/mod.rs | 2 +- crates/engine/src/cmd/workflows.rs | 12 +++++++++++- crates/engine/src/tests.rs | 8 ++++++++ 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/crates/data/src/geometry.rs b/crates/data/src/geometry.rs index b7136b170e..ed09623c68 100644 --- a/crates/data/src/geometry.rs +++ b/crates/data/src/geometry.rs @@ -215,8 +215,8 @@ impl Geometry { /// part, or the centroid of the largest valid polygon (moved inside it if the centroid falls out). /// /// Returns `None` if the geometry is empty (no points, no line vertices), if no polygon part - /// has an outer ring that is finite and not empty, or if the chosen part's centroid isn't - /// finite. + /// has only finite coordinates and a non-empty outer ring (a part with a non-finite hole is + /// left out whole), or if the chosen part's centroid isn't finite. pub fn label_point(&self) -> Option { match self { Geometry::Point(c) => Some(*c), diff --git a/crates/data/src/io.rs b/crates/data/src/io.rs index 242933f18b..ea00e073c3 100644 --- a/crates/data/src/io.rs +++ b/crates/data/src/io.rs @@ -2047,6 +2047,7 @@ pub fn read_zip_in(file_name: &str, bytes: &[u8], crs: Option) -> Result = entries.iter().flatten().filter(|(n, _)| ext_of(n) == "mif").map(|(n, _)| n.clone()).collect(); mifs.sort(); for n in mifs { + // The `.mif` files not taken stay in `entries`, so the loop below names them as past the limit. if out.len() >= MAX_ZIP_LAYERS { break; } @@ -2090,6 +2091,16 @@ pub fn read_zip_in(file_name: &str, bytes: &[u8], crs: Option) -> Result skipped.push(format!("{n} ({e})")), } } + // At most this many skipped members are named; the rest are counted. + const NAMED_SKIPPED: usize = 20; + let skipped = if skipped.len() > NAMED_SKIPPED { + let more = skipped.len() - NAMED_SKIPPED; + let mut named: Vec = skipped.into_iter().take(NAMED_SKIPPED).collect(); + named.push(format!("and {more} more")); + named + } else { + skipped + }; if out.is_empty() { let why = if skipped.is_empty() { String::new() } else { format!(": {}", skipped.join("; ")) }; return Err(DataError::Format(format!("{file_name}: no Shapefile or other vector data in the archive could be read{why}"))); @@ -3504,6 +3515,21 @@ mod tests { let layers = read_zip("x.zip", &crate::zip::write(&shapefiles(MAX_ZIP_LAYERS)).unwrap()).unwrap(); assert_eq!(layers.len(), MAX_ZIP_LAYERS); assert!(layers.iter().all(|(_, r)| r.messages.is_empty()), "{:?}", layers[0].1.messages); + // MapInfo files past the limit are named too (by the loop over the other members, which + // they're left to), once each. + let mif = b"Version 300\nColumns 1\n id Integer\nData\nPoint 1 2\n".to_vec(); + let mifs = |count: usize| -> Vec<(String, Vec)> { + (0..count).flat_map(|i| [(format!("m{i:02}.mif"), mif.clone()), (format!("m{i:02}.mid"), b"1\n".to_vec())]).collect() + }; + let layers = read_zip("x.zip", &crate::zip::write(&mifs(MAX_ZIP_LAYERS + 1)).unwrap()).unwrap(); + assert_eq!(layers.len(), MAX_ZIP_LAYERS); + assert_eq!(layers[0].1.messages, ["x.zip: skipped m32.mif (past the 32-layer limit)"]); + let layers = read_zip("x.zip", &crate::zip::write(&mifs(MAX_ZIP_LAYERS)).unwrap()).unwrap(); + assert!(layers.iter().all(|(_, r)| r.messages.is_empty()), "{:?}", layers[0].1.messages); + // A long list of skipped members names the first ones and counts the rest. + let layers = read_zip("x.zip", &crate::zip::write(&mifs(MAX_ZIP_LAYERS + 25)).unwrap()).unwrap(); + let note = &layers[0].1.messages[0]; + assert!(note.contains("m51.mif") && !note.contains("m52.mif") && note.ends_with("; and 5 more"), "{note}"); } /// A Shapefile's loose files picked or dropped together are zipped into one, which reads as a diff --git a/crates/data/src/source/mod.rs b/crates/data/src/source/mod.rs index a8abc5d936..b05e87edc5 100644 --- a/crates/data/src/source/mod.rs +++ b/crates/data/src/source/mod.rs @@ -204,7 +204,7 @@ impl SourceInfo { } /// The source's coordinate system, when it isn't longitude/latitude: one known by its EPSG - /// code or a custom one without. + /// code or a custom one without. `None` also when `crs` isn't one RustGIS can parse. pub fn coordinate_system(&self) -> Option { Crs::parse(&self.crs).ok().filter(|c| *c != Crs::LonLat) } diff --git a/crates/engine/src/cmd/workflows.rs b/crates/engine/src/cmd/workflows.rs index 8e86691d60..c18a43e923 100644 --- a/crates/engine/src/cmd/workflows.rs +++ b/crates/engine/src/cmd/workflows.rs @@ -1061,7 +1061,17 @@ fn interpolate_work(s: &Session, p: &Value) -> Result { let power = f(p, "power").unwrap_or(2.0).clamp(0.5, 10.0); let neighbors = p.get("neighbors").and_then(Value::as_u64).unwrap_or(12).max(1) as usize; Ok(Box::new(move || { - let m = made(rasterops::idw(&pts, &e, cell, power, neighbors, &name)?, None)?; + // A surface that can't be made says what was left out of it, so the input can be fixed. + let left_out = |e: String| { + if no_point == 0 && no_value == 0 { + e + } else { + format!( + "{e} ({no_point} features with no geometry or no finite coordinates, {no_value} whose value isn't a number left out)" + ) + } + }; + let m = made(rasterops::idw(&pts, &e, cell, power, neighbors, &name).map_err(left_out)?, None)?; if no_point == 0 && no_value == 0 { return Ok(m); } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 356592ae0f..a95333e272 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -33115,4 +33115,12 @@ fn interpolation_says_the_features_it_leaves_out() { said, ["lossy wells: features left out of the surface: 2 with no geometry or no finite coordinates, 1 whose depth isn't a number"] ); + + // A surface with no usable points left fails, and the error says what was left out. + let mut bad = Dataset::new("bad wells", GeometryType::Point, vec![Field::new("depth", FieldType::Double)]); + bad.push(Some(Geometry::Point(Coord::new(f64::NAN, 1.0))), vec![V::Float(1.0)]); + bad.push(None, vec![V::Float(2.0)]); + crate::cmd::layer::add_dataset(&mut s, bad); + let e = s.run("analysis.interpolate", &json!({"layer": "bad wells", "field": "depth", "cellSize": 0.5})).unwrap_err(); + assert!(e.contains("2 features with no geometry or no finite coordinates"), "{e}"); } From dbf4e0666105779d137b5473723198d70c1f1e13 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 06:01:32 -0500 Subject: [PATCH 10/11] Address review feedback - analysis.interpolate: the failure error lists only the kinds of features left out, worded like the success notice, and both say "no usable point" (a MultiPoint whose first point isn't finite has finite coordinates elsewhere). - Test that the failure error counts values that aren't numbers too. --- crates/engine/src/cmd/workflows.rs | 15 ++++++++------- crates/engine/src/tests.rs | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/cmd/workflows.rs b/crates/engine/src/cmd/workflows.rs index c18a43e923..f4a0808daf 100644 --- a/crates/engine/src/cmd/workflows.rs +++ b/crates/engine/src/cmd/workflows.rs @@ -1063,13 +1063,14 @@ fn interpolate_work(s: &Session, p: &Value) -> Result { Ok(Box::new(move || { // A surface that can't be made says what was left out of it, so the input can be fixed. let left_out = |e: String| { - if no_point == 0 && no_value == 0 { - e - } else { - format!( - "{e} ({no_point} features with no geometry or no finite coordinates, {no_value} whose value isn't a number left out)" - ) + let mut why = Vec::new(); + if no_point > 0 { + why.push(format!("{no_point} features with no geometry or no usable point")); + } + if no_value > 0 { + why.push(format!("{no_value} whose value isn't a number")); } + if why.is_empty() { e } else { format!("{e} ({} left out)", why.join(", ")) } }; let m = made(rasterops::idw(&pts, &e, cell, power, neighbors, &name).map_err(left_out)?, None)?; if no_point == 0 && no_value == 0 { @@ -1078,7 +1079,7 @@ fn interpolate_work(s: &Session, p: &Value) -> Result { let then: Then = Box::new(move |s: &mut Session, v: &mut Value| { let mut why = Vec::new(); if no_point > 0 { - why.push(format!("{no_point} with no geometry or no finite coordinates")); + why.push(format!("{no_point} with no geometry or no usable point")); } if no_value > 0 { why.push(format!("{no_value} whose {field_name} isn't a number")); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 0d3c4e38e7..154cad0eb2 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -33113,16 +33113,17 @@ fn interpolation_says_the_features_it_leaves_out() { let said: Vec<_> = s.notices_since(mark).iter().filter(|n| n.text.contains("left out")).map(|n| n.text.clone()).collect(); assert_eq!( said, - ["lossy wells: features left out of the surface: 2 with no geometry or no finite coordinates, 1 whose depth isn't a number"] + ["lossy wells: features left out of the surface: 2 with no geometry or no usable point, 1 whose depth isn't a number"] ); // A surface with no usable points left fails, and the error says what was left out. let mut bad = Dataset::new("bad wells", GeometryType::Point, vec![Field::new("depth", FieldType::Double)]); bad.push(Some(Geometry::Point(Coord::new(f64::NAN, 1.0))), vec![V::Float(1.0)]); bad.push(None, vec![V::Float(2.0)]); + bad.push(Some(Geometry::Point(Coord::new(1.0, 1.0))), vec![V::Null]); crate::cmd::layer::add_dataset(&mut s, bad); let e = s.run("analysis.interpolate", &json!({"layer": "bad wells", "field": "depth", "cellSize": 0.5})).unwrap_err(); - assert!(e.contains("2 features with no geometry or no finite coordinates"), "{e}"); + assert!(e.contains("(2 features with no geometry or no usable point, 1 whose value isn't a number left out)"), "{e}"); } /// `share.exportMap` to a `.tif` writes the view placed on the ground (#1561): in the map's From 9139a91171d48b54a7ac1e77adb5201d9fff9454 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 06:17:55 -0500 Subject: [PATCH 11/11] Address Claude review feedback - Esri PBF reader: count a field name that isn't valid UTF-8 toward the replacement notice only when the field is kept, so a repeated or unread field is said left out and nothing more. --- crates/data/src/esripbf.rs | 3 ++- crates/data/src/esripbf/tests.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/data/src/esripbf.rs b/crates/data/src/esripbf.rs index c580a2109c..255dfd063a 100644 --- a/crates/data/src/esripbf.rs +++ b/crates/data/src/esripbf.rs @@ -276,7 +276,6 @@ pub fn read_page_within(bytes: &[u8], name: &str, limit: usize) -> Result let (mut repeated, mut not_read, mut unknown) = (0usize, 0usize, 0usize); let mut object_id_field = None; for Declared { name, number, utf8, alias } in declared { - tally.not_utf8 += usize::from(!utf8); let Some(read_as) = kind(number) else { not_read += 1; columns.push(None); @@ -292,6 +291,8 @@ pub fn read_page_within(bytes: &[u8], name: &str, limit: usize) -> Result if number == OID && object_id_field.is_none() { object_id_field = Some(fields.len()); } + // Only a field that's kept counts toward the UTF-8 notice: a left-out name isn't shown. + tally.not_utf8 += usize::from(!utf8); columns.push(Some((fields.len(), read_as))); fields.push(Field { name, ty: read_as.field_type(), alias }); } diff --git a/crates/data/src/esripbf/tests.rs b/crates/data/src/esripbf/tests.rs index 70816e71cc..9e1b7afeb2 100644 --- a/crates/data/src/esripbf/tests.rs +++ b/crates/data/src/esripbf/tests.rs @@ -606,6 +606,18 @@ fn a_repeated_field_of_an_unknown_type_is_only_said_left_out() { assert_eq!(report.messages, ["1 fields repeat an earlier field's name and are left out"]); } +#[test] +fn a_left_out_field_whose_name_isnt_utf8_is_only_said_left_out() { + // The name isn't shown, so it isn't said to be read with replacements. + let repeat = message(13, &[message(1, b"N\xffame"), number(2, 4)].concat()); + let bytes = answer(&[field("N\u{FFFD}AME", 4), repeat, feature(&[text("a"), text("b")])]); + let (_, report) = read(&bytes, "t").unwrap(); + assert_eq!(report.messages, ["1 fields repeat an earlier field's name and are left out"]); + let geometry = message(13, &[message(1, b"G\xff"), number(2, 7)].concat()); + let (_, report) = read(&answer(&[field("NAME", 4), geometry, feature(&[text("a")])]), "t").unwrap(); + assert_eq!(report.messages, ["1 fields hold geometries, blobs or rasters, which aren't read, and are left out"]); +} + #[test] fn text_is_taken_from_the_room_at_its_size_once_read_before_it_is_made() { // Each byte that isn't UTF-8 becomes U+FFFD, three bytes.