From f06045c2f0145ec2290913fa144cd690e70736fd Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 6 Dec 2018 21:28:16 +0100 Subject: Add API to retrieve non-deprecated equivalent of an object --- src/crs.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/crs.cpp') diff --git a/src/crs.cpp b/src/crs.cpp index 6212f561..81e9a300 100644 --- a/src/crs.cpp +++ b/src/crs.cpp @@ -603,6 +603,40 @@ CRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { // --------------------------------------------------------------------------- +/** \brief Return CRSs that are non-deprecated substitutes for the current CRS. + */ +std::list +CRS::getNonDeprecated(const io::DatabaseContextNNPtr &dbContext) const { + std::list res; + const auto &l_identifiers = identifiers(); + if (l_identifiers.empty()) { + return res; + } + const char *tableName = nullptr; + if (dynamic_cast(this)) { + tableName = "geodetic_crs"; + } else if (dynamic_cast(this)) { + tableName = "projected_crs"; + } else if (dynamic_cast(this)) { + tableName = "vertical_crs"; + } else if (dynamic_cast(this)) { + tableName = "compound_crs"; + } + if (!tableName) { + return res; + } + const auto &id = l_identifiers[0]; + auto tmpRes = + dbContext->getNonDeprecated(tableName, *(id->codeSpace()), id->code()); + for (const auto &pair : tmpRes) { + res.emplace_back(io::AuthorityFactory::create(dbContext, pair.first) + ->createCoordinateReferenceSystem(pair.second)); + } + return res; +} + +// --------------------------------------------------------------------------- + //! @cond Doxygen_Suppress std::list> -- cgit v1.2.3