aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/crs.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-04-24 19:07:55 +0200
committerGitHub <noreply@github.com>2021-04-24 19:07:55 +0200
commitea196217fd575a3a4bdc2fb8a094ffcd358f3980 (patch)
tree7d796b52ce2ca6ffa6ca3d584fecdab4d70965e0 /src/iso19111/crs.cpp
parent01a5c03c052be14f731b1e96ca3c0005f110aad8 (diff)
parent7898eaba1160631405e8d4eccd73254f453bd3d4 (diff)
downloadPROJ-ea196217fd575a3a4bdc2fb8a094ffcd358f3980.tar.gz
PROJ-ea196217fd575a3a4bdc2fb8a094ffcd358f3980.zip
Merge pull request #2696 from rouault/derived_vertical_crs_unit_height_depth
Improvements related to DerivedVerticalCRS using Change Unit and Height/Depth reversal methods
Diffstat (limited to 'src/iso19111/crs.cpp')
-rw-r--r--src/iso19111/crs.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index 2d589ad1..51317c18 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -6506,6 +6506,33 @@ DerivedVerticalCRSNNPtr DerivedVerticalCRS::create(
void DerivedVerticalCRS::_exportToWKT(io::WKTFormatter *formatter) const {
const bool isWKT2 = formatter->version() == io::WKTFormatter::Version::WKT2;
if (!isWKT2) {
+
+ bool useBaseMethod = true;
+ const DerivedVerticalCRS *dvcrs = this;
+ while (true) {
+ // If the derived vertical CRS is obtained through simple conversion
+ // methods that just do unit change or height/depth reversal, export
+ // it as a regular VerticalCRS
+ const int methodCode =
+ dvcrs->derivingConversionRef()->method()->getEPSGCode();
+ if (methodCode == EPSG_CODE_METHOD_CHANGE_VERTICAL_UNIT ||
+ methodCode ==
+ EPSG_CODE_METHOD_CHANGE_VERTICAL_UNIT_NO_CONV_FACTOR ||
+ methodCode == EPSG_CODE_METHOD_HEIGHT_DEPTH_REVERSAL) {
+ dvcrs = dynamic_cast<DerivedVerticalCRS *>(baseCRS().get());
+ if (dvcrs == nullptr) {
+ break;
+ }
+ } else {
+ useBaseMethod = false;
+ break;
+ }
+ }
+ if (useBaseMethod) {
+ VerticalCRS::_exportToWKT(formatter);
+ return;
+ }
+
io::FormattingException::Throw(
"DerivedVerticalCRS can only be exported to WKT2");
}