From 70bc293a43def169fa34ed8e97a5cb06b336f247 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Feb 2019 12:18:16 +0100 Subject: Vertical CRS transformation: synthetize a vertical unit change transformation when needed, and also sort Null geographic offset transformation in last --- test/unit/test_c_api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 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 6205a9b8..8cfed9ad 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -1421,7 +1421,7 @@ TEST_F(CApi, proj_create_operations_with_pivot) { ASSERT_NE(res, nullptr); ObjListKeeper keeper_res(res); EXPECT_EQ(proj_list_get_count(res), 7); - auto op = proj_list_get(m_ctxt, res, 1); + auto op = proj_list_get(m_ctxt, res, 0); ASSERT_NE(op, nullptr); ObjectKeeper keeper_op(op); @@ -1451,7 +1451,7 @@ TEST_F(CApi, proj_create_operations_with_pivot) { ASSERT_NE(res, nullptr); ObjListKeeper keeper_res(res); // includes results from ESRI - EXPECT_EQ(proj_list_get_count(res), 5); + EXPECT_EQ(proj_list_get_count(res), 4); auto op = proj_list_get(m_ctxt, res, 0); ASSERT_NE(op, nullptr); ObjectKeeper keeper_op(op); -- cgit v1.2.3 From ca8f21ecbcc404b9e9c648784216846c048a3d69 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Feb 2019 15:29:38 +0100 Subject: PROJStringFormatting: change order of emission of push/pop w.r.t axis swap/unitconvert to avoid useless simplification rules --- test/unit/test_c_api.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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 8cfed9ad..69472a58 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -838,14 +838,16 @@ TEST_F(CApi, proj_create_from_database) { ASSERT_NE(info.definition, nullptr); EXPECT_EQ( info.definition, - std::string("proj=pipeline step proj=push v_3 step proj=axisswap " + std::string("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=bessel step proj=helmert " "x=601.705 y=84.263 z=485.227 rx=-4.7354 ry=-1.3145 " - "rz=-5.393 s=-2.3887 convention=coordinate_frame step " - "inv proj=cart ellps=GRS80 step proj=unitconvert " - "xy_in=rad xy_out=deg step proj=axisswap order=2,1 " - "step proj=pop v_3")); + "rz=-5.393 s=-2.3887 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")); EXPECT_EQ(info.accuracy, 1); } } -- cgit v1.2.3 From 94578ea8ff38f4bc6b1f6f52b80ecf7359f5dfc2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Feb 2019 18:04:35 +0100 Subject: CoordinateOperation: add a hasBallparkTransformation() method that can be used to know if it includes a very approximative transformation term --- test/unit/test_c_api.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 69472a58..7682c072 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -1345,6 +1345,7 @@ TEST_F(CApi, proj_create_operations) { auto op = proj_list_get(m_ctxt, res, 0); ASSERT_NE(op, nullptr); ObjectKeeper keeper_op(op); + EXPECT_FALSE(proj_coordoperation_has_ballpark_transformation(m_ctxt, op)); EXPECT_EQ(proj_get_name(op), std::string("NAD27 to NAD83 (3)")); } @@ -1401,8 +1402,9 @@ TEST_F(CApi, proj_create_operations_with_pivot) { ASSERT_NE(op, nullptr); ObjectKeeper keeper_op(op); - EXPECT_EQ(proj_get_name(op), - std::string("Null geographic offset from WGS 84 to JGD2011")); + EXPECT_EQ( + proj_get_name(op), + std::string("Ballpark geographic offset from WGS 84 to JGD2011")); } // Restrict pivot to Tokyo CRS -- cgit v1.2.3 From 69ef7449f5f26453a8b6cab1ba02cb870055615f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Feb 2019 20:42:26 +0100 Subject: typo fixes: s/Explictly/Explicitly/ and s/instanciat/instantiat/ --- test/unit/test_c_api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 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 7682c072..486ab0c7 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -1302,13 +1302,13 @@ TEST_F(CApi, proj_coordoperation_get_grid_used) { // --------------------------------------------------------------------------- -TEST_F(CApi, proj_coordoperation_is_instanciable) { +TEST_F(CApi, proj_coordoperation_is_instantiable) { auto op = proj_create_from_database(m_ctxt, "EPSG", "1671", PJ_CATEGORY_COORDINATE_OPERATION, true, nullptr); ASSERT_NE(op, nullptr); ObjectKeeper keeper(op); - EXPECT_EQ(proj_coordoperation_is_instanciable(m_ctxt, op), 1); + EXPECT_EQ(proj_coordoperation_is_instantiable(m_ctxt, op), 1); } // --------------------------------------------------------------------------- -- cgit v1.2.3 From 6a7e24dce79f93b73f4919f267df2fdf3ee95713 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 28 Mar 2019 15:26:00 +0100 Subject: Add proj_normalize_for_visualization() Fixes #1301 This function takes the output PJ from proj_create_crs_to_crs(), and add (or undo) the needed axis swap operations so that the object returned by proj_normalize_for_visualization() has the usual GIS axis order. In this implementation, this does something only if the coordinate system of the source or target CRS, geographic or projected, has NORTH, EAST ordering. CompoundCRS wrapping those objects are also handled. --- test/unit/test_c_api.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (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 486ab0c7..12e98d7e 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3220,4 +3220,31 @@ TEST_F(CApi, proj_get_crs_info_list_from_database) { proj_crs_info_list_destroy(list); } } + +// --------------------------------------------------------------------------- + +TEST_F(CApi, proj_normalize_for_visualization) { + + { + auto P = proj_create(m_ctxt, "+proj=utm +zone=31 +ellps=WGS84"); + ObjectKeeper keeper_P(P); + ASSERT_NE(P, nullptr); + auto Pnormalized = proj_normalize_for_visualization(m_ctxt, P); + ObjectKeeper keeper_Pnormalized(Pnormalized); + EXPECT_EQ(Pnormalized, nullptr); + } + + auto P = proj_create_crs_to_crs(m_ctxt, "EPSG:4326", "EPSG:32631", nullptr); + ObjectKeeper keeper_P(P); + ASSERT_NE(P, nullptr); + auto Pnormalized = proj_normalize_for_visualization(m_ctxt, P); + ObjectKeeper keeper_Pnormalized(Pnormalized); + ASSERT_NE(Pnormalized, nullptr); + auto projstr = proj_as_proj_string(m_ctxt, Pnormalized, PJ_PROJ_5, nullptr); + ASSERT_NE(projstr, nullptr); + EXPECT_EQ(std::string(projstr), + "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " + "+step +proj=utm +zone=31 +ellps=WGS84"); +} + } // namespace -- cgit v1.2.3 From 4d722565d63d504aab5fb2e403d1dd5c3b649d1a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 8 May 2019 12:00:08 +0200 Subject: proj_normalize_for_visualization(): fix when there are coordinate operation alternatives --- test/unit/test_c_api.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (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 12e98d7e..bea3eaa1 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3247,4 +3247,69 @@ TEST_F(CApi, proj_normalize_for_visualization) { "+step +proj=utm +zone=31 +ellps=WGS84"); } +// --------------------------------------------------------------------------- + +TEST_F(CApi, proj_normalize_for_visualization_with_alternatives) { + + auto P = proj_create_crs_to_crs(m_ctxt, "EPSG:4326", "EPSG:3003", nullptr); + ObjectKeeper keeper_P(P); + ASSERT_NE(P, nullptr); + auto Pnormalized = proj_normalize_for_visualization(m_ctxt, P); + ObjectKeeper keeper_Pnormalized(Pnormalized); + ASSERT_NE(Pnormalized, nullptr); + + { + PJ_COORD c; + // Approximately Roma + c.lpz.lam = 12.5; + c.lpz.phi = 42; + c.lpz.z = 0; + c = proj_trans(Pnormalized, PJ_FWD, c); + EXPECT_NEAR(c.xy.x, 1789912.46264783037, 1e-8); + EXPECT_NEAR(c.xy.y, 4655716.25402576849, 1e-8); + auto projstr = proj_pj_info(Pnormalized).definition; + ASSERT_NE(projstr, nullptr); + EXPECT_EQ(std::string(projstr), + "proj=pipeline step proj=unitconvert xy_in=deg xy_out=rad " + "step proj=push v_3 step proj=cart ellps=WGS84 " + "step inv proj=helmert x=-104.1 y=-49.1 z=-9.9 rx=0.971 " + "ry=-2.917 rz=0.714 s=-11.68 convention=position_vector " + "step inv proj=cart ellps=intl step proj=pop v_3 " + "step proj=tmerc lat_0=0 lon_0=9 k=0.9996 x_0=1500000 " + "y_0=0 ellps=intl"); + } + + { + PJ_COORD c; + // Approximately Roma + c.xyz.x = 1789912.46264783037; + c.xyz.y = 4655716.25402576849; + c.xyz.z = 0; + c = proj_trans(Pnormalized, PJ_INV, c); + EXPECT_NEAR(c.lp.lam, 12.5, 1e-8); + EXPECT_NEAR(c.lp.phi, 42, 1e-8); + } +} + +// --------------------------------------------------------------------------- + +TEST_F(CApi, proj_normalize_for_visualization_with_alternatives_reverse) { + + auto P = proj_create_crs_to_crs(m_ctxt, "EPSG:3003", "EPSG:4326", nullptr); + ObjectKeeper keeper_P(P); + ASSERT_NE(P, nullptr); + auto Pnormalized = proj_normalize_for_visualization(m_ctxt, P); + ObjectKeeper keeper_Pnormalized(Pnormalized); + ASSERT_NE(Pnormalized, nullptr); + + PJ_COORD c; + // Approximately Roma + c.xyz.x = 1789912.46264783037; + c.xyz.y = 4655716.25402576849; + c.xyz.z = 0; + c = proj_trans(Pnormalized, PJ_FWD, c); + EXPECT_NEAR(c.lp.lam, 12.5, 1e-8); + EXPECT_NEAR(c.lp.phi, 42, 1e-8); +} + } // namespace -- cgit v1.2.3 From 97d6060e596d1b044f84e7d140b26200ef56f65e Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 13 May 2019 09:33:38 -0500 Subject: identify(): take into account the authority passed in (fixes #1465) When identifying an object that has already a code with authority A but the authority of interest passed was B, then it was not checking that A != B, and did not try to search in the objects of B. --- test/unit/test_c_api.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (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 bea3eaa1..b9ea0bd5 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -1650,6 +1650,38 @@ TEST_F(CApi, proj_identify) { ObjListKeeper keeper_res(res); EXPECT_EQ(res, nullptr); } + { + auto obj2 = proj_create( + m_ctxt, "+proj=longlat +datum=WGS84 +no_defs +type=crs"); + ObjectKeeper keeper2(obj2); + ASSERT_NE(obj2, nullptr); + int *confidence = nullptr; + auto res = proj_identify(m_ctxt, obj2, nullptr, nullptr, &confidence); + ObjListKeeper keeper_res(res); + EXPECT_EQ(proj_list_get_count(res), 4); + proj_int_list_destroy(confidence); + } + { + auto obj2 = proj_create_from_database(m_ctxt, "IGNF", "ETRS89UTM28", + PJ_CATEGORY_CRS, false, nullptr); + ObjectKeeper keeper2(obj2); + ASSERT_NE(obj2, nullptr); + int *confidence = nullptr; + auto res = proj_identify(m_ctxt, obj2, "EPSG", nullptr, &confidence); + ObjListKeeper keeper_res(res); + EXPECT_EQ(proj_list_get_count(res), 1); + auto gotCRS = proj_list_get(m_ctxt, res, 0); + ASSERT_NE(gotCRS, nullptr); + ObjectKeeper keeper_gotCRS(gotCRS); + auto auth = proj_get_id_auth_name(gotCRS, 0); + ASSERT_TRUE(auth != nullptr); + EXPECT_EQ(auth, std::string("EPSG")); + auto code = proj_get_id_code(gotCRS, 0); + ASSERT_TRUE(code != nullptr); + EXPECT_EQ(code, std::string("25828")); + EXPECT_EQ(confidence[0], 70); + proj_int_list_destroy(confidence); + } } // --------------------------------------------------------------------------- -- cgit v1.2.3