123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_NOCOL_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 nocol
- {
- static const double epsilon = 1e-10;
- template <typename T, typename Parameters>
- struct base_nocol_spheroid
- {
-
-
- 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>();
- if (fabs(lp_lon) < epsilon) {
- xy_x = 0;
- xy_y = lp_lat;
- } else if (fabs(lp_lat) < epsilon) {
- xy_x = lp_lon;
- xy_y = 0.;
- } else if (fabs(fabs(lp_lon) - half_pi) < epsilon) {
- xy_x = lp_lon * cos(lp_lat);
- xy_y = half_pi * sin(lp_lat);
- } else if (fabs(fabs(lp_lat) - half_pi) < epsilon) {
- xy_x = 0;
- xy_y = lp_lat;
- } else {
- T tb, c, d, m, n, r2, sp;
- tb = half_pi / lp_lon - lp_lon / half_pi;
- c = lp_lat / half_pi;
- d = (1 - c * c)/((sp = sin(lp_lat)) - c);
- r2 = tb / d;
- r2 *= r2;
- m = (tb * sp / d - 0.5 * tb)/(1. + r2);
- n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
- xy_x = cos(lp_lat);
- xy_x = sqrt(m * m + xy_x * xy_x / (1. + r2));
- xy_x = half_pi * ( m + (lp_lon < 0. ? -xy_x : xy_x));
- xy_y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
- (1. + 1./r2));
- xy_y = half_pi * ( n + (lp_lat < 0. ? xy_y : -xy_y ));
- }
- }
- static inline std::string get_name()
- {
- return "nocol_spheroid";
- }
- };
-
- template <typename Parameters>
- inline void setup_nicol(Parameters& par)
- {
- par.es = 0.;
- }
- }}
- #endif
-
- template <typename T, typename Parameters>
- struct nicol_spheroid : public detail::nocol::base_nocol_spheroid<T, Parameters>
- {
- template <typename Params>
- inline nicol_spheroid(Params const& , Parameters & par)
- {
- detail::nocol::setup_nicol(par);
- }
- };
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_nicol, nicol_spheroid)
-
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(nicol_entry, nicol_spheroid)
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(nocol_init)
- {
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(nicol, nicol_entry)
- }
- }
- #endif
- }
- }}
- #endif
|