Skip to content

feat(data): city-model readers give each object's base_height above its topmost object (#1269) - #1974

Merged
jgregoriorincon merged 4 commits into
opengeos:mainfrom
jgregoriorincon:feat/1269-extrusion-base-height
Nov 14, 2026
Merged

jgregoriorincon merged 4 commits into
opengeos:mainfrom
jgregoriorincon:feat/1269-extrusion-base-height

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pull request 1 of 3 for the extrusion base height (plan): the data. The renderers and the Style › Extrusion › Base menu come next.

z_min is absolute (sea level, NAP), so it can't be an extrusion's base: a town at 500 m would float 500 m up. The CityJSON and CityGML readers now add a base_height field: how far an object's lowest point is above the lowest point of the topmost object it is part of.

  • A building gets 0; a balcony part from 506 to 507 m on a building from 500 m gets 6.
  • Parts of parts are measured from the topmost object, not the direct parent: a part 5 m up under a part 3 m up gets 8.
  • Several parents: the lowest of their grounds.
  • Groups (CityObjectGroup) aren't containers: a group's members are measured from their own building, not from the group.
  • A basement is part of its building, so the building's lowest point is the basement's: a part on a 3 m basement gets 3. The user guide says it.

Never silent:

  • The footprints notice now says what base_height holds.
  • A base_height too large to be a number is left empty and counted in the existing overflow notice, now "their height or base_height is left empty".
  • Parent chains deeper than the bound already used by raise_parents stop there with their own notice: "some parts' base_height is measured from a parent, not from the topmost object they are part of".

A visible change: base_height joins z_min, z_max and height as a reserved name, so a file's own attribute named base_height is renamed base_height_1, with the existing renaming notice.

Not in this pull request:

  • Extrusions still stand on the ground; the user guide says base_height holds where a part starts until pull request 2 uses it.
  • FileGDB multipatches have no base_height; pull request 2 will take a missing base as 0.
  • The parent index is built in both raise_parents and set_grounds; sharing it is a small change I left out to keep this one to the readers.

Followed no other project's code.

Testing

  • a_part_starts_at_its_height_above_its_building (CityJSON): a building with a raised part, a group whose members are 40 m apart (both 0), a building with a basement (its part gets 3), and a three-level chain listed child first (the grandchild gets 8, not 5). It fails if the group filter is removed or set_grounds runs one round.
  • setting_grounds_is_bounded: a 20-object chain stops at the bound and settles with room; a cycle settles.
  • a_part_above_its_building_starts_there (CityGML): an inline part and one linked by xlink:href 7 m up; a group member gets 0, not 40. It fails without the group filter.
  • The overflow test covers a part whose base overflows; the renaming test covers an attribute named base_height.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo nextest run --workspace, doctests and cargo xtask layers on macOS: all pass, 6259 tests.
  • Manual, in the desktop app: a building at 500 m with a main part and a balcony; the attribute table gives base_height 0 and 6.

UI evidence

No visible UI change: city-model layers have one more field in the attribute table.

Related issue

Part of #1269

Summary by CodeRabbit

  • New Features
    • CityJSON objects now include base_height, measured relative to the lowest point of their topmost containing building. Buildings have a base height of zero; building parts account for building elevation and basements.
    • Notices now report base-height calculation limits, including extreme elevation ranges, unknown parents, and incomplete ground propagation.
  • Documentation
    • Clarified how base heights relate to buildings, building parts, basements, groups, and extrusions.

@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 change adds base_height to city model rows. It propagates ground elevations through parent links, excluding group parents, and updates notices, tests, and CityJSON documentation.

Changes: Base Height Calculation

Layer / File(s) Summary
Propagate object grounds
crates/data/src/citymodel.rs, crates/data/src/citygml.rs, crates/data/src/cityjson.rs, crates/data/src/cityjson/tests.rs
Built objects now hold optional ground values. set_grounds propagates minimum ground values through non-group parents, subject to a visit-based round limit.
Calculate and expose base height
crates/data/src/citymodel.rs, crates/data/src/citygml/tests.rs, crates/data/src/cityjson/tests.rs, docs/user-guide/data-formats.md
Rows now include base_height, calculated from the object’s lowest Z and its propagated ground. Tests cover buildings, parts, groups, attribute collisions, missing parents, and non-finite differences. The CityJSON guide documents the field and its current extrusion behavior.

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

