diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-06 21:28:16 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-06 21:49:59 +0100 |
| commit | f06045c2f0145ec2290913fa144cd690e70736fd (patch) | |
| tree | 555131a028f47e9225eb54d836f973c84e40a816 /src/crs.cpp | |
| parent | 4022e2093a6773458c2453e42089c987da6efbf9 (diff) | |
| download | PROJ-f06045c2f0145ec2290913fa144cd690e70736fd.tar.gz PROJ-f06045c2f0145ec2290913fa144cd690e70736fd.zip | |
Add API to retrieve non-deprecated equivalent of an object
Diffstat (limited to 'src/crs.cpp')
| -rw-r--r-- | src/crs.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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<CRSNNPtr> +CRS::getNonDeprecated(const io::DatabaseContextNNPtr &dbContext) const { + std::list<CRSNNPtr> res; + const auto &l_identifiers = identifiers(); + if (l_identifiers.empty()) { + return res; + } + const char *tableName = nullptr; + if (dynamic_cast<const GeodeticCRS *>(this)) { + tableName = "geodetic_crs"; + } else if (dynamic_cast<const ProjectedCRS *>(this)) { + tableName = "projected_crs"; + } else if (dynamic_cast<const VerticalCRS *>(this)) { + tableName = "vertical_crs"; + } else if (dynamic_cast<const CompoundCRS *>(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<std::pair<CRSNNPtr, int>> |
