diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-03 18:13:05 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-03 22:19:21 +0100 |
| commit | 0ba9d249136ec7adf6e3a44c8148701818d0e63e (patch) | |
| tree | df8b68e9aa03c724a5cec632717f7b005217e961 /src/factory.cpp | |
| parent | ac24807d189e2deea969656a229aad7a8c1236c6 (diff) | |
| download | PROJ-0ba9d249136ec7adf6e3a44c8148701818d0e63e.tar.gz PROJ-0ba9d249136ec7adf6e3a44c8148701818d0e63e.zip | |
projinfo: add a --area option (refs #1188)
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 { |
