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

createOperationsCompoundToGeog(): tune selection logic when --grid-check known_available is specified #3990

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions src/iso19111/operation/coordinateoperationfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5886,7 +5886,7 @@ void CoordinateOperationFactory::Private::createOperationsCompoundToGeog(
}
}
}
if (!foundRegisteredTransformWithAllGridsAvailable && srcGeogCRS &&
if (srcGeogCRS &&
!srcGeogCRS->_isEquivalentTo(
geogDst, util::IComparable::Criterion::EQUIVALENT) &&
!srcGeogCRS->is2DPartOf3D(NN_NO_CHECK(geogDst), dbContext)) {
Expand All @@ -5904,7 +5904,7 @@ void CoordinateOperationFactory::Private::createOperationsCompoundToGeog(
componentsSrc[1], util::optional<common::DataEpoch>(),
geogCRSTmp, util::optional<common::DataEpoch>(), context);
bool foundRegisteredTransform = false;
foundRegisteredTransformWithAllGridsAvailable = false;
bool foundRegisteredTransformWithAllGridsAvailable2 = false;
for (const auto &op : verticalTransformsTmp) {
if (hasIdentifiers(op) && dbContext) {
bool missingGrid = false;
Expand All @@ -5923,13 +5923,14 @@ void CoordinateOperationFactory::Private::createOperationsCompoundToGeog(
}
foundRegisteredTransform = true;
if (!missingGrid) {
foundRegisteredTransformWithAllGridsAvailable =
foundRegisteredTransformWithAllGridsAvailable2 =
true;
break;
}
}
}
if (foundRegisteredTransformWithAllGridsAvailable) {
if (foundRegisteredTransformWithAllGridsAvailable2 &&
!foundRegisteredTransformWithAllGridsAvailable) {
verticalTransforms = std::move(verticalTransformsTmp);
} else if (foundRegisteredTransform) {
verticalTransforms.insert(verticalTransforms.end(),
Expand Down
25 changes: 25 additions & 0 deletions test/unit/test_operationfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6942,6 +6942,31 @@ TEST(operation, compoundCRS_of_projCRS_to_geogCRS_3D_context) {

// ---------------------------------------------------------------------------

TEST(operation, compoundCRS_to_geogCRS_3D_KNOWN_AVAILABLE_context) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");

auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
ctxt->setGridAvailabilityUse(
CoordinateOperationContext::GridAvailabilityUse::KNOWN_AVAILABLE);
auto list = CoordinateOperationFactory::create()->createOperations(
authFactory->createCoordinateReferenceSystem(
"9537"), // RGAF09 + Martinique 1987 height
authFactory->createCoordinateReferenceSystem("4557"), // RRAF 1991
ctxt);
ASSERT_GE(list.size(), 2U);
// Make sure that "RGAF09 to Martinique 1987 height (2)" (using RAMART2016)
// is listed first
EXPECT_EQ(list[0]->nameStr(),
"Inverse of RGAF09 to Martinique 1987 height (2) + "
"Inverse of RRAF 1991 to RGAF09 (1)");
EXPECT_EQ(list[1]->nameStr(),
"Inverse of RRAF 1991 to RGAF09 (1) + "
"Inverse of RRAF 1991 to Martinique 1987 height (1)");
}

// ---------------------------------------------------------------------------

TEST(operation, compoundCRS_from_wkt_without_id_to_geogCRS) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
Expand Down
Loading