diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-08-22 22:52:48 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-08-23 21:49:40 +0200 |
| commit | 11869e2c4d29f0e607a0f78fb289d253fccd9a16 (patch) | |
| tree | 5b8be1637f9272b8b3ddb4a6280b6207389fbf4f /test | |
| parent | b7f829ce8f7c9fce2934b3981493a5d3338143b9 (diff) | |
| download | PROJ-11869e2c4d29f0e607a0f78fb289d253fccd9a16.tar.gz PROJ-11869e2c4d29f0e607a0f78fb289d253fccd9a16.zip | |
Add proj_create_crs_to_crs_from_pj()
I've been frustrated a number of times with proj_create_crs_to_crs()
not accepting a PJ* object for the source and target CRS.
And thus constraining to go back to WKT2 in a artificial way.
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/test_c_api.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 74377738..2a1c8577 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3711,4 +3711,30 @@ TEST_F(Fixture_proj_context_set_autoclose_database, proj_context_set_autoclose_database_false) { test(false); } + +// --------------------------------------------------------------------------- + +TEST_F(CApi, proj_create_crs_to_crs_from_pj) { + + auto src = proj_create(m_ctxt, "EPSG:4326"); + ObjectKeeper keeper_src(src); + ASSERT_NE(src, nullptr); + + auto dst = proj_create(m_ctxt, "EPSG:32631"); + ObjectKeeper keeper_dst(dst); + ASSERT_NE(dst, nullptr); + + auto P = proj_create_crs_to_crs_from_pj(m_ctxt, src, dst, nullptr, 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 |
