Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:51:32

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2017, 2018.
0006 // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0008 
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
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 // TODO: make more for forward/inverse/init/setup
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         //return "Boost.Geometry Projection exception";
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     // NOTE: There is no error code in proj4 which could be used here
0097     // Proj4 sets points as invalid (HUGE_VAL) and last errno to EINVAL
0098     // in pj_inv() if inverse projection is not available.
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 }} // namespace boost::geometry
0113 #endif // BOOST_GEOMETRY_PROJECTIONS_EXCEPTION_HPP