Back to home page

EIC code displayed by LXR

 
 

    


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

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_GOODE_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
0042 
0043 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0044 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0045 #include <boost/geometry/srs/projections/impl/projects.hpp>
0046 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0047 #include <boost/geometry/srs/projections/proj/gn_sinu.hpp>
0048 #include <boost/geometry/srs/projections/proj/moll.hpp>
0049 
0050 namespace boost { namespace geometry
0051 {
0052 
0053 namespace projections
0054 {
0055     #ifndef DOXYGEN_NO_DETAIL
0056     namespace detail { namespace goode
0057     {
0058 
0059             static const double Y_COR = 0.05280;
0060             static const double PHI_LIM = .71093078197902358062;
0061 
0062             // TODO: It would be possible to further decrease the size of par_goode
0063             // because spherical sinu and moll has constant parameters.
0064 
0065             template <typename T, typename Par>
0066             struct par_goode
0067             {
0068                 sinu_spheroid<T, Par>    sinu;
0069                 moll_spheroid<T, Par>    moll;
0070 
0071                 // NOTE: It is ok to share parameters between projections because
0072                 // the only member that is modified in the constructors of
0073                 // spherical sinu and moll projections is es = 0 which is set
0074                 // below in setup_goode() anyway.
0075                 // Moreover in these projections parameters are not used
0076                 // in fwd() nor inv().
0077 
0078                 template <typename Params>
0079                 par_goode(Params const& params, Par & par)
0080                     : sinu(params, par)
0081                     , moll(params, par)
0082                 {}
0083             };
0084 
0085             template <typename T, typename Par>
0086             inline void s_forward(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y,
0087                                   Par const& par, par_goode<T, Par> const& proj_par)
0088             {
0089                 if (fabs(lp_lat) <= PHI_LIM)
0090                     proj_par.sinu.fwd(par, lp_lon, lp_lat, xy_x, xy_y);
0091                 else {
0092                     proj_par.moll.fwd(par, lp_lon, lp_lat, xy_x, xy_y);
0093                     xy_y -= lp_lat >= 0.0 ? Y_COR : -Y_COR;
0094                 }
0095             }
0096 
0097             template <typename T, typename Par>
0098             inline void s_inverse(T const& xy_x, T xy_y, T& lp_lon, T& lp_lat,
0099                                   Par const& par, par_goode<T, Par> const& proj_par)
0100             {
0101                 if (fabs(xy_y) <= PHI_LIM)
0102                     proj_par.sinu.inv(par, xy_x, xy_y, lp_lon, lp_lat);
0103                 else {
0104                     xy_y += xy_y >= 0.0 ? Y_COR : -Y_COR;
0105                     proj_par.moll.inv(par, xy_x, xy_y, lp_lon, lp_lat);
0106                 }
0107             }
0108 
0109             // Goode Homolosine
0110             template <typename Par>
0111             inline Par& setup_goode(Par& par)
0112             {
0113                 par.es = 0.;
0114 
0115                 // NOTE: The following explicit initialization of sinu projection
0116                 // is not needed because setup_goode() is called before proj_par.sinu
0117                 // is constructed and m_par of parent projection is used.
0118 
0119                 //proj_par.sinu.m_par.es = 0.;
0120                 //detail::gn_sinu::setup_sinu(proj_par.sinu.m_par, proj_par.sinu.m_proj_parm);
0121 
0122                 return par;
0123             }
0124 
0125     }} // namespace detail::goode
0126     #endif // doxygen
0127 
0128     /*!
0129         \brief Goode Homolosine projection
0130         \ingroup projections
0131         \tparam Geographic latlong point type
0132         \tparam Cartesian xy point type
0133         \tparam Parameters parameter type
0134         \par Projection characteristics
0135          - Pseudocylindrical
0136          - Spheroid
0137         \par Example
0138         \image html ex_goode.gif
0139     */
0140     template <typename T, typename Parameters>
0141     struct goode_spheroid
0142     {
0143         detail::goode::par_goode<T, Parameters> m_proj_parm;
0144 
0145         template <typename Params>
0146         inline goode_spheroid(Params const& params, Parameters & par)
0147             : m_proj_parm(params, detail::goode::setup_goode(par))
0148         {}
0149 
0150         // FORWARD(s_forward)  spheroid
0151         // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0152         inline void fwd(Parameters const& par, T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0153         {
0154             detail::goode::s_forward(lp_lon, lp_lat, xy_x, xy_y, par, this->m_proj_parm);
0155         }
0156 
0157         // INVERSE(s_inverse)  spheroid
0158         // Project coordinates from cartesian (x, y) to geographic (lon, lat)
0159         inline void inv(Parameters const& par, T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
0160         {
0161             detail::goode::s_inverse(xy_x, xy_y, lp_lon, lp_lat, par, this->m_proj_parm);
0162         }
0163 
0164         static inline std::string get_name()
0165         {
0166             return "goode_spheroid";
0167         }
0168     };
0169 
0170     #ifndef DOXYGEN_NO_DETAIL
0171     namespace detail
0172     {
0173 
0174         // Static projection
0175         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_goode, goode_spheroid)
0176 
0177         // Factory entry(s)
0178         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(goode_entry, goode_spheroid)
0179 
0180         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(goode_init)
0181         {
0182             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(goode, goode_entry);
0183         }
0184 
0185     } // namespace detail
0186     #endif // doxygen
0187 
0188 } // namespace projections
0189 
0190 }} // namespace boost::geometry
0191 
0192 #endif // BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
0193