aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/operation
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-10-08 17:25:06 +0200
committerGitHub <noreply@github.com>2021-10-08 17:25:06 +0200
commit02225ff0bb11ea137751d9694978e61060f829bd (patch)
tree499e6c2471eb5d04f5c471f68a90db41b7009e96 /src/iso19111/operation
parentc8b28d3fd2a8634d4dc97fb4850e56d8ab0a3e4b (diff)
parent2118edd31bb060ce84181c2ca3d30591a3dcd68a (diff)
downloadPROJ-02225ff0bb11ea137751d9694978e61060f829bd.tar.gz
PROJ-02225ff0bb11ea137751d9694978e61060f829bd.zip
Merge pull request #2891 from rouault/fix_2890
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.cpp36
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();