From 45c819b69fb401c21c5571ddc2a602a8e72385d6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 20 Oct 2020 21:14:30 +0200 Subject: 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 --- test/unit/test_crs.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') 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(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(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(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); + } } // --------------------------------------------------------------------------- -- cgit v1.2.3