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 9.2] CRS instanciation from PROJ.4 string: set 'Unknown based on XXXX ellipsoid' datum name... #3728

Merged
merged 1 commit into from May 13, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/iso19111/io.cpp
Expand Up @@ -10365,15 +10365,15 @@ 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);
} else if (ellpsStr == "GRS80") {
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);
Expand Down Expand Up @@ -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())) {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_io.cpp
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand Down