File indexing completed on 2025-01-18 09:35:47
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_WINK2_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
0042
0043 #include <boost/geometry/util/math.hpp>
0044
0045 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0046 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0047 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0048 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
0049 #include <boost/geometry/srs/projections/impl/projects.hpp>
0050
0051 namespace boost { namespace geometry
0052 {
0053
0054 namespace projections
0055 {
0056 #ifndef DOXYGEN_NO_DETAIL
0057 namespace detail { namespace wink2
0058 {
0059
0060 static const int max_iter = 10;
0061 static const double loop_tol = 1e-7;
0062
0063 template <typename T>
0064 struct par_wink2
0065 {
0066 T cosphi1;
0067 };
0068
0069 template <typename T, typename Parameters>
0070 struct base_wink2_spheroid
0071 {
0072 par_wink2<T> m_proj_parm;
0073
0074
0075
0076 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
0077 {
0078 static const T pi = detail::pi<T>();
0079 static const T half_pi = detail::half_pi<T>();
0080 static const T fourth_pi = detail::fourth_pi<T>();
0081 static const T two_div_pi = detail::two_div_pi<T>();
0082
0083 T k, V;
0084 int i;
0085
0086 xy_y = lp_lat * two_div_pi;
0087 k = pi * sin(lp_lat);
0088 lp_lat *= 1.8;
0089 for (i = max_iter; i ; --i) {
0090 lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
0091 (1. + cos(lp_lat));
0092 if (fabs(V) < loop_tol)
0093 break;
0094 }
0095 if (!i)
0096 lp_lat = (lp_lat < 0.) ? -half_pi : half_pi;
0097 else
0098 lp_lat *= 0.5;
0099 xy_x = 0.5 * lp_lon * (cos(lp_lat) + this->m_proj_parm.cosphi1);
0100 xy_y = fourth_pi * (sin(lp_lat) + xy_y);
0101 }
0102
0103 static inline std::string get_name()
0104 {
0105 return "wink2_spheroid";
0106 }
0107
0108 };
0109
0110
0111 template <typename Params, typename Parameters, typename T>
0112 inline void setup_wink2(Params const& params, Parameters& par, par_wink2<T>& proj_parm)
0113 {
0114 proj_parm.cosphi1 = cos(pj_get_param_r<T, srs::spar::lat_1>(params, "lat_1", srs::dpar::lat_1));
0115 par.es = 0.;
0116 }
0117
0118 }}
0119 #endif
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 template <typename T, typename Parameters>
0137 struct wink2_spheroid : public detail::wink2::base_wink2_spheroid<T, Parameters>
0138 {
0139 template <typename Params>
0140 inline wink2_spheroid(Params const& params, Parameters & par)
0141 {
0142 detail::wink2::setup_wink2(params, par, this->m_proj_parm);
0143 }
0144 };
0145
0146 #ifndef DOXYGEN_NO_DETAIL
0147 namespace detail
0148 {
0149
0150
0151 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_wink2, wink2_spheroid)
0152
0153
0154 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(wink2_entry, wink2_spheroid)
0155
0156 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(wink2_init)
0157 {
0158 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wink2, wink2_entry)
0159 }
0160
0161 }
0162 #endif
0163
0164 }
0165
0166 }}
0167
0168 #endif
0169