Add Undefined mercatorOrigin Check to computeMercatorFractionToDb #7269
+30
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is to address this issue: https://github.com/iTwin/itwinjs-backlog/issues/1243
Currently, there is an edge case where if new
BackgroundMapGeometry
is created with project extents centered at(0,0,0)
and anecefLocation.origin
of(0,0,0)
, the creation of theBackgroundMapGeometry
will fail. When the point(0,0,0)
is converted from ECEF to aCartographic
usingCartographic.fromEcef
, the function will returnundefined
and cause an error to occur on the creation ofBackgroundMapGeometry
in the above scenario.To fix this,
ecefToPixelFraction
has been changed to now also returnundefined
iffromEcef
returnsundefined
, and a check has been added tocomputeMercatorFractionToDb
to return an identity transform ifmercatorOrigin
,mercatorX
, ormercatorY
isundefined
due to the change inecefToPixelFraction
. A test has also been added toBackgroundMapGeometry.test.ts
which tests the scenario where the project extents are centered at(0,0,0)
and theecefLocation.origin
is(0,0,0)
and confirms the succesful creation ofBackgroundMapGeometry
.