diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-11-02 18:48:20 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-11-02 22:28:54 +0100 |
| commit | 7492e65bfebadfcd44d3e2e4916a9d19e4bc6ae2 (patch) | |
| tree | e93fe704abf9c95f4b3ef19f42e65bfd8f2a999a /test | |
| parent | 31fd3de9c2b2f823c01b3c2dbadddf4a7101fa16 (diff) | |
| download | PROJ-7492e65bfebadfcd44d3e2e4916a9d19e4bc6ae2.tar.gz PROJ-7492e65bfebadfcd44d3e2e4916a9d19e4bc6ae2.zip | |
Add a geoid_model name in database, use GEOIDMODEL for transformations, add a proj_create_vertical_crs_ex()
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/test_c_api.cpp | 107 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 82 |
2 files changed, 189 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 5e6d1924..cb59563e 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -4213,4 +4213,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 diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 7d457dab..5e04bf23 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -7580,6 +7580,88 @@ TEST( // --------------------------------------------------------------------------- +TEST(operation, compoundCRS_of_vertCRS_with_geoid_model_to_geogCRS) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setSpatialCriterion( + CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION); + ctxt->setGridAvailabilityUse( + CoordinateOperationContext::GridAvailabilityUse:: + IGNORE_GRID_AVAILABILITY); + auto wkt = + "COMPOUNDCRS[\"NAD83 / Pennsylvania South + NAVD88 height\",\n" + " PROJCRS[\"NAD83 / Pennsylvania South\",\n" + " BASEGEOGCRS[\"NAD83\",\n" + " DATUM[\"North American Datum 1983\",\n" + " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]]],\n" + " CONVERSION[\"SPCS83 Pennsylvania South zone (meters)\",\n" + " METHOD[\"Lambert Conic Conformal (2SP)\",\n" + " ID[\"EPSG\",9802]],\n" + " PARAMETER[\"Latitude of false origin\",39.3333333333333,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8821]],\n" + " PARAMETER[\"Longitude of false origin\",-77.75,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8822]],\n" + " PARAMETER[\"Latitude of 1st standard " + "parallel\",40.9666666666667,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8823]],\n" + " PARAMETER[\"Latitude of 2nd standard " + "parallel\",39.9333333333333,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8824]],\n" + " PARAMETER[\"Easting at false origin\",600000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8826]],\n" + " PARAMETER[\"Northing at false origin\",0,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8827]]],\n" + " CS[Cartesian,2],\n" + " AXIS[\"easting (X)\",east,\n" + " ORDER[1],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " AXIS[\"northing (Y)\",north,\n" + " ORDER[2],\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " VERTCRS[\"NAVD88 height\",\n" + " VDATUM[\"North American Vertical Datum 1988\"],\n" + " CS[vertical,1],\n" + " AXIS[\"gravity-related height (H)\",up,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " GEOIDMODEL[\"GEOID12B\"]]]"; + auto srcObj = + createFromUserInput(wkt, authFactory->databaseContext(), false); + auto src = nn_dynamic_pointer_cast<CRS>(srcObj); + ASSERT_TRUE(src != nullptr); + auto dst = authFactory->createCoordinateReferenceSystem("4269"); // NAD83 + + auto list = CoordinateOperationFactory::create()->createOperations( + NN_NO_CHECK(src), dst, ctxt); + ASSERT_TRUE(!list.empty()); + EXPECT_EQ(list[0]->nameStr(), + "Inverse of SPCS83 Pennsylvania South zone (meters) + " + "Ballpark geographic offset from NAD83 to NAD83(2011) + " + "Inverse of NAD83(2011) to NAVD88 height (1) + " + "Ballpark geographic offset from NAD83(2011) to NAD83"); + auto op_proj = + list[0]->exportToPROJString(PROJStringFormatter::create().get()); + EXPECT_EQ(op_proj, + "+proj=pipeline " + "+step +inv +proj=lcc +lat_0=39.3333333333333 +lon_0=-77.75 " + "+lat_1=40.9666666666667 +lat_2=39.9333333333333 +x_0=600000 " + "+y_0=0 +ellps=GRS80 " + "+step +proj=vgridshift +grids=g2012bu0.gtx +multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + +// --------------------------------------------------------------------------- + TEST(operation, compoundCRS_from_WKT2_to_geogCRS_3D_context) { auto authFactory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); |
