File indexing completed on 2025-12-15 09:51:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_GEOMETRY_PROJECTIONS_EXCEPTION_HPP
0014 #define BOOST_GEOMETRY_PROJECTIONS_EXCEPTION_HPP
0015
0016
0017 #include <boost/geometry/core/exception.hpp>
0018 #include <boost/geometry/srs/projections/impl/pj_strerrno.hpp>
0019
0020 #include <boost/throw_exception.hpp>
0021
0022
0023 namespace boost { namespace geometry
0024 {
0025
0026
0027
0028 class projection_exception : public geometry::exception
0029 {
0030 public:
0031 explicit projection_exception(int code = 0)
0032 : m_code(code)
0033 , m_msg(projections::detail::pj_strerrno(code))
0034 {}
0035
0036 explicit projection_exception(std::string const& msg)
0037 : m_code(0)
0038 , m_msg(msg)
0039 {}
0040
0041 projection_exception(int code, std::string const& msg)
0042 : m_code(code)
0043 , m_msg(msg)
0044 {}
0045
0046 char const* what() const noexcept override
0047 {
0048
0049 return m_msg.what();
0050 }
0051
0052 int code() const { return m_code; }
0053 private :
0054 int m_code;
0055 std::runtime_error m_msg;
0056 };
0057
0058
0059 struct projection_not_named_exception
0060 : projection_exception
0061 {
0062 projection_not_named_exception()
0063 : projection_exception(projections::detail::error_proj_not_named)
0064 {}
0065 };
0066
0067 struct projection_unknown_id_exception
0068 : projection_exception
0069 {
0070 projection_unknown_id_exception()
0071 : projection_exception(projections::detail::error_unknown_projection_id,
0072 msg())
0073 {}
0074
0075 projection_unknown_id_exception(std::string const& proj_name)
0076 : projection_exception(projections::detail::error_unknown_projection_id,
0077 msg(proj_name))
0078 {}
0079
0080 private:
0081 static std::string msg()
0082 {
0083 using namespace projections::detail;
0084 return pj_strerrno(error_unknown_projection_id);
0085 }
0086 static std::string msg(std::string const& proj_name)
0087 {
0088 using namespace projections::detail;
0089 return pj_strerrno(error_unknown_projection_id) + " (" + proj_name + ")";
0090 }
0091 };
0092
0093 struct projection_not_invertible_exception
0094 : projection_exception
0095 {
0096
0097
0098
0099 projection_not_invertible_exception(std::string const& proj_name)
0100 : projection_exception(projections::detail::error_non_conv_inv_meri_dist,
0101 msg(proj_name))
0102 {}
0103
0104 private:
0105 static std::string msg(std::string const& proj_name)
0106 {
0107 return std::string("projection (") + proj_name + ") is not invertible";
0108 }
0109 };
0110
0111
0112 }}
0113 #endif