123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
- #include <boost/geometry/srs/projections/impl/base_static.hpp>
- #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
- #include <boost/geometry/srs/projections/impl/projects.hpp>
- #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
- #include <boost/geometry/srs/projections/impl/pj_phi2.hpp>
- #include <boost/geometry/srs/projections/impl/pj_tsfn.hpp>
- namespace boost { namespace geometry
- {
- namespace projections
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail { namespace gstmerc
- {
- template <typename T>
- struct par_gstmerc
- {
- T lamc;
- T phic;
- T c;
- T n1;
- T n2;
- T XS;
- T YS;
- };
- template <typename T, typename Parameters>
- struct base_gstmerc_spheroid
- {
- par_gstmerc<T> m_proj_parm;
-
-
- inline void fwd(Parameters const& par, T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
- {
- T L, Ls, sinLs1, Ls1;
- L= this->m_proj_parm.n1*lp_lon;
- Ls= this->m_proj_parm.c+this->m_proj_parm.n1*log(pj_tsfn(-1.0*lp_lat,-1.0*sin(lp_lat), par.e));
- sinLs1= sin(L)/cosh(Ls);
- Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
- xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1) * par.ra;
- xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L))) * par.ra;
- }
-
-
- inline void inv(Parameters const& par, T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
- {
- T L, LC, sinC;
- L= atan(sinh((xy_x * par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2)/cos((xy_y * par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2));
- sinC= sin((xy_y * par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)/cosh((xy_x * par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2);
- LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
- lp_lon= L/this->m_proj_parm.n1;
- lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1), par.e);
- }
- static inline std::string get_name()
- {
- return "gstmerc_spheroid";
- }
- };
-
- template <typename Parameters, typename T>
- inline void setup_gstmerc(Parameters const& par, par_gstmerc<T>& proj_parm)
- {
- proj_parm.lamc= par.lam0;
- proj_parm.n1= sqrt(T(1)+par.es*math::pow(cos(par.phi0),4)/(T(1)-par.es));
- proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1);
- proj_parm.c= log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0))
- - proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e));
- proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0));
- proj_parm.XS= 0;
- proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;
- }
- }}
- #endif
-
- template <typename T, typename Parameters>
- struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<T, Parameters>
- {
- template <typename Params>
- inline gstmerc_spheroid(Params const& , Parameters const& par)
- {
- detail::gstmerc::setup_gstmerc(par, this->m_proj_parm);
- }
- };
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_gstmerc, gstmerc_spheroid)
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(gstmerc_entry, gstmerc_spheroid)
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(gstmerc_init)
- {
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(gstmerc, gstmerc_entry);
- }
- }
- #endif
- }
- }}
- #endif
|