File indexing completed on 2025-01-18 09:35:40
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_BACON_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_BACON_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 bacon
0057 {
0058
0059
0060 static const double epsilon = 1e-10;
0061
0062 struct par_bacon
0063 {
0064 bool bacn;
0065 bool ortl;
0066 };
0067
0068 template <typename T, typename Parameters>
0069 struct base_bacon_spheroid
0070 {
0071 par_bacon m_proj_parm;
0072
0073
0074
0075 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0076 {
0077 static const T half_pi = detail::half_pi<T>();
0078 static const T half_pi_sqr = detail::half_pi_sqr<T>();
0079
0080 T ax, f;
0081
0082 xy_y = this->m_proj_parm.bacn ? half_pi * sin(lp_lat) : lp_lat;
0083 if ((ax = fabs(lp_lon)) >= epsilon) {
0084 if (this->m_proj_parm.ortl && ax >= half_pi)
0085 xy_x = sqrt(half_pi_sqr - lp_lat * lp_lat + epsilon) + ax - half_pi;
0086 else {
0087 f = 0.5 * (half_pi_sqr / ax + ax);
0088 xy_x = ax - f + sqrt(f * f - xy_y * xy_y);
0089 }
0090 if (lp_lon < 0.) xy_x = - xy_x;
0091 } else
0092 xy_x = 0.;
0093 }
0094
0095 static inline std::string get_name()
0096 {
0097 return "bacon_spheroid";
0098 }
0099
0100 };
0101
0102
0103 template <typename Parameters>
0104 inline void setup_apian(Parameters& par, par_bacon& proj_parm)
0105 {
0106 proj_parm.bacn = proj_parm.ortl = false;
0107 par.es = 0.;
0108 }
0109
0110
0111 template <typename Parameters>
0112 inline void setup_ortel(Parameters& par, par_bacon& proj_parm)
0113 {
0114 proj_parm.bacn = false;
0115 proj_parm.ortl = true;
0116 par.es = 0.;
0117 }
0118
0119
0120 template <typename Parameters>
0121 inline void setup_bacon(Parameters& par, par_bacon& proj_parm)
0122 {
0123 proj_parm.bacn = true;
0124 proj_parm.ortl = false;
0125 par.es = 0.;
0126 }
0127
0128 }}
0129 #endif
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144 template <typename T, typename Parameters>
0145 struct apian_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
0146 {
0147 template <typename Params>
0148 inline apian_spheroid(Params const& , Parameters & par)
0149 {
0150 detail::bacon::setup_apian(par, this->m_proj_parm);
0151 }
0152 };
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167 template <typename T, typename Parameters>
0168 struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
0169 {
0170 template <typename Params>
0171 inline ortel_spheroid(Params const& , Parameters & par)
0172 {
0173 detail::bacon::setup_ortel(par, this->m_proj_parm);
0174 }
0175 };
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190 template <typename T, typename Parameters>
0191 struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
0192 {
0193 template <typename Params>
0194 inline bacon_spheroid(Params const& , Parameters & par)
0195 {
0196 detail::bacon::setup_bacon(par, this->m_proj_parm);
0197 }
0198 };
0199
0200 #ifndef DOXYGEN_NO_DETAIL
0201 namespace detail
0202 {
0203
0204
0205 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_apian, apian_spheroid)
0206 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_bacon, bacon_spheroid)
0207 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_ortel, ortel_spheroid)
0208
0209
0210 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(apian_entry, apian_spheroid)
0211 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(ortel_entry, ortel_spheroid)
0212 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(bacon_entry, bacon_spheroid)
0213
0214 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(bacon_init)
0215 {
0216 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(apian, apian_entry)
0217 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ortel, ortel_entry)
0218 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(bacon, bacon_entry)
0219 }
0220
0221 }
0222 #endif
0223
0224 }
0225
0226 }}
0227
0228 #endif
0229