From da8330e322f7cd3eeb3af8d650951ba902880c4d Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 29 Nov 2026 23:38:11 -0500 Subject: [PATCH 1/8] fix(analysis): release sweep follow-ups (analysis-repo) Line-only tools say they take a line layer; neural classify keeps its overflow count (classify_reporting only); warp keeps a cell's columns on the stack; IDW and Kriging drop their row list early; dissolve, simplify and hillshade comments and docs corrected; wgs84_step_m doc and sweep cover 88-89 degrees; tiles share one cap rule and one bounded sign-in body reader; the render EDT squares in f64 so wasm32 rows past 65,536 pixels don't overflow; the topology notice for skipped features fits lines too; the ratchet script approves a deletion over an unreadable base as a deletion; attribution wildcard directory rows cover their contents; automerge keeps its approval body in one place and says when auto-merge may still be armed; doc wording fixes. --- .github/scripts/ratchet-limits.py | 4 ++ .github/scripts/test_ratchet_limits.py | 6 +++ .github/workflows/automerge.yml | 16 +++++-- .github/workflows/mobile.yml | 2 +- crates/analysis/src/neural.rs | 17 +++----- crates/analysis/src/rasterops.rs | 4 +- crates/analysis/src/tools.rs | 42 ++++++++++++------ crates/analysis/src/warp.rs | 26 +++++------ crates/engine/src/cmd/design.rs | 2 +- crates/engine/src/tests.rs | 24 ++++++++++- crates/geom/src/lib.rs | 9 ++-- crates/render/src/text.rs | 24 ++++++++++- crates/tiles/src/arcgis_auth.rs | 25 ++--------- crates/tiles/src/cache.rs | 60 +++++++++++++++++--------- crates/tiles/src/copernicus.rs | 13 +----- docs/plugins.md | 5 ++- docs/user-guide/analysis.md | 8 ++-- docs/user-guide/loss-codes.md | 4 +- skills/rustgis/SKILL.md | 2 + xtask/src/attribution.rs | 9 +++- 20 files changed, 188 insertions(+), 114 deletions(-) diff --git a/.github/scripts/ratchet-limits.py b/.github/scripts/ratchet-limits.py index b17f43a755..e9a94e6ad8 100644 --- a/.github/scripts/ratchet-limits.py +++ b/.github/scripts/ratchet-limits.py @@ -101,6 +101,10 @@ def compare(path, base_text, head_text): try: base = parse(base_text, path == ROWS_FILE) except ValueError as error: + # A deletion is approved as a deletion, whatever the base held: an approval for an + # unreadable base would otherwise approve a deletion it doesn't name. + if head_text is None: + return [(f"{path}: deleted, and its base can't be read ({error}) to count its limits", f"{path} deleted")] # The limits can't be compared, so a raise could hide behind this: it needs a maintainer's say, # for the head as it is (its digest is in the token), not for whatever is pushed next. digest = hashlib.sha256((head_text or "").encode("utf-8")).hexdigest()[:12] diff --git a/.github/scripts/test_ratchet_limits.py b/.github/scripts/test_ratchet_limits.py index 73ee370789..a5f7c6d1b9 100644 --- a/.github/scripts/test_ratchet_limits.py +++ b/.github/scripts/test_ratchet_limits.py @@ -59,6 +59,12 @@ def test_a_deleted_file_is_refused_and_a_new_one_is_fine(self): self.assertEqual(len(self.problems(ROWS, None)), 1) self.assertEqual(self.problems(None, ROWS), []) + def test_a_deleted_file_with_an_unreadable_base_is_approved_as_a_deletion(self): + [token] = self.tokens("count = many\n", None) + self.assertTrue(token.endswith("deleted"), token) + [message] = self.problems("count = many\n", None) + self.assertIn("deleted", message) + def test_the_first_line_of_a_name_is_the_limit_as_xtask_reads_it(self): self.assertEqual(MODULE.parse("count = 5\ncount = 9\n")["count"][0], 5) self.assertEqual(len(self.problems(ROWS, "count = 782\ncount = 999\n")), 0) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index c523ee1331..66c9064525 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -18,6 +18,10 @@ on: permissions: {} +env: + # The body of the approval automerge posts, by which it later finds the approvals it may dismiss. + APPROVAL_BODY: Approved via automerge. + # `automerge` label and unlabel runs share a queue, so a pending revoke run isn't replaced; GitHub # doesn't guarantee their order, so each run checks the label as it is now rather than relying on # it. `synchronize` and unrelated labels get their own groups. @@ -45,9 +49,13 @@ jobs: # anyway, so each call is attempted and its own failure ignored. refuse() { echo "::error::$1" - gh pr merge "$PR" --disable-auto || true + # Disabled when armed (or when that can't be read); a failure to disable is said. + armed=$(gh pr view "$PR" --json autoMergeRequest --jq '.autoMergeRequest != null') || armed=unknown + if [ "$armed" != false ]; then + gh pr merge "$PR" --disable-auto || echo "::error::auto-merge may still be armed: disabling it failed" + fi if me=$(gh api user --jq .login) && ids=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/reviews?per_page=100" \ - | jq -r --arg owner "$me" '.[] | select((.user.login // "") == $owner and .state == "APPROVED" and (.body // "") == "Approved via automerge.") | .id'); then + | jq -r --arg owner "$me" --arg body "$APPROVAL_BODY" '.[] | select((.user.login // "") == $owner and .state == "APPROVED" and (.body // "") == $body) | .id'); then for review_id in $ids; do gh api -X PUT "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/reviews/$review_id/dismissals" \ -f message="automerge label refused" --silent || true @@ -79,7 +87,7 @@ jobs: # The token owner can't approve their own pull requests, and needn't: they bypass the review. if [ "$AUTHOR" != "$owner" ]; then gh api "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/reviews" -f commit_id="$SHA" -f event=APPROVE \ - -f body="Approved via automerge." --silent || { gh pr merge "$PR" --disable-auto; exit 1; } + -f body="$APPROVAL_BODY" --silent || { gh pr merge "$PR" --disable-auto; exit 1; } fi revoke: @@ -121,7 +129,7 @@ jobs: # Dismiss on both actions, so a push doesn't depend on the label removal succeeding. # Reads in an if condition, where set -e doesn't stop the step; a failed read counts. if owner=$(gh api user --jq .login) && ids=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/reviews?per_page=100" \ - | jq -r --arg owner "$owner" '.[] | select((.user.login // "") == $owner and .state == "APPROVED" and (.body // "") == "Approved via automerge.") | .id'); then + | jq -r --arg owner "$owner" --arg body "$APPROVAL_BODY" '.[] | select((.user.login // "") == $owner and .state == "APPROVED" and (.body // "") == $body) | .id'); then for review_id in $ids; do gh api -X PUT "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/reviews/$review_id/dismissals" \ -f message="Automerge label removed" --silent || failed=1 diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 9fe011e90c..7370560096 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -392,7 +392,7 @@ jobs: sdk="$(xcrun --sdk iphoneos --show-sdk-version)" echo "::notice::$(xcodebuild -version | head -1), iOS SDK $sdk" # App Store Connect requires the iOS 27 SDK from April 2027 (ITMS-90725). - [ "${sdk%%.*}" -ge 27 ] || { echo "::error::$(basename "$newest") has the iOS $sdk SDK; App Store uploads need iOS 27 or later."; exit 1; } + [ "${sdk%%.*}" -ge 27 ] || { echo "::error::$(basename "$newest") has the iOS $sdk SDK; App Store uploads need the iOS 27 SDK from April 2027 (ITMS-90725)."; exit 1; } # The whole bundle, unsigned: any failure on the way fails the step. - name: Build the app diff --git a/crates/analysis/src/neural.rs b/crates/analysis/src/neural.rs index 3ad8b6cd50..685324ef68 100644 --- a/crates/analysis/src/neural.rs +++ b/crates/analysis/src/neural.rs @@ -507,15 +507,9 @@ pub struct Classified { } /// Classifies every pixel: class numbers (1-based, `nodata` where a band has no data) and each -/// pixel's probability of that class. Rows go on several threads when the work is large, except in -/// the browser, which uses one (#1252). -pub fn classify(r: &Raster, model: &Mlp, nodata: f32) -> Result<(Vec, Vec), String> { - let out = classify_on(r, model, nodata, None)?; - Ok((out.class, out.prob)) -} - -/// Like [`classify`], and also counts valid pixels whose values overflowed the network to -/// non-finite probabilities and were left as `nodata`. +/// pixel's probability of that class, and counts valid pixels whose values overflowed the network +/// to non-finite probabilities and were left as `nodata`, for the caller to report. Rows go on +/// several threads when the work is large, except in the browser, which uses one (#1252). pub fn classify_reporting(r: &Raster, model: &Mlp, nodata: f32) -> Result { classify_on(r, model, nodata, None) } @@ -661,8 +655,9 @@ mod tests { let bits = |v: &[f32]| v.iter().map(|x| x.to_bits()).collect::>(); assert_eq!((bits(&c), bits(&p)), (bits(&c1), bits(&p1)), "{threads} threads"); } - // As many threads as pay off, which `classify` picks, give the same. - let (c, p) = classify(&r, &model, -1.0).unwrap(); + // As many threads as pay off, which `classify_reporting` picks, give the same. + let Classified { class: c, prob: p, overflowed: ov } = classify_reporting(&r, &model, -1.0).unwrap(); + assert_eq!(ov, 0); assert_eq!((c, p), (c1, p1)); } diff --git a/crates/analysis/src/rasterops.rs b/crates/analysis/src/rasterops.rs index 18450d6ac7..056904e834 100644 --- a/crates/analysis/src/rasterops.rs +++ b/crates/analysis/src/rasterops.rs @@ -74,8 +74,8 @@ const BYTE_COUNT_CHUNK: usize = 1 << 20; fn byte_stats(cells: &[f32]) -> Result, String> { let chunks: Vec<&[f32]> = cells.chunks(BYTE_COUNT_CHUNK).collect(); crate::control::begin(chunks.len()); - // Two chunks, two million cells, before threads pay off; each thread takes one at a time, as - // there are few of them. + // Two chunks (more than a million cells) before threads pay off; each thread takes one at a + // time, as there are few of them. let threads = crate::parallel::threads_for_each(chunks.len(), 2, 0); let counted = crate::parallel::try_map_each_on( &chunks, diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index f187aaa6b2..2667234333 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -60,9 +60,9 @@ pub static TOOLS: &[ToolSpec] = &[ id: "splitLineAtVertices", name: "Split Line At Vertices", toolbox: "Data Management › Features", - summary: "Writes a separate two-vertex line for each consecutive vertex pair.", + summary: "Writes a separate two-vertex line for each consecutive vertex pair of a line layer.", params: &[ - P { name: "input", label: "Input Features", kind: K::Layer, required: true, default: "", help: "" }, + P { name: "input", label: "Input Line Features", kind: K::Layer, required: true, default: "", help: "" }, P { name: "output", label: "Output Name", kind: K::Text, required: false, default: "", help: "" }, ], run: split_line_at_vertices, @@ -82,9 +82,9 @@ pub static TOOLS: &[ToolSpec] = &[ id: "unsplitLine", name: "Unsplit Line", toolbox: "Data Management › Features", - summary: "Joins exact endpoint matches through degree-two nodes when all attributes agree. Branches stay separate.", + summary: "Joins a line layer's lines at exact endpoint matches through degree-two nodes when all attributes agree. Branches stay separate.", params: &[ - P { name: "input", label: "Input Features", kind: K::Layer, required: true, default: "", help: "" }, + P { name: "input", label: "Input Line Features", kind: K::Layer, required: true, default: "", help: "" }, P { name: "output", label: "Output Name", kind: K::Text, required: false, default: "", help: "" }, ], run: geometry::unsplit, @@ -1727,8 +1727,9 @@ fn geo_union_all<'a>(polys: impl IntoIterator>) -> /// missing and nearly coincident vertices there can leave wrong. At exactly zero (a collapsed /// ring, or lobes that cancel out) it keeps geo's direction, and the positive fill keeps only what /// it goes around counterclockwise. An exterior that encloses nothing is taken without its holes. -/// A group uses Geo's union if any coordinate is outside the finite range ±2^500 (about -/// ±3.27e150). The i_overlay 9 stopgap uses its serial build on desktop and in the browser. Its +/// A group uses Geo's union if any coordinate of the rings the union reads is outside the finite +/// range ±2^500 (about ±3.27e150); the holes of an exterior that encloses nothing are left out +/// unread. The i_overlay 9 stopgap uses its serial build on desktop and in the browser. Its /// optional parallel build would require integrating the sort and split workers with RustGIS's /// thread setting. The union is one step with no Cancel check inside it. fn dissolve_union<'a, P>(polys: P) -> MultiPolygon @@ -5081,8 +5082,9 @@ fn simplify_checked(g: &Geometry, tol_m: f64) -> Simplified { } if matches!(g, Geometry::Line(_) | Geometry::Polygon(_)) { let mut broken = false; - // Beyond 1e150 plane meters (a longitude past about 1e143°), the squares in a distance - // overflow; no place on Earth is within a hair of it. + // Beyond 1e150 plane units (in longitude/latitude, a longitude past about 1e143°; in a + // projected system, its own units), the squares in a distance overflow; no place on Earth + // is within a hair of it. const PLANE_LIMIT: f64 = 1e150; g.for_each_coord(|c| { let p = crate::convert::to_plane(c); @@ -5353,9 +5355,10 @@ fn idw_interpolation(inp: &dyn Inputs, p: &Json) -> Result { let mut pts: Vec<(Coord, f64)> = Vec::new(); let mut left_out = PointsLeftOut::default(); let picked = rows(inp, p, "input", ds); + let total = picked.len(); // Cancel is looked at between features; one feature with millions of vertices is read through // `for_each_coord` without a look inside it. - for (n, r) in picked.iter().copied().enumerate() { + for (n, r) in picked.into_iter().enumerate() { if n % LOOK_EVERY == 0 { crate::control::check()?; } @@ -5423,7 +5426,7 @@ fn idw_interpolation(inp: &dyn Inputs, p: &Json) -> Result { let msg = format!("IDW Interpolation: {} × {} cells from {} points", r.width, r.height, pts.len()); Ok(ToolResult { losses: left_out - .losses("IDW Interpolation", picked.len(), field, "a coordinate is not a finite number") + .losses("IDW Interpolation", total, field, "a coordinate is not a finite number") .into_iter() .chain(raster_losses(&r)) .collect(), @@ -5459,7 +5462,8 @@ fn kriging_interpolation(inp: &dyn Inputs, p: &Json) -> Result = Vec::new(); let mut left_out = PointsLeftOut::default(); let picked = rows(inp, p, "input", ds); - for (n, r) in picked.iter().copied().enumerate() { + let total = picked.len(); + for (n, r) in picked.into_iter().enumerate() { if n % LOOK_EVERY == 0 { crate::control::check()?; } @@ -5582,7 +5586,7 @@ fn kriging_interpolation(inp: &dyn Inputs, p: &Json) -> Result { // and its east corners near the west end: going east along an edge, the column drops by // half the image or more. The pixels between are the far side of the globe. Its // corners in the west go on past the east edge instead (by one turn of longitude, not - // always the image's width), and the pixels past it are the west's again. A westward cell - // that takes in the whole image (its span reaches from column 0 to the image's width, not a - // turn) is not across the seam, nor is a cell whose columns grow eastward as they do in - // an ordinary one. (An - // output that runs east to west, or a cell over half the globe wide in one, cannot be - // told from one across it and is read as before.) + // always the image's width), and the pixels past it are the west's again. A westward + // cell that takes in the whole image (its span reaches from column 0 to the image's + // width, not a turn) is not across the seam, nor is a cell whose columns grow eastward + // as they do in an ordinary one. (An output that runs east to west, or a cell over half + // the globe wide in one, cannot be told from one across it and is read as before.) let mut wrapped = false; let drop = |from: &(f64, f64), to: &(f64, f64)| from.0 - to.0; if let Some(turn) = self.wrap.filter(|turn| { @@ -991,8 +990,8 @@ impl Aggregate<'_> { let (j0, j1) = (first(r0), past(r1, h)); // The columns of the image the cell takes: its own, and for a wrapped one the west's // again, `turn` columns on. - let columns: Vec<(usize, usize, f64)> = - [0.0, turn].into_iter().take(if wrapped { 2 } else { 1 }).map(|off| (first(c0 - off), past(c1 - off, w), off)).collect(); + let columns = [(first(c0), past(c1, w), 0.0), (first(c0 - turn), past(c1 - turn, w), turn)]; + let columns = columns.get(..if wrapped { 2 } else { 1 }).unwrap_or_default(); values.iter_mut().for_each(Vec::clear); weights.iter_mut().for_each(Vec::clear); // The mean is summed as the pixels come (no copy of the cell's values); mode keeps them. @@ -1003,7 +1002,7 @@ impl Aggregate<'_> { if pace.stop(columns.iter().map(|(a, b, _)| b.saturating_sub(*a)).sum()) { return; } - for &(i0, i1, off) in &columns { + for &(i0, i1, off) in columns { for i in i0..i1 { if !holds(&quad, (i as f64 + 0.5 + off, j as f64 + 0.5)) { continue; @@ -1879,11 +1878,12 @@ mod tests { } } - /// A source whose columns stop short of a whole turn (8 of 44° end at 172°) isn't wrapped: a - /// cell across ±180° keeps its corners' columns, and takes nothing from the far side for the part - /// of the globe the source doesn't cover. + /// A source whose columns stop a pixel or less short of a whole turn (8 of 44° end at 172°) + /// still wraps, one turn of longitude being a little more than the image's width. A cell + /// across ±180° centred in the part of the globe the source doesn't cover (172°..180°) holds + /// no pixel's centre (column 7's is at 150°, column 0's at -158°), so it is empty. #[test] - fn a_source_short_of_a_whole_turn_does_not_wrap() { + fn a_cell_centred_where_the_source_has_no_columns_is_empty() { let r = globe(352.0); // Longitudes folded into -180..180, as the output system centred on 180° gives them. let folded = |x: f64, y: f64| Some((((x + 180.0).rem_euclid(360.0)) / 44.0, (90.0 - y) / 90.0)); diff --git a/crates/engine/src/cmd/design.rs b/crates/engine/src/cmd/design.rs index 15459ccde4..7d30f2dfa6 100644 --- a/crates/engine/src/cmd/design.rs +++ b/crates/engine/src/cmd/design.rs @@ -3248,7 +3248,7 @@ fn topology_validate(s: &mut Session, p: &Json) -> CmdResult { } if !skipped.is_empty() { s.warn(format!( - "Polygons left out of the check at a pole (a coordinate missing or infinite, or a million turns around), so its result there may be wrong: {}", + "Features left out of a check (a coordinate missing or infinite, or, at a pole, a polygon a million turns around), so its result there may be wrong: {}", skipped.join("; ") )); } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 13d763f9ca..89f5c9aa4d 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -55184,7 +55184,29 @@ fn must_be_covered_by_says_which_polygons_it_left_out_at_a_pole() { assert_eq!(v["errors"], u64::from(warned)); assert_eq!(v["incomplete"].as_array().map(Vec::len), Some(usize::from(warned))); let said = s.notices_since(mark).iter().any(|n| { - n.text.contains("left out of the check at a pole") && n.text.contains("Must Be Covered By on 'Pole': 1 feature(s) of 'Caps'") + n.text.contains("Features left out of a check") && n.text.contains("Must Be Covered By on 'Pole': 1 feature(s) of 'Caps'") + }); + assert_eq!(said, warned, "{:?}", s.notices_since(mark)); + } +} + +/// A line with a vertex that isn't a number is left out of Must Not Self-Intersect, and the +/// validation says so in words that fit a line, not only a polygon at a pole; a whole line, nothing. +#[test] +fn must_not_self_intersect_says_which_lines_it_left_out() { + use rustgis_data::{Coord, Dataset, Geometry, GeometryType}; + let c = Coord::new; + for (middle, warned) in [(c(f64::NAN, 1.0), true), (c(1.0, 1.0), false)] { + let mut s = Session::new(Project::default()); + let mut lines = Dataset::new("Roads", GeometryType::Polyline, vec![]); + lines.push(Some(Geometry::Line(vec![vec![c(0.0, 0.0), middle, c(2.0, 0.0)]])), vec![]); + s.map_mut().add_dataset(lines); + s.run("topology.rules", &json!({"add": {"rule": "mustNotSelfIntersect", "layer": "Roads"}})).unwrap(); + let mark = s.notice_mark(); + s.run("topology.validate", &Value::Null).unwrap(); + let said = s.notices_since(mark).iter().any(|n| { + n.text.contains("Features left out of a check (a coordinate missing or infinite") + && n.text.contains("Must Not Self-Intersect on 'Roads': 1 feature(s) of 'Roads'") }); assert_eq!(said, warned, "{:?}", s.notices_since(mark)); } diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rs index 60e0b3ed76..d902d0393c 100644 --- a/crates/geom/src/lib.rs +++ b/crates/geom/src/lib.rs @@ -454,7 +454,7 @@ pub fn wgs84_direct(c: Coord, azimuth_deg: f64, dist_m: f64) -> (Coord, f64) { /// The distance (metres) between two nearby lon/lat points on the WGS 84 ellipsoid, for the many /// short steps of a long line (a route's): from the ellipsoid's radii of curvature along and across /// the meridian at the two points' mean latitude, within a millionth of [`wgs84_distance_m`] for a -/// step of up to 0.05° in latitude and in longitude below 89°, and [`wgs84_distance_m`] itself for +/// step of up to 0.05° in latitude and in longitude at or below 89°, and [`wgs84_distance_m`] itself for /// any other. It costs a few operations, where a geodesic solve costs about 20 times a haversine. /// NaN for a coordinate that isn't finite. pub fn wgs84_step_m(a: Coord, b: Coord) -> f64 { @@ -1580,12 +1580,13 @@ mod tests { } /// A short step measured from the ellipsoid's radii agrees with the geodesic solve to within a - /// millionth, at every latitude below 89° and across the antimeridian; a longer step, or one by - /// a pole, is the solve itself. + /// millionth, at every latitude up to 89° and across the antimeridian (the last degree swept + /// more finely, both sides of the equator); a longer step, or one past 89°, is the solve itself. #[test] fn wgs84_steps_agree_with_the_geodesic() { let mut worst: f64 = 0.0; - for lat in (-89..=88).map(f64::from) { + let near_the_poles = [88.5, 88.95, 89.0].into_iter().flat_map(|lat| [lat, -lat]); + for lat in (-89..=88).map(f64::from).chain(near_the_poles) { for (dx, dy) in [(0.05, 0.0), (0.0, 0.05), (0.05, 0.05), (-0.03, 0.01), (1e-5, -2e-5)] { for lon in [-179.98, -12.0, 0.0, 179.99] { let (a, b) = (Coord::new(lon, lat), Coord::new(lon + dx, lat + dy)); diff --git a/crates/render/src/text.rs b/crates/render/src/text.rs index aeb83443ae..40e695d5a7 100644 --- a/crates/render/src/text.rs +++ b/crates/render/src/text.rs @@ -1089,7 +1089,8 @@ impl Edt { return &self.out; } let (v, z) = (&mut self.v, &mut self.z); - let at = |p: usize| f[p] + (p * p) as f64; + // Squared in f64: `p * p` in usize overflows past 65,536 on 32-bit targets (the browser). + let at = |p: usize| f.get(p).copied().unwrap_or(f64::INFINITY) + (p as f64) * (p as f64); let mut k = 0; z[0] = f64::NEG_INFINITY; for q in 1..n { @@ -1112,7 +1113,7 @@ impl Edt { } let p = v[k]; let dq = q as f64 - p as f64; - *out = dq * dq + f[p]; + *out = dq * dq + f.get(p).copied().unwrap_or(f64::INFINITY); } &self.out } @@ -1312,6 +1313,25 @@ mod spread_tests { assert_eq!(spread(&line, 2.0).len(), 32); } + /// A row longer than 65,536 pixels, whose last positions square past 32 bits, gives each + /// pixel its least squared distance to the seeds, as reading every seed directly does. + #[test] + fn the_distance_transform_takes_rows_past_65536_pixels() { + let n = 70_000; + let seeds = [3usize, 40_000, 65_600, 69_998]; + // Far from every seed, as `spread` marks the pixels the letters don't cover. + let mut f = vec![1e20; n]; + for &p in &seeds { + f[p] = 0.0; + } + let mut edt = Edt::default(); + let out = edt.run(&f).to_vec(); + for q in (0..n).step_by(997).chain([65_535, 65_536, 65_537, n - 1]) { + let direct = seeds.iter().map(|&p| (q as f64 - p as f64).powi(2)).fold(f64::INFINITY, f64::min); + assert_eq!(out[q], direct, "q {q}"); + } + } + /// A halo grown far past what a map needs is drawn at most MAX_HALO_PX wide: a pixel past that /// reach from the letter, though within the halo's own width, is left as it was. #[test] diff --git a/crates/tiles/src/arcgis_auth.rs b/crates/tiles/src/arcgis_auth.rs index 023d0277ae..349f0ef3be 100644 --- a/crates/tiles/src/arcgis_auth.rs +++ b/crates/tiles/src/arcgis_auth.rs @@ -880,21 +880,6 @@ mod native { }) } - /// Reads at most `max` decoded bytes from `reader`, refusing larger payloads. - fn read_limited(reader: impl Read, max: usize) -> Result, String> { - let mut buf = Vec::new(); - reader.take(max as u64 + 1).read_to_end(&mut buf).map_err(|e| e.to_string())?; - if buf.len() > max { - return Err(format!("larger than {max} bytes")); - } - Ok(buf) - } - - /// Bounds both wire and decoded bytes (when gzip expands them) to `max`. - fn read_bounded(mut body: ureq::Body, max: usize) -> Result, String> { - read_limited(body.with_config().limit(max as u64 + 2).reader(), max) - } - /// POSTs a form; a refusal's answer (an OAuth `error`, often with HTTP 400) is returned for /// the caller to read, while a server error (5xx) counts as the portal not being reached. fn post_form(url: &str, body: &str) -> Result, String> { @@ -913,7 +898,7 @@ mod native { if status >= 500 { return Err(format!("the portal answered HTTP {status}")); } - read_bounded(resp.into_body(), 1 << 20) + crate::cache::read_bounded(resp.into_body(), 1 << 20) } /// Request preparation (including TLS setup) can wait; the final send has its own check. @@ -934,7 +919,7 @@ mod native { .header("Accept", "application/json") .call() .map_err(|e| e.to_string())?; - read_bounded(resp.into_body(), 4 << 20) + crate::cache::read_bounded(resp.into_body(), 4 << 20) } /// Starts signing in to `portal` (blank: ArcGIS Online) with an OAuth app's `client_id`: @@ -1211,13 +1196,9 @@ mod native { #[cfg(test)] #[test] - fn bounded_body_reader_and_proxy_configuration() { + fn sign_in_agents_use_no_proxy() { assert!(agent(true).config().proxy().is_none()); assert!(agent(false).config().proxy().is_none()); - assert_eq!(read_limited(std::io::Cursor::new(vec![b'a'; 16]), 16).unwrap().len(), 16); - assert!(read_limited(std::io::Cursor::new(vec![b'a'; 17]), 16).unwrap_err().contains("larger than 16")); - // An unbounded stream stops at max + 1 bytes instead of allocating indefinitely. - assert!(read_limited(std::io::repeat(b'x'), 64).unwrap_err().contains("larger than 64")); } /// The request line's target of an HTTP request. diff --git a/crates/tiles/src/cache.rs b/crates/tiles/src/cache.rs index 0e4a6134f7..48fc4cb514 100644 --- a/crates/tiles/src/cache.rs +++ b/crates/tiles/src/cache.rs @@ -2568,6 +2568,20 @@ fn premultiply(data: &mut [u8]) { } } +/// Reads at most `max` decoded bytes from a response body, refusing a larger one ("larger than +/// `max` bytes"): the wire bytes are bounded too, so a compressed answer can't expand past it. For +/// the sign-in answers of Copernicus Data Space and ArcGIS portals. +#[cfg(not(target_arch = "wasm32"))] +pub(crate) fn read_bounded(mut body: ureq::Body, max: usize) -> Result, String> { + use std::io::Read; + let mut buf = Vec::new(); + body.with_config().limit(max as u64 + 2).reader().take(max as u64 + 1).read_to_end(&mut buf).map_err(|e| e.to_string())?; + if buf.len() > max { + return Err(format!("larger than {max} bytes")); + } + Ok(buf) +} + /// Builds a native agent with `config` whose DNS resolver rejects forbidden addresses (such as /// link-local and cloud metadata endpoints) while still allowing loopback and local-network hosts. #[cfg(not(target_arch = "wasm32"))] @@ -2582,10 +2596,10 @@ mod native { //! A tile costs one or two round trips plus the server's own time (Esri's World Imagery //! Wayback answers every tile with a redirect first), and the connections stay open between //! tiles, so fetching is bound by latency: how many requests are under way at once. Each - //! server gets up to [`PER_HOST`] of them (OpenStreetMap's tile servers [`PER_HOST_OSM`], - //! each of CDSE's data servers [`crate::copernicus::PER_HOST`], the connections its quota gives - //! a general account), and the workers share one agent, so a server never sees more open - //! connections than that. + //! server gets up to [`crate::schedule::cap`] of them ([`PER_HOST`], OpenStreetMap's tile + //! servers [`crate::schedule::PER_HOST_OSM`], each of CDSE's data servers + //! [`crate::copernicus::PER_HOST`], the connections its quota gives a general account), and the + //! workers share one agent, so a server never sees more open connections than that. use std::collections::HashMap; use std::sync::{Condvar, Mutex, OnceLock}; @@ -2650,12 +2664,9 @@ mod native { } /// Fetches under way at once, over all servers: two servers at their cap. - const WORKERS: usize = 2 * PER_HOST; + pub(super) const WORKERS: usize = 2 * PER_HOST; /// Fetches under way at once from one server. - const PER_HOST: usize = 16; - /// From the OpenStreetMap Foundation's tile servers, which ask for restraint: what every - /// version of RustGIS before this one used in all. - const PER_HOST_OSM: usize = 8; + const PER_HOST: usize = crate::schedule::PER_HOST; /// Requests waiting beyond this many are dropped, oldest first: the view moved on. const QUEUE: usize = 512; @@ -2699,18 +2710,10 @@ mod native { crate::schedule::server(rest.get(..end).unwrap_or(rest)) } - /// How many fetches may be under way at once from `host`. + /// How many fetches may be under way at once from `host`: [`crate::schedule::cap`]'s, except + /// that local reads (`""`) may take every worker. pub(super) fn cap(host: &str) -> usize { - let name = host.split(':').next().unwrap_or(host); - if host.is_empty() { - WORKERS - } else if name == "tile.openstreetmap.org" || name.ends_with(".tile.openstreetmap.org") { - PER_HOST_OSM - } else if crate::copernicus::has_quota(name) { - crate::copernicus::PER_HOST - } else { - PER_HOST - } + if host.is_empty() { WORKERS } else { crate::schedule::cap(host) } } /// The newest waiting job whose server is below its cap. @@ -4019,6 +4022,18 @@ mod native { #[expect(clippy::disallowed_methods, reason = "a thread the system refuses fails the test, as it should")] #[cfg(test)] mod tests { + /// A sign-in answer of `max` bytes is read whole; one byte more is refused, as is an endless + /// one, which stops at `max + 1` bytes instead of growing. + #[cfg(not(target_arch = "wasm32"))] + #[test] + fn read_bounded_refuses_an_answer_past_its_limit() { + let body = |n: usize| ureq::Body::builder().data(vec![b'a'; n]); + assert_eq!(read_bounded(body(16), 16).unwrap(), vec![b'a'; 16]); + assert!(read_bounded(body(17), 16).unwrap_err().contains("larger than 16 bytes")); + let endless = ureq::Body::builder().reader(std::io::repeat(b'x')); + assert!(read_bounded(endless, 64).unwrap_err().contains("larger than 64 bytes")); + } + #[test] fn policy_refusals_group_paths_without_evicting_other_diagnostics() { let _turn = turn(); @@ -7206,6 +7221,11 @@ Connection: close assert!(native::cap("tile.openstreetmap.org") < native::cap("example.org")); assert_eq!(native::cap("a.tile.openstreetmap.org"), native::cap("tile.openstreetmap.org")); assert!(native::cap("") >= native::cap("example.org")); + // One rule for servers, shared with the browser's scheduler; local reads take every worker. + for host in ["tile.openstreetmap.org", "b.tile.openstreetmap.org:443", "download.dataspace.copernicus.eu", "example.org"] { + assert_eq!(native::cap(host), crate::schedule::cap(host), "{host}"); + } + assert_eq!(native::cap(""), native::WORKERS); // Copernicus Data Space's data servers get an account's quota; its catalog has none. for host in ["download", "zipper", "eodata"] { assert_eq!(native::cap(&format!("{host}.dataspace.copernicus.eu:443")), 4); diff --git a/crates/tiles/src/copernicus.rs b/crates/tiles/src/copernicus.rs index 8c95ec4cb4..bb0b0e5d9e 100644 --- a/crates/tiles/src/copernicus.rs +++ b/crates/tiles/src/copernicus.rs @@ -645,7 +645,6 @@ pub use native::{Restored, authorization_fresh, login, restore}; #[cfg(not(target_arch = "wasm32"))] mod native { - use std::io::Read; use std::sync::{Mutex, OnceLock}; use std::time::Duration; @@ -671,23 +670,13 @@ mod native { }) } - /// Reads at most `max` decoded bytes from a response body, bounding compressed expansion too. - fn read_bounded(mut body: ureq::Body, max: usize) -> Result, String> { - let mut buf = Vec::new(); - body.with_config().limit(max as u64 + 2).reader().take(max as u64 + 1).read_to_end(&mut buf).map_err(|e| e.to_string())?; - if buf.len() > max { - return Err(format!("larger than {max} bytes")); - } - Ok(buf) - } - /// POSTs a form; its status and answer. The error never quotes the form. fn post_form(url: &str, body: &str, still: &Option) -> Result<(u16, Vec), String> { let req = agent().post(url).header("Content-Type", "application/x-www-form-urlencoded").header("Accept", "application/json"); crate::cache::check_still(still)?; let resp = req.send(body).map_err(|e| format!("couldn't reach Copernicus Data Space's sign-in: {e}"))?; let status = resp.status().as_u16(); - let bytes = read_bounded(resp.into_body(), 1 << 20)?; + let bytes = crate::cache::read_bounded(resp.into_body(), 1 << 20)?; Ok((status, bytes)) } diff --git a/docs/plugins.md b/docs/plugins.md index 57376c1ca8..8da373f6ba 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -201,8 +201,9 @@ cargo build --release --target wasm32-unknown-unknown - `tools[].toolbox`: where the tool sits in the **Tools** pane, under **Plugins**. Separate levels with ` › `: `1. Grid and isolines › Variograms` makes a **1. Grid and isolines** group with a **Variograms** group in it, up to eight levels counting **Plugins**. A tool with no toolbox sits - in a group named after the plugin. Groups are listed alphabetically, in whatever order the tools - come in `plugin.json`; empty levels are skipped. Numbered groups sort as text, so write the + in a group named after the plugin. Groups are sorted as text (by character code, so capitals + come before lowercase letters), in whatever order the tools come in `plugin.json`; empty levels + are skipped. Numbered groups sort as text, so write the numbers with leading zeros (`01.`, `02.`, … `10.`) to keep their order. - `commands[].icon`: the name of one of RustGIS's own icons (`stats`, `zoom_full`, `bookmark`, `buffer`…), or a puzzle piece when it isn't one. diff --git a/docs/user-guide/analysis.md b/docs/user-guide/analysis.md index 83c185e3e4..613ee211cc 100644 --- a/docs/user-guide/analysis.md +++ b/docs/user-guide/analysis.md @@ -553,10 +553,10 @@ east–west), and the tool says how many features reach that far. For a layer in (see above), the tolerance is a length in that system, the same everywhere. A feature without geometry is left out, and the tool says how many. A tolerance of 0 leaves every line and polygon as it is. Otherwise a line or polygon with a coordinate missing, or a longitude too far out to place, -is left as it was; a latitude past ±90° is taken as the pole; a line part of fewer than 2 vertices -beside a longer one is left out; and, in a run that can't be canceled, a feature too intricate to -simplify whole within the work allowed keeps more vertices than asked in part of it (a run you can -cancel takes no limit, looking at Cancel within each feature). The tool says how many of each. +is left as it was; in longitude/latitude, a latitude past ±90° is taken as the pole; a line part of +fewer than 2 vertices beside a longer one is left out; and, in a run that can't be canceled, a +feature too intricate to simplify whole within the work allowed keeps more vertices than asked in +part of it (a run you can cancel takes no limit, looking at Cancel within each feature). The tool says how many of each. **Kernel Density** (`kernelDensity`) calculates a continuous magnitude-per-unit-area raster surface from point features using a Quartic (biweight, default) or Gaussian kernel (truncated at 3σ and diff --git a/docs/user-guide/loss-codes.md b/docs/user-guide/loss-codes.md index 76a65b6ed2..d11ee40f6b 100644 --- a/docs/user-guide/loss-codes.md +++ b/docs/user-guide/loss-codes.md @@ -1,8 +1,8 @@ # Data loss codes RustGIS never drops or changes data silently. A notice says what happened, how much and where. -A notice that reports a loss also carries one of the codes on this page. Each notice links to its -entry here, which says what the code means and what to do about it. +A notice that reports a loss with a code carries one of the codes on this page. Each such notice +links to its entry here, which says what the code means and what to do about it. A code is never translated, renamed or reused, so a script can match on it. [`rustgis-cli run --strict`](../cli.md#strict-runs) stops at a code that no `--allow` accepts, diff --git a/skills/rustgis/SKILL.md b/skills/rustgis/SKILL.md index 09a3ee9c6b..0b49b20d2c 100644 --- a/skills/rustgis/SKILL.md +++ b/skills/rustgis/SKILL.md @@ -36,6 +36,8 @@ private project if the relay is unavailable. Do not combine `--attach` with until started, and runs until the user clicks that status bar text or the app closes. Ticking the box is remembered: the relay then starts with the app. + Stopping the relay (clicking the status bar text) also forgets that + choice: tick the box again to keep it. 3. Register the attached server in the agent, for example: ```sh diff --git a/xtask/src/attribution.rs b/xtask/src/attribution.rs index 4ce54d8516..1f31a7e256 100644 --- a/xtask/src/attribution.rs +++ b/xtask/src/attribution.rs @@ -52,7 +52,12 @@ fn uncovered<'a>(files: &[&'a str], attribution: &str) -> Vec<&'a str> { .filter(|f| is_asset(f)) .filter(|f| { !named.iter().any(|(n, path)| { - if *path { f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) } else { !f.contains('/') && wildcard(n, f) } + // A directory with a `*` in it (`crates/*/fixtures/`) covers what is below it too. + if *path { + f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) || wildcard(&format!("{n}/*"), f) + } else { + !f.contains('/') && wildcard(n, f) + } }) }) .collect() @@ -108,6 +113,7 @@ mod tests { | Test corpus (`crates/map/testdata/generated/`: styles and sample data) | us | MIT |\n\ | Test images (`crates/x/tests/a.png`, `b.png`) | us | MIT |\n\ | Root logo (`logo.svg`) | us | MIT |\n\ + | Every crate's fixtures (`crates/*/fixtures/`) | us | MIT |\n\ | Prose (`cargo xtask notices`, `tl!(\"x\")`, `/etc/hosts`) | n/a | n/a |\n"; #[test] @@ -120,6 +126,7 @@ mod tests { "icons/deep/b.png", "crates/map/testdata/generated/data/marker.png", "crates/x/tests/a.png", + "crates/x/fixtures/a/b.png", ]; assert_eq!(uncovered(&files, TABLE), Vec::<&str>::new()); } From e63245723867618487f439422461892954656c60 Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 02:49:32 -0500 Subject: [PATCH 2/8] fix: address review comments on the analysis-repo sweep wgs84_step_m keeps a tiny longitude difference exact (wrapped only across 180 degrees) and the sweep checks a 1e-9 degree step; a file pattern row in ATTRIBUTION.md no longer covers files below a directory of that name; the topology notice says features were not checked completely; dissolve, plugin toolbox sort, EDT test and tiles cap docs qualified. --- crates/analysis/src/tools.rs | 3 ++- crates/engine/src/cmd/design.rs | 2 +- crates/engine/src/tests.rs | 9 +++++---- crates/geom/src/lib.rs | 6 ++++-- crates/render/src/text.rs | 5 ++++- crates/tiles/src/cache.rs | 3 ++- docs/plugins.md | 4 ++-- xtask/src/attribution.rs | 17 ++++++++++------- 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index 2667234333..87573b9e4d 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -1729,7 +1729,8 @@ fn geo_union_all<'a>(polys: impl IntoIterator>) -> /// it goes around counterclockwise. An exterior that encloses nothing is taken without its holes. /// A group uses Geo's union if any coordinate of the rings the union reads is outside the finite /// range ±2^500 (about ±3.27e150); the holes of an exterior that encloses nothing are left out -/// unread. The i_overlay 9 stopgap uses its serial build on desktop and in the browser. Its +/// unread, unless an earlier ring was already out of range (Geo's union then reads every ring). +/// The i_overlay 9 stopgap uses its serial build on desktop and in the browser. Its /// optional parallel build would require integrating the sort and split workers with RustGIS's /// thread setting. The union is one step with no Cancel check inside it. fn dissolve_union<'a, P>(polys: P) -> MultiPolygon diff --git a/crates/engine/src/cmd/design.rs b/crates/engine/src/cmd/design.rs index 7d30f2dfa6..869ae1ccb8 100644 --- a/crates/engine/src/cmd/design.rs +++ b/crates/engine/src/cmd/design.rs @@ -3248,7 +3248,7 @@ fn topology_validate(s: &mut Session, p: &Json) -> CmdResult { } if !skipped.is_empty() { s.warn(format!( - "Features left out of a check (a coordinate missing or infinite, or, at a pole, a polygon a million turns around), so its result there may be wrong: {}", + "Features not checked completely (a coordinate missing or infinite, or, at a pole, a polygon a million turns around), so the result there may be wrong: {}", skipped.join("; ") )); } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 89f5c9aa4d..83b1b30a2c 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -55184,14 +55184,15 @@ fn must_be_covered_by_says_which_polygons_it_left_out_at_a_pole() { assert_eq!(v["errors"], u64::from(warned)); assert_eq!(v["incomplete"].as_array().map(Vec::len), Some(usize::from(warned))); let said = s.notices_since(mark).iter().any(|n| { - n.text.contains("Features left out of a check") && n.text.contains("Must Be Covered By on 'Pole': 1 feature(s) of 'Caps'") + n.text.contains("Features not checked completely") && n.text.contains("Must Be Covered By on 'Pole': 1 feature(s) of 'Caps'") }); assert_eq!(said, warned, "{:?}", s.notices_since(mark)); } } -/// A line with a vertex that isn't a number is left out of Must Not Self-Intersect, and the -/// validation says so in words that fit a line, not only a polygon at a pole; a whole line, nothing. +/// A line with a vertex that isn't a number isn't checked completely by Must Not Self-Intersect, +/// and the validation says so in words that fit a line, not only a polygon at a pole; a whole line, +/// nothing. #[test] fn must_not_self_intersect_says_which_lines_it_left_out() { use rustgis_data::{Coord, Dataset, Geometry, GeometryType}; @@ -55205,7 +55206,7 @@ fn must_not_self_intersect_says_which_lines_it_left_out() { let mark = s.notice_mark(); s.run("topology.validate", &Value::Null).unwrap(); let said = s.notices_since(mark).iter().any(|n| { - n.text.contains("Features left out of a check (a coordinate missing or infinite") + n.text.contains("Features not checked completely (a coordinate missing or infinite") && n.text.contains("Must Not Self-Intersect on 'Roads': 1 feature(s) of 'Roads'") }); assert_eq!(said, warned, "{:?}", s.notices_since(mark)); diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rs index d902d0393c..6e20ba8d28 100644 --- a/crates/geom/src/lib.rs +++ b/crates/geom/src/lib.rs @@ -461,7 +461,9 @@ pub fn wgs84_step_m(a: Coord, b: Coord) -> f64 { if !a.is_finite() || !b.is_finite() { return f64::NAN; } - let (dlat, dlon) = (b.y - a.y, wrap_lon(b.x - a.x)); + // Wrapped only across ±180°: `wrap_lon` rounds a tiny difference to its 180° offset's precision. + let dx = b.x - a.x; + let (dlat, dlon) = (b.y - a.y, if dx.abs() > 180.0 { wrap_lon(dx) } else { dx }); if dlat.abs() > 0.05 || dlon.abs() > 0.05 || a.y.abs().max(b.y.abs()) > 89.0 { return wgs84_distance_m(a, b); } @@ -1587,7 +1589,7 @@ mod tests { let mut worst: f64 = 0.0; let near_the_poles = [88.5, 88.95, 89.0].into_iter().flat_map(|lat| [lat, -lat]); for lat in (-89..=88).map(f64::from).chain(near_the_poles) { - for (dx, dy) in [(0.05, 0.0), (0.0, 0.05), (0.05, 0.05), (-0.03, 0.01), (1e-5, -2e-5)] { + for (dx, dy) in [(0.05, 0.0), (0.0, 0.05), (0.05, 0.05), (-0.03, 0.01), (1e-5, -2e-5), (1e-9, 0.0)] { for lon in [-179.98, -12.0, 0.0, 179.99] { let (a, b) = (Coord::new(lon, lat), Coord::new(lon + dx, lat + dy)); let exact = wgs84_distance_m(a, b); diff --git a/crates/render/src/text.rs b/crates/render/src/text.rs index 40e695d5a7..12575644d9 100644 --- a/crates/render/src/text.rs +++ b/crates/render/src/text.rs @@ -1314,7 +1314,9 @@ mod spread_tests { } /// A row longer than 65,536 pixels, whose last positions square past 32 bits, gives each - /// pixel its least squared distance to the seeds, as reading every seed directly does. + /// pixel its least squared distance to the seeds, as reading every seed directly does. On a + /// 64-bit host this checks the arithmetic only; the overflow it guards against is wasm32's + /// (`u32` squares past 65,535 overflow there, as `checked_mul` shows below). #[test] fn the_distance_transform_takes_rows_past_65536_pixels() { let n = 70_000; @@ -1324,6 +1326,7 @@ mod spread_tests { for &p in &seeds { f[p] = 0.0; } + assert_eq!(65_536u32.checked_mul(65_536), None); let mut edt = Edt::default(); let out = edt.run(&f).to_vec(); for q in (0..n).step_by(997).chain([65_535, 65_536, 65_537, n - 1]) { diff --git a/crates/tiles/src/cache.rs b/crates/tiles/src/cache.rs index 48fc4cb514..d1e298eadb 100644 --- a/crates/tiles/src/cache.rs +++ b/crates/tiles/src/cache.rs @@ -2711,7 +2711,8 @@ mod native { } /// How many fetches may be under way at once from `host`: [`crate::schedule::cap`]'s, except - /// that local reads (`""`) may take every worker. + /// that local reads (`""`) may take every worker here ([`WORKERS`]), whatever the browser's + /// scheduler allows them ([`crate::schedule::LOCAL`]; today both are 32). pub(super) fn cap(host: &str) -> usize { if host.is_empty() { WORKERS } else { crate::schedule::cap(host) } } diff --git a/docs/plugins.md b/docs/plugins.md index 8da373f6ba..0b9fe3f3f8 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -201,8 +201,8 @@ cargo build --release --target wasm32-unknown-unknown - `tools[].toolbox`: where the tool sits in the **Tools** pane, under **Plugins**. Separate levels with ` › `: `1. Grid and isolines › Variograms` makes a **1. Grid and isolines** group with a **Variograms** group in it, up to eight levels counting **Plugins**. A tool with no toolbox sits - in a group named after the plugin. Groups are sorted as text (by character code, so capitals - come before lowercase letters), in whatever order the tools come in `plugin.json`; empty levels + in a group named after the plugin. Groups are sorted as text (by character code: ASCII capitals + come before lowercase letters, and accented or other non-ASCII letters after both), in whatever order the tools come in `plugin.json`; empty levels are skipped. Numbered groups sort as text, so write the numbers with leading zeros (`01.`, `02.`, … `10.`) to keep their order. - `commands[].icon`: the name of one of RustGIS's own icons (`stats`, `zoom_full`, `bookmark`, diff --git a/xtask/src/attribution.rs b/xtask/src/attribution.rs index 1f31a7e256..7db5482e3a 100644 --- a/xtask/src/attribution.rs +++ b/xtask/src/attribution.rs @@ -30,16 +30,16 @@ fn wildcard(pattern: &str, text: &str) -> bool { /// The paths and patterns `ATTRIBUTION.md` names: everything in backticks that has a `/` in it (the /// path of a file may hold spaces) or is a single word with a `.` or `*` (a file at the root), each with -/// a trailing `/` taken off and whether it had a `/` at all. -fn named(attribution: &str) -> Vec<(&str, bool)> { +/// a trailing `/` taken off, whether it had a `/` at all, and whether it ended in one (a directory). +fn named(attribution: &str) -> Vec<(&str, bool, bool)> { // Backticks pair up within a line, so a stray one can't shift the pairing of every later row. attribution .lines() .flat_map(|line| line.split('`').skip(1).step_by(2)) .filter(|t| !t.contains(['\n', '\t']) && !t.starts_with('/')) .filter(|t| t.contains('/') || ((t.contains('.') || t.contains('*')) && !t.contains(' '))) - .map(|t| (t.trim_end_matches('/'), t.contains('/'))) - .filter(|(t, _)| !t.is_empty()) + .map(|t| (t.trim_end_matches('/'), t.contains('/'), t.ends_with('/'))) + .filter(|(t, _, _)| !t.is_empty()) .collect() } @@ -51,10 +51,11 @@ fn uncovered<'a>(files: &[&'a str], attribution: &str) -> Vec<&'a str> { .copied() .filter(|f| is_asset(f)) .filter(|f| { - !named.iter().any(|(n, path)| { - // A directory with a `*` in it (`crates/*/fixtures/`) covers what is below it too. + !named.iter().any(|(n, path, dir)| { + // A directory with a `*` in it (`crates/*/fixtures/`) covers what is below it too; + // a file pattern (`assets/fonts/*.otf`) doesn't. if *path { - f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) || wildcard(&format!("{n}/*"), f) + f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) || (*dir && wildcard(&format!("{n}/*"), f)) } else { !f.contains('/') && wildcard(n, f) } @@ -155,6 +156,8 @@ mod tests { "iconsx/a.png", ]; assert_eq!(uncovered(&files, TABLE), vec!["crates/map/testdata/generated-more/x.png", "iconsx/a.png"]); + // A file pattern names files, not what a directory of that name holds. + assert_eq!(uncovered(&["assets/fonts/x.otf/a.png"], TABLE), vec!["assets/fonts/x.otf/a.png"]); } #[test] From ceb90161285e89f29b9d0bada6122889b334eb6f Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 03:20:09 -0500 Subject: [PATCH 3/8] fix(xtask): a directory row's * matches one level; review wording fixes --- crates/analysis/src/tools.rs | 2 +- docs/plugins.md | 9 +++++---- xtask/src/attribution.rs | 11 ++++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index 87573b9e4d..9d23657d90 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -5083,7 +5083,7 @@ fn simplify_checked(g: &Geometry, tol_m: f64) -> Simplified { } if matches!(g, Geometry::Line(_) | Geometry::Polygon(_)) { let mut broken = false; - // Beyond 1e150 plane units (in longitude/latitude, a longitude past about 1e143°; in a + // Beyond 1e150 plane units (in longitude/latitude, a longitude past about 9e144°; in a // projected system, its own units), the squares in a distance overflow; no place on Earth // is within a hair of it. const PLANE_LIMIT: f64 = 1e150; diff --git a/docs/plugins.md b/docs/plugins.md index 0b9fe3f3f8..cb623f225b 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -201,10 +201,11 @@ cargo build --release --target wasm32-unknown-unknown - `tools[].toolbox`: where the tool sits in the **Tools** pane, under **Plugins**. Separate levels with ` › `: `1. Grid and isolines › Variograms` makes a **1. Grid and isolines** group with a **Variograms** group in it, up to eight levels counting **Plugins**. A tool with no toolbox sits - in a group named after the plugin. Groups are sorted as text (by character code: ASCII capitals - come before lowercase letters, and accented or other non-ASCII letters after both), in whatever order the tools come in `plugin.json`; empty levels - are skipped. Numbered groups sort as text, so write the - numbers with leading zeros (`01.`, `02.`, … `10.`) to keep their order. + in a group named after the plugin. Groups are sorted by their toolbox text as written in + `plugin.json`, by character code (ASCII capitals come before lowercase letters, and accented or + other non-ASCII letters after both), in whatever order the tools come in `plugin.json`; empty + levels are skipped. Numbered groups sort as text, so write the numbers with leading zeros + (`01.`, `02.`, … `10.`) to keep their order. - `commands[].icon`: the name of one of RustGIS's own icons (`stats`, `zoom_full`, `bookmark`, `buffer`…), or a puzzle piece when it isn't one. - `commands[].form` (optional) gives the command a dialog of its own: its ribbon button (tab diff --git a/xtask/src/attribution.rs b/xtask/src/attribution.rs index 7db5482e3a..78bcaf0bc7 100644 --- a/xtask/src/attribution.rs +++ b/xtask/src/attribution.rs @@ -28,6 +28,13 @@ fn wildcard(pattern: &str, text: &str) -> bool { at.ends_with(last) } +/// Whether `file` lies below the directory `dir`, each `*` in `dir` matching within one level +/// (`crates/*/fixtures` holds `crates/x/fixtures/a/b.png`, not `crates/x/y/fixtures/a.png`). +fn below(dir: &str, file: &str) -> bool { + let (levels, parts): (Vec<&str>, Vec<&str>) = (dir.split('/').collect(), file.split('/').collect()); + parts.len() > levels.len() && levels.iter().zip(&parts).all(|(level, part)| wildcard(level, part)) +} + /// The paths and patterns `ATTRIBUTION.md` names: everything in backticks that has a `/` in it (the /// path of a file may hold spaces) or is a single word with a `.` or `*` (a file at the root), each with /// a trailing `/` taken off, whether it had a `/` at all, and whether it ended in one (a directory). @@ -55,7 +62,7 @@ fn uncovered<'a>(files: &[&'a str], attribution: &str) -> Vec<&'a str> { // A directory with a `*` in it (`crates/*/fixtures/`) covers what is below it too; // a file pattern (`assets/fonts/*.otf`) doesn't. if *path { - f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) || (*dir && wildcard(&format!("{n}/*"), f)) + f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) || (*dir && below(n, f)) } else { !f.contains('/') && wildcard(n, f) } @@ -158,6 +165,8 @@ mod tests { assert_eq!(uncovered(&files, TABLE), vec!["crates/map/testdata/generated-more/x.png", "iconsx/a.png"]); // A file pattern names files, not what a directory of that name holds. assert_eq!(uncovered(&["assets/fonts/x.otf/a.png"], TABLE), vec!["assets/fonts/x.otf/a.png"]); + // A directory row's `*` stands for one level, not for a path below another directory. + assert_eq!(uncovered(&["crates/x/y/fixtures/a.png"], TABLE), vec!["crates/x/y/fixtures/a.png"]); } #[test] From 20e33342b3539baa6250e812bf84082fe6c4c35b Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 03:43:28 -0500 Subject: [PATCH 4/8] fix(xtask): directory rows in ATTRIBUTION.md match level by level --- xtask/src/attribution.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xtask/src/attribution.rs b/xtask/src/attribution.rs index 78bcaf0bc7..dbfb14363a 100644 --- a/xtask/src/attribution.rs +++ b/xtask/src/attribution.rs @@ -5,7 +5,9 @@ //! not by any rule that a program could apply to every file, so this checks the classes the rule //! names: images, icons and fonts. A file is covered when a backticked path in `ATTRIBUTION.md` //! (one with a `/`) names it, names a directory above it (a trailing `/` is optional), or matches -//! it as a pattern, in which `*` stands for any characters, `/` included. A bare file name (or a +//! it as a pattern, in which `*` stands for any characters, `/` included. In a row that ends in `/` +//! (a directory), a `*` stands for one level instead: `crates/*/fixtures/` covers +//! `crates/x/fixtures/a/b.png`, not `crates/x/y/fixtures/a.png`. A bare file name (or a //! pattern with no `/`) covers only a file at the repository root, so a row can't cover a //! same-named file somewhere else. @@ -59,10 +61,13 @@ fn uncovered<'a>(files: &[&'a str], attribution: &str) -> Vec<&'a str> { .filter(|f| is_asset(f)) .filter(|f| { !named.iter().any(|(n, path, dir)| { - // A directory with a `*` in it (`crates/*/fixtures/`) covers what is below it too; - // a file pattern (`assets/fonts/*.otf`) doesn't. - if *path { - f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) || (*dir && below(n, f)) + // A directory row (`icons/`, `crates/*/fixtures/`) covers what is below it, its + // `*`s one level each; a path or pattern without the `/` (`assets/fonts/*.otf`) + // covers what it matches, and what is below it when it names a directory. + if *dir { + below(n, f) + } else if *path { + f == n || f.starts_with(&format!("{n}/")) || wildcard(n, f) } else { !f.contains('/') && wildcard(n, f) } @@ -167,6 +172,9 @@ mod tests { assert_eq!(uncovered(&["assets/fonts/x.otf/a.png"], TABLE), vec!["assets/fonts/x.otf/a.png"]); // A directory row's `*` stands for one level, not for a path below another directory. assert_eq!(uncovered(&["crates/x/y/fixtures/a.png"], TABLE), vec!["crates/x/y/fixtures/a.png"]); + let ending_in_a_star = "| All of a crate's top level (`crates/*/`) | us | MIT |\n"; + assert_eq!(uncovered(&["crates/a/b.png", "crates/a/b/c.png"], ending_in_a_star), Vec::<&str>::new()); + assert_eq!(uncovered(&["crates/a.png"], ending_in_a_star), vec!["crates/a.png"]); } #[test] From 4744d3653397ec4324eda5e8070de4d1d7351b0c Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 04:15:27 -0500 Subject: [PATCH 5/8] docs(analysis): dissolve falls back to Geo's union for any out-of-range ring --- crates/analysis/src/tools.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/analysis/src/tools.rs b/crates/analysis/src/tools.rs index 9d23657d90..b51b34681e 100644 --- a/crates/analysis/src/tools.rs +++ b/crates/analysis/src/tools.rs @@ -1729,7 +1729,7 @@ fn geo_union_all<'a>(polys: impl IntoIterator>) -> /// it goes around counterclockwise. An exterior that encloses nothing is taken without its holes. /// A group uses Geo's union if any coordinate of the rings the union reads is outside the finite /// range ±2^500 (about ±3.27e150); the holes of an exterior that encloses nothing are left out -/// unread, unless an earlier ring was already out of range (Geo's union then reads every ring). +/// unread, unless any ring the union reads is out of range (Geo's union then reads every ring). /// The i_overlay 9 stopgap uses its serial build on desktop and in the browser. Its /// optional parallel build would require integrating the sort and split workers with RustGIS's /// thread setting. The union is one step with no Cancel check inside it. From d80b84960ef4646589e0f67c2c4abef21b1c1498 Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 04:49:14 -0500 Subject: [PATCH 6/8] fix(geom): keep a tiny step's length across the antimeridian wgs84_step_m moves the eastern point a turn before subtracting instead of wrapping the rounded difference, so a step of a few hundredths of a nanodegree across 180 degrees keeps its length. The plugin docs say toolbox levels are trimmed before sorting. --- crates/geom/src/lib.rs | 17 +++++++++++++++-- docs/plugins.md | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rs index 6e20ba8d28..999d179964 100644 --- a/crates/geom/src/lib.rs +++ b/crates/geom/src/lib.rs @@ -461,9 +461,18 @@ pub fn wgs84_step_m(a: Coord, b: Coord) -> f64 { if !a.is_finite() || !b.is_finite() { return f64::NAN; } - // Wrapped only across ±180°: `wrap_lon` rounds a tiny difference to its 180° offset's precision. + // Across ±180° the eastern point is moved a turn before subtracting, so a tiny step keeps its + // length (`wrap_lon` of the rounded difference would round it to 180°'s precision); only + // longitudes further out than one turn are wrapped. let dx = b.x - a.x; - let (dlat, dlon) = (b.y - a.y, if dx.abs() > 180.0 { wrap_lon(dx) } else { dx }); + let dlon = if dx > 180.0 { + (b.x - 360.0) - a.x + } else if dx < -180.0 { + (b.x + 360.0) - a.x + } else { + dx + }; + let (dlat, dlon) = (b.y - a.y, if dlon.abs() > 180.0 { wrap_lon(dlon) } else { dlon }); if dlat.abs() > 0.05 || dlon.abs() > 0.05 || a.y.abs().max(b.y.abs()) > 89.0 { return wgs84_distance_m(a, b); } @@ -1598,6 +1607,10 @@ mod tests { } } assert!(worst < 1e-6, "{worst}"); + // A step of a few hundredths of a nanodegree across ±180° keeps its length. + let (a, b) = (Coord::new(180.0, 89.0), Coord::new(-179.999_999_999_999_97, 89.0)); + let exact = wgs84_distance_m(a, b); + assert!(exact > 0.0 && ((wgs84_step_m(a, b) - exact) / exact).abs() < 1e-9, "{} {exact}", wgs84_step_m(a, b)); let far = (Coord::new(10.0, 40.0), Coord::new(10.2, 40.0)); assert_eq!(wgs84_step_m(far.0, far.1), wgs84_distance_m(far.0, far.1)); let polar = (Coord::new(10.0, 89.5), Coord::new(10.01, 89.5)); diff --git a/docs/plugins.md b/docs/plugins.md index cb623f225b..68893dcbd8 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -202,7 +202,7 @@ cargo build --release --target wasm32-unknown-unknown with ` › `: `1. Grid and isolines › Variograms` makes a **1. Grid and isolines** group with a **Variograms** group in it, up to eight levels counting **Plugins**. A tool with no toolbox sits in a group named after the plugin. Groups are sorted by their toolbox text as written in - `plugin.json`, by character code (ASCII capitals come before lowercase letters, and accented or + `plugin.json` (with spaces at either end of a level trimmed, never translated), by character code (ASCII capitals come before lowercase letters, and accented or other non-ASCII letters after both), in whatever order the tools come in `plugin.json`; empty levels are skipped. Numbered groups sort as text, so write the numbers with leading zeros (`01.`, `02.`, … `10.`) to keep their order. From fac06d5cb31da65615671dea3ae147cefb95a4b6 Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 05:26:24 -0500 Subject: [PATCH 7/8] docs: topology notice wording; rewrap plugin sort and simplify paragraphs --- crates/engine/src/cmd/design.rs | 2 +- docs/plugins.md | 9 +++++---- docs/user-guide/analysis.md | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/design.rs b/crates/engine/src/cmd/design.rs index 869ae1ccb8..a0c56d9caa 100644 --- a/crates/engine/src/cmd/design.rs +++ b/crates/engine/src/cmd/design.rs @@ -3248,7 +3248,7 @@ fn topology_validate(s: &mut Session, p: &Json) -> CmdResult { } if !skipped.is_empty() { s.warn(format!( - "Features not checked completely (a coordinate missing or infinite, or, at a pole, a polygon a million turns around), so the result there may be wrong: {}", + "Features not checked completely (a coordinate missing or infinite, or, at a pole, a polygon a million turns around), so their results may be wrong: {}", skipped.join("; ") )); } diff --git a/docs/plugins.md b/docs/plugins.md index 68893dcbd8..88f51386d7 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -202,10 +202,11 @@ cargo build --release --target wasm32-unknown-unknown with ` › `: `1. Grid and isolines › Variograms` makes a **1. Grid and isolines** group with a **Variograms** group in it, up to eight levels counting **Plugins**. A tool with no toolbox sits in a group named after the plugin. Groups are sorted by their toolbox text as written in - `plugin.json` (with spaces at either end of a level trimmed, never translated), by character code (ASCII capitals come before lowercase letters, and accented or - other non-ASCII letters after both), in whatever order the tools come in `plugin.json`; empty - levels are skipped. Numbered groups sort as text, so write the numbers with leading zeros - (`01.`, `02.`, … `10.`) to keep their order. + `plugin.json`, with spaces at either end of a level trimmed and never translated, in whatever + order the tools come; empty levels are skipped. The order is by character code: ASCII capitals + come before lowercase letters, and accented or other non-ASCII letters after both. Numbered + groups sort as text, so write the numbers with leading zeros (`01.`, `02.`, … `10.`) to keep + their order. - `commands[].icon`: the name of one of RustGIS's own icons (`stats`, `zoom_full`, `bookmark`, `buffer`…), or a puzzle piece when it isn't one. - `commands[].form` (optional) gives the command a dialog of its own: its ribbon button (tab diff --git a/docs/user-guide/analysis.md b/docs/user-guide/analysis.md index 613ee211cc..3fcbb71850 100644 --- a/docs/user-guide/analysis.md +++ b/docs/user-guide/analysis.md @@ -556,7 +556,8 @@ it is. Otherwise a line or polygon with a coordinate missing, or a longitude too is left as it was; in longitude/latitude, a latitude past ±90° is taken as the pole; a line part of fewer than 2 vertices beside a longer one is left out; and, in a run that can't be canceled, a feature too intricate to simplify whole within the work allowed keeps more vertices than asked in -part of it (a run you can cancel takes no limit, looking at Cancel within each feature). The tool says how many of each. +part of it (a run you can cancel takes no limit, looking at Cancel within each feature). The tool +says how many of each. **Kernel Density** (`kernelDensity`) calculates a continuous magnitude-per-unit-area raster surface from point features using a Quartic (biweight, default) or Gaussian kernel (truncated at 3σ and From 85cf0db8eb2308b60caba9a1592410b6e96f9e0a Mon Sep 17 00:00:00 2001 From: giswqs Date: Mon, 30 Nov 2026 05:55:31 -0500 Subject: [PATCH 8/8] docs(plugins): toolbox levels sort by their text as written, shown translated or not --- docs/plugins.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index 88f51386d7..7ac0ea7b9c 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -202,8 +202,9 @@ cargo build --release --target wasm32-unknown-unknown with ` › `: `1. Grid and isolines › Variograms` makes a **1. Grid and isolines** group with a **Variograms** group in it, up to eight levels counting **Plugins**. A tool with no toolbox sits in a group named after the plugin. Groups are sorted by their toolbox text as written in - `plugin.json`, with spaces at either end of a level trimmed and never translated, in whatever - order the tools come; empty levels are skipped. The order is by character code: ASCII capitals + `plugin.json`, with spaces at either end of a level trimmed, in whatever order the tools come + (a level shown translated, as command search shows it, still sorts by that text); empty levels + are skipped. The order is by character code: ASCII capitals come before lowercase letters, and accented or other non-ASCII letters after both. Numbered groups sort as text, so write the numbers with leading zeros (`01.`, `02.`, … `10.`) to keep their order.