Repository navigation
fix(analysis): Simplify counts its work toward Cancel across a feature's parts, and says its past-pole count is from before simplifying - #1883
Conversation
…e's parts, and says its past-pole count is from before simplifying Simplify looked at Cancel every 65,536 distances within a run, but each line part and polygon ring started its own count, so a feature of very many short parts never looked at all and ran to its end after Cancel. Its work now counts across the feature's parts and rings (SimplifyRun, on the crate's control::Pace): each vertex set up, each distance, each ring's anchor scans. Once canceled, the rest of the feature is left alone, and the feature is given back as it was rather than part-simplified, for callers outside a tool run (a tool run stops as canceled). The past-pole notice counts the vertices found past a pole, before simplifying, some of which may then go; it now says so.
…ops walking a canceled feature's parts
…nts toward Cancel; a canceled ring isn't copied arc by arc
…stays a counter that can't be copied
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| } | ||
| if past_pole > 0 { | ||
| messages.push(format!("Simplify: {past_pole} vertex(es) with a latitude past a pole found (taken as that pole)")); | ||
| messages.push(format!("Simplify: {past_pole} vertex(es) with a latitude past a pole found (taken as that pole before simplifying, so some may then go)")); |
There was a problem hiding this comment.
This line is over the repo's max_width = 140 (rustfmt.toml), so cargo fmt --check, which cargo xtask ci runs, will reflow it and fail. Same shape as the notices above it:
| messages.push(format!("Simplify: {past_pole} vertex(es) with a latitude past a pole found (taken as that pole before simplifying, so some may then go)")); | |
| messages.push(format!( | |
| "Simplify: {past_pole} vertex(es) with a latitude past a pole found (taken as that pole before simplifying, so some may then go)" | |
| )); |
Confidence: high (about 85%); it's a line-length check, not a logic issue.
| @@ -4112,7 +4172,7 @@ fn simplify_on(inp: &dyn Inputs, p: &Json, threads: Option<usize>) -> Result<Too | |||
| messages.push(format!("Simplify: {short} line part(s) of fewer than 2 vertices left out")); | |||
There was a problem hiding this comment.
Related to the short-part count set at tools.rs:4130 (not in the diff, so commenting here): that count comes from the input g, not the result. A feature canceled partway is given back as it was (simplify_checked returns unchanged), so its short parts are still in the output, yet they're reported here as left out. In a tool run this can't surface today, since run_under turns a canceled run into an error before the notice is shown. Still, the count should follow what was output. Gating the count on changed there (if let Geometry::Line(parts) = g && changed && parts.iter().any(|p| p.len() >= 2)) matches the output, because a line whose parts are all short is kept, and the existing any(len >= 2) check already covers that.
Confidence: medium (about 60%); low impact.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Checked and found sound
Prior reviews: Not verified: I did not run Change sizeCompared: the whole PR against main (merge base ce27286 to PR head 5db2f1b).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
Summary
A follow-up to #1808, from its last review round.
Simplify looked at Cancel every 65,536 distances within a run, but each line part and polygon ring started its own count. A feature made of very many short parts (a million three-vertex parts, say) never reached the count, so it ran to its end after Cancel. Now the work counts across the whole feature, on the crate's
control::Pace, the same pacing other tools use inside a long item: each distance, each ring's two anchor scans, and each vertex's set-up. Set-up (its latitude and scale) counts as 4 distances; I timed it at about 3 to 8. Once canceled, the rest of the feature's parts aren't walked. Inside one long scan this looks less often than before (everyPACE_WORKunits, a few milliseconds, rather than every 65,536 distances), the same as other tools.A canceled feature is given back as it was, not part-simplified. In a tool run the run then stops as canceled anyway, so this just keeps a half-done feature from ever being returned.
Not in this PR: the mobile map package and the globe locator call
simplify_geometryoutside a tool run, where no Cancel is installed, so they don't look at Cancel at all. That's with the rest of those callers' gaps in #1811.The past-pole notice counts the vertices found past a pole, before simplifying, and some of them may then be simplified away; it now says so ("taken as that pole before simplifying, so some may then go"). Counting only the ones that survive isn't possible from the output, since once taken to the pole they're indistinguishable from vertices that were at 90° to begin with.
Testing
simplify_looks_at_cancel_across_a_features_parts: with the work counted to just short of a look at Cancel, a three-vertex part is simplified and every part after it is left as it is; a ring is simplified in full and the next one's anchor scans reach the look, so it's left as it is; and a closed triangle's own work counts, so a polygon of a million small holes is looked at. It fails on main, where each part starts its own count, and fails again with the ring's count taken out.simplify_coords_looks_at_cancel_inside_a_feature: a canceled 200,000-vertex line stops partway through its first scan and keeps its vertices, without calling it a work cap.simplify_gives_back_a_canceled_feature_as_it_was: a 2.2-million-vertex ring, canceled, comes back unchanged.cargo xtask ciandcargo build --target wasm32-unknown-unknown -p rustgis-webpass, apart froma_publication_footer_lines_up_with_its_legend, which fails the same way on main (ce27286's CI).UI evidence
No visible UI change.
Related issue
Part of #1033. Follows #1808; the callers' gaps are #1811.
Summary by CodeRabbit