From aeb024f2df5fb1c4d83959b6b9edcb62e8385226 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 17 Sep 2020 18:34:06 +0200 Subject: Adjust createBoundCRSToWGS84IfPossible() and operation filtering (for POSGAR 2007 to WGS84 issues) (fixes #2356) - We make createBoundCRSToWGS84IfPossible() more restrictive. If there are more than one Helmert transformation from the CRS to WGS 84 covering the area of use of the CRS, we do not create a BoundCRS / +towgs84 - In createOperations() filtering, we are less aggressive in discarding operations that have the same area of use but worse accuracy. We do it only if they involve more transformation steps. We now get: ``` $ projinfo EPSG:5340 -o PROJ PROJ.4 string: +proj=longlat +ellps=GRS80 +no_defs +type=crs $ projinfo -s EPSG:5340 -t EPSG:4326 --spatial-test intersects --summary Candidate operations found: 2 EPSG:9264, POSGAR 2007 to WGS 84 (2), 0.5 m, Argentina EPSG:5351, POSGAR 2007 to WGS 84 (1), 1.0 m, Argentina ``` --- test/unit/test_operation.cpp | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'test/unit/test_operation.cpp') diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 0238638d..eca5d59b 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -4599,7 +4599,7 @@ TEST(operation, geogCRS_to_geogCRS_context_NAD27_to_WGS84) { authFactory->createCoordinateReferenceSystem("4267"), // NAD27 authFactory->createCoordinateReferenceSystem("4326"), // WGS84 ctxt); - ASSERT_EQ(list.size(), 78U); + ASSERT_EQ(list.size(), 79U); EXPECT_EQ(list[0]->nameStr(), "NAD27 to WGS 84 (33)"); // 1.0 m, Canada - NAD27 EXPECT_EQ(list[1]->nameStr(), @@ -5050,7 +5050,7 @@ TEST(operation, geogCRS_to_geogCRS_context_concatenated_operation) { authFactory->createCoordinateReferenceSystem("4807"), // NTF(Paris) authFactory->createCoordinateReferenceSystem("4171"), // RGF93 ctxt); - ASSERT_EQ(list.size(), 5U); + ASSERT_EQ(list.size(), 4U); EXPECT_EQ(list[0]->nameStr(), "NTF (Paris) to RGF93 (1)"); EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()), @@ -5158,7 +5158,7 @@ TEST(operation, geogCRS_to_geogCRS_CH1903_to_CH1903plus_context) { authFactory->createCoordinateReferenceSystem("4149"), // CH1903 authFactory->createCoordinateReferenceSystem("4150"), // CH1903+ ctxt); - ASSERT_TRUE(list.size() == 2U || list.size() == 3U); + ASSERT_TRUE(list.size() == 1U); EXPECT_EQ(list[0]->nameStr(), "CH1903 to CH1903+ (1)"); EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()), @@ -5167,25 +5167,6 @@ TEST(operation, geogCRS_to_geogCRS_CH1903_to_CH1903plus_context) { "+step +proj=hgridshift +grids=ch_swisstopo_CHENyx06a.tif " "+step +proj=unitconvert +xy_in=rad +xy_out=deg " "+step +proj=axisswap +order=2,1"); - - if (list.size() == 2U) { - // Grids not there - EXPECT_EQ(list[1]->nameStr(), - "CH1903 to ETRS89 (1) + Inverse of CH1903+ to ETRS89 (1)"); - EXPECT_EQ( - list[1]->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=noop"); - } else { - // Grids available - EXPECT_EQ(list[1]->nameStr(), - "CH1903 to ETRS89 (2) + Inverse of CH1903+ to ETRS89 (1)"); - - EXPECT_EQ(list[2]->nameStr(), - "CH1903 to ETRS89 (1) + Inverse of CH1903+ to ETRS89 (1)"); - EXPECT_EQ( - list[2]->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=noop"); - } } // --------------------------------------------------------------------------- @@ -6069,7 +6050,7 @@ TEST(operation, projCRS_to_projCRS_context_compatible_area) { authFactory->createCoordinateReferenceSystem( "2171"), // Pulkovo 42 Poland I ctxt); - ASSERT_EQ(list.size(), 1U); + ASSERT_EQ(list.size(), 2U); EXPECT_EQ(list[0]->nameStr(), "Inverse of UTM zone 34N + Inverse of Pulkovo 1942(58) to WGS 84 " "(1) + Poland zone I"); @@ -6088,7 +6069,7 @@ TEST(operation, projCRS_to_projCRS_context_compatible_area_bis) { "3844"), // Pulkovo 42 Stereo 70 (Romania) authFactory->createCoordinateReferenceSystem("32634"), // UTM 34 ctxt); - ASSERT_EQ(list.size(), 1U); + ASSERT_EQ(list.size(), 3U); EXPECT_EQ(list[0]->nameStr(), "Inverse of Stereo 70 + " "Pulkovo 1942(58) to WGS 84 " "(19) + UTM zone 34N"); @@ -6107,7 +6088,7 @@ TEST(operation, projCRS_to_projCRS_context_one_incompatible_area) { authFactory->createCoordinateReferenceSystem( "2171"), // Pulkovo 42 Poland I ctxt); - ASSERT_EQ(list.size(), 1U); + ASSERT_EQ(list.size(), 2U); EXPECT_EQ(list[0]->nameStr(), "Inverse of UTM zone 31N + Inverse of Pulkovo 1942(58) to WGS 84 " "(1) + Poland zone I"); -- cgit v1.2.3 From 75074ce863e36299ec39b39decdd435eed15ad63 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 17 Sep 2020 19:46:07 +0200 Subject: createOperations(): tune sorting of transformations so that the ones with greater 'version numbers' are prefered over other ones, when all other comparison criteria are equal. Helps with Amersfoort RD New to EPSG:4326 --- test/unit/test_operation.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/unit/test_operation.cpp') diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index eca5d59b..23f3489b 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -6214,6 +6214,24 @@ TEST(operation, projCRS_to_projCRS_through_geog3D) { // --------------------------------------------------------------------------- +TEST(operation, transform_from_amersfoort_rd_new_to_epsg_4326) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + auto list = CoordinateOperationFactory::create()->createOperations( + authFactory->createCoordinateReferenceSystem("28992"), + authFactory->createCoordinateReferenceSystem("4326"), ctxt); + ASSERT_EQ(list.size(), 2U); + // The order matters: "Amersfoort to WGS 84 (4)" replaces "Amersfoort to WGS + // 84 (3)" + EXPECT_EQ(list[0]->nameStr(), + "Inverse of RD New + Amersfoort to WGS 84 (4)"); + EXPECT_EQ(list[1]->nameStr(), + "Inverse of RD New + Amersfoort to WGS 84 (3)"); +} + +// --------------------------------------------------------------------------- + TEST(operation, boundCRS_of_geogCRS_to_geogCRS) { auto boundCRS = BoundCRS::createFromTOWGS84( GeographicCRS::EPSG_4807, std::vector{1, 2, 3, 4, 5, 6, 7}); -- cgit v1.2.3