aboutsummaryrefslogtreecommitdiff
path: root/src/apps
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-10-20 21:14:30 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-10-20 21:14:30 +0200
commit45c819b69fb401c21c5571ddc2a602a8e72385d6 (patch)
treef2435121958cff58ee2191750c6e9ff2bdc77813 /src/apps
parent6b8ef545c4200180cc1b4bf7179d0b0951029ae5 (diff)
downloadPROJ-45c819b69fb401c21c5571ddc2a602a8e72385d6.tar.gz
PROJ-45c819b69fb401c21c5571ddc2a602a8e72385d6.zip
Improve identification of compound CRS from ESRI WKT1, and for compound CRS whose result is not in the DB but whose horiz and vertical parts are known
Diffstat (limited to 'src/apps')
-rw-r--r--src/apps/projinfo.cpp58
1 files changed, 40 insertions, 18 deletions
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp
index e8c97576..37b76346 100644
--- a/src/apps/projinfo.cpp
+++ b/src/apps/projinfo.cpp
@@ -1198,26 +1198,48 @@ int main(int argc, char **argv) {
std::cout << *ids[0]->codeSpace() << ":"
<< ids[0]->code() << ": "
<< pair.second << " %" << std::endl;
- } else {
- auto boundCRS = dynamic_cast<BoundCRS *>(
- identifiedCRS.get());
- if (boundCRS &&
- !boundCRS->baseCRS()
- ->identifiers()
- .empty()) {
- const auto &idsBase =
- boundCRS->baseCRS()->identifiers();
- std::cout << "BoundCRS of "
- << *idsBase[0]->codeSpace() << ":"
- << idsBase[0]->code() << ": "
- << pair.second << " %"
- << std::endl;
- } else {
- std::cout
- << "un-identifier CRS: " << pair.second
- << " %" << std::endl;
+ continue;
+ }
+
+ auto boundCRS =
+ dynamic_cast<BoundCRS *>(identifiedCRS.get());
+ if (boundCRS &&
+ !boundCRS->baseCRS()->identifiers().empty()) {
+ const auto &idsBase =
+ boundCRS->baseCRS()->identifiers();
+ std::cout << "BoundCRS of "
+ << *idsBase[0]->codeSpace() << ":"
+ << idsBase[0]->code() << ": "
+ << pair.second << " %" << std::endl;
+ continue;
+ }
+
+ auto compoundCRS = dynamic_cast<CompoundCRS *>(
+ identifiedCRS.get());
+ if (compoundCRS) {
+ const auto &components =
+ compoundCRS->componentReferenceSystems();
+ if (components.size() == 2 &&
+ !components[0]->identifiers().empty() &&
+ !components[1]->identifiers().empty()) {
+ const auto &idH =
+ components[0]->identifiers().front();
+ const auto &idV =
+ components[1]->identifiers().front();
+ if (*idH->codeSpace() ==
+ *idV->codeSpace()) {
+ std::cout << *idH->codeSpace() << ":"
+ << idH->code() << '+'
+ << idV->code() << ": "
+ << pair.second << " %"
+ << std::endl;
+ continue;
+ }
}
}
+
+ std::cout << "un-identified CRS: " << pair.second
+ << " %" << std::endl;
}
} catch (const std::exception &e) {
std::cerr << "Identification failed: " << e.what()