From 45c819b69fb401c21c5571ddc2a602a8e72385d6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 20 Oct 2020 21:14:30 +0200 Subject: 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 --- src/apps/projinfo.cpp | 58 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'src/apps/projinfo.cpp') 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( - 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(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( + 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() -- cgit v1.2.3