Skip to content

Commit

Permalink
createOperations(): do Helmert transformation in 2D when one of sourc…
Browse files Browse the repository at this point in the history
…e or target CRS is compound

Fixes #4335
  • Loading branch information
rouault committed Dec 4, 2024
1 parent 9ab0f64 commit b4c0550
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/iso19111/operation/singleoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3545,7 +3545,11 @@ bool SingleOperation::exportToPROJStringGeneric(
((sourceCRSGeog &&
sourceCRSGeog->coordinateSystem()->axisList().size() == 2) ||
(targetCRSGeog &&
targetCRSGeog->coordinateSystem()->axisList().size() == 2));
targetCRSGeog->coordinateSystem()->axisList().size() == 2)) ||
(!sourceCRSGeog &&
dynamic_cast<const crs::CompoundCRS *>(l_sourceCRS.get())) ||
(!targetCRSGeog &&
dynamic_cast<const crs::CompoundCRS *>(l_targetCRS.get()));

if (l_sourceCRS) {
setupPROJGeodeticSourceCRS(formatter, NN_NO_CHECK(l_sourceCRS),
Expand Down
38 changes: 38 additions & 0 deletions test/unit/test_operationfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5954,6 +5954,44 @@ TEST(operation,

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

TEST(operation, compoundCRS_to_compoundCRS_context_helmert) {
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);
// GDA94 + AHD height
auto objSrc = createFromUserInput("EPSG:9464", dbContext);
auto srcCrs = nn_dynamic_pointer_cast<CompoundCRS>(objSrc);
ASSERT_TRUE(srcCrs != nullptr);
// GDA2020 + AHD height
auto objDest = createFromUserInput("EPSG:9463", 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);
// Check presence of push/pop v_3
EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
"+proj=pipeline "
"+step +proj=axisswap +order=2,1 "
"+step +proj=unitconvert +xy_in=deg +xy_out=rad "
"+step +proj=push +v_3 "
"+step +proj=cart +ellps=GRS80 "
"+step +proj=helmert +x=0.06155 +y=-0.01087 +z=-0.04019 "
"+rx=-0.0394924 +ry=-0.0327221 +rz=-0.0328979 +s=-0.009994 "
"+convention=coordinate_frame "
"+step +inv +proj=cart +ellps=GRS80 "
"+step +proj=pop +v_3 "
"+step +proj=unitconvert +xy_in=rad +xy_out=deg "
"+step +proj=axisswap +order=2,1");
}

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

TEST(
operation,
compoundCRS_to_compoundCRS_concatenated_operation_with_two_vert_transformation) {
Expand Down

0 comments on commit b4c0550

Please sign in to comment.