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_c_api.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'test/unit/test_c_api.cpp') diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index b9a6cdd5..564833db 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -540,7 +540,7 @@ TEST_F(CApi, proj_as_proj_string_approx_tmerc_option_yes) { // --------------------------------------------------------------------------- TEST_F(CApi, proj_crs_create_bound_crs_to_WGS84) { - auto crs = proj_create_from_database(m_ctxt, "EPSG", "3844", + auto crs = proj_create_from_database(m_ctxt, "EPSG", "4807", PJ_CATEGORY_CRS, false, nullptr); ObjectKeeper keeper(crs); ASSERT_NE(crs, nullptr); @@ -552,10 +552,8 @@ TEST_F(CApi, proj_crs_create_bound_crs_to_WGS84) { auto proj_4 = proj_as_proj_string(m_ctxt, res, PJ_PROJ_4, nullptr); ASSERT_NE(proj_4, nullptr); EXPECT_EQ(std::string(proj_4), - "+proj=sterea +lat_0=46 +lon_0=25 +k=0.99975 +x_0=500000 " - "+y_0=500000 +ellps=krass " - "+towgs84=2.329,-147.042,-92.08,-0.309,0.325,0.497,5.69 " - "+units=m +no_defs +type=crs"); + "+proj=longlat +ellps=clrk80ign +pm=paris " + "+towgs84=-168,-60,320,0,0,0,0 +no_defs +type=crs"); auto base_crs = proj_get_source_crs(m_ctxt, res); ObjectKeeper keeper_base_crs(base_crs); @@ -572,8 +570,7 @@ TEST_F(CApi, proj_crs_create_bound_crs_to_WGS84) { std::vector values(7, 0); EXPECT_TRUE(proj_coordoperation_get_towgs84_values(m_ctxt, transf, values.data(), 7, true)); - auto expected = std::vector{2.329, -147.042, -92.08, -0.309, - 0.325, 0.497, 5.69}; + auto expected = std::vector{-168, -60, 320, 0, 0, 0, 0}; EXPECT_EQ(values, expected); auto res2 = proj_crs_create_bound_crs(m_ctxt, base_crs, hub_crs, transf); @@ -1485,7 +1482,7 @@ TEST_F(CApi, proj_create_operations_discard_superseded) { ASSERT_NE(res, nullptr); ObjListKeeper keeper_res(res); - EXPECT_EQ(proj_list_get_count(res), 2); + EXPECT_EQ(proj_list_get_count(res), 4); } // --------------------------------------------------------------------------- @@ -1594,7 +1591,7 @@ TEST_F(CApi, proj_create_operations_with_pivot) { auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt); ASSERT_NE(res, nullptr); ObjListKeeper keeper_res(res); - EXPECT_EQ(proj_list_get_count(res), 7); + EXPECT_EQ(proj_list_get_count(res), 8); auto op = proj_list_get(m_ctxt, res, 0); ASSERT_NE(op, nullptr); ObjectKeeper keeper_op(op); -- cgit v1.2.3