123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_EXCEPTION_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_EXCEPTION_HPP
- #include <boost/geometry/core/exception.hpp>
- #include <boost/geometry/srs/projections/impl/pj_strerrno.hpp>
- #include <boost/throw_exception.hpp>
- namespace boost { namespace geometry
- {
- class projection_exception : public geometry::exception
- {
- public:
- explicit projection_exception(int code = 0)
- : m_code(code)
- , m_msg(projections::detail::pj_strerrno(code))
- {}
- explicit projection_exception(std::string const& msg)
- : m_code(0)
- , m_msg(msg)
- {}
- projection_exception(int code, std::string const& msg)
- : m_code(code)
- , m_msg(msg)
- {}
- char const* what() const noexcept override
- {
-
- return m_msg.what();
- }
- int code() const { return m_code; }
- private :
- int m_code;
- std::runtime_error m_msg;
- };
- struct projection_not_named_exception
- : projection_exception
- {
- projection_not_named_exception()
- : projection_exception(projections::detail::error_proj_not_named)
- {}
- };
- struct projection_unknown_id_exception
- : projection_exception
- {
- projection_unknown_id_exception()
- : projection_exception(projections::detail::error_unknown_projection_id,
- msg())
- {}
- projection_unknown_id_exception(std::string const& proj_name)
- : projection_exception(projections::detail::error_unknown_projection_id,
- msg(proj_name))
- {}
- private:
- static std::string msg()
- {
- using namespace projections::detail;
- return pj_strerrno(error_unknown_projection_id);
- }
- static std::string msg(std::string const& proj_name)
- {
- using namespace projections::detail;
- return pj_strerrno(error_unknown_projection_id) + " (" + proj_name + ")";
- }
- };
- struct projection_not_invertible_exception
- : projection_exception
- {
-
-
-
- projection_not_invertible_exception(std::string const& proj_name)
- : projection_exception(projections::detail::error_non_conv_inv_meri_dist,
- msg(proj_name))
- {}
- private:
- static std::string msg(std::string const& proj_name)
- {
- return std::string("projection (") + proj_name + ") is not invertible";
- }
- };
- }}
- #endif
|