Skip to content

Commit

Permalink
Merge pull request #3990 from rouault/createOperationsCompoundToGeog_…
Browse files Browse the repository at this point in the history
…tune

createOperationsCompoundToGeog(): tune selection logic when --grid-check known_available is specified
  • Loading branch information
rouault authored Jan 9, 2024
2 parents fac122d + 9697f59 commit 92628b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
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

0 comments on commit 92628b3

Please sign in to comment.