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_VANDG2_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_VANDG2_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/projects.hpp>
0048 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0049 
0050 namespace boost { namespace geometry
0051 {
0052 
0053 namespace projections
0054 {
0055     #ifndef DOXYGEN_NO_DETAIL
0056     namespace detail { namespace vandg2
0057     {
0058 
0059             static const double tolerance = 1e-10;
0060 
0061             struct par_vandg2
0062             {
0063                 bool    vdg3;
0064             };
0065 
0066             template <typename T, typename Parameters>
0067             struct base_vandg2_spheroid
0068             {
0069                 par_vandg2 m_proj_parm;
0070 
0071                 // FORWARD(s_forward)  spheroid
0072                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0073                 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0074                 {
0075                     static const T pi = detail::pi<T>();
0076                     static const T two_div_pi = detail::two_div_pi<T>();
0077 
0078                     T x1, at, bt, ct;
0079 
0080                     bt = fabs(two_div_pi * lp_lat);
0081                     if ((ct = 1. - bt * bt) < 0.)
0082                         ct = 0.;
0083                     else
0084                         ct = sqrt(ct);
0085                     if (fabs(lp_lon) < tolerance) {
0086                         xy_x = 0.;
0087                         xy_y = pi * (lp_lat < 0. ? -bt : bt) / (1. + ct);
0088                     } else {
0089                         at = 0.5 * fabs(pi / lp_lon - lp_lon / pi);
0090                         if (this->m_proj_parm.vdg3) {
0091                             x1 = bt / (1. + ct);
0092                             xy_x = pi * (sqrt(at * at + 1. - x1 * x1) - at);
0093                             xy_y = pi * x1;
0094                         } else {
0095                             x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
0096                                 (1. + at * at * bt * bt);
0097                             xy_x = pi * x1;
0098                             xy_y = pi * sqrt(1. - x1 * (x1 + 2. * at) + tolerance);
0099                         }
0100                         if ( lp_lon < 0.) xy_x = -xy_x;
0101                         if ( lp_lat < 0.) xy_y = -xy_y;
0102                     }
0103                 }
0104 
0105                 static inline std::string get_name()
0106                 {
0107                     return "vandg2_spheroid";
0108                 }
0109 
0110             };
0111 
0112             // van der Grinten II
0113             inline void setup_vandg2(par_vandg2& proj_parm)
0114             {
0115                 proj_parm.vdg3 = false;
0116             }
0117 
0118             // van der Grinten III
0119             template <typename Parameters>
0120             inline void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
0121             {
0122                 proj_parm.vdg3 = true;
0123                 par.es = 0.;
0124             }
0125 
0126     }} // namespace detail::vandg2
0127     #endif // doxygen
0128 
0129     /*!
0130         \brief van der Grinten II projection
0131         \ingroup projections
0132         \tparam Geographic latlong point type
0133         \tparam Cartesian xy point type
0134         \tparam Parameters parameter type
0135         \par Projection characteristics
0136          - Miscellaneous
0137          - Spheroid
0138          - no inverse
0139         \par Example
0140         \image html ex_vandg2.gif
0141     */
0142     template <typename T, typename Parameters>
0143     struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters>
0144     {
0145         template <typename Params>
0146         inline vandg2_spheroid(Params const& , Parameters const& )
0147         {
0148             detail::vandg2::setup_vandg2(this->m_proj_parm);
0149         }
0150     };
0151 
0152     /*!
0153         \brief van der Grinten III projection
0154         \ingroup projections
0155         \tparam Geographic latlong point type
0156         \tparam Cartesian xy point type
0157         \tparam Parameters parameter type
0158         \par Projection characteristics
0159          - Miscellaneous
0160          - Spheroid
0161          - no inverse
0162         \par Example
0163         \image html ex_vandg3.gif
0164     */
0165     template <typename T, typename Parameters>
0166     struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<T, Parameters>
0167     {
0168         template <typename Params>
0169         inline vandg3_spheroid(Params const& , Parameters & par)
0170         {
0171             detail::vandg2::setup_vandg3(par, this->m_proj_parm);
0172         }
0173     };
0174 
0175     #ifndef DOXYGEN_NO_DETAIL
0176     namespace detail
0177     {
0178 
0179         // Static projection
0180         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_vandg2, vandg2_spheroid)
0181         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_vandg3, vandg3_spheroid)
0182 
0183         // Factory entry(s)
0184         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(vandg2_entry, vandg2_spheroid)
0185         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(vandg3_entry, vandg3_spheroid)
0186 
0187         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(vandg2_init)
0188         {
0189             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(vandg2, vandg2_entry)
0190             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(vandg3, vandg3_entry)
0191         }
0192 
0193     } // namespace detail
0194     #endif // doxygen
0195 
0196 } // namespace projections
0197 
0198 }} // namespace boost::geometry
0199 
0200 #endif // BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
0201