diff options
Diffstat (limited to 'src/iso19111')
| -rw-r--r-- | src/iso19111/operation/concatenatedoperation.cpp | 24 | ||||
| -rw-r--r-- | src/iso19111/operation/projbasedoperation.cpp | 16 |
2 files changed, 25 insertions, 15 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(), diff --git a/src/iso19111/operation/projbasedoperation.cpp b/src/iso19111/operation/projbasedoperation.cpp index 6e0fd109..fd03fc09 100644 --- a/src/iso19111/operation/projbasedoperation.cpp +++ b/src/iso19111/operation/projbasedoperation.cpp @@ -232,15 +232,13 @@ void PROJBasedOperation::_exportToJSON( method()->_exportToJSON(formatter); const auto &l_parameterValues = parameterValues(); - if (!l_parameterValues.empty()) { - writer->AddObjKey("parameters"); - { - auto parametersContext(writer->MakeArrayContext(false)); - for (const auto &genOpParamvalue : l_parameterValues) { - formatter->setAllowIDInImmediateChild(); - formatter->setOmitTypeInImmediateChild(); - genOpParamvalue->_exportToJSON(formatter); - } + writer->AddObjKey("parameters"); + { + auto parametersContext(writer->MakeArrayContext(false)); + for (const auto &genOpParamvalue : l_parameterValues) { + formatter->setAllowIDInImmediateChild(); + formatter->setOmitTypeInImmediateChild(); + genOpParamvalue->_exportToJSON(formatter); } } } |
