Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:47

0001 // Boost.Geometry - gis-projections (based on PROJ4)
0002 
0003 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2017, 2018, 2019.
0006 // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
0008 
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 // This file is converted from PROJ4, http://trac.osgeo.org/proj
0014 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
0015 // PROJ4 is maintained by Frank Warmerdam
0016 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
0017 
0018 // Last updated version of proj: 5.0.0
0019 
0020 // Original copyright notice:
0021 
0022 // Permission is hereby granted, free of charge, to any person obtaining a
0023 // copy of this software and associated documentation files (the "Software"),
0024 // to deal in the Software without restriction, including without limitation
0025 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
0026 // and/or sell copies of the Software, and to permit persons to whom the
0027 // Software is furnished to do so, subject to the following conditions:
0028 
0029 // The above copyright notice and this permission notice shall be included
0030 // in all copies or substantial portions of the Software.
0031 
0032 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0033 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0034 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0035 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0036 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0037 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0038 // DEALINGS IN THE SOFTWARE.
0039 
0040 #ifndef BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
0042 
0043 #include <boost/geometry/util/math.hpp>
0044 
0045 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0046 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0047 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0048 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
0049 #include <boost/geometry/srs/projections/impl/projects.hpp>
0050 
0051 namespace boost { namespace geometry
0052 {
0053 
0054 namespace projections
0055 {
0056     #ifndef DOXYGEN_NO_DETAIL
0057     namespace detail { namespace wink2
0058     {
0059 
0060             static const int max_iter = 10;
0061             static const double loop_tol = 1e-7;
0062 
0063             template <typename T>
0064             struct par_wink2
0065             {
0066                 T    cosphi1;
0067             };
0068 
0069             template <typename T, typename Parameters>
0070             struct base_wink2_spheroid
0071             {
0072                 par_wink2<T> m_proj_parm;
0073 
0074                 // FORWARD(s_forward)  spheroid
0075                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0076                 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
0077                 {
0078                     static const T pi = detail::pi<T>();
0079                     static const T half_pi = detail::half_pi<T>();
0080                     static const T fourth_pi = detail::fourth_pi<T>();
0081                     static const T two_div_pi = detail::two_div_pi<T>();
0082 
0083                     T k, V;
0084                     int i;
0085 
0086                     xy_y = lp_lat * two_div_pi;
0087                     k = pi * sin(lp_lat);
0088                     lp_lat *= 1.8;
0089                     for (i = max_iter; i ; --i) {
0090                         lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
0091                             (1. + cos(lp_lat));
0092                         if (fabs(V) < loop_tol)
0093                             break;
0094                     }
0095                     if (!i)
0096                         lp_lat = (lp_lat < 0.) ? -half_pi : half_pi;
0097                     else
0098                         lp_lat *= 0.5;
0099                     xy_x = 0.5 * lp_lon * (cos(lp_lat) + this->m_proj_parm.cosphi1);
0100                     xy_y = fourth_pi * (sin(lp_lat) + xy_y);
0101                 }
0102 
0103                 static inline std::string get_name()
0104                 {
0105                     return "wink2_spheroid";
0106                 }
0107 
0108             };
0109 
0110             // Winkel II
0111             template <typename Params, typename Parameters, typename T>
0112             inline void setup_wink2(Params const& params, Parameters& par, par_wink2<T>& proj_parm)
0113             {
0114                 proj_parm.cosphi1 = cos(pj_get_param_r<T, srs::spar::lat_1>(params, "lat_1", srs::dpar::lat_1));
0115                 par.es = 0.;
0116             }
0117 
0118     }} // namespace detail::wink2
0119     #endif // doxygen
0120 
0121     /*!
0122         \brief Winkel II projection
0123         \ingroup projections
0124         \tparam Geographic latlong point type
0125         \tparam Cartesian xy point type
0126         \tparam Parameters parameter type
0127         \par Projection characteristics
0128          - Pseudocylindrical
0129          - Spheroid
0130          - no inverse
0131         \par Projection parameters
0132          - lat_1: Latitude of first standard parallel (degrees)
0133         \par Example
0134         \image html ex_wink2.gif
0135     */
0136     template <typename T, typename Parameters>
0137     struct wink2_spheroid : public detail::wink2::base_wink2_spheroid<T, Parameters>
0138     {
0139         template <typename Params>
0140         inline wink2_spheroid(Params const& params, Parameters & par)
0141         {
0142             detail::wink2::setup_wink2(params, par, this->m_proj_parm);
0143         }
0144     };
0145 
0146     #ifndef DOXYGEN_NO_DETAIL
0147     namespace detail
0148     {
0149 
0150         // Static projection
0151         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_wink2, wink2_spheroid)
0152 
0153         // Factory entry(s)
0154         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(wink2_entry, wink2_spheroid)
0155 
0156         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(wink2_init)
0157         {
0158             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wink2, wink2_entry)
0159         }
0160 
0161     } // namespace detail
0162     #endif // doxygen
0163 
0164 } // namespace projections
0165 
0166 }} // namespace boost::geometry
0167 
0168 #endif // BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
0169