diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index d7fcea4933..d9a69849ed 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -10365,7 +10365,7 @@ PROJStringParser::Private::buildDatum(Step &step, const std::string &title) { return GeodeticReferenceFrame::create( grfMap.set(IdentifiedObject::NAME_KEY, title.empty() - ? "Unknown based on WGS84 ellipsoid" + + ? "Unknown based on WGS 84 ellipsoid" + datumNameSuffix : title), Ellipsoid::WGS84, optionalEmptyString, pm); @@ -10373,7 +10373,7 @@ PROJStringParser::Private::buildDatum(Step &step, const std::string &title) { return GeodeticReferenceFrame::create( grfMap.set(IdentifiedObject::NAME_KEY, title.empty() - ? "Unknown based on GRS80 ellipsoid" + + ? "Unknown based on GRS 1980 ellipsoid" + datumNameSuffix : title), Ellipsoid::GRS1980, optionalEmptyString, pm); @@ -10441,10 +10441,20 @@ PROJStringParser::Private::buildDatum(Step &step, const std::string &title) { const auto createGRF = [&grfMap, &title, &optionalEmptyString, &datumNameSuffix, &pm](const EllipsoidNNPtr &ellipsoid) { + std::string datumName(title); + if (title.empty()) { + if (ellipsoid->nameStr() != "unknown") { + datumName = "Unknown based on "; + datumName += ellipsoid->nameStr(); + datumName += " ellipsoid"; + } else { + datumName = "unknown"; + } + datumName += datumNameSuffix; + } return GeodeticReferenceFrame::create( - grfMap.set(IdentifiedObject::NAME_KEY, - title.empty() ? "unknown" + datumNameSuffix : title), - ellipsoid, optionalEmptyString, fixupPrimeMeridan(ellipsoid, pm)); + grfMap.set(IdentifiedObject::NAME_KEY, datumName), ellipsoid, + optionalEmptyString, fixupPrimeMeridan(ellipsoid, pm)); }; if (a > 0 && (b > 0 || !bStr.empty())) { diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 2d8626e29b..bcc3d4ee30 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -9656,7 +9656,7 @@ TEST(io, projparse_longlat_ellps_WGS84) { f->simulCurNodeHasId(); crs->exportToWKT(f.get()); auto expected = "GEODCRS[\"unknown\",\n" - " DATUM[\"Unknown based on WGS84 ellipsoid\",\n" + " DATUM[\"Unknown based on WGS 84 ellipsoid\",\n" " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n" " LENGTHUNIT[\"metre\",1]]],\n" " PRIMEM[\"Greenwich\",0,\n" @@ -9682,7 +9682,7 @@ TEST(io, projparse_longlat_ellps_GRS80) { f->simulCurNodeHasId(); crs->exportToWKT(f.get()); auto expected = "GEODCRS[\"unknown\",\n" - " DATUM[\"Unknown based on GRS80 ellipsoid\",\n" + " DATUM[\"Unknown based on GRS 1980 ellipsoid\",\n" " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n" " LENGTHUNIT[\"metre\",1]]],\n" " PRIMEM[\"Greenwich\",0,\n" @@ -9735,7 +9735,7 @@ TEST(io, projparse_longlat_a_rf_WGS84) { f->simulCurNodeHasId(); crs->exportToWKT(f.get()); auto expected = "GEODCRS[\"unknown\",\n" - " DATUM[\"unknown\",\n" + " DATUM[\"Unknown based on WGS 84 ellipsoid\",\n" " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n" " LENGTHUNIT[\"metre\",1]]],\n" " PRIMEM[\"Greenwich\",0,\n" @@ -11621,7 +11621,7 @@ TEST(io, projparse_geocent) { f->setMultiLine(false); crs->exportToWKT(f.get()); auto wkt = f->toString(); - EXPECT_EQ(wkt, "GEODCRS[\"unknown\",DATUM[\"Unknown based on WGS84 " + EXPECT_EQ(wkt, "GEODCRS[\"unknown\",DATUM[\"Unknown based on WGS 84 " "ellipsoid\",ELLIPSOID[\"WGS " "84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]]]," "PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0."