Change: Feature

Merge Risk: Minimal · up to 4f9f4

This adds a base_height field to CityJSON and CityGML rows, with notices for unknown parents and overflow. The change is additive and well covered by tests, so no actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the city-model readers now give each object a base_height relative to its topmost object. It follows the conventional type(scope) form and matches the raw summary and …
Description check Passed The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the problem (z_min is absolute), the new base_height field, its rules for nested p…
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.
Full details: Title check

Explanation

The title names the main change: the city-model readers now give each object a base_height relative to its topmost object. It follows the conventional type(scope) form and matches the raw summary and objectives. It does not mention the reserved-name rename or the user-guide update, which is acceptable because it need not cover every detail.

Full details: Description check

Explanation

The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the problem (z_min is absolute), the new base_height field, its rules for nested parts, multiple parents, groups, and basements, and the scope limits. Testing lists the named tests, the checks run, and a manual check. The UI evidence section keeps the 'No visible UI change.' line, as the template requires. The Related issue section says 'Part of #1269'. Minor point: the template comment asks for a Closes/Part of reference, and the description provides one.

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 ground below,
And maps the heights where buildings grow.
The parts receive their measured place,
While groups keep out of parent trace.
With carrots packed, the rows are clear,
The rabbit hops away from here.

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: dc6fc7da-26ff-427c-a905-a9b557f1392d
Commits

Reviewing files that changed from the base of the PR and between f157ae5 and 4f9f4e9.

Files selected for processing: 3

  • crates/data/src/citygml/tests.rs
  • crates/data/src/cityjson/tests.rs
  • crates/data/src/citymodel.rs

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

Comment thread crates/data/src/citymodel.rs Resolved
Comment thread crates/data/src/citymodel.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no correctness bugs. I checked the grounds propagation, the group filter, the basement case, the three-level chain and the cycle case by hand against the test fixtures. I could not compile or run the tests, since there is no Bash tool here, so formatting and compilation are unverified. No earlier review threads existed, so nothing was skipped as already raised.

Bugs

  • None found.

Security

  • None found.

Performance

  • None significant. set_grounds rescans all objects each round, but it exits early when nothing changes and is bounded the same way as raise_parents.

Quality

  • Built.ground name collision (crates/data/src/citymodel.rs:87, nit, high confidence): ground already names the GroundSurface flag in citymodel.rs and citygml.rs. Also stale: the height_overflows doc (line 112) and an overlong doc line at line 823. Posted inline as one grouped nit.

AGENTS.md

  • Missing test for the new notice (crates/data/src/citymodel.rs:1111, high confidence that no test asserts the text; medium that a read-level test is impractical): the "parent chains go deeper…" notice for base_height is never asserted. The repo rule is "test both ways", so a unit test on messages() is the practical fix. Posted inline.

Left alone: none. Both threads are new.

Change size

Compared with the base branch (merge base 11622d9 to PR head 00e565b). Sizes are file sizes, not line counts.

Files changed Added Modified Removed Renamed Size before Size after Total change
6 0 6 0 0 533.2 KB 543.6 KB +10.4 KB
Path Before After Change
crates/data/src/cityjson/tests.rs 84.8 KB 90.0 KB +5.2 KB
crates/data/src/citymodel.rs 48.8 KB 51.8 KB +3.0 KB
crates/data/src/citygml/tests.rs 157.6 KB 159.4 KB +1.8 KB
docs/user-guide/data-formats.md 87.8 KB 88.2 KB +349 B
crates/data/src/citygml.rs 133.7 KB 133.7 KB +26 B
crates/data/src/cityjson.rs 20.5 KB 20.5 KB +26 B

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-1974/
Web app https://preview.rustgis.app/pr-1974/app/
Commit 4f9f4e9

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

Comment thread crates/data/src/citymodel.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • Silent base_height of 0 when a parent isn't in the file (medium confidence). CityJSON parents are used as written, with no check that the named object exists. If the parent is missing, or was skipped as unreadable, set_grounds drops the link. The part then gets base_height 0 with no notice, and the "couldn't be read" notice doesn't say this happened. CityGML reports unresolved links via relate(), so only CityJSON has the gap. Posted inline at crates/data/src/citymodel.rs:834.

