aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-10-20 21:14:30 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-10-20 21:14:30 +0200
commit45c819b69fb401c21c5571ddc2a602a8e72385d6 (patch)
treef2435121958cff58ee2191750c6e9ff2bdc77813 /test
parent6b8ef545c4200180cc1b4bf7179d0b0951029ae5 (diff)
downloadPROJ-45c819b69fb401c21c5571ddc2a602a8e72385d6.tar.gz
PROJ-45c819b69fb401c21c5571ddc2a602a8e72385d6.zip
Improve identification of compound CRS from ESRI WKT1, and for compound CRS whose result is not in the DB but whose horiz and vertical parts are known
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_crs.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index ec30580a..c2031081 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -4058,6 +4058,42 @@ TEST(crs, compoundCRS_identify_db) {
// Just check we don't get an exception
crs->identify(factory);
}
+ // Identify from ESRI WKT
+ {
+ auto sourceCRS = factory->createCompoundCRS("7405");
+ auto wkt = sourceCRS->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT1_ESRI, dbContext)
+ .get());
+ auto obj =
+ WKTParser().attachDatabaseContext(dbContext).createFromWKT(wkt);
+ auto crs = nn_dynamic_pointer_cast<CompoundCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ auto res = crs->identify(factory);
+ ASSERT_EQ(res.size(), 1U);
+ EXPECT_EQ(res.front().first->getEPSGCode(), 7405);
+ EXPECT_EQ(res.front().second, 100);
+ }
+ // Identify a CompoundCRS whose horizontal and vertical parts are known
+ // but not the composition.
+ {
+ auto obj = createFromUserInput("EPSG:4326+3855", dbContext);
+ auto sourceCRS = nn_dynamic_pointer_cast<CompoundCRS>(obj);
+ ASSERT_TRUE(sourceCRS != nullptr);
+ auto wkt = sourceCRS->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT1_ESRI, dbContext)
+ .get());
+ auto obj2 =
+ WKTParser().attachDatabaseContext(dbContext).createFromWKT(wkt);
+ auto crs = nn_dynamic_pointer_cast<CompoundCRS>(obj2);
+ ASSERT_TRUE(crs != nullptr);
+ auto res = crs->identify(factory);
+ ASSERT_EQ(res.size(), 1U);
+ EXPECT_EQ(res.front().first->getEPSGCode(), 0);
+ EXPECT_EQ(res.front().second, 100);
+ const auto &components = res.front().first->componentReferenceSystems();
+ EXPECT_EQ(components[0]->getEPSGCode(), 4326);
+ EXPECT_EQ(components[1]->getEPSGCode(), 3855);
+ }
}
// ---------------------------------------------------------------------------