aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/crs.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-05-15 11:58:17 +0200
committerGitHub <noreply@github.com>2020-05-15 11:58:17 +0200
commit330b2066244f77f89995a1aa195ef4323948a9b9 (patch)
tree9501bb3a670ce2a6ba8b8044ab256e5d8f28455d /src/iso19111/crs.cpp
parent6c5164eb49bdb6fcc9bf976db33c1b0a4bf5d7ad (diff)
parenta2f8fd1a21da1352a39cc56db2bb39613fc29091 (diff)
downloadPROJ-330b2066244f77f89995a1aa195ef4323948a9b9.tar.gz
PROJ-330b2066244f77f89995a1aa195ef4323948a9b9.zip
Merge pull request #2224 from rouault/fix_2202
Make projinfo --3d --boundcrs-to-wgs84 better work (fixes #2202)
Diffstat (limited to 'src/iso19111/crs.cpp')
-rw-r--r--src/iso19111/crs.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index ec342a8f..88db81f9 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -902,9 +902,17 @@ CRSNNPtr CRS::promoteTo3D(const std::string &newName,
const auto boundCRS = dynamic_cast<const BoundCRS *>(this);
if (boundCRS) {
- return BoundCRS::create(
- boundCRS->baseCRS()->promoteTo3D(newName, dbContext),
- boundCRS->hubCRS(), boundCRS->transformation());
+ auto base3DCRS = boundCRS->baseCRS()->promoteTo3D(newName, dbContext);
+ auto transf = boundCRS->transformation();
+ try {
+ transf->getTOWGS84Parameters();
+ return BoundCRS::create(
+ base3DCRS,
+ boundCRS->hubCRS()->promoteTo3D(std::string(), dbContext),
+ transf->promoteTo3D(std::string(), dbContext));
+ } catch (const io::FormattingException &) {
+ return BoundCRS::create(base3DCRS, boundCRS->hubCRS(), transf);
+ }
}
return NN_NO_CHECK(
@@ -937,9 +945,17 @@ CRSNNPtr CRS::demoteTo2D(const std::string &newName,
const auto boundCRS = dynamic_cast<const BoundCRS *>(this);
if (boundCRS) {
- return BoundCRS::create(
- boundCRS->baseCRS()->demoteTo2D(newName, dbContext),
- boundCRS->hubCRS(), boundCRS->transformation());
+ auto base2DCRS = boundCRS->baseCRS()->demoteTo2D(newName, dbContext);
+ auto transf = boundCRS->transformation();
+ try {
+ transf->getTOWGS84Parameters();
+ return BoundCRS::create(
+ base2DCRS,
+ boundCRS->hubCRS()->demoteTo2D(std::string(), dbContext),
+ transf->demoteTo2D(std::string(), dbContext));
+ } catch (const io::FormattingException &) {
+ return BoundCRS::create(base2DCRS, boundCRS->hubCRS(), transf);
+ }
}
const auto compoundCRS = dynamic_cast<const CompoundCRS *>(this);