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_VANDG2_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_VANDG2_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/projects.hpp>
0048 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0049
0050 namespace boost { namespace geometry
0051 {
0052
0053 namespace projections
0054 {
0055 #ifndef DOXYGEN_NO_DETAIL
0056 namespace detail { namespace vandg2
0057 {
0058
0059 static const double tolerance = 1e-10;
0060
0061 struct par_vandg2
0062 {
0063 bool vdg3;
0064 };
0065
0066 template <typename T, typename Parameters>
0067 struct base_vandg2_spheroid
0068 {
0069 par_vandg2 m_proj_parm;
0070
0071
0072
0073 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0074 {
0075 static const T pi = detail::pi<T>();
0076 static const T two_div_pi = detail::two_div_pi<T>();
0077
0078 T x1, at, bt, ct;
0079
0080 bt = fabs(two_div_pi * lp_lat);
0081 if ((ct = 1. - bt * bt) < 0.)
0082 ct = 0.;
0083 else
0084 ct = sqrt(ct);
0085 if (fabs(lp_lon) < tolerance) {
0086 xy_x = 0.;
0087 xy_y = pi * (lp_lat < 0. ? -bt : bt) / (1. + ct);
0088 } else {
0089 at = 0.5 * fabs(pi / lp_lon - lp_lon / pi);
0090 if (this->m_proj_parm.vdg3) {
0091 x1 = bt / (1. + ct);
0092 xy_x = pi * (sqrt(at * at + 1. - x1 * x1) - at);
0093 xy_y = pi * x1;
0094 } else {
0095 x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
0096 (1. + at * at * bt * bt);
0097 xy_x = pi * x1;
0098 xy_y = pi * sqrt(1. - x1 * (x1 + 2. * at) + tolerance);
0099 }
0100 if ( lp_lon < 0.) xy_x = -xy_x;
0101 if ( lp_lat < 0.) xy_y = -xy_y;
0102 }
0103 }
0104
0105 static inline std::string get_name()
0106 {
0107 return "vandg2_spheroid";
0108 }
0109
0110 };
0111
0112
0113 inline void setup_vandg2(par_vandg2& proj_parm)
0114 {
0115 proj_parm.vdg3 = false;
0116 }
0117
0118
0119 template <typename Parameters>
0120 inline void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
0121 {
0122 proj_parm.vdg3 = true;
0123 par.es = 0.;
0124 }
0125
0126 }}
0127 #endif
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 template <typename T, typename Parameters>
0143 struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters>
0144 {
0145 template <typename Params>
0146 inline vandg2_spheroid(Params const& , Parameters const& )
0147 {
0148 detail::vandg2::setup_vandg2(this->m_proj_parm);
0149 }
0150 };
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 template <typename T, typename Parameters>
0166 struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters>
0167 {
0168 template <typename Params>
0169 inline vandg3_spheroid(Params const& , Parameters & par)
0170 {
0171 detail::vandg2::setup_vandg3(par, this->m_proj_parm);
0172 }
0173 };
0174
0175 #ifndef DOXYGEN_NO_DETAIL
0176 namespace detail
0177 {
0178
0179
0180 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_vandg2, vandg2_spheroid)
0181 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_vandg3, vandg3_spheroid)
0182
0183
0184 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(vandg2_entry, vandg2_spheroid)
0185 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(vandg3_entry, vandg3_spheroid)
0186
0187 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(vandg2_init)
0188 {
0189 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(vandg2, vandg2_entry)
0190 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(vandg3, vandg3_entry)
0191 }
0192
0193 }
0194 #endif
0195
0196 }
0197
0198 }}
0199
0200 #endif
0201