Skip to content

Commit

Permalink
Merge pull request OSGeo#4120 from rouault/fix_4116
Browse files Browse the repository at this point in the history
ConcatenatedOperation::fixStepsDirection(): handle case where conversion is chained with transformation that must be reversed
  • Loading branch information
rouault authored Apr 17, 2024
2 parents 4324796 + 091bed1 commit 08ee492
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/iso19111/operation/concatenatedoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,38 @@ void ConcatenatedOperation::fixStepsDirection(
} else {
op->setCRSs(NN_NO_CHECK(l_sourceCRS),
NN_NO_CHECK(l_targetCRS), nullptr);

// Deal with special case of
// https://github.com/OSGeo/PROJ/issues/4116 where EPSG:7989
// -- NAVD88 height to NAVD88 depth conversion is chained
// with "NAD83(FBN)+LMSL to NAD83(FBN)+NAVD88 depth" The
// latter must thus be inversed
const auto nPosTo = conv->nameStr().find(" to ");
const auto nPosToNextOp =
operationsInOut[i + 1]->nameStr().find(" to ");
if (nPosTo != std::string::npos &&
nPosToNextOp != std::string::npos) {
const std::string convTo =
conv->nameStr().substr(nPosTo + strlen(" to "));
const std::string nextOpFrom =
operationsInOut[i + 1]->nameStr().substr(
0, nPosToNextOp);
const std::string nextOpTo =
operationsInOut[i + 1]->nameStr().substr(
nPosToNextOp + strlen(" to "));
if (nextOpTo.find(convTo) != std::string::npos &&
nextOpFrom.find(convTo) == std::string::npos &&
operationsInOut[i + 1]->sourceCRS()) {
operationsInOut[i + 1] =
operationsInOut[i + 1]->inverse();

op->setCRSs(
NN_NO_CHECK(l_sourceCRS),
NN_NO_CHECK(
operationsInOut[i + 1]->sourceCRS()),
nullptr);
}
}
}
} else if (l_sourceCRS && l_targetCRS == nullptr &&
conv->method()->getEPSGCode() ==
Expand Down

0 comments on commit 08ee492

Please sign in to comment.