Skip to content

fix(data): a 3D footprint's union no longer hangs on a curved mesh (#1891) - #1919

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/1891-footprint-union-hang
Nov 13, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/1891-footprint-union-hang

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reading a 3D model could hang: the union that builds an object's footprint (footprint::footprint → geo::unary_union → i_overlay 4.5.2) never finished on the rocking chair in OGC's CityGML 3.0 LoD 3 sample. The footprint is shared by the File Geodatabase multipatch, CityJSON and CityGML readers, so the same faces hang any of them, in any version (the chair in a CityGML 2.0 file hangs on main).

Cause. It isn't a loop. A curved mesh seen from above lays its faces almost on each other, their edges less than a micrometre apart, and the union's work grows with every near crossing: 34 of the chair's faces take 7 ms, 97 take 15 s, 478 more than 90 s, and the 956 never finish. MAX_UNION_FACES (50,000) bounds how many faces enter a union, not its time.

Not a dependency bump. i_overlay 9.1 hangs on the same faces too, and geo 0.33.1, the latest release, pins i_overlay below 4.6.

Fix. Before the union, each corner is taken from the shape's lower corner and rounded to a grid, and the union is moved back:

  • The grid is the power of two below a millionth of the shape's size (UNION_GRID). On a kilometre that is a millimetre or less, a hundredth of the narrowest face shows() already takes.
  • A power of two, because a corner a whole number of steps from the shape's corner stays where it is. A first try with exactly a millionth moved a box's corner from 10 to 9.99999.
  • Corners that nearly meet now meet. The whole chair's union takes about 20 ms.

What it changes in a footprint. A merged footprint's corners lie within a two-millionth of the shape's size of its faces'. The data's own coordinates don't change. This isn't announced: it is 1/200 of the face width below which shows() already leaves faces out without a notice, and the footprint doc states it.

What it doesn't do. The grid narrows the union's worst cases; it doesn't bound its time. The union is still one call that Cancel can't stop, as before this change. Both are said in the doc comment.

Found while testing #1884 (CityGML 3.0), whose pull request follows this one.

