diff options
| author | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2020-03-29 22:37:47 +0000 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2020-03-29 22:37:47 +0000 |
| commit | 2b91a507297a7e13b51a55d0f1ef7b3ec6ca6a60 (patch) | |
| tree | dcf209e049cb0fc1be4a9fd71ce3ea38abcfc028 | |
| parent | 9d596034ceecb63f290fc6d88bc0f68c1864b05a (diff) | |
| download | PROJ-2b91a507297a7e13b51a55d0f1ef7b3ec6ca6a60.tar.gz PROJ-2b91a507297a7e13b51a55d0f1ef7b3ec6ca6a60.zip | |
Fix working of Helmert transform between the horizontal part of 2 compoundCRS (fixes #2108)
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 20 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 26 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index 91801100..1b35e35a 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -8824,6 +8824,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); @@ -8852,6 +8862,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 5bea9099..924ad950 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -7231,6 +7231,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"); |
