123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_BACON_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 bacon
- {
-
- static const double epsilon = 1e-10;
- struct par_bacon
- {
- bool bacn;
- bool ortl;
- };
- template <typename T, typename Parameters>
- struct base_bacon_spheroid
- {
- par_bacon 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 half_pi = detail::half_pi<T>();
- static const T half_pi_sqr = detail::half_pi_sqr<T>();
- T ax, f;
- xy_y = this->m_proj_parm.bacn ? half_pi * sin(lp_lat) : lp_lat;
- if ((ax = fabs(lp_lon)) >= epsilon) {
- if (this->m_proj_parm.ortl && ax >= half_pi)
- xy_x = sqrt(half_pi_sqr - lp_lat * lp_lat + epsilon) + ax - half_pi;
- else {
- f = 0.5 * (half_pi_sqr / ax + ax);
- xy_x = ax - f + sqrt(f * f - xy_y * xy_y);
- }
- if (lp_lon < 0.) xy_x = - xy_x;
- } else
- xy_x = 0.;
- }
- static inline std::string get_name()
- {
- return "bacon_spheroid";
- }
- };
-
- template <typename Parameters>
- inline void setup_apian(Parameters& par, par_bacon& proj_parm)
- {
- proj_parm.bacn = proj_parm.ortl = false;
- par.es = 0.;
- }
-
- template <typename Parameters>
- inline void setup_ortel(Parameters& par, par_bacon& proj_parm)
- {
- proj_parm.bacn = false;
- proj_parm.ortl = true;
- par.es = 0.;
- }
-
- template <typename Parameters>
- inline void setup_bacon(Parameters& par, par_bacon& proj_parm)
- {
- proj_parm.bacn = true;
- proj_parm.ortl = false;
- par.es = 0.;
- }
- }}
- #endif
-
- template <typename T, typename Parameters>
- struct apian_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
- {
- template <typename Params>
- inline apian_spheroid(Params const& , Parameters & par)
- {
- detail::bacon::setup_apian(par, this->m_proj_parm);
- }
- };
-
- template <typename T, typename Parameters>
- struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
- {
- template <typename Params>
- inline ortel_spheroid(Params const& , Parameters & par)
- {
- detail::bacon::setup_ortel(par, this->m_proj_parm);
- }
- };
-
- template <typename T, typename Parameters>
- struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<T, Parameters>
- {
- template <typename Params>
- inline bacon_spheroid(Params const& , Parameters & par)
- {
- detail::bacon::setup_bacon(par, this->m_proj_parm);
- }
- };
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_apian, apian_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_bacon, bacon_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_ortel, ortel_spheroid)
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(apian_entry, apian_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(ortel_entry, ortel_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(bacon_entry, bacon_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(bacon_init)
- {
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(apian, apian_entry)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ortel, ortel_entry)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(bacon, bacon_entry)
- }
- }
- #endif
- }
- }}
- #endif
|