From bb770de3b7cb04aad8116ed84a5815b7f6f7a82c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 3 Apr 2020 19:41:23 +0200 Subject: createFromUserInput(): allow compound CRS with the 2 parts given by names, e.g. 'WGS 84 + EGM96 height' --- test/unit/test_io.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/unit/test_io.cpp') diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 9d6c2c43..6cdd3014 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -9548,6 +9548,36 @@ TEST(io, createFromUserInput) { ParsingException); EXPECT_NO_THROW(createFromUserInput("WGS84 UTM zone 31N", dbContext)); EXPECT_NO_THROW(createFromUserInput("ID74", dbContext)); + + { + // Exact match on each piece of the compound CRS + auto obj = createFromUserInput("WGS 84 + EGM96 height", dbContext); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->nameStr(), "WGS 84 + EGM96 height"); + } + + { + // Aproximate match on each piece of the compound CRS + auto obj = createFromUserInput("WGS84 + EGM96", dbContext); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->nameStr(), "WGS 84 + EGM96 height"); + } + + { + // Exact match of a CompoundCRS object + auto obj = createFromUserInput( + "WGS 84 / World Mercator + EGM2008 height", dbContext); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->identifiers().size(), 1U); + } + + EXPECT_THROW(createFromUserInput("WGS 84 + foobar", dbContext), + ParsingException); + EXPECT_THROW(createFromUserInput("foobar + EGM96 height", dbContext), + ParsingException); } // --------------------------------------------------------------------------- -- cgit v1.2.3