@@ -7275,13 +7275,15 @@ TEST(operation, vertCRS_to_vertCRS_New_Zealand_context) {
72757275
72767276// ---------------------------------------------------------------------------
72777277
7278- TEST(operation, vertCRS_to_vertCRS_height_depth_pivot_context ) {
7278+ TEST(operation, vertCRS_to_vertCRS_pivot_context ) {
72797279 // Test that PROJ can chain a registered vertical CT with a
72807280 // height-to-depth axis conversion when the target CRS differs from
72817281 // the CT's registered target only by axis direction.
72827282 auto authFactory =
72837283 AuthorityFactory::create(DatabaseContext::create(), "EPSG");
72847284 auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
7285+ ctxt->setSpatialCriterion(
7286+ CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
72857287
72867288 auto checkPipeline = [&](const std::string &srcCode,
72877289 const std::string &tgtCode,
@@ -7296,28 +7298,20 @@ TEST(operation, vertCRS_to_vertCRS_height_depth_pivot_context) {
72967298 expectedProj);
72977299 };
72987300
7301+ // Using Strategy 1 of createOperationsVertToVertWithIntermediateVert()
7302+
72997303 // Caspian: EPSG:5705 (Baltic 1977 height) -> EPSG:5706 (Caspian depth)
73007304 // via EPSG:5438 (dh=28) + height-to-depth axisswap
73017305 checkPipeline("5705", "5706",
73027306 "+proj=pipeline +step +proj=geogoffset +dh=28 "
73037307 "+step +proj=axisswap +order=1,2,-3");
73047308
7305- // AIOC95: EPSG:5705 -> EPSG:5734 (AIOC95 depth)
7306- // via EPSG:5443 (dh=26.3) + height-to-depth axisswap
7307- checkPipeline("5705", "5734",
7308- "+proj=pipeline +step +proj=geogoffset +dh=26.3 "
7309- "+step +proj=axisswap +order=1,2,-3");
7310-
7311- // KOC: EPSG:5790 (KOC CD height) -> EPSG:5789 (KOC WD depth)
7312- // via EPSG:7986 (dh=-4.74) + height-to-depth axisswap
7313- checkPipeline("5790", "5789",
7314- "+proj=pipeline +step +proj=geogoffset +dh=-4.74 "
7315- "+step +proj=axisswap +order=1,2,-3");
7316-
7317- // Kuwait PWD: EPSG:5788 -> EPSG:5789 (KOC WD depth)
7318- // via EPSG:7981 (dh=-4.25) + height-to-depth axisswap
7319- checkPipeline("5788", "5789",
7320- "+proj=pipeline +step +proj=geogoffset +dh=-4.25 "
7309+ // Caspian: EPSG:5706 (Caspian depth) -> EPSG:5705 (Baltic 1977 height)
7310+ // axisswap + inverse of EPSG:5438 (dh=-28)
7311+ // Note: yes that pipeline is identical to the above one, since it is its
7312+ // own inverse.
7313+ checkPipeline("5706", "5705",
7314+ "+proj=pipeline +step +proj=geogoffset +dh=28 "
73217315 "+step +proj=axisswap +order=1,2,-3");
73227316
73237317 // KOC ft: EPSG:5790 -> EPSG:5614 (KOC WD depth ft)
@@ -7327,55 +7321,6 @@ TEST(operation, vertCRS_to_vertCRS_height_depth_pivot_context) {
73277321 "+step +proj=geogoffset +dh=-4.74 "
73287322 "+step +proj=axisswap +order=1,2,-3 "
73297323 "+step +proj=unitconvert +z_in=m +z_out=ft");
7330- }
7331-
7332- // ---------------------------------------------------------------------------
7333-
7334- TEST(operation, vertCRS_to_vertCRS_depth_height_pivot_context) {
7335- // Test the reverse direction: depth to height.
7336- // When the source is depth (axis DOWN) and the target is height (axis UP),
7337- // the code prefers pivoting through the SOURCE's datum, composing:
7338- // depth-to-height axisswap + inverse of the registered forward op.
7339- auto authFactory =
7340- AuthorityFactory::create(DatabaseContext::create(), "EPSG");
7341- auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
7342-
7343- auto checkPipeline = [&](const std::string &srcCode,
7344- const std::string &tgtCode,
7345- const std::string &expectedProj) {
7346- auto list = CoordinateOperationFactory::create()->createOperations(
7347- authFactory->createCoordinateReferenceSystem(srcCode),
7348- authFactory->createCoordinateReferenceSystem(tgtCode), ctxt);
7349- ASSERT_GE(list.size(), 1U);
7350- EXPECT_FALSE(list[0]->hasBallparkTransformation());
7351- EXPECT_EQ(
7352- list[0]->exportToPROJString(PROJStringFormatter::create().get()),
7353- expectedProj);
7354- };
7355-
7356- // Caspian: EPSG:5706 (Caspian depth) -> EPSG:5705 (Baltic 1977 height)
7357- // axisswap + inverse of EPSG:5438 (dh=-28)
7358- checkPipeline("5706", "5705",
7359- "+proj=pipeline +step +proj=axisswap +order=1,2,-3 "
7360- "+step +proj=geogoffset +dh=-28");
7361-
7362- // AIOC95: EPSG:5734 (AIOC95 depth) -> EPSG:5705 (Baltic 1977 height)
7363- // axisswap + inverse of EPSG:5443 (dh=-26.3)
7364- checkPipeline("5734", "5705",
7365- "+proj=pipeline +step +proj=axisswap +order=1,2,-3 "
7366- "+step +proj=geogoffset +dh=-26.3");
7367-
7368- // KOC: EPSG:5789 (KOC WD depth) -> EPSG:5790 (KOC CD height)
7369- // axisswap + inverse of EPSG:7986 (dh=4.74)
7370- checkPipeline("5789", "5790",
7371- "+proj=pipeline +step +proj=axisswap +order=1,2,-3 "
7372- "+step +proj=geogoffset +dh=4.74");
7373-
7374- // Kuwait PWD: EPSG:5789 (KOC WD depth) -> EPSG:5788 (Kuwait PWD height)
7375- // axisswap + inverse of EPSG:7981 (dh=4.25)
7376- checkPipeline("5789", "5788",
7377- "+proj=pipeline +step +proj=axisswap +order=1,2,-3 "
7378- "+step +proj=geogoffset +dh=4.25");
73797324
73807325 // KOC ft: EPSG:5614 (KOC WD depth ft) -> EPSG:5790 (KOC CD height)
73817326 // unit conversion ft->m + axisswap + inverse of EPSG:7987 (dh=4.74)
@@ -7384,62 +7329,24 @@ TEST(operation, vertCRS_to_vertCRS_depth_height_pivot_context) {
73847329 "+step +proj=unitconvert +z_in=ft +z_out=m "
73857330 "+step +proj=axisswap +order=1,2,-3 "
73867331 "+step +proj=geogoffset +dh=4.74");
7387- }
73887332
7389- // ---------------------------------------------------------------------------
7390-
7391- TEST(operation, vertCRS_to_vertCRS_height_depth_pivot_blacksea_context) {
7392- // Test that the intermediate-vert pivot finds a registered cross-datum
7393- // height-to-height transformation and composes it with an axis reversal.
7394- //
73957333 // EPSG:5705 (Baltic 1977 height) to EPSG:5336 (Black Sea depth)
73967334 // Strategy 1 composes: EPSG:5447 (5705 to 5735, geogoffset +dh=0.4)
73977335 // + height-to-depth (axisswap order=1,2,-3)
7398- // PARTIAL_INTERSECTION is needed because EPSG:5447's area
7399- // is slightly smaller than EPSG:5336's extent
7400- auto authFactory =
7401- AuthorityFactory::create(DatabaseContext::create(), "EPSG");
7402- auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
7403- ctxt->setSpatialCriterion(
7404- CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
7405- auto list = CoordinateOperationFactory::create()->createOperations(
7406- // Baltic 1977 height
7407- authFactory->createCoordinateReferenceSystem("5705"),
7408- // Black Sea depth
7409- authFactory->createCoordinateReferenceSystem("5336"), ctxt);
7410- ASSERT_GE(list.size(), 1U);
7411- EXPECT_FALSE(list[0]->hasBallparkTransformation());
7412- auto projStr =
7413- list[0]->exportToPROJString(PROJStringFormatter::create().get());
7414- EXPECT_EQ(projStr, "+proj=pipeline +step +proj=geogoffset +dh=0.4 +step "
7415- "+proj=axisswap +order=1,2,-3");
7416- }
7336+ checkPipeline("5705", "5336",
7337+ "+proj=pipeline "
7338+ "+step +proj=geogoffset +dh=0.4 "
7339+ "+step +proj=axisswap +order=1,2,-3");
74177340
7418- // ---------------------------------------------------------------------------
7341+ // Using Strategy 2 of createOperationsVertToVertWithIntermediateVert()
74197342
7420- TEST(operation, vertCRS_to_vertCRS_depth_height_pivot_blacksea_context) {
7421- // Test the reverse direction for the Black Sea case.
7422- //
74237343 // EPSG:5336 (Black Sea depth) to EPSG:5705 (Baltic 1977 height)
74247344 // Strategy 2 composes: depth-to-height (5336 to 5735, axisswap)
74257345 // + inverse of EPSG:5447 (5735 to 5705, dh=-0.4)
7426-
7427- auto authFactory =
7428- AuthorityFactory::create(DatabaseContext::create(), "EPSG");
7429- auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
7430- ctxt->setSpatialCriterion(
7431- CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
7432- auto list = CoordinateOperationFactory::create()->createOperations(
7433- // Black Sea depth
7434- authFactory->createCoordinateReferenceSystem("5336"),
7435- // Baltic 1977 height
7436- authFactory->createCoordinateReferenceSystem("5705"), ctxt);
7437- ASSERT_GE(list.size(), 1U);
7438- EXPECT_FALSE(list[0]->hasBallparkTransformation());
7439- auto projStr =
7440- list[0]->exportToPROJString(PROJStringFormatter::create().get());
7441- EXPECT_EQ(projStr, "+proj=pipeline +step +proj=axisswap +order=1,2,-3 "
7442- "+step +proj=geogoffset +dh=-0.4");
7346+ checkPipeline("5336", "5705",
7347+ "+proj=pipeline "
7348+ "+step +proj=axisswap +order=1,2,-3 "
7349+ "+step +proj=geogoffset +dh=-0.4");
74437350}
74447351
74457352// ---------------------------------------------------------------------------
0 commit comments