File indexing completed on 2025-10-29 08:18:56
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 
0014 
0015 
0016 
0017 
0018 
0019 
0020 
0021 
0022 
0023 
0024 
0025 
0026 
0027 
0028 
0029 
0030 
0031 
0032 
0033 
0034 
0035 
0036 
0037 
0038 
0039 
0040 #ifndef BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
0042 
0043 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
0044 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0045 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0046 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0047 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
0048 #include <boost/geometry/srs/projections/impl/projects.hpp>
0049 
0050 #include <boost/geometry/util/math.hpp>
0051 
0052 namespace boost { namespace geometry
0053 {
0054 
0055 namespace projections
0056 {
0057     #ifndef DOXYGEN_NO_DETAIL
0058     namespace detail { namespace fouc_s
0059     {
0060 
0061             static const int max_iter = 10;
0062             static const double loop_tol = 1e-7;
0063 
0064             template <typename T>
0065             struct par_fouc_s
0066             {
0067                 T n, n1;
0068             };
0069 
0070             template <typename T, typename Parameters>
0071             struct base_fouc_s_spheroid
0072             {
0073                 par_fouc_s<T> m_proj_parm;
0074 
0075                 
0076                 
0077                 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0078                 {
0079                     T t;
0080 
0081                     t = cos(lp_lat);
0082                     xy_x = lp_lon * t / (this->m_proj_parm.n + this->m_proj_parm.n1 * t);
0083                     xy_y = this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat);
0084                 }
0085 
0086                 
0087                 
0088                 inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
0089                 {
0090                     static T const half_pi = detail::half_pi<T>();
0091 
0092                     T V;
0093                     int i;
0094 
0095                     if (this->m_proj_parm.n != 0.0) {
0096                         lp_lat = xy_y;
0097                         for (i = max_iter; i ; --i) {
0098                             lp_lat -= V = (this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat) - xy_y ) /
0099                                 (this->m_proj_parm.n + this->m_proj_parm.n1 * cos(lp_lat));
0100                             if (fabs(V) < loop_tol)
0101                                 break;
0102                         }
0103                         if (!i)
0104                             lp_lat = xy_y < 0. ? -half_pi : half_pi;
0105                     } else
0106                         lp_lat = aasin(xy_y);
0107                     V = cos(lp_lat);
0108                     lp_lon = xy_x * (this->m_proj_parm.n + this->m_proj_parm.n1 * V) / V;
0109                 }
0110 
0111                 static inline std::string get_name()
0112                 {
0113                     return "fouc_s_spheroid";
0114                 }
0115 
0116             };
0117 
0118             
0119             template <typename Params, typename Parameters, typename T>
0120             inline void setup_fouc_s(Params const& params, Parameters& par, par_fouc_s<T>& proj_parm)
0121             {
0122                 proj_parm.n = pj_get_param_f<T, srs::spar::n>(params, "n", srs::dpar::n);
0123                 if ((proj_parm.n < 0.) || (proj_parm.n > 1.))
0124                     BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
0125 
0126                 proj_parm.n1 = 1. - proj_parm.n;
0127                 par.es = 0;
0128             }
0129 
0130     }} 
0131     #endif 
0132 
0133     
0134 
0135 
0136 
0137 
0138 
0139 
0140 
0141 
0142 
0143 
0144 
0145 
0146 
0147     template <typename T, typename Parameters>
0148     struct fouc_s_spheroid : public detail::fouc_s::base_fouc_s_spheroid<T, Parameters>
0149     {
0150         template <typename Params>
0151         inline fouc_s_spheroid(Params const& params, Parameters & par)
0152         {
0153             detail::fouc_s::setup_fouc_s(params, par, this->m_proj_parm);
0154         }
0155     };
0156 
0157     #ifndef DOXYGEN_NO_DETAIL
0158     namespace detail
0159     {
0160 
0161         
0162         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_fouc_s, fouc_s_spheroid)
0163 
0164         
0165         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(fouc_s_entry, fouc_s_spheroid)
0166 
0167         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(fouc_s_init)
0168         {
0169             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(fouc_s, fouc_s_entry);
0170         }
0171 
0172     } 
0173     #endif 
0174 
0175 } 
0176 
0177 }} 
0178 
0179 #endif 
0180