diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-10-08 18:06:50 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-10-08 18:06:50 +0200 |
| commit | f0f9ec43e56a09dd4aaa6c25c9ea08ad09e4ecf8 (patch) | |
| tree | a3abfc585317835ccbb294a3b6a6f988ff776904 /src | |
| parent | 7cec30b85ece4bca206f27642ee9aeb2807f5aba (diff) | |
| download | PROJ-f0f9ec43e56a09dd4aaa6c25c9ea08ad09e4ecf8.tar.gz PROJ-f0f9ec43e56a09dd4aaa6c25c9ea08ad09e4ecf8.zip | |
promoteTo3D(): add a remark with the original CRS identifier (fixes #2368)
```
$ projinfo EPSG:32631 --3d
WKT2:2019 string:
PROJCRS["WGS 84 / UTM zone 31N",
[ ...snip ]
REMARK["Promoted to 3D from EPSG:32631"]]
```
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/crs.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index ecbd39e1..e9082473 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -982,6 +982,22 @@ CRSNNPtr CRS::promoteTo3D(const std::string &newName, const io::DatabaseContextPtr &dbContext, const cs::CoordinateSystemAxisNNPtr &verticalAxisIfNotAlreadyPresent) const { + + const auto createProperties = [this, &newName]() { + auto props = + util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, + !newName.empty() ? newName : nameStr()); + const auto &l_identifiers = identifiers(); + if (l_identifiers.size() == 1) { + std::string remarks("Promoted to 3D from "); + remarks += *(l_identifiers[0]->codeSpace()); + remarks += ':'; + remarks += l_identifiers[0]->code(); + props.set(common::IdentifiedObject::REMARKS_KEY, remarks); + } + return props; + }; + const auto geogCRS = dynamic_cast<const GeographicCRS *>(this); if (geogCRS) { const auto &axisList = geogCRS->coordinateSystem()->axisList(); @@ -1016,10 +1032,9 @@ CRSNNPtr CRS::promoteTo3D(const std::string &newName, auto cs = cs::EllipsoidalCS::create( util::PropertyMap(), axisList[0], axisList[1], verticalAxisIfNotAlreadyPresent); - return util::nn_static_pointer_cast<CRS>(GeographicCRS::create( - util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, - !newName.empty() ? newName : nameStr()), - geogCRS->datum(), geogCRS->datumEnsemble(), cs)); + return util::nn_static_pointer_cast<CRS>( + GeographicCRS::create(createProperties(), geogCRS->datum(), + geogCRS->datumEnsemble(), cs)); } } @@ -1033,8 +1048,7 @@ CRSNNPtr CRS::promoteTo3D(const std::string &newName, axisList[1], verticalAxisIfNotAlreadyPresent); return util::nn_static_pointer_cast<CRS>(ProjectedCRS::create( - util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, - !newName.empty() ? newName : nameStr()), + createProperties(), NN_NO_CHECK( util::nn_dynamic_pointer_cast<GeodeticCRS>(base3DCRS)), projCRS->derivingConversion(), cs)); |
