aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2022-03-16 00:15:16 +0100
committerEven Rouault <even.rouault@spatialys.com>2022-03-16 00:15:24 +0100
commitfdf5111a9a790926aacec75a07d30508a8ed9c91 (patch)
treea7765015f4f59914c71a596b985f0c6b8b73ee51 /test/unit
parent50ca95d01001710921ba36ce5deff712deec3f2e (diff)
downloadPROJ-fdf5111a9a790926aacec75a07d30508a8ed9c91.tar.gz
PROJ-fdf5111a9a790926aacec75a07d30508a8ed9c91.zip
Fix comparison of GeodeticRefrenceFrame vs DynamicGeodeticReferenceFrame
If comparing a DynamicGeodeticReferenceFrame object and its export to WKT1, which is a simple DATUM object, currently in non-strict comparison mode, we'd consider the datum to be equivalent to the dynamic datum, but not the reverse, which breaks the symmetric property of the isEquivalentTo() operation. So fix this, to consider both equivalent whatever the operand order. (in strict mode, the objects will be considered different of course) Spotted in the GDAL GeoTIFF CRS reader code: https://github.com/OSGeo/gdal/blob/f9d48bdcc8c90df20e53b5af5785f1e5d78910db/frmts/gtiff/gt_wkt_srs.cpp#L832 Do same change for vertical datum vs dynamic vertical datum.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/test_datum.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/unit/test_datum.cpp b/test/unit/test_datum.cpp
index 26098d5c..457bde4d 100644
--- a/test/unit/test_datum.cpp
+++ b/test/unit/test_datum.cpp
@@ -287,6 +287,33 @@ TEST(datum, dynamic_geodetic_reference_frame) {
drf->exportToWKT(
WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get()),
expected_wtk2_2019);
+
+ EXPECT_TRUE(drf->isEquivalentTo(drf.get()));
+ EXPECT_TRUE(
+ drf->isEquivalentTo(drf.get(), IComparable::Criterion::EQUIVALENT));
+ EXPECT_FALSE(drf->isEquivalentTo(createUnrelatedObject().get()));
+
+ // "Same" datum, except that it is a non-dynamic one
+ auto datum = GeodeticReferenceFrame::create(
+ PropertyMap().set(IdentifiedObject::NAME_KEY, "test"), Ellipsoid::WGS84,
+ optional<std::string>("My anchor"), PrimeMeridian::GREENWICH);
+ EXPECT_FALSE(datum->isEquivalentTo(drf.get()));
+ EXPECT_FALSE(drf->isEquivalentTo(datum.get()));
+ EXPECT_TRUE(
+ datum->isEquivalentTo(drf.get(), IComparable::Criterion::EQUIVALENT));
+ EXPECT_TRUE(
+ drf->isEquivalentTo(datum.get(), IComparable::Criterion::EQUIVALENT));
+
+ auto unrelated_datum = GeodeticReferenceFrame::create(
+ PropertyMap().set(IdentifiedObject::NAME_KEY, "test2"),
+ Ellipsoid::WGS84, optional<std::string>("My anchor"),
+ PrimeMeridian::GREENWICH);
+ EXPECT_FALSE(unrelated_datum->isEquivalentTo(drf.get()));
+ EXPECT_FALSE(drf->isEquivalentTo(unrelated_datum.get()));
+ EXPECT_FALSE(unrelated_datum->isEquivalentTo(
+ drf.get(), IComparable::Criterion::EQUIVALENT));
+ EXPECT_FALSE(drf->isEquivalentTo(unrelated_datum.get(),
+ IComparable::Criterion::EQUIVALENT));
}
// ---------------------------------------------------------------------------
@@ -395,6 +422,32 @@ TEST(datum, dynamic_vertical_reference_frame) {
drf->exportToWKT(
WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get()),
expected_wtk2_2019);
+
+ EXPECT_TRUE(drf->isEquivalentTo(drf.get()));
+ EXPECT_TRUE(
+ drf->isEquivalentTo(drf.get(), IComparable::Criterion::EQUIVALENT));
+ EXPECT_FALSE(drf->isEquivalentTo(createUnrelatedObject().get()));
+
+ // "Same" datum, except that it is a non-dynamic one
+ auto datum = VerticalReferenceFrame::create(
+ PropertyMap().set(IdentifiedObject::NAME_KEY, "test"),
+ optional<std::string>("My anchor"), optional<RealizationMethod>());
+ EXPECT_FALSE(datum->isEquivalentTo(drf.get()));
+ EXPECT_FALSE(drf->isEquivalentTo(datum.get()));
+ EXPECT_TRUE(
+ datum->isEquivalentTo(drf.get(), IComparable::Criterion::EQUIVALENT));
+ EXPECT_TRUE(
+ drf->isEquivalentTo(datum.get(), IComparable::Criterion::EQUIVALENT));
+
+ auto unrelated_datum = VerticalReferenceFrame::create(
+ PropertyMap().set(IdentifiedObject::NAME_KEY, "test2"),
+ optional<std::string>("My anchor"), optional<RealizationMethod>());
+ EXPECT_FALSE(unrelated_datum->isEquivalentTo(drf.get()));
+ EXPECT_FALSE(drf->isEquivalentTo(unrelated_datum.get()));
+ EXPECT_FALSE(unrelated_datum->isEquivalentTo(
+ drf.get(), IComparable::Criterion::EQUIVALENT));
+ EXPECT_FALSE(drf->isEquivalentTo(unrelated_datum.get(),
+ IComparable::Criterion::EQUIVALENT));
}
// ---------------------------------------------------------------------------