aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-04-10 22:09:29 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-04-11 00:22:03 +0200
commitd870b33803c184feb97e4abd67e1896b89c8e8c1 (patch)
treed6bfbf198afaca4617fbc5fce97ad76a6dbaa707 /src
parent5f3fda7527bb3f41f1ac842d7dc6d7a6fa2f0529 (diff)
downloadPROJ-d870b33803c184feb97e4abd67e1896b89c8e8c1.tar.gz
PROJ-d870b33803c184feb97e4abd67e1896b89c8e8c1.zip
CRS::normalizeForVisualization(): propagate domains/extent of original CRS (fixes #2603)
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/crs.cpp64
1 files changed, 55 insertions, 9 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index d7058a56..2d589ad1 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -824,21 +824,58 @@ bool CRS::mustAxisOrderBeSwitchedForVisualization() const {
//! @cond Doxygen_Suppress
CRSNNPtr CRS::normalizeForVisualization() const {
- auto props = util::PropertyMap().set(
- common::IdentifiedObject::NAME_KEY,
- nameStr() + " (with axis order normalized for visualization)");
+
+ const auto createProperties = [this](const std::string &newName =
+ std::string()) {
+ auto props = util::PropertyMap().set(
+ common::IdentifiedObject::NAME_KEY,
+ !newName.empty()
+ ? newName
+ : nameStr() +
+ " (with axis order normalized for visualization)");
+ const auto &l_domains = domains();
+ if (!l_domains.empty()) {
+ auto array = util::ArrayOfBaseObject::create();
+ for (const auto &domain : l_domains) {
+ array->add(domain);
+ }
+ if (!array->empty()) {
+ props.set(common::ObjectUsage::OBJECT_DOMAIN_KEY, array);
+ }
+ }
+ const auto &l_identifiers = identifiers();
+ const auto &l_remarks = remarks();
+ if (l_identifiers.size() == 1) {
+ std::string remarks("Axis order reversed compared to ");
+ remarks += *(l_identifiers[0]->codeSpace());
+ remarks += ':';
+ remarks += l_identifiers[0]->code();
+ if (!l_remarks.empty()) {
+ remarks += ". ";
+ remarks += l_remarks;
+ }
+ props.set(common::IdentifiedObject::REMARKS_KEY, remarks);
+ } else if (!l_remarks.empty()) {
+ props.set(common::IdentifiedObject::REMARKS_KEY, l_remarks);
+ }
+ return props;
+ };
const CompoundCRS *compoundCRS = dynamic_cast<const CompoundCRS *>(this);
if (compoundCRS) {
const auto &comps = compoundCRS->componentReferenceSystems();
- if (!comps.empty()) {
+ if (!comps.empty() &&
+ comps[0]->mustAxisOrderBeSwitchedForVisualization()) {
std::vector<CRSNNPtr> newComps;
newComps.emplace_back(comps[0]->normalizeForVisualization());
+ std::string l_name = newComps.back()->nameStr();
for (size_t i = 1; i < comps.size(); i++) {
newComps.emplace_back(comps[i]);
+ l_name += " + ";
+ l_name += newComps.back()->nameStr();
}
return util::nn_static_pointer_cast<CRS>(
- CompoundCRS::create(props, newComps));
+ CompoundCRS::create(createProperties(l_name), newComps));
}
}
@@ -852,8 +889,9 @@ CRSNNPtr CRS::normalizeForVisualization() const {
: cs::EllipsoidalCS::create(util::PropertyMap(),
axisList[1], axisList[0],
axisList[2]);
- return util::nn_static_pointer_cast<CRS>(GeographicCRS::create(
- props, geogCRS->datum(), geogCRS->datumEnsemble(), cs));
+ return util::nn_static_pointer_cast<CRS>(
+ GeographicCRS::create(createProperties(), geogCRS->datum(),
+ geogCRS->datumEnsemble(), cs));
}
}
@@ -867,8 +905,9 @@ CRSNNPtr CRS::normalizeForVisualization() const {
axisList[0])
: cs::CartesianCS::create(util::PropertyMap(), axisList[1],
axisList[0], axisList[2]);
- return util::nn_static_pointer_cast<CRS>(ProjectedCRS::create(
- props, projCRS->baseCRS(), projCRS->derivingConversion(), cs));
+ return util::nn_static_pointer_cast<CRS>(
+ ProjectedCRS::create(createProperties(), projCRS->baseCRS(),
+ projCRS->derivingConversion(), cs));
}
}
@@ -1021,12 +1060,19 @@ CRSNNPtr CRS::promoteTo3D(const std::string &newName,
}
}
const auto &l_identifiers = identifiers();
+ const auto &l_remarks = remarks();
if (l_identifiers.size() == 1) {
std::string remarks("Promoted to 3D from ");
remarks += *(l_identifiers[0]->codeSpace());
remarks += ':';
remarks += l_identifiers[0]->code();
+ if (!l_remarks.empty()) {
+ remarks += ". ";
+ remarks += l_remarks;
+ }
props.set(common::IdentifiedObject::REMARKS_KEY, remarks);
+ } else if (!l_remarks.empty()) {
+ props.set(common::IdentifiedObject::REMARKS_KEY, l_remarks);
}
return props;
};