Skip to content

Commit 964d4da

Browse files
committed
CRS instanciation from PROJ.4 string: set 'Unknown based on XXXX ellipsoid' datum name...
...when instanciating from known +a,+rf and change WGS84 -> WGS 84 and GRS80 -> GRS 1980 to use EPSG names when building from +ellps=WGS84/GRS80 (fixes OSGeo#3725) Now we get ``` $ bin/projinfo "+proj=geos +lon_0=0 +h=35786400 +ellps=WGS84 +units=m +sweep=y +no_defs +type=crs" PROJ.4 string: +proj=geos +lon_0=0 +h=35786400 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs +type=crs WKT2:2019 string: PROJCRS["unknown", BASEGEOGCRS["unknown", DATUM["Unknown based on WGS 84 ellipsoid", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1], ID["EPSG",7030]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8901]]], CONVERSION["unknown", METHOD["Geostationary Satellite (Sweep Y)"], PARAMETER["Longitude of natural origin",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8802]], PARAMETER["Satellite Height",35786400, LENGTHUNIT["metre",1, ID["EPSG",9001]]], PARAMETER["False easting",0, LENGTHUNIT["metre",1], ID["EPSG",8806]], PARAMETER["False northing",0, LENGTHUNIT["metre",1], ID["EPSG",8807]]], CS[Cartesian,2], AXIS["(E)",east, ORDER[1], LENGTHUNIT["metre",1, ID["EPSG",9001]]], AXIS["(N)",north, ORDER[2], LENGTHUNIT["metre",1, ID["EPSG",9001]]]] $ bin/projinfo "+proj=geos +lon_0=0 +h=35786400 +a=6378137.0 +rf=298.257223563 +units=m +sweep=y +no_defs +type=crs" PROJ.4 string: +proj=geos +lon_0=0 +h=35786400 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs +type=crs WKT2:2019 string: PROJCRS["unknown", BASEGEOGCRS["unknown", DATUM["Unknown based on WGS 84 ellipsoid", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1, ID["EPSG",9001]]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8901]]], CONVERSION["unknown", METHOD["Geostationary Satellite (Sweep Y)"], PARAMETER["Longitude of natural origin",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8802]], PARAMETER["Satellite Height",35786400, LENGTHUNIT["metre",1, ID["EPSG",9001]]], PARAMETER["False easting",0, LENGTHUNIT["metre",1], ID["EPSG",8806]], PARAMETER["False northing",0, LENGTHUNIT["metre",1], ID["EPSG",8807]]], CS[Cartesian,2], AXIS["(E)",east, ORDER[1], LENGTHUNIT["metre",1, ID["EPSG",9001]]], AXIS["(N)",north, ORDER[2], LENGTHUNIT["metre",1, ID["EPSG",9001]]]] ```
1 parent cfed44d commit 964d4da

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/iso19111/io.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10365,15 +10365,15 @@ PROJStringParser::Private::buildDatum(Step &step, const std::string &title) {
1036510365
return GeodeticReferenceFrame::create(
1036610366
grfMap.set(IdentifiedObject::NAME_KEY,
1036710367
title.empty()
10368-
? "Unknown based on WGS84 ellipsoid" +
10368+
? "Unknown based on WGS 84 ellipsoid" +
1036910369
datumNameSuffix
1037010370
: title),
1037110371
Ellipsoid::WGS84, optionalEmptyString, pm);
1037210372
} else if (ellpsStr == "GRS80") {
1037310373
return GeodeticReferenceFrame::create(
1037410374
grfMap.set(IdentifiedObject::NAME_KEY,
1037510375
title.empty()
10376-
? "Unknown based on GRS80 ellipsoid" +
10376+
? "Unknown based on GRS 1980 ellipsoid" +
1037710377
datumNameSuffix
1037810378
: title),
1037910379
Ellipsoid::GRS1980, optionalEmptyString, pm);
@@ -10441,10 +10441,20 @@ PROJStringParser::Private::buildDatum(Step &step, const std::string &title) {
1044110441
const auto createGRF = [&grfMap, &title, &optionalEmptyString,
1044210442
&datumNameSuffix,
1044310443
&pm](const EllipsoidNNPtr &ellipsoid) {
10444+
std::string datumName(title);
10445+
if (title.empty()) {
10446+
if (ellipsoid->nameStr() != "unknown") {
10447+
datumName = "Unknown based on ";
10448+
datumName += ellipsoid->nameStr();
10449+
datumName += " ellipsoid";
10450+
} else {
10451+
datumName = "unknown";
10452+
}
10453+
datumName += datumNameSuffix;
10454+
}
1044410455
return GeodeticReferenceFrame::create(
10445-
grfMap.set(IdentifiedObject::NAME_KEY,
10446-
title.empty() ? "unknown" + datumNameSuffix : title),
10447-
ellipsoid, optionalEmptyString, fixupPrimeMeridan(ellipsoid, pm));
10456+
grfMap.set(IdentifiedObject::NAME_KEY, datumName), ellipsoid,
10457+
optionalEmptyString, fixupPrimeMeridan(ellipsoid, pm));
1044810458
};
1044910459

1045010460
if (a > 0 && (b > 0 || !bStr.empty())) {

test/unit/test_io.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9656,7 +9656,7 @@ TEST(io, projparse_longlat_ellps_WGS84) {
96569656
f->simulCurNodeHasId();
96579657
crs->exportToWKT(f.get());
96589658
auto expected = "GEODCRS[\"unknown\",\n"
9659-
" DATUM[\"Unknown based on WGS84 ellipsoid\",\n"
9659+
" DATUM[\"Unknown based on WGS 84 ellipsoid\",\n"
96609660
" ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n"
96619661
" LENGTHUNIT[\"metre\",1]]],\n"
96629662
" PRIMEM[\"Greenwich\",0,\n"
@@ -9682,7 +9682,7 @@ TEST(io, projparse_longlat_ellps_GRS80) {
96829682
f->simulCurNodeHasId();
96839683
crs->exportToWKT(f.get());
96849684
auto expected = "GEODCRS[\"unknown\",\n"
9685-
" DATUM[\"Unknown based on GRS80 ellipsoid\",\n"
9685+
" DATUM[\"Unknown based on GRS 1980 ellipsoid\",\n"
96869686
" ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n"
96879687
" LENGTHUNIT[\"metre\",1]]],\n"
96889688
" PRIMEM[\"Greenwich\",0,\n"
@@ -9735,7 +9735,7 @@ TEST(io, projparse_longlat_a_rf_WGS84) {
97359735
f->simulCurNodeHasId();
97369736
crs->exportToWKT(f.get());
97379737
auto expected = "GEODCRS[\"unknown\",\n"
9738-
" DATUM[\"unknown\",\n"
9738+
" DATUM[\"Unknown based on WGS 84 ellipsoid\",\n"
97399739
" ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n"
97409740
" LENGTHUNIT[\"metre\",1]]],\n"
97419741
" PRIMEM[\"Greenwich\",0,\n"
@@ -11621,7 +11621,7 @@ TEST(io, projparse_geocent) {
1162111621
f->setMultiLine(false);
1162211622
crs->exportToWKT(f.get());
1162311623
auto wkt = f->toString();
11624-
EXPECT_EQ(wkt, "GEODCRS[\"unknown\",DATUM[\"Unknown based on WGS84 "
11624+
EXPECT_EQ(wkt, "GEODCRS[\"unknown\",DATUM[\"Unknown based on WGS 84 "
1162511625
"ellipsoid\",ELLIPSOID[\"WGS "
1162611626
"84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]]],"
1162711627
"PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0."

0 commit comments

Comments
 (0)