\brief Gets a description of the object corresponding to a code. * * \note In case of several objects of different types with the same code, * one of them will be arbitrarily selected. But if a CRS object is found, it * will be selected. * * @param code Object code allocated by authority. (e.g. "4326") * @return description. * @throw NoSuchAuthorityCodeException if there is no matching obj
| 8773 | * @throw FactoryException in case of other errors. |
| 8774 | */ |
| 8775 | std::string |
| 8776 | AuthorityFactory::getDescriptionText(const std::string &code) const { |
| 8777 | auto sql = "SELECT name, table_name FROM object_view WHERE auth_name = ? " |
| 8778 | "AND code = ? ORDER BY table_name"; |
| 8779 | auto sqlRes = d->runWithCodeParam(sql, code); |
| 8780 | if (sqlRes.empty()) { |
| 8781 | throw NoSuchAuthorityCodeException("object not found", d->authority(), |
| 8782 | code); |
| 8783 | } |
| 8784 | std::string text; |
| 8785 | for (const auto &row : sqlRes) { |
| 8786 | const auto &tableName = row[1]; |
| 8787 | if (tableName == "geodetic_crs" || tableName == "projected_crs" || |
| 8788 | tableName == "vertical_crs" || tableName == "compound_crs" || |
| 8789 | tableName == "engineering_crs") { |
| 8790 | return row[0]; |
| 8791 | } else if (text.empty()) { |
| 8792 | text = row[0]; |
| 8793 | } |
| 8794 | } |
| 8795 | return text; |
| 8796 | } |
| 8797 | |
| 8798 | // --------------------------------------------------------------------------- |
| 8799 |