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/factory.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/factory.cpp')
| -rw-r--r-- | src/factory.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/factory.cpp b/src/factory.cpp index 20701def..d56fb7b6 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -918,6 +918,38 @@ std::vector<std::string> DatabaseContext::getAllowedAuthorities( return split(res[0][0], ','); } +// --------------------------------------------------------------------------- + +std::list<std::pair<std::string, std::string>> +DatabaseContext::getNonDeprecated(const std::string &tableName, + const std::string &authName, + const std::string &code) const { + auto sqlRes = + d->run("SELECT replacement_auth_name, replacement_code, source " + "FROM deprecation " + "WHERE table_name = ? AND deprecated_auth_name = ? " + "AND deprecated_code = ?", + {tableName, authName, code}); + std::list<std::pair<std::string, std::string>> res; + for (const auto &row : sqlRes) { + const auto &source = row[2]; + if (source == "PROJ") { + const auto &replacement_auth_name = row[0]; + const auto &replacement_code = row[1]; + res.emplace_back(replacement_auth_name, replacement_code); + } + } + if (!res.empty()) { + return res; + } + for (const auto &row : sqlRes) { + const auto &replacement_auth_name = row[0]; + const auto &replacement_code = row[1]; + res.emplace_back(replacement_auth_name, replacement_code); + } + return res; +} + //! @endcond // --------------------------------------------------------------------------- |
