diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-11-03 18:49:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-03 18:49:16 +0100 |
| commit | b71bee7b60b07d27d39b8a3366433ae123bcd633 (patch) | |
| tree | 31a2d2c7d989a5f5d4454ecf4c1deda539fa4553 | |
| parent | 94ebc12ccee80042fb5789b34c179c40c92e9693 (diff) | |
| parent | 4739adcc55a0a0cacd5691de1f9951561e08ac2b (diff) | |
| download | PROJ-b71bee7b60b07d27d39b8a3366433ae123bcd633.tar.gz PROJ-b71bee7b60b07d27d39b8a3366433ae123bcd633.zip | |
Merge pull request #2918 from OSGeo/backport-2917-to-8.2
[Backport 8.2] BoundCRS WKT import: fix setting of name
| -rw-r--r-- | src/iso19111/io.cpp | 13 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 1 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 9ce642e7..5f2472a7 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -1262,7 +1262,8 @@ struct WKTParser::Private { bool removeInverseOf); PropertyMap &buildProperties(const WKTNodeNNPtr &node, - bool removeInverseOf = false); + bool removeInverseOf = false, + bool hasName = true); ObjectDomainPtr buildObjectDomain(const WKTNodeNNPtr &node); @@ -1577,7 +1578,8 @@ IdentifierPtr WKTParser::Private::buildId(const WKTNodeNNPtr &node, // --------------------------------------------------------------------------- PropertyMap &WKTParser::Private::buildProperties(const WKTNodeNNPtr &node, - bool removeInverseOf) { + bool removeInverseOf, + bool hasName) { if (propertyCount_ == MAX_PROPERTY_SIZE) { throw ParsingException("MAX_PROPERTY_SIZE reached"); @@ -1603,7 +1605,7 @@ PropertyMap &WKTParser::Private::buildProperties(const WKTNodeNNPtr &node, } } - if (!nodeChildren.empty()) { + if (hasName && !nodeChildren.empty()) { const auto &nodeName(nodeP->value()); auto name(stripQuotes(nodeChildren[0])); if (removeInverseOf && starts_with(name, "Inverse of ")) { @@ -4670,8 +4672,9 @@ BoundCRSNNPtr WKTParser::Private::buildBoundCRS(const WKTNodeNNPtr &node) { NN_NO_CHECK(targetCRS), nullptr, buildProperties(methodNode), parameters, values, std::vector<PositionalAccuracyNNPtr>()); - return BoundCRS::create(buildProperties(node), NN_NO_CHECK(sourceCRS), - NN_NO_CHECK(targetCRS), transformation); + return BoundCRS::create(buildProperties(node, false, false), + NN_NO_CHECK(sourceCRS), NN_NO_CHECK(targetCRS), + transformation); } // --------------------------------------------------------------------------- diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index 500ff4a4..c44d2d38 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -4680,6 +4680,7 @@ TEST(crs, boundCRS_with_usage) { auto crs = nn_dynamic_pointer_cast<BoundCRS>(WKTParser().createFromWKT(wkt)); ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->nameStr(), "Monte Mario / Italy zone 2"); auto got_wkt = crs->exportToWKT( WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get()); |
