Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:37

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2017-2020.
0006 // Modifications copyright (c) 2017-2020, 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_IMPL_BASE_STATIC_HPP
0014 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP
0015 
0016 #if defined(_MSC_VER)
0017 // For CRTP, *this is acceptable in constructor -> turn warning off
0018 #pragma warning( disable : 4355 )
0019 #endif // defined(_MSC_VER)
0020 
0021 
0022 #include <string>
0023 
0024 #include <boost/geometry/core/assert.hpp>
0025 #include <boost/geometry/core/static_assert.hpp>
0026 #include <boost/geometry/core/tags.hpp>
0027 
0028 #include <boost/geometry/srs/projections/impl/pj_fwd.hpp>
0029 #include <boost/geometry/srs/projections/impl/pj_inv.hpp>
0030 
0031 
0032 namespace boost { namespace geometry { namespace projections
0033 {
0034 
0035 
0036 #ifndef DOXYGEN_NO_DETAIL
0037 namespace detail
0038 {
0039 
0040 template <typename Prj, typename CSTag, typename SP, typename CT, typename P>
0041 struct static_projection_type
0042 {
0043     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0044         "Not implemented for this projection or coordinate system.",
0045         Prj, CSTag, SP, CT, P);
0046 };
0047 
0048 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(PROJ, P_SPHXXX) \
0049 template <typename SP, typename CT, typename P> \
0050 struct static_projection_type<PROJ, srs_sphere_tag, SP, CT, P> \
0051 { \
0052     typedef projections::detail::static_wrapper_f<P_SPHXXX<CT, P>, P> type; \
0053 }; \
0054 template <typename SP, typename CT, typename P> \
0055 struct static_projection_type<PROJ, srs_spheroid_tag, SP, CT, P> \
0056 { \
0057     typedef projections::detail::static_wrapper_f<P_SPHXXX<CT, P>, P> type; \
0058 }; \
0059 
0060 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(PROJ, P_SPHXXX) \
0061 template <typename SP, typename CT, typename P> \
0062 struct static_projection_type<PROJ, srs_sphere_tag, SP, CT, P> \
0063 { \
0064     typedef projections::detail::static_wrapper_fi<P_SPHXXX<CT, P>, P> type; \
0065 }; \
0066 template <typename SP, typename CT, typename P> \
0067 struct static_projection_type<PROJ, srs_spheroid_tag, SP, CT, P> \
0068 { \
0069     typedef projections::detail::static_wrapper_fi<P_SPHXXX<CT, P>, P> type; \
0070 }; \
0071 
0072 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI2(PROJ, P_SPHERE, P_SPHEROID) \
0073 template <typename SP, typename CT, typename P> \
0074 struct static_projection_type<PROJ, srs_sphere_tag, SP, CT, P> \
0075 { \
0076     typedef projections::detail::static_wrapper_fi<P_SPHERE<CT, P>, P> type; \
0077 }; \
0078 template <typename SP, typename CT, typename P> \
0079 struct static_projection_type<PROJ, srs_spheroid_tag, SP, CT, P> \
0080 { \
0081     typedef projections::detail::static_wrapper_fi<P_SPHEROID<CT, P>, P> type; \
0082 }; \
0083 
0084 template <typename P>
0085 struct static_wrapper_b
0086 {
0087     inline explicit static_wrapper_b(P const& par)
0088         : m_par(par)
0089     {}
0090 
0091     std::string name() const { return m_par.id.name; }
0092 
0093     P const& params() const { return m_par; }
0094 
0095     P& mutable_params() { return m_par; }
0096 
0097 protected:
0098     P m_par;
0099 };
0100 
0101 // Forward
0102 template <typename Prj, typename P>
0103 struct static_wrapper_f
0104     : public static_wrapper_b<P>
0105     , public Prj
0106 {
0107 public:
0108     template <typename Params>
0109     inline static_wrapper_f(Params const& params, P const& par)
0110         : static_wrapper_b<P>(par)
0111         , Prj(params, this->m_par) // prj can modify parameters
0112     {}
0113 
0114     template <typename LL, typename XY>
0115     inline bool forward(LL const& lp, XY& xy) const
0116     {
0117         try
0118         {
0119             pj_fwd(*this, this->m_par, lp, xy);
0120             return true;
0121         }
0122         catch (...)
0123         {
0124             return false;
0125         }
0126     }
0127 
0128     template <typename XY, typename LL>
0129     inline bool inverse(XY const&, LL&) const
0130     {
0131         BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0132             "This projection is not invertable.",
0133             Prj);
0134         return false;
0135     }
0136 };
0137 
0138 // Forward/inverse
0139 template <typename Prj, typename P>
0140 struct static_wrapper_fi
0141     : public static_wrapper_f<Prj, P>
0142 {
0143 public:
0144     template <typename Params>
0145     inline static_wrapper_fi(Params const& params, P const& par)
0146         : static_wrapper_f<Prj, P>(params, par)
0147     {}
0148 
0149     template <typename XY, typename LL>
0150     inline bool inverse(XY const& xy, LL& lp) const
0151     {
0152         try
0153         {
0154             pj_inv(*this, this->m_par, xy, lp);
0155             return true;
0156         }
0157         catch (...)
0158         {
0159             return false;
0160         }
0161     }
0162 };
0163 
0164 } // namespace detail
0165 #endif // DOXYGEN_NO_DETAIL
0166 
0167 
0168 }}} // namespace boost::geometry::projections
0169 
0170 
0171 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP