123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
- #include <boost/geometry/util/math.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>
- namespace boost { namespace geometry
- {
- namespace projections
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail { namespace vandg2
- {
- static const double tolerance = 1e-10;
- struct par_vandg2
- {
- bool vdg3;
- };
- template <typename T, typename Parameters>
- struct base_vandg2_spheroid
- {
- par_vandg2 m_proj_parm;
-
-
- inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
- {
- static const T pi = detail::pi<T>();
- static const T two_div_pi = detail::two_div_pi<T>();
- T x1, at, bt, ct;
- bt = fabs(two_div_pi * lp_lat);
- if ((ct = 1. - bt * bt) < 0.)
- ct = 0.;
- else
- ct = sqrt(ct);
- if (fabs(lp_lon) < tolerance) {
- xy_x = 0.;
- xy_y = pi * (lp_lat < 0. ? -bt : bt) / (1. + ct);
- } else {
- at = 0.5 * fabs(pi / lp_lon - lp_lon / pi);
- if (this->m_proj_parm.vdg3) {
- x1 = bt / (1. + ct);
- xy_x = pi * (sqrt(at * at + 1. - x1 * x1) - at);
- xy_y = pi * x1;
- } else {
- x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
- (1. + at * at * bt * bt);
- xy_x = pi * x1;
- xy_y = pi * sqrt(1. - x1 * (x1 + 2. * at) + tolerance);
- }
- if ( lp_lon < 0.) xy_x = -xy_x;
- if ( lp_lat < 0.) xy_y = -xy_y;
- }
- }
- static inline std::string get_name()
- {
- return "vandg2_spheroid";
- }
- };
-
- inline void setup_vandg2(par_vandg2& proj_parm)
- {
- proj_parm.vdg3 = false;
- }
-
- template <typename Parameters>
- inline void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
- {
- proj_parm.vdg3 = true;
- par.es = 0.;
- }
- }}
- #endif
-
- template <typename T, typename Parameters>
- struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters>
- {
- template <typename Params>
- inline vandg2_spheroid(Params const& , Parameters const& )
- {
- detail::vandg2::setup_vandg2(this->m_proj_parm);
- }
- };
-
- template <typename T, typename Parameters>
- struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters>
- {
- template <typename Params>
- inline vandg3_spheroid(Params const& , Parameters & par)
- {
- detail::vandg2::setup_vandg3(par, this->m_proj_parm);
- }
- };
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_vandg2, vandg2_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_vandg3, vandg3_spheroid)
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(vandg2_entry, vandg2_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(vandg3_entry, vandg3_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(vandg2_init)
- {
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(vandg2, vandg2_entry)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(vandg3, vandg3_entry)
- }
- }
- #endif
- }
- }}
- #endif
|