Skip to content

Fix reality data not being reprojected correctly when its CRS is different than iModel#9059

Merged
anmolshres98 merged 15 commits into
masterfrom
eringram/rd-reproject-crs
Mar 9, 2026
Merged

Fix reality data not being reprojected correctly when its CRS is different than iModel#9059
anmolshres98 merged 15 commits into
masterfrom
eringram/rd-reproject-crs

Conversation

@eringram

@eringram eringram commented Mar 4, 2026

Copy link
Copy Markdown
Member

There is a bug where when using the reproject parameter of TileTreeReference.createGeometryTreeReference, if the reality data is not in the same CRS than the iModel, the reprojection will put the geometry at the wrong place.

This was because in RealityTileLoader.loadGeometryFromStream, the geometry returned by RealityTileLoader.readGltfAndCreateGeometry is in iModel coordinates, but the reprojection transform is in the reality tree's coordinates.

The fix is to take this difference into account by doing the following:

  1. multiply polyface by inverse of tree's iModelTransform to "convert" polyface from iModel CRS->tile tree CRS
  2. apply the original reprojection transform xForm
  3. multiply by original iModelTransform to convert back from tile tree CRS->iModel CRS

Tested with a couple different iModels with reality data in different CRS. I also added some unit tests for this.

@aruniverse

Copy link
Copy Markdown
Member

@Mergifyio backport release/5.6.x release/5.7.x

@mergify

mergify Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

backport release/5.6.x release/5.7.x

✅ Backports have been created

Details

Cherry-pick of d122ee6 has failed:

On branch mergify/bp/release/5.6.x/pr-9059
Your branch is up to date with 'origin/release/5.6.x'.

You are currently cherry-picking commit d122ee67a0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   common/changes/@itwin/core-frontend/eringram-rd-reproject-crs_2026-03-04-23-15.json
	modified:   core/frontend/src/internal/tile/RealityTileLoader.ts
	modified:   core/frontend/src/test/tile/RealityTile.test.ts

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   docs/changehistory/NextVersion.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Cherry-pick of d122ee6 has failed:

On branch mergify/bp/release/5.7.x/pr-9059
Your branch is up to date with 'origin/release/5.7.x'.

You are currently cherry-picking commit d122ee67a0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   common/changes/@itwin/core-frontend/eringram-rd-reproject-crs_2026-03-04-23-15.json
	modified:   core/frontend/src/internal/tile/RealityTileLoader.ts
	modified:   core/frontend/src/test/tile/RealityTile.test.ts

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   docs/changehistory/NextVersion.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@aruniverse aruniverse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work! Do we need to run image tests?

Copilot AI left a comment

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.

Pull request overview

Fixes incorrect reprojection of reality tile geometry when the reality data’s CRS differs from the iModel’s CRS by converting the reprojection transform from root-tile coordinates into iModel coordinates before transforming collected polyfaces.

Changes:

  • Conjugate tile.reprojectionTransform by RealityTileTree.iModelTransform when cloning transformed polyfaces during geometry collection.
  • Extend reality tile loader unit tests to cover reprojection when the tree’s iModelTransform is non-identity.
  • Add a change file for @itwin/core-frontend.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
core/frontend/src/internal/tile/RealityTileLoader.ts Applies reprojection in the correct coordinate space by conjugating the root-tile CRS transform into iModel CRS before transforming polyfaces.
core/frontend/src/test/tile/RealityTile.test.ts Adds tests around reprojection behavior when iModelTransform is non-identity and when it is identity.
common/changes/@itwin/core-frontend/eringram-rd-reproject-crs_2026-03-04-23-15.json Records the change for the package.

Comment thread core/frontend/src/internal/tile/RealityTileLoader.ts Outdated
Comment thread core/frontend/src/internal/tile/RealityTileLoader.ts Outdated
Comment thread core/frontend/src/test/tile/RealityTile.test.ts
@markschlosseratbentley

Copy link
Copy Markdown
Contributor

Nice work! Do we need to run image tests?

@eringram I think we should just to be safe.

@eringram

eringram commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

No image tests differences of note.

The V4 tests had some missing reality data, but I confirmed in the logs it was related to flaky requests for the data and not due to the rendering. The same reality data looked correct in the V1 tests, and since it's reality data and not iModel geometry, the tiles are the same in both versions. (correct me if that doesn't sound right, @markschlosseratbentley ..?)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@markschlosseratbentley markschlosseratbentley left a comment

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.

Does a NextVersion.md entry make sense?

@eringram eringram requested a review from a team as a code owner March 5, 2026 19:40
@eringram eringram requested review from rschili and saeeedtorabi March 5, 2026 19:40
@eringram

eringram commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

Does a NextVersion.md entry make sense?

Added

@markschlosseratbentley

Copy link
Copy Markdown
Contributor

Does a NextVersion.md entry make sense?

Added

Thanks. LGTM.

@eringram

eringram commented Mar 6, 2026

Copy link
Copy Markdown
Member Author

Doing some more testing of this before merging

@mergify

mergify Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in conflicts. Could you fix it @eringram? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

@anmolshres98

Copy link
Copy Markdown
Contributor

@eringram are you planning on getting this merged in today? I am waiting on this to release the next 5.6 patch release. No worries if you are not planning on merging today, just wanted to check :)

@eringram

eringram commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

@anmolshres98 Hey sorry for the delay, yes planning to merge today. I'll fix the conflicts to do that now.

@anmolshres98 anmolshres98 merged commit d122ee6 into master Mar 9, 2026
15 checks passed
@anmolshres98 anmolshres98 deleted the eringram/rd-reproject-crs branch March 9, 2026 20:49
mergify Bot pushed a commit that referenced this pull request Mar 9, 2026
…erent than iModel (#9059)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Polinsky <78756012+ben-polinsky@users.noreply.github.com>
Co-authored-by: Anmol Shrestha <98850418+anmolshres98@users.noreply.github.com>
(cherry picked from commit d122ee6)

# Conflicts:
#	docs/changehistory/NextVersion.md
mergify Bot pushed a commit that referenced this pull request Mar 9, 2026
…erent than iModel (#9059)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Polinsky <78756012+ben-polinsky@users.noreply.github.com>
Co-authored-by: Anmol Shrestha <98850418+anmolshres98@users.noreply.github.com>
(cherry picked from commit d122ee6)

# Conflicts:
#	docs/changehistory/NextVersion.md
anmolshres98 added a commit that referenced this pull request Mar 9, 2026
…erent than iModel (backport #9059) [release/5.6.x] (#9074)

Co-authored-by: Erin Ingram <47707444+eringram@users.noreply.github.com>
Co-authored-by: anmolshres98 <anmolshres98@users.noreply.github.com>
Copilot AI added a commit that referenced this pull request Mar 10, 2026
Co-authored-by: hl662 <50554904+hl662@users.noreply.github.com>
hl662 added a commit that referenced this pull request Mar 10, 2026
…erent than iModel (backport #9059) [release/5.7.x] (#9075)

Co-authored-by: Erin Ingram <47707444+eringram@users.noreply.github.com>
Co-authored-by: Nam Le <50554904+hl662@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

6 participants