aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/operation/concatenatedoperation.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2022-03-09 11:42:09 +0100
committerEven Rouault <even.rouault@spatialys.com>2022-03-09 14:26:00 +0100
commita16407e9d78ecb79c9d8920f9325652d9503a1c7 (patch)
treef2d53773fed5498f2b69509ba258091551f0ff5f /src/iso19111/operation/concatenatedoperation.cpp
parenta95b6736a3e08fea6d578e28e600fed297763d8c (diff)
downloadPROJ-a16407e9d78ecb79c9d8920f9325652d9503a1c7.tar.gz
PROJ-a16407e9d78ecb79c9d8920f9325652d9503a1c7.zip
Fix import of WKT of concatenated operation with inverse conversion of a compound CRS of a projected CRS (fixes #3076)
Diffstat (limited to 'src/iso19111/operation/concatenatedoperation.cpp')
-rw-r--r--src/iso19111/operation/concatenatedoperation.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/iso19111/operation/concatenatedoperation.cpp b/src/iso19111/operation/concatenatedoperation.cpp
index 7da561b4..e5728c4c 100644
--- a/src/iso19111/operation/concatenatedoperation.cpp
+++ b/src/iso19111/operation/concatenatedoperation.cpp
@@ -276,14 +276,28 @@ void ConcatenatedOperation::fixStepsDirection(
}
}
+ const auto extractDerivedCRS =
+ [](const crs::CRS *crs) -> const crs::DerivedCRS * {
+ auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>(crs);
+ if (derivedCRS)
+ return derivedCRS;
+ auto compoundCRS = dynamic_cast<const crs::CompoundCRS *>(crs);
+ if (compoundCRS) {
+ derivedCRS = dynamic_cast<const crs::DerivedCRS *>(
+ compoundCRS->componentReferenceSystems().front().get());
+ if (derivedCRS)
+ return derivedCRS;
+ }
+ return nullptr;
+ };
+
for (size_t i = 0; i < operationsInOut.size(); ++i) {
auto &op = operationsInOut[i];
auto l_sourceCRS = op->sourceCRS();
auto l_targetCRS = op->targetCRS();
auto conv = dynamic_cast<const Conversion *>(op.get());
if (conv && i == 0 && !l_sourceCRS && !l_targetCRS) {
- if (auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>(
- concatOpSourceCRS.get())) {
+ if (auto derivedCRS = extractDerivedCRS(concatOpSourceCRS.get())) {
if (i + 1 < operationsInOut.size()) {
// use the sourceCRS of the next operation as our target CRS
l_targetCRS = operationsInOut[i + 1]->sourceCRS();
@@ -323,8 +337,7 @@ void ConcatenatedOperation::fixStepsDirection(
}
} else if (conv && i + 1 == operationsInOut.size() && !l_sourceCRS &&
!l_targetCRS) {
- auto derivedCRS =
- dynamic_cast<const crs::DerivedCRS *>(concatOpTargetCRS.get());
+ auto derivedCRS = extractDerivedCRS(concatOpTargetCRS.get());
if (derivedCRS) {
if (i >= 1) {
// use the sourceCRS of the previous operation as our source
@@ -350,8 +363,7 @@ void ConcatenatedOperation::fixStepsDirection(
} else if (i >= 1) {
l_sourceCRS = operationsInOut[i - 1]->targetCRS();
if (l_sourceCRS) {
- derivedCRS = dynamic_cast<const crs::DerivedCRS *>(
- l_sourceCRS.get());
+ derivedCRS = extractDerivedCRS(l_sourceCRS.get());
if (derivedCRS &&
conv->isEquivalentTo(
derivedCRS->derivingConversion().get(),