I checked the rest of the new logic and found no other defects: the group filter, the bounded rounds, the overflow handling (base_height nulled and counted), the notice wording, and the cycle and chain tests. The algorithm gives the expected values in the tests I traced by hand.

Security

  • None found. The new code uses get() and does no unchecked indexing.

Performance

  • Minor: set_grounds rebuilds the same parent index that raise_parents builds. Both now spend up to MAX_PARENT_VISITS each, so the worst case roughly doubles. Both are bounded, and the PR body already mentions the duplicate index. Low priority.

Quality

  • Left for the release quality pass, not re-raised: the Built.ground name clashes with the GroundSurface flag, and the set_grounds doc comment line is about 145 columns. Both were raised in an earlier thread.
  • MAX_PARENT_VISITS's doc comment (citymodel.rs:30-32) still says it bounds only passing heights up. It now bounds grounds too. Low priority.

AGENTS.md

  • Notices: the new notice is counted and says what, how much and where. Lossy and clean inputs are both tested. Compliant apart from the dangling-parent gap above.
  • No unwrap or expect in non-test code. unsafe is not used. Let-chains are fine on edition 2024 with rust-version 1.90.
  • Cancel: set_grounds's doc comment says it does not look at Cancel and why. This meets the rule.
  • The data-formats guide is updated. The CityGML row covers base_height by reference to CityJSON.

Earlier concerns

  • Two earlier threads exist. One says the ground_rounds notice is untested. The diff now asserts its exact text in setting_grounds_is_bounded, so that concern is answered by the code and I did not re-raise it. The other is the quality-nit thread, which I left alone. In total, 2 earlier concerns were left alone: 1 answered by the diff and 1 quality nit.

I could not run cargo or the tests in this environment, so the results above come from reading the code.

Change size

Compared with main (merge base 11622d9 to PR head f157ae5).

Measure Value
Files changed 6 (0 added, 6 modified, 0 removed, 0 renamed)
Size before 546.0 KB
Size after 557.2 KB
Total size change +11.2 KB
Path Before After Change
crates/data/src/cityjson/tests.rs 84.8 KB 90.5 KB +5.7 KB
crates/data/src/citymodel.rs 48.8 KB 51.8 KB +3.0 KB
crates/data/src/citygml/tests.rs 157.6 KB 159.3 KB +1.8 KB
docs/user-guide/data-formats.md 87.8 KB 88.2 KB +0.3 KB
crates/data/src/citygml.rs 133.7 KB 133.7 KB +26 B
crates/data/src/cityjson.rs 20.5 KB 20.5 KB +26 B

@jgregoriorincon
jgregoriorincon marked this pull request as draft November 13, 2026 23:23
Comment thread crates/data/src/citymodel.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • base_height has the wrong sign in depth vertical systems, and nothing says so (medium-high). For EPSG 5715, 6357, 6358, 8051 and 8053 the heights are kept as the file has them, with Z increasing downward. set_grounds then measures in the numeric direction, so the value is how far the part's top sits below the building's top, not how far its lowest point sits above the building's lowest point. The depth notice names only z_min and z_max. Inline comment posted at crates/data/src/citymodel.rs:881.

Security

  • None found.

Performance

  • set_grounds rebuilds the parent index and link lists that raise_parents has already built (low). The PR body acknowledges this. The worst case per file is now about two passes at the visit cap instead of one.

Quality

  • The vertical-unit notices omit base_height (medium-high). The notices at citymodel.rs:366, :372 and :463 say "z_min, z_max and height are kept as the file has them". base_height is in the same unit, so a feet file gives no warning for it. The exact-text assertion at crates/data/src/citygml/tests.rs:244 would need updating along with the text. Suggested wording: "z_min, z_max, height and base_height are kept as the file has them".
  • Module docs are stale (low). citymodel.rs:8-10, cityjson.rs:3 and citygml.rs:3 still list only z_min, z_max and height.
  • Long doc line (low, release quality pass). The MAX_PARENT_VISITS doc at about citymodel.rs:295 runs to roughly 150 columns.

