diff options
| author | Javier Jimenez Shaw <j1@jimenezshaw.com> | 2021-04-13 14:48:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 14:48:35 +0200 |
| commit | a850aac5e0de3f86f2e4cf29f211e88744db5133 (patch) | |
| tree | f35226f99d2c0e732a9ddd44d6f464c42cf32c44 | |
| parent | 58b991b8b98fdff6f6685e6bf5010f216b3ee1be (diff) | |
| download | PROJ-a850aac5e0de3f86f2e4cf29f211e88744db5133.tar.gz PROJ-a850aac5e0de3f86f2e4cf29f211e88744db5133.zip | |
createFromUserInput(): parse compound id with two authorities, like ESRI:103668+EPSG:5703 (#2669)
| -rw-r--r-- | src/iso19111/io.cpp | 25 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 22 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index d4b3dcb0..c59e21f4 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -6424,6 +6424,30 @@ static BaseObjectNNPtr createFromUserInput(const std::string &text, } throw; } + } else if (tokens.size() == 3) { + // ESRI:103668+EPSG:5703 ... compound + auto tokensCenter = split(tokens[1], '+'); + if (tokensCenter.size() == 2) { + if (!dbContext) { + throw ParsingException("no database context specified"); + } + DatabaseContextNNPtr dbContextNNPtr(NN_NO_CHECK(dbContext)); + + const auto &authName1 = tokens[0]; + const auto &code1 = tokensCenter[0]; + const auto &authName2 = tokensCenter[1]; + const auto &code2 = tokens[2]; + + auto factory1 = AuthorityFactory::create(dbContextNNPtr, authName1); + auto crs1 = factory1->createCoordinateReferenceSystem(code1, false); + auto factory2 = AuthorityFactory::create(dbContextNNPtr, authName2); + auto crs2 = factory2->createCoordinateReferenceSystem(code2, false); + return CompoundCRS::createLax( + util::PropertyMap().set(IdentifiedObject::NAME_KEY, + crs1->nameStr() + " + " + + crs2->nameStr()), + {crs1, crs2}, dbContext); + } } if (starts_with(text, "urn:ogc:def:crs,")) { @@ -6803,6 +6827,7 @@ static BaseObjectNNPtr createFromUserInput(const std::string &text, * <li> OGC URN combining references for compound coordinate reference systems * e.g. "urn:ogc:def:crs,crs:EPSG::2393,crs:EPSG::5717" * We also accept a custom abbreviated syntax EPSG:2393+5717 + * or ESRI:103668+EPSG:5703 * </li> * <li> OGC URN combining references for references for projected or derived * CRSs diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index cd880a3f..b7081c21 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -10307,6 +10307,8 @@ TEST(io, createFromUserInput) { EXPECT_THROW(createFromUserInput("+proj=unhandled +type=crs", nullptr), ParsingException); EXPECT_THROW(createFromUserInput("EPSG:4326", nullptr), ParsingException); + EXPECT_THROW(createFromUserInput("ESRI:103668+EPSG:5703", nullptr), + ParsingException); EXPECT_THROW( createFromUserInput("urn:ogc:def:unhandled:EPSG::4326", dbContext), ParsingException); @@ -10386,6 +10388,26 @@ TEST(io, createFromUserInput) { EXPECT_EQ(crs->nameStr(), "KKJ / Finland Uniform Coordinate System + N60 height"); } + + { + auto obj = createFromUserInput("EPSG:2393+EPSG:5717", dbContext); + auto crs = nn_dynamic_pointer_cast<CompoundCRS>(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->nameStr(), + "KKJ / Finland Uniform Coordinate System + N60 height"); + } + { + auto obj = createFromUserInput("ESRI:103668+EPSG:5703", dbContext); + auto crs = nn_dynamic_pointer_cast<CompoundCRS>(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->nameStr(), + "NAD_1983_HARN_Adj_MN_Ramsey_Meters + NAVD88 height"); + } + EXPECT_THROW(createFromUserInput("ESRI:42+EPSG:5703", dbContext), + NoSuchAuthorityCodeException); + EXPECT_THROW(createFromUserInput("ESRI:103668+EPSG:999999", dbContext), + NoSuchAuthorityCodeException); + { auto obj = createFromUserInput( "urn:ogc:def:crs,crs:EPSG::2393,crs:EPSG::5717", dbContext); |
