Skip to content

Commit

Permalink
Merge pull request #3491 from rouault/local_cs_import_fix
Browse files Browse the repository at this point in the history
WKT import: when importing LOCAL_CS["foo"], generates a non-empty name for the datum
  • Loading branch information
rouault authored Dec 2, 2022
2 parents 30d0d9d + 8bafafb commit 026e5f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/iso19111/crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6929,7 +6929,9 @@ void EngineeringCRS::_exportToWKT(io::WKTFormatter *formatter) const {
: io::WKTConstants::LOCAL_CS,
!identifiers().empty());
formatter->addQuotedString(nameStr());
if (isWKT2 || !datum()->nameStr().empty()) {
const auto &datumName = datum()->nameStr();
if (isWKT2 ||
(!datumName.empty() && datumName != "Unknown engineering datum")) {
datum()->_exportToWKT(formatter);
}
if (!isWKT2) {
Expand Down
7 changes: 6 additions & 1 deletion src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5080,7 +5080,12 @@ WKTParser::Private::buildEngineeringCRSFromLocalCS(const WKTNodeNNPtr &node) {
:
// In theory OGC 01-009 mandates LOCAL_DATUM, but GDAL has a
// tradition of emitting just LOCAL_CS["foo"]
emptyPropertyMap);
[]() {
PropertyMap map;
map.set(IdentifiedObject::NAME_KEY,
"Unknown engineering datum");
return map;
}());
return EngineeringCRS::create(buildProperties(node), datum, cs);
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5273,7 +5273,7 @@ TEST(wkt_parse, LOCAL_CS_short) {
ASSERT_TRUE(crs != nullptr);

EXPECT_EQ(crs->nameStr(), "Engineering CRS");
EXPECT_FALSE(!crs->datum()->nameStr().empty());
EXPECT_EQ(crs->datum()->nameStr(), "Unknown engineering datum");
auto cs = crs->coordinateSystem();
ASSERT_EQ(cs->axisList().size(), 2U);

Expand Down

0 comments on commit 026e5f2

Please sign in to comment.