diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-10-04 01:13:43 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-10-04 01:13:43 +0200 |
| commit | ae779eaa8264914a401f585f747a0f87fd5350e9 (patch) | |
| tree | a82bfb05cf329f05fb2563389b9efe5f002595e9 /test/unit/test_c_api.cpp | |
| parent | 109f75c74ee9e251b9507aeb5f3add109042bd5f (diff) | |
| download | PROJ-ae779eaa8264914a401f585f747a0f87fd5350e9.tar.gz PROJ-ae779eaa8264914a401f585f747a0f87fd5350e9.zip | |
Add a proj_crs_demote_to_2D(). Useful if forced to export a 3D CRS to a best approximate as WKT1 that doesn't support it
Diffstat (limited to 'test/unit/test_c_api.cpp')
| -rw-r--r-- | test/unit/test_c_api.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 40122cb2..d5475346 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3949,6 +3949,31 @@ TEST_F(CApi, proj_crs_promote_to_3D) { // --------------------------------------------------------------------------- +TEST_F(CApi, proj_crs_demote_to_2D) { + + auto crs3D = + proj_create(m_ctxt, GeographicCRS::EPSG_4979 + ->exportToWKT(WKTFormatter::create().get()) + .c_str()); + ObjectKeeper keeper_crs3D(crs3D); + EXPECT_NE(crs3D, nullptr); + + auto crs2D = proj_crs_demote_to_2D(m_ctxt, nullptr, crs3D); + ObjectKeeper keeper_crs2D(crs2D); + EXPECT_NE(crs2D, nullptr); + + auto cs = proj_crs_get_coordinate_system(m_ctxt, crs2D); + ASSERT_NE(cs, nullptr); + ObjectKeeper keeperCs(cs); + EXPECT_EQ(proj_cs_get_axis_count(m_ctxt, cs), 2); + + auto code = proj_get_id_code(crs2D, 0); + ASSERT_TRUE(code != nullptr); + EXPECT_EQ(code, std::string("4326")); +} + +// --------------------------------------------------------------------------- + TEST_F(CApi, proj_crs_create_projected_3D_crs_from_2D) { auto projCRS = proj_create_from_database(m_ctxt, "EPSG", "32631", |