AGENTS.md

  • The depth finding above breaks the "says what, how much and where" rule. The rest of the change follows the guidelines: the new notices have tests both ways, set_grounds says in its doc comment that it doesn't look at Cancel, and there are no unwrap, expect or indexing calls in non-test code.

Checked and not raised

  • The earlier "silent 0 for a part whose parent isn't in the file" concern is covered by the new unknown_parents notice.
  • The group filter, the overflow checks, the Counts wiring and the determinism of the lookups all hold.
  • Anonymous parents are already said in their own notice. Duplicate gml:ids are said under repeated_ids.
  • Parents with no Z are given one by raise_parents, so the ground chain doesn't break at them.

Earlier concerns left alone: 5. The silent-zero parent concern (addressed by the new notice), the test-gap thread (resolved), and three quality points from the earlier thread (the ground name, the height_overflows doc, the long set_grounds doc line).

Change size

Compared with main (merge base 11622d9 to PR head 467d2f9).

Measure Value
Files changed 6 (0 added, 6 modified, 0 removed, 0 renamed)
Size before 533.2 KB
Size after 545.6 KB
Total size change +12.4 KB
Path Before After Change
crates/data/src/cityjson/tests.rs 84.8 KB 91.4 KB +6.6 KB
crates/data/src/citymodel.rs 48.8 KB 52.4 KB +3.6 KB
crates/data/src/citygml/tests.rs 157.6 KB 159.4 KB +1.8 KB
docs/user-guide/data-formats.md 87.8 KB 88.2 KB +349 B
crates/data/src/citygml.rs 133.7 KB 133.7 KB +26 B
crates/data/src/cityjson.rs 20.5 KB 20.5 KB +26 B

Comment thread crates/data/src/citymodel.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff, the staged metadata, the four prior review threads, and the surrounding code in citymodel.rs, cityjson.rs and citygml.rs. I did not run the tests; the checks below are by reading.

Bugs

  • Group parents still raise a building's lowest point. raise_parents (citymodel.rs:804) links objects to every parent, groups included, while set_grounds drops group parents. A group with a grp:parent building passes its members' Z up to that building, so a balcony part's base_height can come out too large. Posted inline at citymodel.rs:840. Confidence: medium-low (about 40%).

Security

  • None found. The new code uses get(), checked arithmetic and bounded rounds, and has no unwrap, expect or unsafe.

Performance

  • set_grounds repeats the parent index and per-object Vec allocations that raise_parents already builds, and unknown_parents builds another id HashSet. The author already accepted the duplicate index. Confidence: low; this is a minor cost, not a defect.

Quality

  • The doc comment on a_part_starts_at_its_height_above_its_building says a roof-top part gets "its own height". The asserted value is the gap above the building's lowest point (balcony 13–14 m on a building at 10 m gets 3, not 1). Left for the release quality pass.
  • The MAX_PARENT_VISITS doc comment (citymodel.rs:314) runs well past the wrap width. Left for the release quality pass.

AGENTS.md

  • The PR body cites checks.sh as the passing gate. No checks.sh exists in the repository; AGENTS.md specifies cargo xtask ci. Confidence: high.
  • The rest of the changes follow the rules: notices for lossy cases (the overflow, missing-parent and bounded-chain paths) are each covered by a test, the clean case is asserted silent, and the user guide is updated.

Already raised (left alone)

  • Four earlier threads were checked and left alone, since each is resolved and answered: the missing messages test, the ground naming, the missing-parent notice, and the depth-system sign. The depth-system answer ("said rather than recomputed") is consistent with the notice text.

Change size

Compared: the whole PR against main (merge base 11622d9 to PR head 4f9f4e9).

Measure Value
Files changed 6 (0 added, 6 modified, 0 removed, 0 renamed)
Size before 533.2 KB
Size after 545.9 KB
Total size change +12.7 KB
Path Before After Change
crates/data/src/cityjson/tests.rs 84.8 KB 91.4 KB +6.6 KB
crates/data/src/citymodel.rs 48.8 KB 52.5 KB +3.7 KB
crates/data/src/citygml/tests.rs 157.5 KB 159.5 KB +2.0 KB
docs/user-guide/data-formats.md 87.8 KB 88.2 KB +0.3 KB
crates/data/src/citygml.rs 133.7 KB 133.7 KB +26 B
crates/data/src/cityjson.rs 20.5 KB 20.5 KB +26 B

