Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api] Add QgsProject::crs3D #57107

Merged
merged 9 commits into from Apr 26, 2024
Merged

[api] Add QgsProject::crs3D #57107

merged 9 commits into from Apr 26, 2024

Conversation

nyalldawson
Copy link
Collaborator

Returns the CRS to use for the project when transforming 3D data, or when z/elevation value handling is important.

The returned CRS will take into account verticalCrs(), e.g. by returning a compound CRS consisting of crs() + verticalCrs().

This method may still return a 2D CRS, e.g in the case that crs() is a 2D CRS and no verticalCrs() has been set for the project. I.E. It is NOT guaranteed that the returned CRS will actually be a 3D CRS, but rather it is guaranteed that the returned CRS is ALWAYS the most appropriate CRS to use when handling 3D data.

Refs discussion in #56791, qgis/QGIS-Enhancement-Proposals#267

@nyalldawson
Copy link
Collaborator Author

@rouault @wonder-sk as previously discussed

@wonder-sk
Copy link
Member

@nyalldawson is this going to work if 3D Geographic (e.g. EPSG:4979) or Geocentric (e.g. EPSG:4978) CRS is set as the project CRS? Or is support for that out of scope for now?

@github-actions github-actions bot added this to the 3.38.0 milestone Apr 10, 2024
@nyalldawson
Copy link
Collaborator Author

@wonder-sk

is this going to work if 3D Geographic (e.g. EPSG:4979) or Geocentric (e.g. EPSG:4978) CRS is set as the project CRS? Or is support for that out of scope for now?

It works fine for this situation:

image

@nyalldawson
Copy link
Collaborator Author

@wonder-sk I've applied some more related refinements here

case Qgis::CrsType::Unknown:
case Qgis::CrsType::Geodetic:
case Qgis::CrsType::Geographic2d:
case Qgis::CrsType::Projected:
Copy link
Contributor

Choose a reason for hiding this comment

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

some Projected CRS might already be 3D. You should probably check the axis count

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rouault
Thanks!

Does 458b1fd and 6773e67 address this correctly?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, looks good

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @rouault !

Returns the CRS to use for the project when transforming 3D data,
or when z/elevation value handling is important.

The returned CRS will take into account verticalCrs(), e.g. by
returning a compound CRS consisting of crs() + verticalCrs().

This method may still return a 2D CRS, e.g in the case that crs()
is a 2D CRS and no verticalCrs() has been set for the project.
I.E. It is NOT guaranteed that the returned CRS will actually
be a 3D CRS, but rather it is guaranteed that the returned CRS
is **ALWAYS** the most appropriate CRS to use when handling 3D data.
Report proj error when compound crs cannot be created
or geocentric

Following https://docs.ogc.org/as/18-005r5/18-005r5.html#34 it is not
a valid combination to create a compound crs from these types
Can be used to test if a crs contains a vertical axis
@nyalldawson nyalldawson merged commit 1b59026 into qgis:master Apr 26, 2024
29 of 30 checks passed
@nyalldawson nyalldawson deleted the crs3d branch April 26, 2024 10:26
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.

None yet

4 participants