Back to home page

EIC code displayed by LXR

 
 

    


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

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_BOGGS_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_BOGGS_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 boggs
0057     {
0058 
0059             static const int n_iter = 20;
0060             static const double epsilon = 1e-7;
0061             static const double FXC = 2.00276;
0062             static const double FXC2 = 1.11072;
0063             static const double FYC = 0.49931;
0064 
0065             template <typename T, typename Parameters>
0066             struct base_boggs_spheroid
0067             {
0068                 // FORWARD(s_forward)  spheroid
0069                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0070                 inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
0071                 {
0072                     static const T half_pi = detail::half_pi<T>();
0073                     static const T pi = detail::pi<T>();
0074                     static const T root_two = boost::math::constants::root_two<T>();
0075 
0076                     T theta, th1, c;
0077                     int i;
0078 
0079                     theta = lp_lat;
0080                     if (fabs(fabs(lp_lat) - half_pi) < epsilon)
0081                         xy_x = 0.;
0082                     else {
0083                         c = sin(theta) * pi;
0084                         for (i = n_iter; i; --i) {
0085                             theta -= th1 = (theta + sin(theta) - c) /
0086                                 (1. + cos(theta));
0087                             if (fabs(th1) < epsilon) break;
0088                         }
0089                         theta *= 0.5;
0090                         xy_x = FXC * lp_lon / (1. / cos(lp_lat) + FXC2 / cos(theta));
0091                     }
0092                     xy_y = FYC * (lp_lat + root_two * sin(theta));
0093                 }
0094 
0095                 static inline std::string get_name()
0096                 {
0097                     return "boggs_spheroid";
0098                 }
0099 
0100             };
0101 
0102             // Boggs Eumorphic
0103             template <typename Parameters>
0104             inline void setup_boggs(Parameters& par)
0105             {
0106                 par.es = 0.;
0107             }
0108 
0109     }} // namespace detail::boggs
0110     #endif // doxygen
0111 
0112     /*!
0113         \brief Boggs Eumorphic projection
0114         \ingroup projections
0115         \tparam Geographic latlong point type
0116         \tparam Cartesian xy point type
0117         \tparam Parameters parameter type
0118         \par Projection characteristics
0119          - Pseudocylindrical
0120          - no inverse
0121          - Spheroid
0122         \par Example
0123         \image html ex_boggs.gif
0124     */
0125     template <typename T, typename Parameters>
0126     struct boggs_spheroid : public detail::boggs::base_boggs_spheroid<T, Parameters>
0127     {
0128         template <typename Params>
0129         inline boggs_spheroid(Params const& , Parameters & par)
0130         {
0131             detail::boggs::setup_boggs(par);
0132         }
0133     };
0134 
0135     #ifndef DOXYGEN_NO_DETAIL
0136     namespace detail
0137     {
0138 
0139         // Static projection
0140         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_boggs, boggs_spheroid)
0141 
0142         // Factory entry(s)
0143         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(boggs_entry, boggs_spheroid)
0144 
0145         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(boggs_init)
0146         {
0147             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(boggs, boggs_entry);
0148         }
0149 
0150     } // namespace detail
0151     #endif // doxygen
0152 
0153 } // namespace projections
0154 
0155 }} // namespace boost::geometry
0156 
0157 #endif // BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
0158