From b210728be7960e713a5558e8980af20dccc698e2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 9 Feb 2022 16:20:22 +0100 Subject: createOperations(): fix transformations from/to a BoundCRS of a DerivedGeographicCRS coming from WKT --- src/iso19111/operation/transformation.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/iso19111/operation/transformation.cpp b/src/iso19111/operation/transformation.cpp index 1f399c7e..1e452d2c 100644 --- a/src/iso19111/operation/transformation.cpp +++ b/src/iso19111/operation/transformation.cpp @@ -2460,10 +2460,15 @@ static void setupPROJGeodeticSourceCRS(io::PROJStringFormatter *formatter, formatter->stopInversion(); if (util::isOfExactType( *(sourceCRSGeog.get()))) { + const auto derivedGeogCRS = + dynamic_cast( + sourceCRSGeog.get()); // The export of a DerivedGeographicCRS in non-CRS mode adds - // unit conversion and axis swapping. We must compensate for that + // unit conversion and axis swapping to the base CRS. + // We must compensate for that formatter->startInversion(); formatter->startInversion(); - sourceCRSGeog->addAngularUnitConvertAndAxisSwap(formatter); + derivedGeogCRS->baseCRS()->addAngularUnitConvertAndAxisSwap( + formatter); formatter->stopInversion(); } @@ -2502,8 +2507,13 @@ static void setupPROJGeodeticTargetCRS(io::PROJStringFormatter *formatter, if (util::isOfExactType( *(targetCRSGeog.get()))) { // The export of a DerivedGeographicCRS in non-CRS mode adds - // unit conversion and axis swapping. We must compensate for that - targetCRSGeog->addAngularUnitConvertAndAxisSwap(formatter); + // unit conversion and axis swapping to the base CRS. + // We must compensate for that formatter->startInversion(); + const auto derivedGeogCRS = + dynamic_cast( + targetCRSGeog.get()); + derivedGeogCRS->baseCRS()->addAngularUnitConvertAndAxisSwap( + formatter); } targetCRSGeog->_exportToPROJString(formatter); } else { -- cgit v1.2.3