File indexing completed on 2025-01-18 09:35:46
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
0041
0042 #ifndef BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP
0043 #define BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP
0044
0045 #include <boost/math/special_functions/hypot.hpp>
0046
0047 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0048 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0049 #include <boost/geometry/srs/projections/impl/projects.hpp>
0050 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0051 #include <boost/geometry/srs/projections/impl/pj_gauss.hpp>
0052
0053
0054 namespace boost { namespace geometry
0055 {
0056
0057 namespace projections
0058 {
0059 #ifndef DOXYGEN_NO_DETAIL
0060 namespace detail { namespace sterea
0061 {
0062
0063 template <typename T>
0064 struct par_sterea
0065 {
0066 T phic0;
0067 T cosc0, sinc0;
0068 T R2;
0069 gauss<T> en;
0070 };
0071
0072 template <typename T, typename Parameters>
0073 struct base_sterea_ellipsoid
0074 {
0075 par_sterea<T> m_proj_parm;
0076
0077
0078
0079 inline void fwd(Parameters const& par, T lp_lon, T lp_lat, T& xy_x, T& xy_y) const
0080 {
0081 T cosc, sinc, cosl_, k;
0082
0083 detail::gauss_fwd(m_proj_parm.en, lp_lon, lp_lat);
0084 sinc = sin(lp_lat);
0085 cosc = cos(lp_lat);
0086 cosl_ = cos(lp_lon);
0087 k = par.k0 * this->m_proj_parm.R2 / (1. + this->m_proj_parm.sinc0 * sinc + this->m_proj_parm.cosc0 * cosc * cosl_);
0088 xy_x = k * cosc * sin(lp_lon);
0089 xy_y = k * (this->m_proj_parm.cosc0 * sinc - this->m_proj_parm.sinc0 * cosc * cosl_);
0090 }
0091
0092
0093
0094 inline void inv(Parameters const& par, T xy_x, T xy_y, T& lp_lon, T& lp_lat) const
0095 {
0096 T rho, c, sinc, cosc;
0097
0098 xy_x /= par.k0;
0099 xy_y /= par.k0;
0100 if((rho = boost::math::hypot(xy_x, xy_y)) != 0.0) {
0101 c = 2. * atan2(rho, this->m_proj_parm.R2);
0102 sinc = sin(c);
0103 cosc = cos(c);
0104 lp_lat = asin(cosc * this->m_proj_parm.sinc0 + xy_y * sinc * this->m_proj_parm.cosc0 / rho);
0105 lp_lon = atan2(xy_x * sinc, rho * this->m_proj_parm.cosc0 * cosc -
0106 xy_y * this->m_proj_parm.sinc0 * sinc);
0107 } else {
0108 lp_lat = this->m_proj_parm.phic0;
0109 lp_lon = 0.;
0110 }
0111 detail::gauss_inv(m_proj_parm.en, lp_lon, lp_lat);
0112 }
0113
0114 static inline std::string get_name()
0115 {
0116 return "sterea_ellipsoid";
0117 }
0118
0119 };
0120
0121
0122 template <typename Parameters, typename T>
0123 inline void setup_sterea(Parameters const& par, par_sterea<T>& proj_parm)
0124 {
0125 T R;
0126
0127 proj_parm.en = detail::gauss_ini(par.e, par.phi0, proj_parm.phic0, R);
0128 proj_parm.sinc0 = sin(proj_parm.phic0);
0129 proj_parm.cosc0 = cos(proj_parm.phic0);
0130 proj_parm.R2 = 2. * R;
0131 }
0132
0133 }}
0134 #endif
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 template <typename T, typename Parameters>
0150 struct sterea_ellipsoid : public detail::sterea::base_sterea_ellipsoid<T, Parameters>
0151 {
0152 template <typename Params>
0153 inline sterea_ellipsoid(Params const& , Parameters const& par)
0154 {
0155 detail::sterea::setup_sterea(par, this->m_proj_parm);
0156 }
0157 };
0158
0159 #ifndef DOXYGEN_NO_DETAIL
0160 namespace detail
0161 {
0162
0163
0164 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_sterea, sterea_ellipsoid)
0165
0166
0167 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(sterea_entry, sterea_ellipsoid)
0168
0169 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(sterea_init)
0170 {
0171 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(sterea, sterea_entry)
0172 }
0173
0174 }
0175 #endif
0176
0177 }
0178
0179 }}
0180
0181 #endif
0182