Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcatenatedOperation::fixStepsDirection(): handle case where conversion is chained with transformation that must be reversed #4120

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading