Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 8.2] BoundCRS WKT import: fix setting of name #2918

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand All @@ -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 ")) {
Expand Down Expand Up @@ -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);
}

// ---------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions test/unit/test_crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down