diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-06 19:26:09 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-10-06 19:26:09 +0200 |
| commit | f28d36cee9ec099ae5fea3873988204a7ebda520 (patch) | |
| tree | 9adde1d0f8936b3439bb2b42e5c075f9d8df6362 /test/unit | |
| parent | 3a67ea87fac5b835df7966fa801881eaf7503e78 (diff) | |
| download | PROJ-f28d36cee9ec099ae5fea3873988204a7ebda520.tar.gz PROJ-f28d36cee9ec099ae5fea3873988204a7ebda520.zip | |
CRS::_isEquivalentTo(): be tolerant to different order of PROJ step options (fixes #2886)
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/test_crs.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index a1838896..987ffe1b 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -6726,4 +6726,37 @@ TEST(crs, projected_is_equivalent_to_with_proj4_extension) { // Check equivalence of the CRS from PROJ.4 and WKT EXPECT_TRUE(crs1->isEquivalentTo(crs_from_wkt.get(), IComparable::Criterion::EQUIVALENT)); + + ASSERT_TRUE(crs_from_wkt != nullptr); + // Same as above but with different option order + const auto obj2 = PROJStringParser().createFromPROJString( + "+proj=omerc +lat_0=50 +no_rot +alpha=50.0 +a=6378144.0 +b=6356759.0 " + "+lon_0=8.0 +type=crs"); + const auto crs2 = nn_dynamic_pointer_cast<ProjectedCRS>(obj2); + ASSERT_TRUE(crs2 != nullptr); + + // Check equivalence of the 2 PROJ.4 based CRS + EXPECT_TRUE( + crs1->isEquivalentTo(crs2.get(), IComparable::Criterion::EQUIVALENT)); + + // Without +no_rot --> no PROJ.4 extension + const auto objNoRot = PROJStringParser().createFromPROJString( + "+proj=omerc +lat_0=50 +alpha=50.0 +a=6378144.0 +b=6356759.0 " + "+lon_0=8.0 +type=crs"); + const auto crsNoRot = nn_dynamic_pointer_cast<ProjectedCRS>(objNoRot); + ASSERT_TRUE(crsNoRot != nullptr); + EXPECT_FALSE(crs1->isEquivalentTo(crsNoRot.get(), + IComparable::Criterion::EQUIVALENT)); + EXPECT_FALSE(crsNoRot->isEquivalentTo(crs1.get(), + IComparable::Criterion::EQUIVALENT)); + + // Change alpha value + const auto objDifferent = PROJStringParser().createFromPROJString( + "+proj=omerc +lat_0=50 +alpha=49.0 +no_rot +a=6378144.0 +b=6356759.0 " + "+lon_0=8.0 +type=crs"); + const auto crsDifferent = + nn_dynamic_pointer_cast<ProjectedCRS>(objDifferent); + ASSERT_TRUE(crsDifferent != nullptr); + EXPECT_FALSE(crs1->isEquivalentTo(crsDifferent.get(), + IComparable::Criterion::EQUIVALENT)); } |
