aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-01-17 17:01:20 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-01-17 21:57:27 +0100
commitc0ac895d77e823fe9a9458d013eb0f6378f39060 (patch)
tree9e7641cda61a75c3a6209d17dad6fa7c8448cd44 /test/unit
parent3121d9bc309b439adcc2ab9743a3d2b3a8f48296 (diff)
downloadPROJ-c0ac895d77e823fe9a9458d013eb0f6378f39060.tar.gz
PROJ-c0ac895d77e823fe9a9458d013eb0f6378f39060.zip
Remove proj_create_from_proj_string() and proj_create_from_user_input(), and make proj_create() do more or less what proj_create_from_user_input() did before (fixes #1214)
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/pj_transform_test.cpp1
-rw-r--r--test/unit/test_c_api.cpp79
-rw-r--r--test/unit/test_crs.cpp2
-rw-r--r--test/unit/test_io.cpp255
-rw-r--r--test/unit/test_operation.cpp13
5 files changed, 147 insertions, 203 deletions
diff --git a/test/unit/pj_transform_test.cpp b/test/unit/pj_transform_test.cpp
index 22f7afca..9d8439ee 100644
--- a/test/unit/pj_transform_test.cpp
+++ b/test/unit/pj_transform_test.cpp
@@ -572,6 +572,7 @@ TEST(pj_transform_test, init_epsg) {
auto src = pj_init_plus("+init=epsg:4326");
ASSERT_TRUE(src != nullptr);
auto dst = pj_init_plus("+init=epsg:32631");
+ ASSERT_TRUE(dst != nullptr);
double x = 3 * DEG_TO_RAD;
double y = 0 * DEG_TO_RAD;
EXPECT_EQ(pj_transform(src, dst, 1, 0, &x, &y, nullptr), 0);
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 4c13a5e2..ff29185f 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -148,15 +148,14 @@ class CApi : public ::testing::Test {
// ---------------------------------------------------------------------------
-TEST_F(CApi, proj_create_from_user_input) {
+TEST_F(CApi, proj_create) {
proj_destroy(nullptr);
- EXPECT_EQ(proj_create_from_user_input(m_ctxt, "invalid", nullptr), nullptr);
+ EXPECT_EQ(proj_create(m_ctxt, "invalid"), nullptr);
{
- auto obj = proj_create_from_user_input(
- m_ctxt,
- GeographicCRS::EPSG_4326->exportToWKT(WKTFormatter::create().get())
- .c_str(),
- nullptr);
+ auto obj =
+ proj_create(m_ctxt, GeographicCRS::EPSG_4326
+ ->exportToWKT(WKTFormatter::create().get())
+ .c_str());
ObjectKeeper keeper(obj);
EXPECT_NE(obj, nullptr);
@@ -182,7 +181,7 @@ TEST_F(CApi, proj_create_from_user_input) {
EXPECT_EQ(info.definition, std::string(""));
}
{
- auto obj = proj_create_from_user_input(m_ctxt, "EPSG:4326", nullptr);
+ auto obj = proj_create(m_ctxt, "EPSG:4326");
ObjectKeeper keeper(obj);
EXPECT_NE(obj, nullptr);
}
@@ -318,17 +317,6 @@ TEST_F(CApi, proj_create_from_wkt) {
// ---------------------------------------------------------------------------
-TEST_F(CApi, proj_create_from_proj_string) {
-
- EXPECT_EQ(proj_create_from_proj_string(m_ctxt, "invalid", nullptr),
- nullptr);
- auto obj = proj_create_from_proj_string(m_ctxt, "+proj=longlat", nullptr);
- ObjectKeeper keeper(obj);
- EXPECT_NE(obj, nullptr);
-}
-
-// ---------------------------------------------------------------------------
-
TEST_F(CApi, proj_as_wkt) {
auto obj = proj_create_from_wkt(
m_ctxt,
@@ -520,8 +508,7 @@ TEST_F(CApi, proj_as_proj_string_incompatible_WKT1) {
// ---------------------------------------------------------------------------
TEST_F(CApi, proj_as_proj_string_etmerc_option_yes) {
- auto obj =
- proj_create_from_proj_string(m_ctxt, "+proj=tmerc +type=crs", nullptr);
+ auto obj = proj_create(m_ctxt, "+proj=tmerc +type=crs");
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
@@ -536,8 +523,7 @@ TEST_F(CApi, proj_as_proj_string_etmerc_option_yes) {
// ---------------------------------------------------------------------------
TEST_F(CApi, proj_as_proj_string_etmerc_option_no) {
- auto obj = proj_create_from_proj_string(
- m_ctxt, "+proj=utm +zone=31 +type=crs", nullptr);
+ auto obj = proj_create(m_ctxt, "+proj=utm +zone=31 +type=crs");
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
@@ -1698,8 +1684,7 @@ TEST_F(CApi, proj_get_area_of_use) {
EXPECT_EQ(std::string(name), "World");
}
{
- auto obj =
- proj_create_from_user_input(m_ctxt, "+proj=longlat", nullptr);
+ auto obj = proj_create(m_ctxt, "+proj=longlat +type=crs");
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
EXPECT_FALSE(proj_get_area_of_use(m_ctxt, obj, nullptr, nullptr,
@@ -1726,8 +1711,7 @@ TEST_F(CApi, proj_coordoperation_get_accuracy) {
EXPECT_EQ(proj_coordoperation_get_accuracy(m_ctxt, obj), 16.0);
}
{
- auto obj =
- proj_create_from_user_input(m_ctxt, "+proj=helmert", nullptr);
+ auto obj = proj_create(m_ctxt, "+proj=helmert");
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
EXPECT_EQ(proj_coordoperation_get_accuracy(m_ctxt, obj), -1.0);
@@ -1750,11 +1734,10 @@ TEST_F(CApi, proj_create_geographic_crs) {
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
- auto objRef = proj_create_from_user_input(
- m_ctxt,
- GeographicCRS::EPSG_4326->exportToWKT(WKTFormatter::create().get())
- .c_str(),
- nullptr);
+ auto objRef =
+ proj_create(m_ctxt, GeographicCRS::EPSG_4326
+ ->exportToWKT(WKTFormatter::create().get())
+ .c_str());
ObjectKeeper keeperobjRef(objRef);
EXPECT_NE(objRef, nullptr);
@@ -1787,11 +1770,10 @@ TEST_F(CApi, proj_create_geographic_crs) {
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
- auto objRef = proj_create_from_user_input(
- m_ctxt,
- GeographicCRS::EPSG_4326->exportToWKT(WKTFormatter::create().get())
- .c_str(),
- nullptr);
+ auto objRef =
+ proj_create(m_ctxt, GeographicCRS::EPSG_4326
+ ->exportToWKT(WKTFormatter::create().get())
+ .c_str());
ObjectKeeper keeperobjRef(objRef);
EXPECT_NE(objRef, nullptr);
@@ -1806,11 +1788,10 @@ TEST_F(CApi, proj_create_geographic_crs) {
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
- auto objRef = proj_create_from_user_input(
- m_ctxt,
- GeographicCRS::EPSG_4269->exportToWKT(WKTFormatter::create().get())
- .c_str(),
- nullptr);
+ auto objRef =
+ proj_create(m_ctxt, GeographicCRS::EPSG_4269
+ ->exportToWKT(WKTFormatter::create().get())
+ .c_str());
ObjectKeeper keeperobjRef(objRef);
EXPECT_NE(objRef, nullptr);
@@ -1865,11 +1846,10 @@ TEST_F(CApi, proj_create_geocentric_crs) {
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
- auto objRef = proj_create_from_user_input(
- m_ctxt,
- GeographicCRS::EPSG_4978->exportToWKT(WKTFormatter::create().get())
- .c_str(),
- nullptr);
+ auto objRef =
+ proj_create(m_ctxt, GeographicCRS::EPSG_4978
+ ->exportToWKT(WKTFormatter::create().get())
+ .c_str());
ObjectKeeper keeperobjRef(objRef);
EXPECT_NE(objRef, nullptr);
@@ -2415,7 +2395,7 @@ TEST_F(CApi, proj_context_get_database_metadata) {
// ---------------------------------------------------------------------------
TEST_F(CApi, proj_clone) {
- auto obj = proj_create_from_proj_string(m_ctxt, "+proj=longlat", nullptr);
+ auto obj = proj_create(m_ctxt, "+proj=longlat");
ObjectKeeper keeper(obj);
ASSERT_NE(obj, nullptr);
@@ -2436,8 +2416,7 @@ TEST_F(CApi, proj_crs_alter_geodetic_crs) {
ObjectKeeper keeper(projCRS);
ASSERT_NE(projCRS, nullptr);
- auto newGeodCRS = proj_create_from_proj_string(
- m_ctxt, "+proj=longlat +type=crs", nullptr);
+ auto newGeodCRS = proj_create(m_ctxt, "+proj=longlat +type=crs");
ObjectKeeper keeper_newGeodCRS(newGeodCRS);
ASSERT_NE(newGeodCRS, nullptr);
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index b71fd248..69cec01b 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -1977,7 +1977,7 @@ TEST(crs, projectedCRS_identify_db) {
{
// Identify from a PROJ string
auto obj = PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+type=crs +proj=pipeline +step +proj=axisswap +order=2,1 +step "
"+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=omerc "
"+no_uoff +lat_0=4 +lonc=102.25 +alpha=323.025796466667 "
"+gamma=323.130102361111 +k=0.99984 +x_0=804671 +y_0=0 "
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 7b75cdc8..15ba30f1 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -1276,7 +1276,8 @@ TEST(wkt_parse, wkt1_krovak_south_west) {
expectedPROJString);
obj = PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
+ "+type=crs +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 "
@@ -6915,8 +6916,8 @@ TEST(io, projparse_longlat_complex) {
"+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("+proj=pipeline " + input);
+ auto obj = PROJStringParser().createFromPROJString(
+ "+type=crs +proj=pipeline " + input);
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
auto op = CoordinateOperationFactory::create()->createOperation(
@@ -7194,7 +7195,7 @@ TEST(io, projparse_longlat_axis_swu) {
TEST(io, projparse_longlat_unitconvert_deg) {
auto obj = PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step "
+ "+type=crs +proj=pipeline +step +proj=longlat +ellps=GRS80 +step "
"+proj=unitconvert +xy_in=rad +xy_out=deg");
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
@@ -7210,7 +7211,7 @@ TEST(io, projparse_longlat_unitconvert_deg) {
TEST(io, projparse_longlat_unitconvert_grad) {
auto obj = PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step "
+ "+type=crs +proj=pipeline +step +proj=longlat +ellps=GRS80 +step "
"+proj=unitconvert +xy_in=rad +xy_out=grad");
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
@@ -7228,7 +7229,7 @@ TEST(io, projparse_longlat_unitconvert_grad) {
TEST(io, projparse_longlat_unitconvert_rad) {
auto obj = PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=longlat +ellps=GRS80 +step "
+ "+type=crs +proj=pipeline +step +proj=longlat +ellps=GRS80 +step "
"+proj=unitconvert +xy_in=rad +xy_out=rad");
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
@@ -7248,9 +7249,10 @@ TEST(io, projparse_longlat_axisswap) {
for (auto order2 : {"1", "-1", "2", "-2"}) {
if (std::abs(atoi(order1) * atoi(order2)) == 2 &&
!(atoi(order1) == 1 && atoi(order2) == 2)) {
- auto str = "+proj=pipeline +step +proj=longlat +ellps=GRS80 "
- "+step +proj=axisswap +order=" +
- std::string(order1) + "," + order2;
+ auto str =
+ "+type=crs +proj=pipeline +step +proj=longlat +ellps=GRS80 "
+ "+step +proj=axisswap +order=" +
+ std::string(order1) + "," + order2;
auto obj = PROJStringParser().createFromPROJString(str);
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
@@ -7363,9 +7365,11 @@ TEST(io, projparse_tmerc_south_oriented) {
EXPECT_EQ(f->toString(), expected);
obj = PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=tmerc +x_0=1 +lat_0=1 +k_0=2 +step "
+ "+type=crs +proj=pipeline +step +proj=tmerc +x_0=1 +lat_0=1 +k_0=2 "
+ "+step "
"+proj=axisswap +order=-1,-2");
crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
EXPECT_EQ(crs->derivingConversion()->method()->nameStr(),
"Transverse Mercator (South Orientated)");
}
@@ -7917,7 +7921,7 @@ TEST(io, projparse_non_earth_ellipsoid) {
TEST(io, projparse_axisswap_unitconvert_longlat_proj) {
std::string input =
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+type=crs +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 "
@@ -7939,7 +7943,7 @@ TEST(io, projparse_axisswap_unitconvert_longlat_proj) {
TEST(io, projparse_axisswap_unitconvert_proj_axisswap) {
std::string input =
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+type=crs +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";
auto obj = PROJStringParser().createFromPROJString(input);
@@ -7959,7 +7963,7 @@ TEST(io, projparse_axisswap_unitconvert_proj_axisswap) {
TEST(io, projparse_axisswap_unitconvert_proj_unitconvert) {
std::string input =
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+type=crs +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";
@@ -7980,7 +7984,7 @@ TEST(io, projparse_axisswap_unitconvert_proj_unitconvert) {
TEST(io, projparse_axisswap_unitconvert_proj_unitconvert_numeric_axisswap) {
std::string input =
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+type=crs +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";
@@ -8294,7 +8298,7 @@ TEST(io, projparse_projected_wktext) {
TEST(io, projparse_ob_tran_longlat) {
std::string input(
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+type=crs +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 "
@@ -8316,7 +8320,11 @@ TEST(io, projparse_ob_tran_longlat) {
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_translation) {
- std::string projString("+proj=helmert +x=1 +y=2 +z=3");
+ std::string projString("+proj=pipeline +step +proj=unitconvert +xy_in=deg "
+ "+xy_out=rad +step +proj=cart +ellps=GRS80 +step "
+ "+proj=helmert +x=1 +y=2 +z=3 +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
+ "+xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8330,8 +8338,11 @@ TEST(io, projparse_helmert_translation) {
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_translation_inv) {
- std::string projString(
- "+proj=pipeline +step +inv +proj=helmert +x=1 +y=2 +z=3");
+ std::string projString("+proj=pipeline +step +proj=unitconvert +xy_in=deg "
+ "+xy_out=rad +step +proj=cart +ellps=GRS80 +step "
+ "+inv +proj=helmert +x=1 +y=2 +z=3 +step +inv "
+ "+proj=cart +ellps=GRS80 +step +proj=unitconvert "
+ "+xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8339,14 +8350,20 @@ TEST(io, projparse_helmert_translation_inv) {
transf->exportToPROJString(
PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5)
.get()),
- "+proj=helmert +x=-1 +y=-2 +z=-3");
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=cart +ellps=GRS80 +step +proj=helmert +x=-1 +y=-2 +z=-3 +step "
+ "+inv +proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
+ "+xy_out=deg");
}
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_position_vector) {
- std::string projString("+proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 "
- "+s=7 +convention=position_vector");
+ std::string projString(
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=cart +ellps=GRS80 +step +proj=helmert +x=1 +y=2 +z=3 +rx=4 "
+ "+ry=5 +rz=6 +s=7 +convention=position_vector +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8360,9 +8377,11 @@ TEST(io, projparse_helmert_position_vector) {
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_position_vector_inv) {
- std::string projString("+proj=pipeline +step +inv +proj=helmert +x=1 +y=2 "
- "+z=3 +rx=4 +ry=5 +rz=6 "
- "+s=7 +convention=position_vector");
+ std::string projString(
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=1 +y=2 +z=3 +rx=4 "
+ "+ry=5 +rz=6 +s=7 +convention=position_vector +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<CoordinateOperation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8376,10 +8395,14 @@ TEST(io, projparse_helmert_position_vector_inv) {
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_time_dependent_position_vector) {
- std::string projString("+proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 "
+ std::string projString("+proj=pipeline +step +proj=unitconvert +xy_in=deg "
+ "+xy_out=rad +step +proj=cart +ellps=GRS80 +step "
+ "+proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 "
"+s=7 +dx=0.1 +dy=0.2 +dz=0.3 +drx=0.4 +dry=0.5 "
"+drz=0.6 +ds=0.7 +t_epoch=2018.5 "
- "+convention=position_vector");
+ "+convention=position_vector +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
+ "+xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8393,8 +8416,11 @@ TEST(io, projparse_helmert_time_dependent_position_vector) {
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_coordinate_frame) {
- std::string projString("+proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 "
- "+s=7 +convention=coordinate_frame");
+ std::string projString(
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=cart +ellps=GRS80 +step +proj=helmert +x=1 +y=2 +z=3 +rx=4 "
+ "+ry=5 +rz=6 +s=7 +convention=coordinate_frame +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8408,10 +8434,14 @@ TEST(io, projparse_helmert_coordinate_frame) {
// ---------------------------------------------------------------------------
TEST(io, projparse_helmert_time_dependent_coordinate_frame) {
- std::string projString("+proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 "
+ std::string projString("+proj=pipeline +step +proj=unitconvert +xy_in=deg "
+ "+xy_out=rad +step +proj=cart +ellps=GRS80 +step "
+ "+proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 "
"+s=7 +dx=0.1 +dy=0.2 +dz=0.3 +drx=0.4 +dry=0.5 "
"+drz=0.6 +ds=0.7 +t_epoch=2018.5 "
- "+convention=coordinate_frame");
+ "+convention=coordinate_frame +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
+ "+xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8426,28 +8456,6 @@ TEST(io, projparse_helmert_time_dependent_coordinate_frame) {
TEST(io, projparse_helmert_complex_pipeline) {
std::string projString(
- "+proj=pipeline +step +proj=cart "
- "+ellps=WGS84 +step +proj=helmert +x=-1 +y=-2 +z=-3 +rx=-4 "
- "+ry=-5 +rz=-6 +s=-7 +convention=position_vector +step +inv "
- "+proj=cart +ellps=clrk80ign");
- auto obj = PROJStringParser().createFromPROJString(projString);
- auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
- ASSERT_TRUE(transf != nullptr);
- EXPECT_EQ(
- transf->exportToPROJString(
- PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5)
- .get()),
- "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
- "+step +proj=cart +ellps=WGS84 +step +proj=helmert +x=-1 +y=-2 "
- "+z=-3 +rx=-4 +ry=-5 +rz=-6 +s=-7 +convention=position_vector "
- "+step +inv +proj=cart +ellps=clrk80ign +step +proj=unitconvert "
- "+xy_in=rad +xy_out=deg");
-}
-
-// ---------------------------------------------------------------------------
-
-TEST(io, projparse_helmert_complex_pipeline_2) {
- std::string projString(
"+proj=pipeline +step +proj=axisswap +order=2,1 +step "
"+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=cart "
"+ellps=WGS84 +step +proj=helmert +x=-1 +y=-2 +z=-3 +rx=-4 "
@@ -8472,21 +8480,18 @@ TEST(io, projparse_helmert_errors) {
// Missing convention
EXPECT_THROW(PROJStringParser().createFromPROJString("+proj=helmert +rx=4"),
ParsingException);
-
- EXPECT_THROW(PROJStringParser().createFromPROJString(
- "+proj=helmert +convention=unhandled"),
- ParsingException);
-
- EXPECT_THROW(PROJStringParser().createFromPROJString(
- "+proj=helmert +unhandled_keyword"),
- ParsingException);
}
// ---------------------------------------------------------------------------
TEST(io, projparse_molodensky) {
- std::string projString("+proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05");
+ std::string projString(
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
+ "+proj=longlat +ellps=WGS84 +step +proj=molodensky +ellps=WGS84 "
+ "+dx=84.87 +dy=96.49 "
+ "+dz=116.95 +da=251 +df=1.41927e-05 +step +proj=longlat "
+ "+ellps=GRS80 +step +proj=unitconvert "
+ "+xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8505,12 +8510,13 @@ TEST(io, projparse_molodensky) {
"ellipsoidal,2],AXIS[\"longitude\",east,ORDER[1],ANGLEUNIT[\"degree\","
"0.0174532925199433]],AXIS[\"latitude\",north,ORDER[2],ANGLEUNIT["
"\"degree\",0.0174532925199433]]]],TARGETCRS[GEODCRS[\"unknown\",DATUM["
- "\"unknown\",ELLIPSOID[\"unknown\",6378388,297.000000198989,LENGTHUNIT["
- "\"metre\",1]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0."
- "0174532925199433]],CS[ellipsoidal,2],AXIS[\"longitude\",east,ORDER[1],"
- "ANGLEUNIT[\"degree\",0.0174532925199433]],AXIS[\"latitude\",north,"
- "ORDER[2],ANGLEUNIT[\"degree\",0.0174532925199433]]]],METHOD["
- "\"Molodensky\",ID[\"EPSG\",9604]],PARAMETER[\"X-axis "
+ "\"Unknown based on GRS80 ellipsoid\",ELLIPSOID[\"GRS "
+ "1980\",6378137,298.257222101,LENGTHUNIT[\"metre\",1]]],PRIMEM["
+ "\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],CS["
+ "ellipsoidal,2],AXIS[\"longitude\",east,ORDER[1],ANGLEUNIT[\"degree\","
+ "0.0174532925199433]],AXIS[\"latitude\",north,ORDER[2],ANGLEUNIT["
+ "\"degree\",0.0174532925199433]]]],METHOD[\"Molodensky\",ID[\"EPSG\","
+ "9604]],PARAMETER[\"X-axis "
"translation\",84.87,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8605]],"
"PARAMETER[\"Y-axis "
"translation\",96.49,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8606]],"
@@ -8524,19 +8530,21 @@ TEST(io, projparse_molodensky) {
transf->exportToPROJString(
PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5)
.get()),
- "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
- "+step +proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05 +step +proj=longlat "
- "+a=6378388 +rf=297.000000198989 +step +proj=unitconvert "
- "+xy_in=rad +xy_out=deg");
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 +dz=116.95 +da=251 "
+ "+df=1.41927e-05 +step +proj=unitconvert +xy_in=rad +xy_out=deg");
}
// ---------------------------------------------------------------------------
TEST(io, projparse_molodensky_inv) {
- std::string projString("+proj=pipeline +step +inv +proj=molodensky "
- "+ellps=WGS84 +dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05");
+ std::string projString(
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
+ "+proj=longlat +ellps=WGS84 +step +inv +proj=molodensky "
+ "+ellps=WGS84 +dx=84.87 +dy=96.49 "
+ "+dz=116.95 +da=251 +df=1.41927e-05 +step +proj=longlat "
+ "+ellps=GRS80 +step +proj=unitconvert "
+ "+xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<CoordinateOperation>(obj);
ASSERT_TRUE(transf != nullptr);
@@ -8544,66 +8552,33 @@ TEST(io, projparse_molodensky_inv) {
transf->exportToPROJString(
PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5)
.get()),
- "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
- "+step +inv +proj=longlat +a=6378388 +rf=297.000000198989 +step "
- "+proj=molodensky +a=6378388 +rf=297.000000198989 +dx=-84.87 "
- "+dy=-96.49 +dz=-116.95 +da=-251 +df=-1.41927e-05 +step "
- "+proj=unitconvert +xy_in=rad +xy_out=deg");
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=molodensky +ellps=GRS80 +dx=-84.87 +dy=-96.49 +dz=-116.95 "
+ "+da=-251 +df=-1.41927e-05 +step +proj=unitconvert +xy_in=rad "
+ "+xy_out=deg");
}
// ---------------------------------------------------------------------------
TEST(io, projparse_molodensky_abridged) {
- std::string projString("+proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05 +abridged");
- auto obj = PROJStringParser().createFromPROJString(projString);
- auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
- ASSERT_TRUE(transf != nullptr);
- EXPECT_EQ(
- transf->exportToPROJString(
- PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5)
- .get()),
- "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
- "+step +proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05 +abridged +step +proj=longlat "
- "+a=6378388 +rf=297.000000198989 +step "
- "+proj=unitconvert +xy_in=rad +xy_out=deg");
-}
-
-// ---------------------------------------------------------------------------
-
-TEST(io, projparse_molodensky_complex_pipeline) {
std::string projString(
"+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
"+proj=longlat +ellps=WGS84 +step +proj=molodensky +ellps=WGS84 "
"+dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05 +step +proj=longlat "
+ "+dz=116.95 +da=251 +df=1.41927e-05 +abridged +step +proj=longlat "
"+ellps=GRS80 +step +proj=unitconvert "
"+xy_in=rad +xy_out=deg");
auto obj = PROJStringParser().createFromPROJString(projString);
auto transf = nn_dynamic_pointer_cast<Transformation>(obj);
ASSERT_TRUE(transf != nullptr);
-
- WKTFormatterNNPtr f(WKTFormatter::create());
- f->simulCurNodeHasId();
- f->setMultiLine(false);
- transf->exportToWKT(f.get());
- auto wkt = f->toString();
- EXPECT_TRUE(wkt.find("SOURCECRS[GEODCRS[\"unknown\",DATUM[\"Unknown based "
- "on WGS84 ellipsoid\"") != std::string::npos)
- << wkt;
- EXPECT_TRUE(wkt.find("TARGETCRS[GEODCRS[\"unknown\",DATUM[\"Unknown based "
- "on GRS80 ellipsoid\"") != std::string::npos)
- << wkt;
-
EXPECT_EQ(
transf->exportToPROJString(
PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5)
.get()),
- "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
- "+step +proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 "
- "+dz=116.95 +da=251 +df=1.41927e-05 +step +proj=unitconvert "
- "+xy_in=rad +xy_out=deg");
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step "
+ "+proj=molodensky +ellps=WGS84 +dx=84.87 +dy=96.49 +dz=116.95 +da=251 "
+ "+df=1.41927e-05 +abridged +step +proj=unitconvert +xy_in=rad "
+ "+xy_out=deg");
}
// ---------------------------------------------------------------------------
@@ -8665,12 +8640,12 @@ TEST(io, projparse_init) {
{
// EPSG:4326 is normally latitude-longitude order with degree,
- // but in compatibillity mode it will be long-lat radian
+ // but in compatibillity mode it will be long-lat
auto obj = createFromUserInput("init=epsg:4326", dbContext, true);
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
EXPECT_TRUE(crs->coordinateSystem()->isEquivalentTo(
- EllipsoidalCS::createLongitudeLatitude(UnitOfMeasure::RADIAN)
+ EllipsoidalCS::createLongitudeLatitude(UnitOfMeasure::DEGREE)
.get()));
}
@@ -8691,20 +8666,19 @@ TEST(io, projparse_init) {
auto co = nn_dynamic_pointer_cast<CoordinateOperation>(obj);
ASSERT_TRUE(co != nullptr);
EXPECT_EQ(co->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=helmert +x=-0.0001 +y=0.0008 +z=0.0058 +rx=0 +ry=0 "
- "+rz=0 +s=-0.0004 +dx=0.0002 +dy=-0.0001 +dz=0.0018 +drx=0 "
- "+dry=0 +drz=0 +ds=-8e-06 +t_epoch=2000 "
- "+convention=position_vector");
+ "+proj=helmert +x=-0.0001 +y=0.0008 +z=0.0058 +s=-0.0004 "
+ "+dx=0.0002 +dy=-0.0001 +dz=0.0018 +ds=-0.000008 "
+ "+t_epoch=2000.0 +convention=position_vector");
}
{
- auto obj = createFromUserInput(
- "title=mytitle init=epsg:4326 ellps=WGS84", dbContext, true);
- auto co = nn_dynamic_pointer_cast<CoordinateOperation>(obj);
- ASSERT_TRUE(co != nullptr);
- EXPECT_EQ(co->nameStr(), "mytitle");
- EXPECT_EQ(co->exportToPROJString(PROJStringFormatter::create().get()),
- "+init=epsg:4326 +ellps=WGS84");
+ auto obj = createFromUserInput("+title=mytitle +geoc +init=epsg:4326",
+ dbContext, true);
+ auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ EXPECT_EQ(crs->nameStr(), "mytitle");
+ EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=longlat +geoc +datum=WGS84 +no_defs +type=crs");
}
{
@@ -8717,16 +8691,6 @@ TEST(io, projparse_init) {
"+proj=pipeline +step +init=epsg:4326 +step +proj=longlat "
"+ellps=WGS84");
}
-
- {
- auto obj = createFromUserInput(
- "init=epsg:4326 proj=longlat ellps=GRS80 +type=crs", dbContext,
- true);
- auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
- ASSERT_TRUE(crs != nullptr);
- EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
- }
}
// ---------------------------------------------------------------------------
@@ -8850,10 +8814,11 @@ TEST(io, projparse_projected_errors) {
"+proj=tmerc +lat_0=foo +type=crs"),
ParsingException);
// Inconsistent pm values between geogCRS and projectedCRS
- EXPECT_THROW(PROJStringParser().createFromPROJString(
- "+proj=pipeline +step +proj=longlat +ellps=WGS84 "
- "+proj=tmerc +ellps=WGS84 +lat_0=foo +pm=paris"),
- ParsingException);
+ EXPECT_THROW(
+ PROJStringParser().createFromPROJString(
+ "+type=crs +proj=pipeline +step +proj=longlat +ellps=WGS84 "
+ "+step +proj=tmerc +ellps=WGS84 +lat_0=0 +pm=paris"),
+ ParsingException);
}
// ---------------------------------------------------------------------------
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index 3cf633b6..d134f086 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -4116,14 +4116,11 @@ TEST(operation, PROJ_based) {
->exportToPROJString(PROJStringFormatter::create().get()),
str);
- EXPECT_THROW(SingleOperation::createPROJBased(PropertyMap(), "+inv",
- nullptr, nullptr)
+ EXPECT_THROW(SingleOperation::createPROJBased(
+ PropertyMap(), "+proj=pipeline +step +proj=pipeline",
+ nullptr, nullptr)
->exportToPROJString(PROJStringFormatter::create().get()),
FormattingException);
- EXPECT_THROW(
- SingleOperation::createPROJBased(PropertyMap(), "foo", nullptr, nullptr)
- ->exportToPROJString(PROJStringFormatter::create().get()),
- FormattingException);
}
// ---------------------------------------------------------------------------
@@ -4690,7 +4687,9 @@ TEST(operation, geogCRS_to_geogCRS_init_IGNF_to_init_IGNF_context) {
EXPECT_EQ(list[0]->nameStr(),
"NOUVELLE TRIANGULATION DE LA FRANCE (NTF) vers RGF93 (ETRS89)");
EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=hgridshift +grids=ntf_r93.gsb");
+ "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
+ "+step +proj=hgridshift +grids=ntf_r93.gsb +step "
+ "+proj=unitconvert +xy_in=rad +xy_out=deg");
}
// ---------------------------------------------------------------------------