diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-08 14:50:55 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-10-08 14:50:55 +0200 |
| commit | 2118edd31bb060ce84181c2ca3d30591a3dcd68a (patch) | |
| tree | 7483ec93650c77f98f9821465578f5aca52bcb7a /src/iso19111/operation | |
| parent | 7be04dedc2b23d6836f994c9bc1412d6a23a7267 (diff) | |
| download | PROJ-2118edd31bb060ce84181c2ca3d30591a3dcd68a.tar.gz PROJ-2118edd31bb060ce84181c2ca3d30591a3dcd68a.zip | |
WKT concatenated operation parsing: fix when a axis order reversal conversion is the first or last operation (fixes #2890)
Diffstat (limited to 'src/iso19111/operation')
| -rw-r--r-- | src/iso19111/operation/concatenatedoperation.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/iso19111/operation/concatenatedoperation.cpp b/src/iso19111/operation/concatenatedoperation.cpp index 185ebb4a..7da561b4 100644 --- a/src/iso19111/operation/concatenatedoperation.cpp +++ b/src/iso19111/operation/concatenatedoperation.cpp @@ -37,6 +37,7 @@ #include "proj/metadata.hpp" #include "proj/util.hpp" +#include "proj/internal/crs_internal.hpp" #include "proj/internal/internal.hpp" #include "proj/internal/io_internal.hpp" @@ -245,15 +246,44 @@ void ConcatenatedOperation::fixStepsDirection( return false; }; + // Apply axis order reversal operation on first operation if needed + // to set CRSs on it + if (operationsInOut.size() >= 1) { + auto &op = operationsInOut.front(); + auto l_sourceCRS = op->sourceCRS(); + auto l_targetCRS = op->targetCRS(); + auto conv = dynamic_cast<const Conversion *>(op.get()); + if (conv && !l_sourceCRS && !l_targetCRS && + isAxisOrderReversal(conv->method()->getEPSGCode())) { + auto reversedCRS = concatOpSourceCRS->applyAxisOrderReversal( + NORMALIZED_AXIS_ORDER_SUFFIX_STR); + op->setCRSs(concatOpSourceCRS, reversedCRS, nullptr); + } + } + + // Apply axis order reversal operation on last operation if needed + // to set CRSs on it + if (operationsInOut.size() >= 2) { + auto &op = operationsInOut.back(); + auto l_sourceCRS = op->sourceCRS(); + auto l_targetCRS = op->targetCRS(); + auto conv = dynamic_cast<const Conversion *>(op.get()); + if (conv && !l_sourceCRS && !l_targetCRS && + isAxisOrderReversal(conv->method()->getEPSGCode())) { + auto reversedCRS = concatOpTargetCRS->applyAxisOrderReversal( + NORMALIZED_AXIS_ORDER_SUFFIX_STR); + op->setCRSs(reversedCRS, concatOpTargetCRS, 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) { - auto derivedCRS = - dynamic_cast<const crs::DerivedCRS *>(concatOpSourceCRS.get()); - if (derivedCRS) { + if (auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>( + concatOpSourceCRS.get())) { if (i + 1 < operationsInOut.size()) { // use the sourceCRS of the next operation as our target CRS l_targetCRS = operationsInOut[i + 1]->sourceCRS(); |
