aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/iso19111/coordinateoperation.cpp20
-rw-r--r--test/unit/test_operation.cpp26
2 files changed, 46 insertions, 0 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index 33210d24..267e9450 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -8930,6 +8930,16 @@ static void setupPROJGeodeticSourceCRS(io::PROJStringFormatter *formatter,
const crs::CRSNNPtr &crs, bool addPushV3,
const char *trfrm_name) {
auto sourceCRSGeog = dynamic_cast<const crs::GeographicCRS *>(crs.get());
+ if (!sourceCRSGeog) {
+ auto compoundCRS = dynamic_cast<const crs::CompoundCRS *>(crs.get());
+ if (compoundCRS) {
+ const auto &components = compoundCRS->componentReferenceSystems();
+ if (!components.empty()) {
+ sourceCRSGeog = dynamic_cast<const crs::GeographicCRS *>(
+ components[0].get());
+ }
+ }
+ }
if (sourceCRSGeog) {
formatter->startInversion();
sourceCRSGeog->_exportToPROJString(formatter);
@@ -8958,6 +8968,16 @@ static void setupPROJGeodeticTargetCRS(io::PROJStringFormatter *formatter,
const crs::CRSNNPtr &crs, bool addPopV3,
const char *trfrm_name) {
auto targetCRSGeog = dynamic_cast<const crs::GeographicCRS *>(crs.get());
+ if (!targetCRSGeog) {
+ auto compoundCRS = dynamic_cast<const crs::CompoundCRS *>(crs.get());
+ if (compoundCRS) {
+ const auto &components = compoundCRS->componentReferenceSystems();
+ if (!components.empty()) {
+ targetCRSGeog = dynamic_cast<const crs::GeographicCRS *>(
+ components[0].get());
+ }
+ }
+ }
if (targetCRSGeog) {
formatter->addStep("cart");
formatter->setCurrentStepInverted(true);
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index 076686b4..ad218899 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -7347,6 +7347,32 @@ TEST(operation, compoundCRS_to_compoundCRS_context) {
// ---------------------------------------------------------------------------
+TEST(operation, compoundCRS_to_compoundCRS_context_helmert_noop) {
+ auto dbContext = DatabaseContext::create();
+ auto authFactory = AuthorityFactory::create(dbContext, "EPSG");
+ auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ ctxt->setGridAvailabilityUse(
+ CoordinateOperationContext::GridAvailabilityUse::
+ IGNORE_GRID_AVAILABILITY);
+ ctxt->setSpatialCriterion(
+ CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
+ // WGS84 + EGM96
+ auto objSrc = createFromUserInput("EPSG:4326+3855", dbContext);
+ auto srcCrs = nn_dynamic_pointer_cast<CompoundCRS>(objSrc);
+ ASSERT_TRUE(srcCrs != nullptr);
+ // ETRS89 + EGM96
+ auto objDest = createFromUserInput("EPSG:4258+3855", dbContext);
+ auto destCrs = nn_dynamic_pointer_cast<CompoundCRS>(objDest);
+ ASSERT_TRUE(destCrs != nullptr);
+ auto list = CoordinateOperationFactory::create()->createOperations(
+ NN_NO_CHECK(srcCrs), NN_NO_CHECK(destCrs), ctxt);
+ ASSERT_GE(list.size(), 1U);
+ EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=noop");
+}
+
+// ---------------------------------------------------------------------------
+
TEST(operation, vertCRS_to_vertCRS) {
auto vertcrs_m_obj = PROJStringParser().createFromPROJString("+vunits=m");