Back to home page

EIC code displayed by LXR

 
 

    


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

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_ECK3_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
0042 
0043 #include <boost/core/ignore_unused.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 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
0050 
0051 namespace boost { namespace geometry
0052 {
0053 
0054 namespace projections
0055 {
0056     #ifndef DOXYGEN_NO_DETAIL
0057     namespace detail { namespace eck3
0058     {
0059 
0060             template <typename T>
0061             struct par_eck3
0062             {
0063                 T C_x, C_y, A, B;
0064             };
0065 
0066             template <typename T, typename Parameters>
0067             struct base_eck3_spheroid
0068             {
0069                 par_eck3<T> 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                     xy_y = this->m_proj_parm.C_y * lp_lat;
0076                     xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat));
0077                 }
0078 
0079                 // INVERSE(s_inverse)  spheroid
0080                 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
0081                 inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
0082                 {
0083                     T denominator;
0084                     lp_lat = xy_y / this->m_proj_parm.C_y;
0085                     denominator = (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat)));
0086                     if ( denominator == 0.0) {
0087                         lp_lon = HUGE_VAL;
0088                         lp_lat = HUGE_VAL;
0089                     } else
0090                         lp_lon = xy_x / denominator;
0091                 }
0092 
0093                 static inline std::string get_name()
0094                 {
0095                     return "eck3_spheroid";
0096                 }
0097 
0098             };
0099 
0100             template <typename Parameters>
0101             inline void setup(Parameters& par)
0102             {
0103                 par.es = 0.;
0104             }
0105 
0106 
0107             // Eckert III
0108             template <typename Parameters, typename T>
0109             inline void setup_eck3(Parameters& par, par_eck3<T>& proj_parm)
0110             {
0111                 proj_parm.C_x = 0.42223820031577120149;
0112                 proj_parm.C_y = 0.84447640063154240298;
0113                 proj_parm.A = 1.0;
0114                 proj_parm.B = 0.4052847345693510857755;
0115 
0116                 setup(par);
0117             }
0118 
0119             // Putnins P1
0120             template <typename Parameters, typename T>
0121             inline void setup_putp1(Parameters& par, par_eck3<T>& proj_parm)
0122             {
0123                 proj_parm.C_x = 1.89490;
0124                 proj_parm.C_y = 0.94745;
0125                 proj_parm.A = -0.5;
0126                 proj_parm.B = 0.30396355092701331433;
0127 
0128                 setup(par);
0129             }
0130 
0131             // Wagner VI
0132             template <typename Parameters, typename T>
0133             inline void setup_wag6(Parameters& par, par_eck3<T>& proj_parm)
0134             {
0135                 proj_parm.C_x = proj_parm.C_y = 0.94745;
0136                 proj_parm.A = 0.0;
0137                 proj_parm.B = 0.30396355092701331433;
0138 
0139                 setup(par);
0140             }
0141 
0142             // Kavraisky VII
0143             template <typename Parameters, typename T>
0144             inline void setup_kav7(Parameters& par, par_eck3<T>& proj_parm)
0145             {
0146                 /* Defined twice in original code - Using 0.866...,
0147                  * but leaving the other one here as a safety measure.
0148                  * proj_parm.C_x = 0.2632401569273184856851; */
0149                 proj_parm.C_x = 0.8660254037844;
0150                 proj_parm.C_y = 1.0;
0151                 proj_parm.A = 0.0;
0152                 proj_parm.B = 0.30396355092701331433;
0153 
0154                 setup(par);
0155             }
0156 
0157     }} // namespace detail::eck3
0158     #endif // doxygen
0159 
0160     /*!
0161         \brief Eckert III projection
0162         \ingroup projections
0163         \tparam Geographic latlong point type
0164         \tparam Cartesian xy point type
0165         \tparam Parameters parameter type
0166         \par Projection characteristics
0167          - Pseudocylindrical
0168          - Spheroid
0169         \par Example
0170         \image html ex_eck3.gif
0171     */
0172     template <typename T, typename Parameters>
0173     struct eck3_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
0174     {
0175         template <typename Params>
0176         inline eck3_spheroid(Params const& , Parameters & par)
0177         {
0178             detail::eck3::setup_eck3(par, this->m_proj_parm);
0179         }
0180     };
0181 
0182     /*!
0183         \brief Putnins P1 projection
0184         \ingroup projections
0185         \tparam Geographic latlong point type
0186         \tparam Cartesian xy point type
0187         \tparam Parameters parameter type
0188         \par Projection characteristics
0189          - Pseudocylindrical
0190          - Spheroid
0191         \par Example
0192         \image html ex_putp1.gif
0193     */
0194     template <typename T, typename Parameters>
0195     struct putp1_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
0196     {
0197         template <typename Params>
0198         inline putp1_spheroid(Params const& , Parameters & par)
0199         {
0200             detail::eck3::setup_putp1(par, this->m_proj_parm);
0201         }
0202     };
0203 
0204     /*!
0205         \brief Wagner VI projection
0206         \ingroup projections
0207         \tparam Geographic latlong point type
0208         \tparam Cartesian xy point type
0209         \tparam Parameters parameter type
0210         \par Projection characteristics
0211          - Pseudocylindrical
0212          - Spheroid
0213         \par Example
0214         \image html ex_wag6.gif
0215     */
0216     template <typename T, typename Parameters>
0217     struct wag6_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
0218     {
0219         template <typename Params>
0220         inline wag6_spheroid(Params const& , Parameters & par)
0221         {
0222             detail::eck3::setup_wag6(par, this->m_proj_parm);
0223         }
0224     };
0225 
0226     /*!
0227         \brief Kavraisky VII projection
0228         \ingroup projections
0229         \tparam Geographic latlong point type
0230         \tparam Cartesian xy point type
0231         \tparam Parameters parameter type
0232         \par Projection characteristics
0233          - Pseudocylindrical
0234          - Spheroid
0235         \par Example
0236         \image html ex_kav7.gif
0237     */
0238     template <typename T, typename Parameters>
0239     struct kav7_spheroid : public detail::eck3::base_eck3_spheroid<T, Parameters>
0240     {
0241         template <typename Params>
0242         inline kav7_spheroid(Params const& , Parameters & par)
0243         {
0244             detail::eck3::setup_kav7(par, this->m_proj_parm);
0245         }
0246     };
0247 
0248     #ifndef DOXYGEN_NO_DETAIL
0249     namespace detail
0250     {
0251 
0252         // Static projection
0253         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_eck3, eck3_spheroid)
0254         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_putp1, putp1_spheroid)
0255         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_wag6, wag6_spheroid)
0256         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_kav7, kav7_spheroid)
0257 
0258         // Factory entry(s)
0259         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(eck3_entry, eck3_spheroid)
0260         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(putp1_entry, putp1_spheroid)
0261         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(wag6_entry, wag6_spheroid)
0262         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(kav7_entry, kav7_spheroid)
0263 
0264         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(eck3_init)
0265         {
0266             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(eck3, eck3_entry);
0267             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(putp1, putp1_entry);
0268             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wag6, wag6_entry);
0269             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(kav7, kav7_entry);
0270         }
0271 
0272     } // namespace detail
0273     #endif // doxygen
0274 
0275 } // namespace projections
0276 
0277 }} // namespace boost::geometry
0278 
0279 #endif // BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
0280