Skip to content

Commit

Permalink
Merge pull request #3727 from rouault/fix_3725
Browse files Browse the repository at this point in the history
CRS instanciation from PROJ.4 string: set 'Unknown based on XXXX ellipsoid' datum name...
  • Loading branch information
rouault authored May 12, 2023
2 parents cfed44d + 964d4da commit 9d3737b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 15 additions & 5 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 9d3737b

Please sign in to comment.