File indexing completed on 2025-01-18 09:35:44
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_LOXIM_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
0042
0043 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0044 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0045 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0046 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
0047 #include <boost/geometry/srs/projections/impl/projects.hpp>
0048
0049 #include <boost/geometry/util/math.hpp>
0050
0051 namespace boost { namespace geometry
0052 {
0053
0054 namespace projections
0055 {
0056 #ifndef DOXYGEN_NO_DETAIL
0057 namespace detail { namespace loxim
0058 {
0059 static const double epsilon = 1e-8;
0060
0061 template <typename T>
0062 struct par_loxim
0063 {
0064 T phi1;
0065 T cosphi1;
0066 T tanphi1;
0067 };
0068
0069 template <typename T, typename Parameters>
0070 struct base_loxim_spheroid
0071 {
0072 par_loxim<T> m_proj_parm;
0073
0074
0075
0076 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0077 {
0078 static const T fourth_pi = detail::fourth_pi<T>();
0079 static const T half_pi = detail::half_pi<T>();
0080
0081 xy_y = lp_lat - this->m_proj_parm.phi1;
0082 if (fabs(xy_y) < epsilon)
0083 xy_x = lp_lon * this->m_proj_parm.cosphi1;
0084 else {
0085 xy_x = fourth_pi + 0.5 * lp_lat;
0086 if (fabs(xy_x) < epsilon || fabs(fabs(xy_x) - half_pi) < epsilon)
0087 xy_x = 0.;
0088 else
0089 xy_x = lp_lon * xy_y / log( tan(xy_x) / this->m_proj_parm.tanphi1 );
0090 }
0091 }
0092
0093
0094
0095 inline void inv(Parameters const&, T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
0096 {
0097 static const T fourth_pi = detail::fourth_pi<T>();
0098 static const T half_pi = detail::half_pi<T>();
0099
0100 lp_lat = xy_y + this->m_proj_parm.phi1;
0101 if (fabs(xy_y) < epsilon) {
0102 lp_lon = xy_x / this->m_proj_parm.cosphi1;
0103 } else {
0104 lp_lon = fourth_pi + 0.5 * lp_lat;
0105 if (fabs(lp_lon) < epsilon || fabs(fabs(lp_lon) - half_pi) < epsilon)
0106 lp_lon = 0.;
0107 else
0108 lp_lon = xy_x * log( tan(lp_lon) / this->m_proj_parm.tanphi1 ) / xy_y ;
0109 }
0110 }
0111
0112 static inline std::string get_name()
0113 {
0114 return "loxim_spheroid";
0115 }
0116
0117 };
0118
0119
0120 template <typename Params, typename Parameters, typename T>
0121 inline void setup_loxim(Params const& params, Parameters& par, par_loxim<T>& proj_parm)
0122 {
0123 static const T fourth_pi = detail::fourth_pi<T>();
0124
0125 proj_parm.phi1 = pj_get_param_r<T, srs::spar::lat_1>(params, "lat_1", srs::dpar::lat_1);
0126 proj_parm.cosphi1 = cos(proj_parm.phi1);
0127 if (proj_parm.cosphi1 < epsilon)
0128 BOOST_THROW_EXCEPTION( projection_exception(error_lat_larger_than_90) );
0129
0130 proj_parm.tanphi1 = tan(fourth_pi + 0.5 * proj_parm.phi1);
0131
0132 par.es = 0.;
0133 }
0134
0135 }}
0136 #endif
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152 template <typename T, typename Parameters>
0153 struct loxim_spheroid : public detail::loxim::base_loxim_spheroid<T, Parameters>
0154 {
0155 template <typename Params>
0156 inline loxim_spheroid(Params const& params, Parameters & par)
0157 {
0158 detail::loxim::setup_loxim(params, par, this->m_proj_parm);
0159 }
0160 };
0161
0162 #ifndef DOXYGEN_NO_DETAIL
0163 namespace detail
0164 {
0165
0166
0167 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_loxim, loxim_spheroid)
0168
0169
0170 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(loxim_entry, loxim_spheroid)
0171
0172 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(loxim_init)
0173 {
0174 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(loxim, loxim_entry)
0175 }
0176
0177 }
0178 #endif
0179
0180 }
0181
0182 }}
0183
0184 #endif
0185