Skip to content

Commit

Permalink
ConcatenatedOperation::fixStepsDirection(): handle case where convers…
Browse files Browse the repository at this point in the history
…ion is chained with transformation that must be reversed

Fixes #4116
  • Loading branch information
rouault authored and github-actions[bot] committed Apr 17, 2024
1 parent b0e38e6 commit f570b9f
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 f570b9f

Please sign in to comment.