diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2018-12-03 22:51:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-03 22:51:40 +0100 |
| commit | addf30e4446fd39891fd5bdcb22413ed41e0913b (patch) | |
| tree | f1494607cebc2316b8ab17b43a9b37c887ccdec8 /src/factory.cpp | |
| parent | d0506e19a71888f7f0c3aa8618d919624e754c4d (diff) | |
| parent | 0ba9d249136ec7adf6e3a44c8148701818d0e63e (diff) | |
| download | PROJ-addf30e4446fd39891fd5bdcb22413ed41e0913b.tar.gz PROJ-addf30e4446fd39891fd5bdcb22413ed41e0913b.zip | |
Merge pull request #1189 from rouault/projinfo_improvements
Projinfo improvements: output operation summary and add --area option
Diffstat (limited to 'src/factory.cpp')
| -rw-r--r-- | src/factory.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/factory.cpp b/src/factory.cpp index 91d0c478..7bc9c4d2 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -3642,7 +3642,7 @@ std::list<common::IdentifiedObjectNNPtr> AuthorityFactory::createObjectsFromName( const std::string &searchedName, const std::vector<ObjectType> &allowedObjectTypes, bool approximateMatch, - size_t limitResultCount) { + size_t limitResultCount) const { std::string searchedNameWithoutDeprecated(searchedName); bool deprecated = false; @@ -3885,6 +3885,39 @@ AuthorityFactory::createObjectsFromName( // --------------------------------------------------------------------------- +/** \brief Return a list of area of use from their name + * + * @param name Searched name. + * @param approximateMatch Whether approximate name identification is allowed. + * @return list of (auth_name, code) of matched objects. + * @throw FactoryException + */ +std::list<std::pair<std::string, std::string>> +AuthorityFactory::listAreaOfUseFromName(const std::string &name, + bool approximateMatch) const { + std::string sql( + "SELECT auth_name, code FROM area WHERE deprecated = 0 AND "); + std::vector<SQLValues> params; + if (!getAuthority().empty()) { + sql += " auth_name = ? AND "; + params.emplace_back(getAuthority()); + } + sql += "name LIKE ?"; + if (!approximateMatch) { + params.push_back(name); + } else { + params.push_back('%' + name + '%'); + } + auto sqlRes = d->run(sql, params); + std::list<std::pair<std::string, std::string>> res; + for (const auto &row : sqlRes) { + res.emplace_back(row[0], row[1]); + } + return res; +} + +// --------------------------------------------------------------------------- + //! @cond Doxygen_Suppress std::list<datum::EllipsoidNNPtr> AuthorityFactory::createEllipsoidFromExisting( const datum::EllipsoidNNPtr &ellipsoid) const { |
