Skip to content

fix(analysis): warn about Clip boundary slivers (#1998) - #2118

Merged
Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/clip-sliver-notice
Nov 15, 2026
Merged

Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/clip-sliver-notice

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Clip can keep tiny positive-area polygons where an input feature meets the clip boundary. Used as a map series index, these can produce apparently empty pages. Clip now gives one notice counting output polygon features with less than 1e-6 of their source feature's total polygon area, saying they may be slivers along the clip boundary. Every output feature and coordinate is kept as before; no parameter is added. The user guide explains the notice and the map series consequence.

The ratio is dimensionless and measured in the existing overlay plane. The trial's three slivers have approximate area ratios from 1.3e-12 to 3.9e-10, while the smallest of the 14 real pieces is 0.0375. The 1e-6 threshold is more than 2,500 times above the largest artifact ratio and 37,000 times below the smallest real piece. It catches all three artifacts without flagging any real trial piece, with ample separation on both sides.

Each worker measures its already-projected input and intersection once per kept polygon feature, without extra projection, geometry copies, or contact predicates. The existing Cancel checks remain in place. Other overlay tools are unchanged.

Testing

  • New regression: a shared diagonal that mask normalization turns into a kept positive-area sliver. Two such output features give one notice with count two, on one and four threads; their coordinates match the existing part path bit for bit. An ordinary partial clip gives no sliver notice.
  • Original census trial: 17 features retained, with one notice counting exactly the three slivers (tracts 215.47, 607.02 and 210.20). All 14 ordinary pieces remain unflagged.
  • cargo fmt --all: passed.
  • cargo test -p rustgis-analysis: 613 tests passed.
  • RUSTFLAGS="-D warnings" cargo check -p rustgis-analysis --target wasm32-unknown-unknown: passed.
  • cargo xtask ci on the fork's CI: passed, including workspace Clippy and tests, layers, schema-feature Clippy, and schema/fixture consistency.

UI evidence

No visible UI layout or rendering change. The new text uses the existing tool-result notice path; the trial output above is the behavior evidence.

Related issue

Part of #1998: Clip boundary sliver notice only.

Summary by CodeRabbit

  • New Features
    • Clip now reports how many output polygon features have an area below one-millionth of their corresponding input feature’s area. These features remain unchanged; ordinary clipped pieces and empty intersections do not trigger the notice.
  • Documentation
    • Updated the analysis guide to describe the area threshold, notice, and which clipping results are counted.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Clip now reports the count of output polygon features whose area is less than one millionth of the corresponding input area in the overlay plane. It retains those features unchanged. Tests cover multiple worker counts and ordinary partial clips.

Changes: Clip sliver notice

Layer / File(s) Summary
Detection and reporting
crates/analysis/src/tools.rs, docs/user-guide/analysis.md
Clip flags qualifying polygon intersections, counts the output features, and reports the count without changing their geometry. Tests check results at one and four threads and confirm ordinary partial clips do not trigger a notice. The documentation describes the threshold and exclusions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Possibly related issues

  • Issue 1998: The notice addresses the lack of a Clip notice for qualifying slivers. The change does not remove zero-area slivers.

Suggested reviewers: pick2510

Merge Risk: Minimal · up to ecd8a

Clip now reports a notice when output polygon features are tiny slivers, and it keeps all output geometry unchanged. Tests and documentation cover the new notice. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Clip now warns about boundary slivers. It matches the summary and objectives, and the fix(analysis) prefix and issue number are clear. It does not describe the thresho…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description covers the summary of the change, the testing performed, and the UI evidence section. It explains that the Clip notice counts output polygon features below a 1e-6 area-ratio threshold …
Full details: Title check

Explanation

The title names the main change: Clip now warns about boundary slivers. It matches the summary and objectives, and the fix(analysis) prefix and issue number are clear. It does not describe the threshold or the user-guide update, which is acceptable.

Full details: Description check

Explanation

The description covers the summary of the change, the testing performed, and the UI evidence section. It explains that the Clip notice counts output polygon features below a 1e-6 area-ratio threshold and that features and coordinates are kept unchanged. It gives concrete test results: a regression test for two slivers on one and four threads, the census trial (17 features retained, three slivers flagged, 14 unflagged), cargo fmt, cargo test with 613 passing, a wasm check, and cargo xtask ci. The UI section states there is no visible UI change, which the template allows. The Related issue section names Part of #1998. The template's related-issue placeholder is filled, so no required section is missing.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each clipped line,
Small polygon slivers get a sign.
Their shapes stay just the same,
The count now names each one,
Then hops away through maps in sun.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c338f744-6800-431e-a93a-cb50873f7473
Commits

Reviewing files that changed from the base of the PR and between c84e8cf and ecd8a44.

Files selected for processing: 2

  • crates/analysis/src/tools.rs
  • docs/user-guide/analysis.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Comment on lines +689 to +690
index, where a tiny sliver can make an apparently empty page. Ordinary clipped pieces give no
sliver notice, and empty intersections are still left out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc overclaim (Quality, confidence high). "Ordinary clipped pieces give no sliver notice" is not true as a general statement. The check is a ratio against the input feature's area, so a small real piece below 1e-6 of a very large input is counted too. The notice text hedges with "may be", but this sentence does not. Suggested wording:

Suggested change
index, where a tiny sliver can make an apparently empty page. Ordinary clipped pieces give no
sliver notice, and empty intersections are still left out.
index, where a tiny sliver can make an apparently empty page. A small real piece below that
ratio is counted too; empty intersections are still left out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair: a small real piece of a very large input can fall under the ratio too, so the sentence should say a notice is possible there. That's wording, left for the release quality pass.

}
r.messages.extend(left.notes("Clip", &clip_ds.name));
if slivers > 0 {
r.messages.push(format!("Clip: {slivers} output feature(s) have less than one millionth of their input feature's area; they may be slivers along the clip boundary (kept unchanged)"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality, confidence medium (not a blocker). The ratio is taken in the analysis plane (Web Mercator within ±85.05°), so "area" in this message means plane area, not ground area. Mercator's scale grows as 1/cos²(lat), so for a feature spanning many degrees of latitude the ratio can be off by a large factor. The user guide says "overlay plane"; the notice does not. Also, 1e-6 appears here, in clip_part, and in the docs. A named constant would keep the three in step.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's a ratio of plane areas, and a ratio within one feature barely moves with Mercator's scale at county size. Saying "area in the overlay plane" in the message is wording, left for the release quality pass.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. clip_part matches the polygon branch of part (same intersection, same empty-result None, same from_multipolygon). to_multipolygon returns Some only for polygons, so the non-polygon fallback is correct. The count is a notice only: no feature or coordinate is dropped. (confidence: high)

Security: None. No new input parsing or parameters. (confidence: high)

Performance: Two extra O(n) area passes per feature, which are negligible next to the overlay. The sliver count is summed on the calling thread after each batch, so Cancel behaviour is unchanged. (confidence: high)

Quality:

  • Inline: the user guide's "Ordinary clipped pieces give no sliver notice" overclaims, since small real pieces below the ratio are counted too. (confidence: high)
  • Inline: the notice says "area" but the ratio is in the Web Mercator analysis plane, whose scale distorts area by roughly 1/cos²(lat). The threshold is a heuristic, so this is a wording and accuracy point. The same 1e-6 is repeated in code, notice text and docs; a named constant would keep them together. (confidence: medium)
  • The catalogue of Clip notices in docs/user-guide/analysis.md (around lines 759–767) does not list the new notice. (confidence: high)

AGENTS.md:

  • Never silent: a notice with a count is added, and the test covers both the lossy and clean cases. Satisfied.
  • Never crash: no non-test unwrap. The new test uses unwrap(), as other tests in this module do. Satisfied.
  • Never hold the window: Clip already runs in the background, and no new command or tool was added, so the cancellation test list needs no change. Satisfied.
  • No saved-format change, so no schema or fixture update is needed. Satisfied.
  • Wasm: only geo::Area is used, which is pure. Satisfied.

Nothing here blocks merging. The two inline comments cover the substantive points. The notice-catalogue gap and the constant are nits for the release quality pass.

Earlier review concerns already raised: 0 (there were no prior threads).

Change size

Compared: the whole PR against main (merge base 4585899 to PR head ecd8a44).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 991.4 KB
Size after 995.9 KB
Total size change +4.5 KB
Path Before After Change
crates/analysis/src/tools.rs 838.9 KB 842.8 KB +4.0 KB
docs/user-guide/analysis.md 152.5 KB 153.0 KB +536 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2118/
Web app https://preview.rustgis.app/pr-2118/app/
Commit ecd8a44

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@Mavrick-F
Mavrick-F merged commit 1ec28d3 into opengeos:main Nov 15, 2026
21 checks passed
@Mavrick-F Mavrick-F mentioned this pull request Nov 15, 2026
56 of 63 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant