diff options
| author | Alan D. Snow <alansnow21@gmail.com> | 2021-04-18 05:34:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-18 12:34:29 +0200 |
| commit | e4e2991b174ea48b67e9b41c8f356a9cf1bba081 (patch) | |
| tree | d523f7534caf2662f1b97d5e8e40b5d16886c998 /src/iso19111/factory.cpp | |
| parent | 3d1c573dc9d9f56ced597554ad9fa1643f0a0ae9 (diff) | |
| download | PROJ-e4e2991b174ea48b67e9b41c8f356a9cf1bba081.tar.gz PROJ-e4e2991b174ea48b67e9b41c8f356a9cf1bba081.zip | |
Added proj_get_celestial_body_list_from_database (#2674)
Closes #2667
Diffstat (limited to 'src/iso19111/factory.cpp')
| -rw-r--r-- | src/iso19111/factory.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 19db111b..088289c5 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -7465,6 +7465,14 @@ AuthorityFactory::UnitInfo::UnitInfo() deprecated{} {} //! @endcond + +// --------------------------------------------------------------------------- + +//! @cond Doxygen_Suppress +AuthorityFactory::CelestialBodyInfo::CelestialBodyInfo() : authName{}, name{} {} +//! @endcond + + // --------------------------------------------------------------------------- /** \brief Return the list of units. @@ -7517,6 +7525,35 @@ std::list<AuthorityFactory::UnitInfo> AuthorityFactory::getUnitList() const { // --------------------------------------------------------------------------- +/** \brief Return the list of celestial bodies. + * @throw FactoryException + * + * @since 8.1 + */ +std::list<AuthorityFactory::CelestialBodyInfo> +AuthorityFactory::getCelestialBodyList() const { + std::string sql = "SELECT auth_name, name FROM celestial_body"; + ListOfParams params; + if (d->hasAuthorityRestriction()) { + sql += " WHERE auth_name = ?"; + params.emplace_back(d->authority()); + } + sql += " ORDER BY auth_name, name"; + + auto sqlRes = d->run(sql, params); + std::list<AuthorityFactory::CelestialBodyInfo> res; + for (const auto &row : sqlRes) { + AuthorityFactory::CelestialBodyInfo info; + info.authName = row[0]; + info.name = row[1]; + res.emplace_back(info); + } + return res; +} + + +// --------------------------------------------------------------------------- + /** \brief Gets the official name from a possibly alias name. * * @param aliasedName Alias name. |
