diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-01-08 16:22:15 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-01-08 21:25:07 +0100 |
| commit | f5e5435fd5071d550e0d13f7a5d71e09c1fab2c0 (patch) | |
| tree | f569d5270f7cb34adf056d04c84a23db6b4f6ed0 /test | |
| parent | fdee4277efb45b07db2dcc4d93376cbd01cfbd0a (diff) | |
| download | PROJ-f5e5435fd5071d550e0d13f7a5d71e09c1fab2c0.tar.gz PROJ-f5e5435fd5071d550e0d13f7a5d71e09c1fab2c0.zip | |
ISO19111: remove PROJ.5 specific format for CRS (refs #1214)
As discussed in https://github.com/OSGeo/proj.4/issues/1214#issuecomment-452084720,
the introduction of a new PROJ.5 format to export CRS using pipeline/unitconvert/axisswap
as an attempt of improving the PROJ.4 format used by GDAL and other products is
likely a dead-end since it is still lossy in many aspects and can cause confusion
with coodinate operations.
Consequently the PROJ_5 convention will be identical to PROJ_4 for CRS export.
Note: on the import side, I've kept the code that could parse unitconvert and
axisswap when building a CRS definition from a pipeline. It is there as a hidden
feature as it was kind of a tear to remove that code in case it might still be
useful...
Diffstat (limited to 'test')
| -rw-r--r-- | test/cli/testprojinfo_out.dist | 9 | ||||
| -rw-r--r-- | test/unit/proj_angular_io_test.cpp | 36 | ||||
| -rw-r--r-- | test/unit/test_c_api.cpp | 5 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 212 | ||||
| -rw-r--r-- | test/unit/test_factory.cpp | 24 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 215 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 72 |
7 files changed, 254 insertions, 319 deletions
diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist index 1fd3bbbf..3d70bd99 100644 --- a/test/cli/testprojinfo_out.dist +++ b/test/cli/testprojinfo_out.dist @@ -1,6 +1,6 @@ Testing projinfo EPSG:4326 PROJ string: -+proj=pipeline +step +proj=longlat +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=longlat +datum=WGS84 +no_defs WKT2_2015 string: GEODCRS["WGS 84", @@ -22,9 +22,6 @@ GEODCRS["WGS 84", Testing projinfo -o ALL EPSG:4326 PROJ string: -+proj=pipeline +step +proj=longlat +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 - -PROJ.4 string: +proj=longlat +datum=WGS84 +no_defs WKT2_2015 string: @@ -484,7 +481,7 @@ Alternative non-deprecated CRS: EPSG:3003 PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=longlat +ellps=intl +pm=rome +step +proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +pm=rome ++proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +pm=rome +units=m +no_defs WKT2_2015 string: PROJCRS["Monte Mario (Rome) / Italy zone 1", @@ -529,7 +526,7 @@ Warning: Parsing error : syntax error, unexpected UNIT, expecting PRIMEM. Error HEROID["WGS 84",6378137,298.257223563]],UNIT["degree",0.0174532925199433]] ^ PROJ string: -+proj=pipeline +step +proj=longlat +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg ++proj=longlat +datum=WGS84 +no_defs WKT2_2015 string: GEODCRS["WGS 84", diff --git a/test/unit/proj_angular_io_test.cpp b/test/unit/proj_angular_io_test.cpp index fdb44704..dbf09986 100644 --- a/test/unit/proj_angular_io_test.cpp +++ b/test/unit/proj_angular_io_test.cpp @@ -48,7 +48,9 @@ TEST(AngularUnits, Basic) { TEST(AngularUnits, Pipelines) { auto ctx = proj_context_create(); - auto P = proj_create(ctx, "proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=latlong +step +proj=axisswap +order=2,1"); + auto P = + proj_create(ctx, "proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=latlong +step +proj=axisswap +order=2,1"); EXPECT_TRUE(proj_angular_input(P, PJ_FWD)); EXPECT_TRUE(proj_angular_output(P, PJ_FWD)); @@ -57,45 +59,43 @@ TEST(AngularUnits, Pipelines) { proj_destroy(P); proj_context_destroy(ctx); - } TEST(AngularUnits, Pipelines2) { auto ctx = proj_context_create(); auto P = proj_create( - ctx, - "+proj=pipeline " - "+step +proj=axisswap +order=2,1 " - "+step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 " - "+step +proj=axisswap +order=2,1 " - "+step +proj=unitconvert +xy_in=m +z_in=m +xy_out=us-ft +z_out=us-ft"); + ctx, + "+proj=pipeline " + "+step +proj=axisswap +order=2,1 " + "+step +proj=unitconvert +xy_in=deg +xy_out=rad " + "+step +proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 " + "+y_0=0 +ellps=WGS84 " + "+step +proj=axisswap +order=2,1 " + "+step +proj=unitconvert +xy_in=m +z_in=m +xy_out=us-ft +z_out=us-ft"); EXPECT_FALSE(proj_angular_input(P, PJ_FWD)); EXPECT_FALSE(proj_angular_output(P, PJ_FWD)); proj_destroy(P); proj_context_destroy(ctx); - } TEST(AngularUnits, Pipelines3) { auto ctx = proj_context_create(); auto P = proj_create( - ctx, - "+proj=pipeline " - "+step +proj=axisswap +order=2,1 " - "+step +proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 " - "+step +proj=axisswap +order=2,1 " - "+step +proj=unitconvert +xy_in=m +z_in=m +xy_out=us-ft +z_out=us-ft"); + ctx, + "+proj=pipeline " + "+step +proj=axisswap +order=2,1 " + "+step +proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 " + "+y_0=0 +ellps=WGS84 " + "+step +proj=axisswap +order=2,1 " + "+step +proj=unitconvert +xy_in=m +z_in=m +xy_out=us-ft +z_out=us-ft"); EXPECT_TRUE(proj_angular_input(P, PJ_FWD)); EXPECT_FALSE(proj_angular_output(P, PJ_FWD)); proj_destroy(P); proj_context_destroy(ctx); - } - } // namespace diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 82cb7b75..6353d46f 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -492,10 +492,7 @@ TEST_F(CApi, proj_as_proj_string) { { auto proj_5 = proj_as_proj_string(m_ctxt, obj, PJ_PROJ_5, nullptr); ASSERT_NE(proj_5, nullptr); - EXPECT_EQ(std::string(proj_5), "+proj=pipeline +step +proj=longlat " - "+ellps=WGS84 +step +proj=unitconvert " - "+xy_in=rad +xy_out=deg +step " - "+proj=axisswap +order=2,1"); + EXPECT_EQ(std::string(proj_5), "+proj=longlat +datum=WGS84 +no_defs"); } { auto proj_4 = proj_as_proj_string(m_ctxt, obj, PJ_PROJ_4, nullptr); diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index fe0ac7e8..d694d297 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -388,14 +388,7 @@ TEST(crs, EPSG_4326_as_WKT1_ESRI_without_database) { TEST(crs, EPSG_4326_as_PROJ_string) { auto crs = GeographicCRS::EPSG_4326; EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=WGS84 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " - "+order=2,1"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=longlat +datum=WGS84 +no_defs"); + "+proj=longlat +datum=WGS84 +no_defs"); } // --------------------------------------------------------------------------- @@ -595,14 +588,7 @@ TEST(crs, EPSG_4807_as_WKT1_ESRI_without_database) { TEST(crs, EPSG_4807_as_PROJ_string) { auto crs = GeographicCRS::EPSG_4807; EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=clrk80ign " - "+pm=paris +step +proj=unitconvert +xy_in=rad +xy_out=grad +step " - "+proj=axisswap +order=2,1"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=longlat +ellps=clrk80ign +pm=paris +no_defs"); + "+proj=longlat +ellps=clrk80ign +pm=paris +no_defs"); } // --------------------------------------------------------------------------- @@ -624,11 +610,8 @@ TEST(crs, EPSG_4267) { " ORDER[2],\n" " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" " ID[\"EPSG\",4267]]"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=longlat +datum=NAD27 +no_defs"); + EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=longlat +datum=NAD27 +no_defs"); } // --------------------------------------------------------------------------- @@ -663,11 +646,8 @@ TEST(crs, EPSG_4269) { " ORDER[2],\n" " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" " ID[\"EPSG\",4269]]"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=longlat +datum=NAD83 +no_defs"); + EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=longlat +datum=NAD83 +no_defs"); } // --------------------------------------------------------------------------- @@ -725,15 +705,6 @@ TEST(crs, EPSG_27561_projected_with_geodetic_in_grad_as_PROJ_string_and_WKT1) { ASSERT_TRUE(crs != nullptr); EXPECT_EQ( crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=grad +xy_out=rad +step +inv +proj=longlat " - "+ellps=clrk80ign +pm=paris +step +proj=lcc +lat_1=49.5 " - "+lat_0=49.5 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 " - "+ellps=clrk80ign +pm=paris"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), "+proj=lcc +lat_1=49.5 +lat_0=49.5 +lon_0=0 +k_0=0.999877341 " "+x_0=600000 +y_0=200000 +ellps=clrk80ign +pm=paris +units=m +no_defs"); @@ -811,9 +782,7 @@ TEST(crs, EPSG_3040_projected_northing_easting_as_PROJ_string) { auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=utm " - "+zone=28 +ellps=GRS80 +step +proj=axisswap +order=2,1"); + "+proj=utm +zone=28 +ellps=GRS80 +units=m +no_defs"); } // --------------------------------------------------------------------------- @@ -843,17 +812,8 @@ TEST(crs, EPSG_2222_projected_unit_foot_as_PROJ_string_and_WKT1) { auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=tmerc " - "+lat_0=31 +lon_0=-110.166666666667 +k=0.9999 +x_0=213360 " - "+y_0=0 +ellps=GRS80 +step +proj=unitconvert +xy_in=m +z_in=m " - "+xy_out=ft +z_out=ft"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=tmerc +lat_0=31 +lon_0=-110.166666666667 +k=0.9999 " - "+x_0=213360 +y_0=0 +datum=NAD83 +units=ft +no_defs"); + "+proj=tmerc +lat_0=31 +lon_0=-110.166666666667 +k=0.9999 " + "+x_0=213360 +y_0=0 +datum=NAD83 +units=ft +no_defs"); auto wkt1 = crs->exportToWKT( WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get()); @@ -931,22 +891,18 @@ TEST(crs, EPSG_32661_projected_north_pole_north_east) { auto crs = factory->createCoordinateReferenceSystem("32661"); auto proj_crs = nn_dynamic_pointer_cast<ProjectedCRS>(crs); ASSERT_TRUE(proj_crs != nullptr); + auto proj_string = "+proj=pipeline +step +proj=axisswap +order=2,1 +step " "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=stere " "+lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 " "+ellps=WGS84 +step +proj=axisswap +order=2,1"; - EXPECT_EQ(proj_crs->exportToPROJString(PROJStringFormatter::create().get()), - proj_string); - auto obj_from_proj = PROJStringParser().createFromPROJString(proj_string); - auto crs_from_proj = nn_dynamic_pointer_cast<ProjectedCRS>(obj_from_proj); - ASSERT_TRUE(crs_from_proj != nullptr); - EXPECT_EQ( - crs_from_proj->exportToPROJString(PROJStringFormatter::create().get()), - proj_string); - EXPECT_TRUE(crs_from_proj->coordinateSystem()->isEquivalentTo( - proj_crs->coordinateSystem().get())); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(proj_crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + proj_string); } // --------------------------------------------------------------------------- @@ -962,17 +918,12 @@ TEST(crs, EPSG_5041_projected_north_pole_east_north) { "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=stere " "+lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 " "+ellps=WGS84"; - EXPECT_EQ(proj_crs->exportToPROJString(PROJStringFormatter::create().get()), - proj_string); - auto obj_from_proj = PROJStringParser().createFromPROJString(proj_string); - auto crs_from_proj = nn_dynamic_pointer_cast<ProjectedCRS>(obj_from_proj); - ASSERT_TRUE(crs_from_proj != nullptr); - EXPECT_EQ( - crs_from_proj->exportToPROJString(PROJStringFormatter::create().get()), - proj_string); - EXPECT_TRUE(crs_from_proj->coordinateSystem()->isEquivalentTo( - proj_crs->coordinateSystem().get())); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(proj_crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + proj_string); } // --------------------------------------------------------------------------- @@ -988,17 +939,12 @@ TEST(crs, EPSG_32761_projected_south_pole_north_east) { "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=stere " "+lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 " "+ellps=WGS84 +step +proj=axisswap +order=2,1"; - EXPECT_EQ(proj_crs->exportToPROJString(PROJStringFormatter::create().get()), - proj_string); - auto obj_from_proj = PROJStringParser().createFromPROJString(proj_string); - auto crs_from_proj = nn_dynamic_pointer_cast<ProjectedCRS>(obj_from_proj); - ASSERT_TRUE(crs_from_proj != nullptr); - EXPECT_EQ( - crs_from_proj->exportToPROJString(PROJStringFormatter::create().get()), - proj_string); - EXPECT_TRUE(crs_from_proj->coordinateSystem()->isEquivalentTo( - proj_crs->coordinateSystem().get())); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(proj_crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + proj_string); } // --------------------------------------------------------------------------- @@ -1009,11 +955,17 @@ TEST(crs, EPSG_5042_projected_south_pole_east_north) { auto crs = factory->createCoordinateReferenceSystem("5042"); auto proj_crs = nn_dynamic_pointer_cast<ProjectedCRS>(crs); ASSERT_TRUE(proj_crs != nullptr); - EXPECT_EQ(proj_crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=stere " - "+lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 " - "+ellps=WGS84"); + auto proj_string = + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=stere " + "+lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 " + "+ellps=WGS84"; + + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(proj_crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + proj_string); } // --------------------------------------------------------------------------- @@ -1157,12 +1109,7 @@ TEST(crs, EPSG_4978_as_WKT1_GDAL_with_database) { TEST(crs, geocentricCRS_as_PROJ_string) { auto crs = createGeocentric(); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=cart +ellps=WGS84"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=geocent +datum=WGS84 +units=m +no_defs"); + "+proj=geocent +datum=WGS84 +units=m +no_defs"); } // --------------------------------------------------------------------------- @@ -1173,14 +1120,17 @@ TEST(crs, geocentricCRS_non_meter_unit_as_PROJ_string) { CartesianCS::createGeocentric( UnitOfMeasure("kilometre", 1000.0, UnitOfMeasure::Type::LINEAR))); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=cart +ellps=WGS84 +step " - "+proj=unitconvert +xy_in=m +z_in=m +xy_out=km +z_out=km"); - EXPECT_THROW( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - FormattingException); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, crs); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=cart " + "+ellps=WGS84 +step +proj=unitconvert +xy_in=m +z_in=m " + "+xy_out=km +z_out=km"); + + EXPECT_THROW(crs->exportToPROJString(PROJStringFormatter::create().get()), + FormattingException); } // --------------------------------------------------------------------------- @@ -1191,9 +1141,14 @@ TEST(crs, geocentricCRS_unsupported_unit_as_PROJ_string) { CartesianCS::createGeocentric( UnitOfMeasure("my unit", 500.0, UnitOfMeasure::Type::LINEAR))); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=cart +ellps=WGS84 +step " - "+proj=unitconvert +xy_in=m +z_in=m +xy_out=500 +z_out=500"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, crs); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=cart " + "+ellps=WGS84 +step +proj=unitconvert +xy_in=m +z_in=m " + "+xy_out=500 +z_out=500"); } // --------------------------------------------------------------------------- @@ -1556,7 +1511,7 @@ TEST(crs, projectedCRS_shallowClone) { } EXPECT_EQ(clone->baseCRS()->exportToPROJString( PROJStringFormatter::create().get()), - "+proj=cart +ellps=WGS84"); + "+proj=geocent +datum=WGS84 +units=m +no_defs"); } } @@ -1785,15 +1740,16 @@ TEST(crs, projectedCRS_from_WKT1_ESRI_as_WKT1_ESRI) { TEST(crs, projectedCRS_as_PROJ_string) { auto crs = createProjected(); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, crs); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=pipeline +step +proj=axisswap +order=2,1 +step " "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=utm " "+zone=31 +ellps=WGS84"); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=utm +zone=31 +datum=WGS84 +units=m +no_defs"); + EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=utm +zone=31 +datum=WGS84 +units=m +no_defs"); } // --------------------------------------------------------------------------- @@ -1802,7 +1758,10 @@ TEST(crs, projectedCRS_Krovak_EPSG_5221_as_PROJ_string) { auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); auto crs = factory->createProjectedCRS("5221"); // 30deg 17' 17.30311'' = 30.28813975277777776 - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + auto op = CoordinateOperationFactory::create()->createOperation( + crs->baseCRS(), crs); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=pipeline +step +proj=axisswap +order=2,1 " "+step +proj=unitconvert +xy_in=deg +xy_out=rad " "+step +inv +proj=longlat +ellps=bessel +pm=ferro " @@ -1819,7 +1778,10 @@ TEST(crs, projectedCRS_Krovak_with_approximate_alpha_as_PROJ_string) { "+proj=krovak +lat_0=49.5 +lon_0=42.5 +alpha=30.28813972222222 " "+k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m +no_defs"); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + auto op = CoordinateOperationFactory::create()->createOperation( + crs->baseCRS(), NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=pipeline " "+step +proj=unitconvert +xy_in=deg +xy_out=rad " "+step +inv +proj=longlat +ellps=bessel +pm=ferro " @@ -3159,17 +3121,8 @@ TEST(crs, compoundCRS_as_WKT1_GDAL) { TEST(crs, compoundCRS_as_PROJ_string) { auto crs = createCompoundCRS(); - auto expected = "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=utm " - "+zone=31 +ellps=WGS84 +vunits=m"; - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - expected); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=utm +zone=31 +datum=WGS84 +units=m +vunits=m +no_defs"); + "+proj=utm +zone=31 +datum=WGS84 +units=m +vunits=m +no_defs"); } // --------------------------------------------------------------------------- @@ -4022,8 +3975,11 @@ TEST(crs, derivedGeographicCRS_to_PROJ) { auto obj = WKTParser().createFromWKT(wkt); auto crs = nn_dynamic_pointer_cast<DerivedGeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); + auto op = CoordinateOperationFactory::create()->createOperation( + crs->baseCRS(), NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); EXPECT_EQ( - crs->exportToPROJString(PROJStringFormatter::create().get()), + op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=pipeline +step +proj=axisswap +order=2,1 +step " "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=ob_tran " "+o_proj=longlat +o_lat_p=52 +o_lon_p=-30 +lon_0=-25 +ellps=WGS84 " @@ -4071,7 +4027,10 @@ TEST(crs, derivedGeographicCRS_with_affine_transform_to_PROJ) { auto crs = nn_dynamic_pointer_cast<DerivedGeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_TRUE(crs->derivingConversion()->validateParameters().empty()); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + auto op = CoordinateOperationFactory::create()->createOperation( + crs->baseCRS(), NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=affine +xoff=0.5 +s11=1 +s12=0 +yoff=2.5 +s21=0 +s22=1"); } @@ -4254,15 +4213,6 @@ TEST(crs, derivedProjectedCRS_WKT2_2015) { // --------------------------------------------------------------------------- -TEST(crs, derivedProjectedCRS_to_PROJ) { - - auto crs = createDerivedProjectedCRS(); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=unimplemented"); -} - -// --------------------------------------------------------------------------- - static DateTimeTemporalCSNNPtr createDateTimeTemporalCS() { return DateTimeTemporalCS::create( PropertyMap(), diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index deff6b63..e9b29728 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -409,9 +409,7 @@ TEST(factory, AuthorityFactory_createGeodeticCRS_geographic2D) { EXPECT_TRUE(extent->isEquivalentTo(factory->createExtent("1262").get())); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=WGS84 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " - "+order=2,1"); + "+proj=longlat +datum=WGS84 +no_defs"); } // --------------------------------------------------------------------------- @@ -972,11 +970,9 @@ TEST(factory, AuthorityFactory_test_uom_9110) { // This tests conversion from unit of measure EPSG:9110 DDD.MMSSsss auto crs = factory->createProjectedCRS("2172"); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=sterea " - "+lat_0=53.0019444444444 +lon_0=21.5027777777778 +k=0.9998 " - "+x_0=4603000 +y_0=5806000 +ellps=krass +step +proj=axisswap " - "+order=2,1"); + "+proj=sterea +lat_0=53.0019444444444 +lon_0=21.5027777777778 " + "+k=0.9998 +x_0=4603000 +y_0=5806000 +ellps=krass +units=m " + "+no_defs"); } // --------------------------------------------------------------------------- @@ -2327,10 +2323,8 @@ TEST_F(FactoryWithTmpDatabase, custom_projected_crs) { EXPECT_EQ(*(crs->name()->description()), "my name"); EXPECT_EQ(crs->identifiers().size(), 1); EXPECT_EQ(crs->derivingConversion()->targetCRS().get(), crs.get()); - EXPECT_EQ( - crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=mbt_s +unused_flag +ellps=WGS84"); + EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=mbt_s +unused_flag +datum=WGS84 +units=m +no_defs"); EXPECT_TRUE(crs->canonicalBoundCRS() == nullptr); } { @@ -2338,10 +2332,8 @@ TEST_F(FactoryWithTmpDatabase, custom_projected_crs) { EXPECT_EQ(*(crs->name()->description()), "my name"); EXPECT_EQ(crs->identifiers().size(), 1); EXPECT_EQ(crs->derivingConversion()->targetCRS().get(), crs.get()); - EXPECT_EQ( - crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=mbt_s +unused_flag +ellps=WGS84"); + EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=mbt_s +unused_flag +datum=WGS84 +units=m +no_defs"); EXPECT_TRUE(crs->canonicalBoundCRS() != nullptr); } diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index fc20b08d..3eabfc03 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -1253,11 +1253,10 @@ TEST(wkt_parse, wkt1_krovak_south_west) { auto projString = crs->exportToPROJString(PROJStringFormatter::create().get()); - auto expectedPROJString = - "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=krovak +axis=swu +lat_0=49.5 " - "+lon_0=24.8333333333333 +alpha=30.2881397222222 " - "+k=0.9999 +x_0=0 +y_0=0 +ellps=bessel"; + auto expectedPROJString = "+proj=krovak +axis=swu +lat_0=49.5 " + "+lon_0=24.8333333333333 +alpha=30.2881397222222 " + "+k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m " + "+no_defs"; EXPECT_EQ(projString, expectedPROJString); obj = PROJStringParser().createFromPROJString(projString); @@ -1368,9 +1367,9 @@ TEST(wkt_parse, wkt1_krovak_north_oriented) { " ID[\"EPSG\",5514]]"); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=krovak +lat_0=49.5 +lon_0=24.8333333333333 " - "+alpha=30.2881397222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel"); + "+proj=krovak +lat_0=49.5 +lon_0=24.8333333333333 " + "+alpha=30.2881397222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel " + "+units=m +no_defs"); } // --------------------------------------------------------------------------- @@ -6892,17 +6891,20 @@ TEST(io, projparse_longlat_pm_overriding_datum) { TEST(io, projparse_longlat_complex) { std::string input = - "+proj=pipeline +step +proj=longlat +ellps=clrk80ign " + "+step +proj=longlat +ellps=clrk80ign " "+pm=paris +step +proj=unitconvert +xy_in=rad +xy_out=grad +step " "+proj=axisswap +order=2,1"; - auto obj = PROJStringParser().createFromPROJString(input); + auto obj = + PROJStringParser().createFromPROJString("+proj=pipeline " + input); auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad " + + input); } // --------------------------------------------------------------------------- @@ -7069,7 +7071,7 @@ TEST(io, projparse_vunits) { auto crs = nn_dynamic_pointer_cast<VerticalCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+vunits=ft"); + "+vunits=ft +no_defs"); } // --------------------------------------------------------------------------- @@ -7079,7 +7081,7 @@ TEST(io, projparse_vto_meter) { auto crs = nn_dynamic_pointer_cast<VerticalCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+vto_meter=2"); + "+vto_meter=2 +no_defs"); } // --------------------------------------------------------------------------- @@ -7102,9 +7104,11 @@ TEST(io, projparse_longlat_axis_enu) { std::string::npos) << wkt; - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=axisswap +order=2,1"); } // --------------------------------------------------------------------------- @@ -7127,10 +7131,10 @@ TEST(io, projparse_longlat_axis_neu) { std::string::npos) << wkt; - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " - "+order=2,1"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), ""); } // --------------------------------------------------------------------------- @@ -7153,10 +7157,12 @@ TEST(io, projparse_longlat_axis_swu) { std::string::npos) << wkt; - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " - "+order=-2,-1"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=axisswap +order=-2,-1"); } // --------------------------------------------------------------------------- @@ -7168,9 +7174,11 @@ TEST(io, projparse_longlat_unitconvert_deg) { auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=axisswap +order=2,1"); } // --------------------------------------------------------------------------- @@ -7182,8 +7190,12 @@ TEST(io, projparse_longlat_unitconvert_grad) { auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step " "+proj=unitconvert +xy_in=rad +xy_out=grad"); } @@ -7196,9 +7208,12 @@ TEST(io, projparse_longlat_unitconvert_rad) { auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " - "+proj=unitconvert +xy_in=rad +xy_out=rad"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad"); } // --------------------------------------------------------------------------- @@ -7215,13 +7230,16 @@ TEST(io, projparse_longlat_axisswap) { auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step " - "+proj=unitconvert +xy_in=rad +xy_out=deg +step " - "+proj=axisswap +order=" + - std::string(order1) + "," + order2); + op->exportToPROJString(PROJStringFormatter::create().get()), + (atoi(order1) == 2 && atoi(order2) == 1) + ? "" + : "+proj=pipeline +step +proj=axisswap +order=2,1 " + "+step +proj=axisswap +order=" + + std::string(order1) + "," + order2); } } } @@ -7870,11 +7888,14 @@ TEST(io, projparse_axisswap_unitconvert_longlat_proj) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=lcc " + "+lat_1=49.5 +lat_0=49.5 +lon_0=0 +k_0=0.999877341 +x_0=600000 " + "+y_0=200000 +ellps=clrk80ign +pm=paris"); } // --------------------------------------------------------------------------- @@ -7887,11 +7908,14 @@ TEST(io, projparse_axisswap_unitconvert_proj_axisswap) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=igh " + "+lon_0=0 +x_0=0 +y_0=0 +ellps=GRS80 +step +proj=axisswap " + "+order=2,1"); } // --------------------------------------------------------------------------- @@ -7905,11 +7929,14 @@ TEST(io, projparse_axisswap_unitconvert_proj_unitconvert) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=igh " + "+lon_0=0 +x_0=0 +y_0=0 +ellps=GRS80 +step +proj=unitconvert " + "+xy_in=m +z_in=m +xy_out=ft +z_out=ft"); } // --------------------------------------------------------------------------- @@ -7923,11 +7950,15 @@ TEST(io, projparse_axisswap_unitconvert_proj_unitconvert_numeric_axisswap) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=igh " + "+lon_0=0 +x_0=0 +y_0=0 +ellps=GRS80 +step +proj=unitconvert " + "+xy_in=m +z_in=m +xy_out=2.5 +z_out=2.5 +step +proj=axisswap " + "+order=-2,-1"); } // --------------------------------------------------------------------------- @@ -8059,20 +8090,9 @@ TEST(io, projparse_projected_unknown) { EXPECT_EQ(wkt, expected_wkt1); } - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=mbt_s +unused_flag +lat_0=45 +lon_0=0 +k=1 +x_0=10 " - "+y_0=0 +datum=WGS84 +units=m +no_defs"); - - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=mbt_s +unused_flag +lat_0=45 +lon_0=0 +k=1 " - "+x_0=10 +y_0=0 +ellps=WGS84"); + EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=mbt_s +unused_flag +lat_0=45 +lon_0=0 +k=1 +x_0=10 " + "+y_0=0 +datum=WGS84 +units=m +no_defs"); { auto obj2 = WKTParser().createFromWKT(expected_wkt1); @@ -8160,11 +8180,14 @@ TEST(io, projparse_cart_unit) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<GeodeticCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=cart " + "+ellps=WGS84 +step +proj=unitconvert +xy_in=m +z_in=m " + "+xy_out=km +z_out=km"); } // --------------------------------------------------------------------------- @@ -8176,11 +8199,14 @@ TEST(io, projparse_cart_unit_numeric) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<GeodeticCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=cart " + "+ellps=WGS84 +step +proj=unitconvert +xy_in=m +z_in=m " + "+xy_out=500 +z_out=500"); } // --------------------------------------------------------------------------- @@ -8237,11 +8263,15 @@ TEST(io, projparse_ob_tran_longlat) { auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast<DerivedGeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - input); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, NN_NO_CHECK(crs)); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=ob_tran " + "+o_proj=longlat +o_lat_p=52 +o_lon_p=-30 +lon_0=-25 " + "+ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); } // --------------------------------------------------------------------------- @@ -8651,8 +8681,7 @@ TEST(io, projparse_init) { auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=longlat +ellps=GRS80 " - "+step +proj=unitconvert +xy_in=rad +xy_out=deg"); + "+proj=longlat +ellps=GRS80 +no_defs"); } } diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 9b9273b5..379ef31a 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -1377,9 +1377,8 @@ TEST(operation, tmerc_south_oriented_export) { auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=tmerc " - "+axis=wsu +lat_0=0 +lon_0=29 +k=1 +x_0=0 +y_0=0 +ellps=WGS84"); + "+proj=tmerc +axis=wsu +lat_0=0 +lon_0=29 +k=1 +x_0=0 +y_0=0 " + "+ellps=WGS84 +units=m +no_defs"); } // --------------------------------------------------------------------------- @@ -1630,8 +1629,8 @@ TEST(operation, bonne_export) { auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=bonne +lat_1=1 +lon_0=2 +x_0=3 +y_0=4 +ellps=WGS84"); + "+proj=bonne +lat_1=1 +lon_0=2 +x_0=3 +y_0=4 +ellps=WGS84 " + "+units=m +no_defs"); } // --------------------------------------------------------------------------- @@ -3016,12 +3015,6 @@ TEST(operation, webmerc_export) { EXPECT_EQ(conv->exportToPROJString(PROJStringFormatter::create().get()), "+proj=webmerc +lat_0=0 +lon_0=2 +x_0=3 +y_0=4"); - EXPECT_THROW( - conv->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - FormattingException); - EXPECT_EQ(conv->exportToWKT(WKTFormatter::create().get()), "CONVERSION[\"Popular Visualisation Pseudo Mercator\",\n" " METHOD[\"Popular Visualisation Pseudo Mercator\",\n" @@ -3072,20 +3065,17 @@ TEST(operation, webmerc_export) { "+x_0=3 +y_0=4 +k=1 +units=m " "+nadgrids=@null +wktext +no_defs\"]]"); - EXPECT_EQ( - projCRS->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5) - .get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=webmerc " - "+lat_0=0 +lon_0=2 +x_0=3 +y_0=4 +ellps=WGS84"); + auto op = CoordinateOperationFactory::create()->createOperation( + GeographicCRS::EPSG_4326, projCRS); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=webmerc " + "+lat_0=0 +lon_0=2 +x_0=3 +y_0=4 +ellps=WGS84"); - EXPECT_EQ( - projCRS->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=2 +x_0=3 " - "+y_0=4 +k=1 +units=m +nadgrids=@null +wktext +no_defs"); + EXPECT_EQ(projCRS->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=2 +x_0=3 " + "+y_0=4 +k=1 +units=m +nadgrids=@null +wktext +no_defs"); } // --------------------------------------------------------------------------- @@ -3183,17 +3173,8 @@ TEST(operation, webmerc_import_from_GDAL_wkt1_EPSG_3785_deprecated) { ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=webmerc " - "+lat_0=0 +lon_0=0 +x_0=0 +y_0=0 " - "+ellps=WGS84"); - - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 " - "+y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"); + "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 " + "+y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"); auto convGot = crs->derivingConversion(); @@ -3257,16 +3238,8 @@ TEST(operation, webmerc_import_from_WKT2_EPSG_3785_deprecated) { ASSERT_TRUE(crs != nullptr); EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=webmerc " - "+ellps=WGS84"); - - EXPECT_EQ( - crs->exportToPROJString( - PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4) - .get()), - "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 " - "+y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"); + "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 " + "+y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"); EXPECT_EQ( crs->exportToWKT( @@ -4105,12 +4078,9 @@ TEST(operation, eqearth_export) { TEST(operation, laborde_oblique_mercator) { // Content of EPSG:29701 "Tananarive (Paris) / Laborde Grid" - auto projString = "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=grad +xy_out=rad +step +inv " - "+proj=longlat +ellps=intl +pm=paris +step +proj=labrd " - "+lat_0=-18.9 +lon_0=44.1 +azi=18.9 +k=0.9995 " - "+x_0=400000 +y_0=800000 +ellps=intl +pm=paris +step " - "+proj=axisswap +order=2,1"; + auto projString = "+proj=labrd +lat_0=-18.9 +lon_0=44.1 +azi=18.9 " + "+k=0.9995 +x_0=400000 +y_0=800000 +ellps=intl +pm=paris " + "+units=m +no_defs"; auto obj = PROJStringParser().createFromPROJString(projString); auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); |