@jgregoriorincon
jgregoriorincon marked this pull request as ready for review November 14, 2026 00:35
@jgregoriorincon
jgregoriorincon enabled auto-merge (squash) November 14, 2026 00:36
counts.ground_rounds = set_grounds(&mut built, MAX_PARENT_VISITS).unwrap_or(0);
counts.unknown_parents = {
let ids: HashSet<&str> = built.iter().map(|b| b.id.as_str()).collect();
built.iter().filter(|b| b.parent_ids.iter().any(|p| !ids.contains(p.as_str()))).count()

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.

The "name a parent that isn't in the file" count also takes in group parents, and TINRelief parents. set_grounds never links a child to a CityObjectGroup, so a member whose group couldn't be read gets the same base_height either way, yet this count sends it into the notice "their base_height leaves it out". A TINRelief parent is in the file, not unreadable. Confidence: low (about 40%). The fix needs the parent's type, which an unreadable group doesn't have, so this may be worth a reworded notice rather than a code change.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no crash, panic or data-loss bug in the new code. The bounds, the cycle handling and the overflow checks hold up on reading. Two notice-accuracy findings remain, and I posted one of them inline. The second could not be posted inline because its line is outside the diff, so it is listed here only.

Bugs

  • Low (about 40%): the "parent isn't in the file" count is broader than its notice. citymodel.rs:544 counts any object whose parent id is missing from built. That includes a CityObjectGroup that couldn't be read, which set_grounds never links anyway, and a TINRelief parent, which is in the file. The notice "their base_height leaves it out" is then false for those objects. Posted inline on citymodel.rs:544.

Security

  • None found. The new code indexes only through get() and get_mut(), and the new notices carry no file content.

Performance

  • Nothing that matters. set_grounds is bounded by MAX_PARENT_VISITS, the same bound as raise_parents, and the extra HashSet in finish is linear. The author already acknowledged the duplicated parent index.

Quality

These may wait for the release quality pass.

  • citymodel.rs:314: the new MAX_PARENT_VISITS doc line runs to roughly 150 columns and needs rewrapping.
  • Stale field lists in module docs: citymodel.rs:8, cityjson.rs:3 and citygml.rs:3 still describe the heights as z_min, z_max and height only, without base_height.

AGENTS.md

  • Medium (about 60%): the bad-heights notice at citymodel.rs:1099 omits base_height. It still reads "which z_min, z_max and height leave out". Non-finite points are dropped from z, so base_height is measured from the finite points only and is affected the same way. The notice should name base_height. This line is outside the PR's hunks, so GitHub rejected an inline comment on it. The suggested text is "{} city objects have heights that aren't finite numbers, which z_min, z_max, height and base_height leave out".

Earlier concerns left alone

I left 5 existing review threads alone because they were already raised:

  • The naming of Built.ground and the height_overflows doc.
  • The depth-system sign question, which the author answered by saying the heights are kept as the file has them.
  • The group-parent height passing through raise_parents, which the author answered by moving it to a separate issue.
  • The silent zero for a missing parent, which the author fixed.
  • The test gap on the parent-chain notice, which the author fixed.

Change size

Compared with the base branch (merge base 11622d9 to PR head 4f9f4e9).

Metric Value
Files changed 6 (0 added, 6 modified, 0 removed, 0 renamed)
Size before 533.2 KB
Size after 545.9 KB
Total size change +12.7 KB
Path Before After Change
crates/data/src/cityjson/tests.rs 84.8 KB 91.4 KB +6.6 KB
crates/data/src/citymodel.rs 48.8 KB 52.5 KB +3.7 KB
crates/data/src/citygml/tests.rs 157.6 KB 159.4 KB +2.0 KB
docs/user-guide/data-formats.md 87.8 KB 88.2 KB +341 B
crates/data/src/citygml.rs 133.7 KB 133.7 KB +26 B
crates/data/src/cityjson.rs 20.5 KB 20.5 KB +26 B

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