diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-11-04 22:35:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-04 22:35:57 +0100 |
| commit | 34dc695402ba5d10248ea47bec3ab88ed950eccb (patch) | |
| tree | 56bfb7962cca13095a85a93af4e372ffac2e0be2 /test/unit/test_c_api.cpp | |
| parent | 1bee3d54b05d2f6bd406749126ff7d6ac26e7013 (diff) | |
| parent | 67e987ed84e19dd0ce46bdc529e8a73010af2c66 (diff) | |
| download | PROJ-34dc695402ba5d10248ea47bec3ab88ed950eccb.tar.gz PROJ-34dc695402ba5d10248ea47bec3ab88ed950eccb.zip | |
Merge pull request #1710 from rouault/geoid_model
Add support for GEOIDMODEL
Diffstat (limited to 'test/unit/test_c_api.cpp')
| -rw-r--r-- | test/unit/test_c_api.cpp | 109 |
1 files changed, 108 insertions, 1 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index b8310ce5..bdadc8b8 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3602,7 +3602,7 @@ TEST_F(CApi, proj_as_projjson) { EXPECT_EQ(std::string(projjson), "{\n" " \"$schema\": " - "\"https://proj.org/schemas/v0.1/projjson.schema.json\",\n" + "\"https://proj.org/schemas/v0.2/projjson.schema.json\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"WGS 84\",\n" " \"semi_major_axis\": 6378137,\n" @@ -4215,4 +4215,111 @@ TEST_F( EXPECT_NEAR(outcoord.xyzt.z, -32.5823, 1e-3); } +// --------------------------------------------------------------------------- + +TEST_F(CApi, proj_create_vertical_crs_ex) { + + // NAD83(2011) / UTM zone 11N + auto horiz_crs = proj_create_from_database(m_ctxt, "EPSG", "6340", + PJ_CATEGORY_CRS, false, nullptr); + ObjectKeeper keeper_horiz_crs(horiz_crs); + ASSERT_NE(horiz_crs, nullptr); + + auto vert_crs = proj_create_vertical_crs_ex( + m_ctxt, "myVertCRS (ftUS)", "myVertDatum", nullptr, nullptr, + "US survey foot", 0.304800609601219, "PROJ @foo.gtx", nullptr, nullptr, + nullptr, nullptr); + ObjectKeeper keeper_vert_crs(vert_crs); + ASSERT_NE(vert_crs, nullptr); + + auto compound = + proj_create_compound_crs(m_ctxt, "Compound", horiz_crs, vert_crs); + ObjectKeeper keeper_compound(compound); + ASSERT_NE(compound, nullptr); + + // NAD83(2011) 3D + PJ *geog_crs = proj_create(m_ctxt, "EPSG:6319"); + ObjectKeeper keeper_geog_crs(geog_crs); + ASSERT_NE(geog_crs, nullptr); + + auto P = proj_create_crs_to_crs_from_pj(m_ctxt, compound, geog_crs, nullptr, + nullptr); + ObjectKeeper keeper_P(P); + ASSERT_NE(P, nullptr); + + auto name = proj_get_name(P); + ASSERT_TRUE(name != nullptr); + EXPECT_EQ(name, + std::string("Inverse of UTM zone 11N + " + "Transformation from myVertCRS (ftUS) to myVertCRS + " + "Transformation from myVertCRS to NAD83(2011)")); + + auto proj_5 = proj_as_proj_string(m_ctxt, P, PJ_PROJ_5, nullptr); + ASSERT_NE(proj_5, nullptr); + EXPECT_EQ(std::string(proj_5), + "+proj=pipeline " + "+step +inv +proj=utm +zone=11 +ellps=GRS80 " + "+step +proj=unitconvert +z_in=us-ft +z_out=m " + "+step +proj=vgridshift +grids=@foo.gtx +multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + +// --------------------------------------------------------------------------- + +TEST_F(CApi, proj_create_vertical_crs_ex_with_geog_crs) { + + // NAD83(2011) / UTM zone 11N + auto horiz_crs = proj_create_from_database(m_ctxt, "EPSG", "6340", + PJ_CATEGORY_CRS, false, nullptr); + ObjectKeeper keeper_horiz_crs(horiz_crs); + ASSERT_NE(horiz_crs, nullptr); + + // WGS84 + PJ *wgs84 = proj_create(m_ctxt, "EPSG:4979"); + ObjectKeeper keeper_wgs84(wgs84); + ASSERT_NE(wgs84, nullptr); + + auto vert_crs = proj_create_vertical_crs_ex( + m_ctxt, "myVertCRS", "myVertDatum", nullptr, nullptr, "US survey foot", + 0.304800609601219, "PROJ @foo.gtx", nullptr, nullptr, wgs84, nullptr); + ObjectKeeper keeper_vert_crs(vert_crs); + ASSERT_NE(vert_crs, nullptr); + + auto compound = + proj_create_compound_crs(m_ctxt, "Compound", horiz_crs, vert_crs); + ObjectKeeper keeper_compound(compound); + ASSERT_NE(compound, nullptr); + + // NAD83(2011) 3D + PJ *geog_crs = proj_create(m_ctxt, "EPSG:6319"); + ObjectKeeper keeper_geog_crs(geog_crs); + ASSERT_NE(geog_crs, nullptr); + + auto P = proj_create_crs_to_crs_from_pj(m_ctxt, compound, geog_crs, nullptr, + nullptr); + ObjectKeeper keeper_P(P); + ASSERT_NE(P, nullptr); + + auto name = proj_get_name(P); + ASSERT_TRUE(name != nullptr); + EXPECT_EQ( + name, + std::string("Inverse of UTM zone 11N + " + "Ballpark geographic offset from NAD83(2011) to WGS 84 + " + "Transformation from myVertCRS to myVertCRS (metre) + " + "Transformation from myVertCRS (metre) to WGS 84 + " + "Ballpark geographic offset from WGS 84 to NAD83(2011)")); + + auto proj_5 = proj_as_proj_string(m_ctxt, P, PJ_PROJ_5, nullptr); + ASSERT_NE(proj_5, nullptr); + EXPECT_EQ(std::string(proj_5), + "+proj=pipeline " + "+step +inv +proj=utm +zone=11 +ellps=GRS80 " + "+step +proj=unitconvert +z_in=us-ft +z_out=m " + "+step +proj=vgridshift +grids=@foo.gtx +multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + } // namespace |
