diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-04-10 16:59:08 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-04-10 19:17:39 +0200 |
| commit | 21f0af0f8b56ab76b93aaf6ce962580ec7978fcb (patch) | |
| tree | f77790ea35031c0a55e376dac5c33962a40dbf8b /test/unit/test_io.cpp | |
| parent | 84a679954b1fa4c41c7bdbac87013be78b64bea4 (diff) | |
| download | PROJ-21f0af0f8b56ab76b93aaf6ce962580ec7978fcb.tar.gz PROJ-21f0af0f8b56ab76b93aaf6ce962580ec7978fcb.zip | |
createFromUserInput(): add support for OGC URLs
e.g:
http://www.opengis.net/def/crs/EPSG/0/4326
http://www.opengis.net/def/crs-compound?1=http://www.opengis.net/def/crs/EPSG/0/4326&2=http://www.opengis.net/def/crs/EPSG/0/3855
Diffstat (limited to 'test/unit/test_io.cpp')
| -rw-r--r-- | test/unit/test_io.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 9d627ce9..708b3874 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -10637,6 +10637,84 @@ TEST(io, createFromUserInput) { // --------------------------------------------------------------------------- +TEST(io, createFromUserInput_ogc_crs_url) { + auto dbContext = DatabaseContext::create(); + + { + auto obj = createFromUserInput( + "http://www.opengis.net/def/crs/EPSG/0/4326", dbContext); + auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj); + ASSERT_TRUE(crs != nullptr); + } + + EXPECT_THROW( + createFromUserInput("http://www.opengis.net/def/crs", dbContext), + ParsingException); + + EXPECT_THROW( + createFromUserInput("http://www.opengis.net/def/crs/EPSG/0", dbContext), + ParsingException); + + EXPECT_THROW(createFromUserInput( + "http://www.opengis.net/def/crs/EPSG/0/XXXX", dbContext), + NoSuchAuthorityCodeException); + + { + auto obj = createFromUserInput( + "http://www.opengis.net/def/crs-compound?1=http://www.opengis.net/" + "def/crs/EPSG/0/4326&2=http://www.opengis.net/def/crs/EPSG/0/3855", + dbContext); + auto crs = nn_dynamic_pointer_cast<CompoundCRS>(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->nameStr(), "WGS 84 + EGM2008 height"); + } + + // No part + EXPECT_THROW(createFromUserInput("http://www.opengis.net/def/crs-compound?", + dbContext), + ParsingException); + + // Just one part + EXPECT_THROW( + createFromUserInput("http://www.opengis.net/def/crs-compound?1=http://" + "www.opengis.net/def/crs/EPSG/0/4326", + dbContext), + InvalidCompoundCRSException); + + // Invalid compound CRS + EXPECT_THROW( + createFromUserInput( + "http://www.opengis.net/def/crs-compound?1=http://www.opengis.net/" + "def/crs/EPSG/0/4326&2=http://www.opengis.net/def/crs/EPSG/0/4326", + dbContext), + InvalidCompoundCRSException); + + // Missing 2= + EXPECT_THROW( + createFromUserInput( + "http://www.opengis.net/def/crs-compound?1=http://www.opengis.net/" + "def/crs/EPSG/0/4326&3=http://www.opengis.net/def/crs/EPSG/0/3855", + dbContext), + ParsingException); + + // Invalid query parameter + EXPECT_THROW( + createFromUserInput("http://www.opengis.net/def/crs-compound?1=http://" + "www.opengis.net/def/crs/EPSG/0/4326&bla", + dbContext), + ParsingException); + + // Invalid query parameter + EXPECT_THROW( + createFromUserInput("http://www.opengis.net/def/crs-compound?1=http://" + "www.opengis.net/def/crs/EPSG/0/4326&two=http://" + "www.opengis.net/def/crs/EPSG/0/3855", + dbContext), + ParsingException); +} + +// --------------------------------------------------------------------------- + TEST(io, createFromUserInput_hack_EPSG_102100) { auto dbContext = DatabaseContext::create(); auto obj = createFromUserInput("EPSG:102100", dbContext); |
