aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_crs.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-02-24 15:40:25 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-02-25 00:19:19 +0100
commit1ce2cc80a4a0ff248cda778ae16de51946fa61b7 (patch)
tree8d0bda34e07d8637f6bc6c29c86400b6ce81c08c /test/unit/test_crs.cpp
parent254bead44a3fe11a24418bf71813298aa2b386f1 (diff)
downloadPROJ-1ce2cc80a4a0ff248cda778ae16de51946fa61b7.tar.gz
PROJ-1ce2cc80a4a0ff248cda778ae16de51946fa61b7.zip
CompoundCRS::create(): reject combinations of components not allowed by ISO 19111
Diffstat (limited to 'test/unit/test_crs.cpp')
-rw-r--r--test/unit/test_crs.cpp66
1 files changed, 49 insertions, 17 deletions
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 542d1226..c988080b 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -3331,6 +3331,46 @@ static CompoundCRSNNPtr createCompoundCRS() {
// ---------------------------------------------------------------------------
+TEST(crs, compoundCRS_valid) {
+ // geographic 2D + vertical
+ CompoundCRS::create(
+ PropertyMap(),
+ std::vector<CRSNNPtr>{GeographicCRS::EPSG_4326, createVerticalCRS()});
+
+ // projected 2D + vertical
+ CompoundCRS::create(
+ PropertyMap(),
+ std::vector<CRSNNPtr>{createProjected(), createVerticalCRS()});
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(crs, compoundCRS_invalid) {
+ EXPECT_THROW(CompoundCRS::create(PropertyMap(), {}),
+ InvalidCompoundCRSException);
+
+ // Only one component
+ EXPECT_THROW(CompoundCRS::create(PropertyMap(),
+ std::vector<CRSNNPtr>{createProjected()}),
+ InvalidCompoundCRSException);
+
+ // Two geographic
+ EXPECT_THROW(
+ CompoundCRS::create(PropertyMap(),
+ std::vector<CRSNNPtr>{GeographicCRS::EPSG_4326,
+ GeographicCRS::EPSG_4326}),
+ InvalidCompoundCRSException);
+
+ // geographic 3D + vertical
+ EXPECT_THROW(
+ CompoundCRS::create(PropertyMap(),
+ std::vector<CRSNNPtr>{GeographicCRS::EPSG_4979,
+ createVerticalCRS()}),
+ InvalidCompoundCRSException);
+}
+
+// ---------------------------------------------------------------------------
+
TEST(crs, compoundCRS_as_WKT2) {
auto crs = createCompoundCRS();
auto expected =
@@ -3385,18 +3425,10 @@ TEST(crs, compoundCRS_isEquivalentTo) {
EXPECT_TRUE(crs->isEquivalentTo(crs.get()));
EXPECT_TRUE(crs->shallowClone()->isEquivalentTo(crs.get()));
EXPECT_FALSE(crs->isEquivalentTo(createUnrelatedObject().get()));
- auto compoundCRSOfProjCRS =
- CompoundCRS::create(PropertyMap().set(IdentifiedObject::NAME_KEY, ""),
- std::vector<CRSNNPtr>{createProjected()});
- auto emptyCompoundCRS =
- CompoundCRS::create(PropertyMap().set(IdentifiedObject::NAME_KEY, ""),
- std::vector<CRSNNPtr>{});
- EXPECT_FALSE(compoundCRSOfProjCRS->isEquivalentTo(emptyCompoundCRS.get()));
- auto compoundCRSOfGeogCRS =
- CompoundCRS::create(PropertyMap().set(IdentifiedObject::NAME_KEY, ""),
- std::vector<CRSNNPtr>{GeographicCRS::EPSG_4326});
- EXPECT_FALSE(
- compoundCRSOfProjCRS->isEquivalentTo(compoundCRSOfGeogCRS.get()));
+ auto otherCompoundCRS = CompoundCRS::create(
+ PropertyMap().set(IdentifiedObject::NAME_KEY, ""),
+ std::vector<CRSNNPtr>{GeographicCRS::EPSG_4326, createVerticalCRS()});
+ EXPECT_FALSE(crs->isEquivalentTo(otherCompoundCRS.get()));
}
// ---------------------------------------------------------------------------
@@ -4154,11 +4186,11 @@ TEST(crs, extractGeographicCRS) {
GeographicCRS::EPSG_4326);
EXPECT_EQ(createProjected()->extractGeographicCRS(),
GeographicCRS::EPSG_4326);
- EXPECT_EQ(
- CompoundCRS::create(PropertyMap(),
- std::vector<CRSNNPtr>{GeographicCRS::EPSG_4326})
- ->extractGeographicCRS(),
- GeographicCRS::EPSG_4326);
+ EXPECT_EQ(CompoundCRS::create(
+ PropertyMap(), std::vector<CRSNNPtr>{GeographicCRS::EPSG_4326,
+ createVerticalCRS()})
+ ->extractGeographicCRS(),
+ GeographicCRS::EPSG_4326);
}
// ---------------------------------------------------------------------------