Testing

  • New citygml::tests::a_curved_mesh_is_merged_in_a_moment:
    • It reads 97 of the chair's faces (crates/data/tests/data/rocking-chair.gml, MIT, with its row in ATTRIBUTION.md and the licence in its header) with a 5 s limit, and checks that the faces are merged, not drawn as the outline of their points.
    • 18 ms with the fix. Without the grid (UNION_GRID = 0) it fails at the limit.
  • New footprint::tests::a_footprint_far_from_the_origin_is_where_its_faces_are: a 10 m box at (458879, 5438353) keeps its corners and its area through the move and back.
  • The 186 existing tests of the FileGDB, CityJSON and CityGML readers pass unchanged.
  • The full chair (956 faces), timed through footprint: about 20 ms (it didn't finish in 5 minutes before).
  • checks.sh (fmt, clippy, nextest, doctests, layers) on macOS: all pass except rustgis-engine tests::a_layout_pdf_sets_its_text_in_its_fonts. That test fails alone too, on this branch and with nothing of it on its path: this Mac's "System Font" is drawn at another weight than its file's default and goes out as outlines. It came in with feat(render): embed real fonts in a layout's vector PDF (#1815, part 1) #1828 and doesn't touch footprint.
  • Manual, desktop app:
    • the 2.0 file with the full chair opens at once, merged, with no outline notice;
    • OGC's LoD 2 and building-and-garage samples give the same footprints and notices as before.

UI evidence

No visible UI change.

Related issue

Closes #1891

Summary by CodeRabbit

  • Bug Fixes
    • Footprints for shapes located far from the origin now retain their correct position and area after merging.
    • Curved CityGML mesh data is verified to load as a feature with geometry within five seconds, without an “outline” notice.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The footprint union now uses shape-relative coordinates snapped to a power-of-two grid, then translates successful results back to the original location. A CityGML rocking-chair fixture and a timeout test cover reading a mesh with 97 faces.

Changes: Footprint Union Stability

Layer / File(s) Summary
Shape-relative footprint union
crates/data/src/footprint.rs
The union now uses shape-relative coordinates and snaps them for positive-size shapes. Successful results are translated back to the original coordinates. A test checks the bounds and area of a square far from the origin and confirms no hull fallback.
CityGML regression coverage
crates/data/src/citygml/tests.rs, crates/data/tests/data/rocking-chair.gml, ATTRIBUTION.md
A CityGML rocking-chair fixture supports a test that checks read time, returned geometry, and the absence of the outline notice. The fixture source and license are documented.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • opengeos/RustGIS#1269 — The PR changes the shared footprint union path used by CityJSON, but does not add a CityJSON-specific fallback.
  • opengeos/RustGIS#1536 — The PR changes footprint union behavior, but does not add the requested level-of-detail footprint selection.

Suggested reviewers: giswqs

Merge Risk: Minimal · up to b2b87

The change snaps footprint corners to a fine grid before the union so curved meshes merge quickly, and the result is moved back to its original location. No concrete merge-blocking risk was found. Union time remains unbounded and uncancellable, as the PR states.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (union hang on a curved mesh) and the affected area (data crate footprint union), which matches the main change: grid snapping before the footprint union so the rocking-chair m…
Description check Passed The description follows the template. It has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the cause, the fix, its precision effects, and its limits. Testing lists ne…
Linked Issues check Passed Issue #1891 asks that loading the reported OGC chair mesh finish well under a second with its footprint, and that loading never hang. The diff at crates/data/src/footprint.rs adds UNION_GRID = 1e-6. I…
Out of Scope Changes check Passed All changed paths relate to #1891. footprint.rs holds the grid snapping, the translation back, the doc comment and the new test. citygml/tests.rs holds the regression test for the reported mesh. tests…
Full details: Title check

Explanation

The title names the fix (union hang on a curved mesh) and the affected area (data crate footprint union), which matches the main change: grid snapping before the footprint union so the rocking-chair mesh union completes quickly. The title is concise, single-sentence, and specific, and it follows the conventional commit style. It omits the grid-snapping mechanism, but that detail is not required.

Full details: Description check

Explanation

The description follows the template. It has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the cause, the fix, its precision effects, and its limits. Testing lists new tests, timings, existing test results, a known unrelated failure with its explanation, and manual checks. The UI evidence section keeps the 'No visible UI change.' line as the template requires. The Related issue section contains 'Closes #1891'. The description is complete and specific.

Full details: Linked Issues check

Explanation

Issue #1891 asks that loading the reported OGC chair mesh finish well under a second with its footprint, and that loading never hang. The diff at crates/data/src/footprint.rs adds UNION_GRID = 1e-6. In footprint(), corners are snapped relative to the shape's lower corner to a power-of-two grid, unioned, and moved back by (x0, y0). The new test a_curved_mesh_is_merged_in_a_moment (per the PR) reads 97 chair faces with a 5 s limit, and the author reports about 20 ms for the full 956-face chair. The footprint far-from-origin test checks a 10 m box at (458879, 5438353). The fallback clause of #1891 applies only when a union cannot finish. The grid narrows union worst cases but does not bound union time, and the PR states that Cancel cannot stop the union. So the fallback to the outline notice is not implemented for an arbitrary pathological mesh. The reported object and its reproduction are fixed, and no test covers an unfinishable union. This residual gap is noted, but the reported bug's requirements are met by the code and the reported measurements.

Full details: Out of Scope Changes check

Explanation

All changed paths relate to #1891. footprint.rs holds the grid snapping, the translation back, the doc comment and the new test. citygml/tests.rs holds the regression test for the reported mesh. tests/data/rocking-chair.gml is the fixture for that test, and ATTRIBUTION.md records its source and MIT licence. No engine or UI code changes. The failing rustgis-engine font test named in the PR is reported as pre-existing and unrelated, and this diff does not touch that path.

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 the mesh at dawn,
While chair-shaped faces merge as one.
The grid keeps far-off corners near,
The footprint finds its place right here.
Then carrots celebrate the run.

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: aa2127f8-4ed1-469a-8c07-58a8cb61895f
Commits

Reviewing files that changed from the base of the PR and between a9f7c1c and b2b871b.

Files selected for processing: 4

  • ATTRIBUTION.md
  • crates/data/src/citygml/tests.rs
  • crates/data/src/footprint.rs
  • crates/data/tests/data/rocking-chair.gml

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 thread crates/data/src/footprint.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Two inline comments are posted (one on footprint.rs:113, one that could not be placed; see below). The rest is in this summary.

Bugs

  • None confirmed. The grid arithmetic holds: the grid is a power of two, so corners on a shape-relative whole step stay exact, the zero-grid path for subnormal or zero sizes is guarded, and shows() keeps faces at least about 100 grid cells wide, so snapping should not collapse them. Not verified: I could not run the tests or the timing claims (no build or run tools here).

Security

  • None found. The change is numeric and adds no input parsing.

Performance

  • Nothing new. The union is still one uncancellable call, and the doc comment says so. The PR's 20 ms timing is unverified here.

Quality

  • footprint.rs:87: the doc says a merged footprint's corners "are on [UNION_GRID]". Only the input corners are on the grid, relative to the shape's minimum corner. The union's output vertices are intersection points and generally are not. Reword to "within a two-millionth of the shape's size of the faces' corners". Confidence: high. Nit.
  • citygml/tests.rs:31: the spawned thread keeps running after recv_timeout fails, so a regression would leave a busy thread through the rest of the test run. Also, the 5 s limit is tight for a debug build on slower CI runners, and the PR's timings are from a release-style run. Confidence: low. Nit.

AGENTS.md

  • "Never silent" (inline, footprint.rs:113, confidence medium-high): every merged footprint moves its corners by up to about 5e-7 of the shape's size with no notice. The PR's argument that this is below the threshold where shows() already drops faces silently does not fit the rule: approximations must say what, how much and where, and existing silent losses are bugs, not a precedent.
  • Holes (could not be placed inline, footprint.rs:122, confidence low-medium): shows() gates only the outer ring, so a hole narrower than about half a grid step collapses to a line once snapped. The union may then fill in a courtyard the data has, with no notice. Check holes after snapping and add a sub-grid hole test. The line is unchanged context, which is why GitHub would not accept an inline comment there.
  • The fixture's licence header, its ATTRIBUTION row and the test's unwrap use all look consistent with the repo's rules. No other violations found.

Prior review threads: none on this PR, so no earlier concerns were left alone.

Change size

Compared with main (merge base 8f3c5cc to PR head b2b871b): the whole PR, not the latest push.

Measure Value
Files changed 4 (1 added, 3 modified, 0 removed, 0 renamed)
Size before 164.5 KB
Size after 211.2 KB
Total size change +46.8 KB
Path Before After Change
crates/data/tests/data/rocking-chair.gml 0 B 42.6 KB +42.6 KB
crates/data/src/footprint.rs 14.4 KB 17.1 KB +2.6 KB
crates/data/src/citygml/tests.rs 141.0 KB 141.9 KB +1.0 KB
ATTRIBUTION.md 9.1 KB 9.6 KB +0.5 KB

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-1919/
Web app https://preview.rustgis.app/pr-1919/app/
Commit b2b871b

GitHub Pages takes a minute or two to publish a new commit.

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

Thanks for the review. On the points in the summary (the never-silent one is answered in its thread):

  • Holes narrower than a grid step (footprint.rs:122):
    • Such a hole is under size·1e-6 wide (a millimetre on a kilometre-wide model), not a courtyard.
    • i_overlay already dropped holes below its own lattice step, and shows() already leaves out whole faces narrower than size·1e-4, without a notice, before and after this change.
    • The grid only moves that hole threshold from about size·2e-9 to size·1e-6, still a hundredth of the face width shows() takes. Keeping it as it is.
  • The thread left running and the 5 s limit:
    • CI tests in the same dev profile as the timings here (opt-level 1, dependencies at 2), where the test takes 18 ms with the fix.
    • Without the fix it took 15 s on these 97 faces, so the limit catches a regression with room either side.
    • A thread left busy after a failure ends with the test binary: nextest runs each test in its own process.
  • "Corners are on UNION_GRID" (footprint.rs:87): right, only the input corners are on it; the union's crossings needn't be. Rewording it is left for the release quality pass.

@jgregoriorincon
jgregoriorincon enabled auto-merge (squash) November 13, 2026 05:00
@jgregoriorincon
jgregoriorincon merged commit 714c8ed into opengeos:main Nov 13, 2026
18 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/1891-footprint-union-hang branch November 13, 2026 10:05
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.

[Bug]: A 3D model's footprint never finishes for some meshes, and loading hangs

1 participant