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_URMFPS_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
0042 
0043 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
0044 #include <boost/geometry/srs/projections/impl/base_static.hpp>
0045 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
0046 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0047 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
0048 #include <boost/geometry/srs/projections/impl/projects.hpp>
0049 
0050 namespace boost { namespace geometry
0051 {
0052 
0053 namespace projections
0054 {
0055     #ifndef DOXYGEN_NO_DETAIL
0056     namespace detail { namespace urmfps
0057     {
0058 
0059             static const double C_x = 0.8773826753;
0060             static const double Cy = 1.139753528477;
0061 
0062             template <typename T>
0063             struct par_urmfps
0064             {
0065                 T    n, C_y;
0066             };
0067 
0068             template <typename T, typename Parameters>
0069             struct base_urmfps_spheroid
0070             {
0071                 par_urmfps<T> m_proj_parm;
0072 
0073                 // FORWARD(s_forward)  sphere
0074                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0075                 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
0076                 {
0077                     lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat));
0078                     xy_x = C_x * lp_lon * cos(lp_lat);
0079                     xy_y = this->m_proj_parm.C_y * lp_lat;
0080                 }
0081 
0082                 // INVERSE(s_inverse)  sphere
0083                 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
0084                 inline void inv(Parameters const& , T const& xy_x, T xy_y, T& lp_lon, T& lp_lat) const
0085                 {
0086                     xy_y /= this->m_proj_parm.C_y;
0087                     lp_lat = aasin(sin(xy_y) / this->m_proj_parm.n);
0088                     lp_lon = xy_x / (C_x * cos(xy_y));
0089                 }
0090 
0091                 static inline std::string get_name()
0092                 {
0093                     return "urmfps_spheroid";
0094                 }
0095 
0096             };
0097 
0098             template <typename Parameters, typename T>
0099             inline void setup(Parameters& par, par_urmfps<T>& proj_parm)
0100             {
0101                 proj_parm.C_y = Cy / proj_parm.n;
0102                 par.es = 0.;
0103             }
0104 
0105 
0106             // Urmaev Flat-Polar Sinusoidal
0107             template <typename Params, typename Parameters, typename T>
0108             inline void setup_urmfps(Params const& params, Parameters& par, par_urmfps<T>& proj_parm)
0109             {
0110                 if (pj_param_f<srs::spar::n>(params, "n", srs::dpar::n, proj_parm.n)) {
0111                     if (proj_parm.n <= 0. || proj_parm.n > 1.)
0112                         BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
0113                 } else
0114                     BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
0115 
0116                 setup(par, proj_parm);
0117             }
0118 
0119             // Wagner I (Kavraisky VI)
0120             template <typename Parameters, typename T>
0121             inline void setup_wag1(Parameters& par, par_urmfps<T>& proj_parm)
0122             {
0123                 proj_parm.n = 0.8660254037844386467637231707;
0124                 setup(par, proj_parm);
0125             }
0126 
0127     }} // namespace detail::urmfps
0128     #endif // doxygen
0129 
0130     /*!
0131         \brief Urmaev Flat-Polar Sinusoidal projection
0132         \ingroup projections
0133         \tparam Geographic latlong point type
0134         \tparam Cartesian xy point type
0135         \tparam Parameters parameter type
0136         \par Projection characteristics
0137          - Pseudocylindrical
0138          - Spheroid
0139         \par Projection parameters
0140          - n (real)
0141         \par Example
0142         \image html ex_urmfps.gif
0143     */
0144     template <typename T, typename Parameters>
0145     struct urmfps_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters>
0146     {
0147         template <typename Params>
0148         inline urmfps_spheroid(Params const& params, Parameters & par)
0149         {
0150             detail::urmfps::setup_urmfps(params, par, this->m_proj_parm);
0151         }
0152     };
0153 
0154     /*!
0155         \brief Wagner I (Kavraisky VI) projection
0156         \ingroup projections
0157         \tparam Geographic latlong point type
0158         \tparam Cartesian xy point type
0159         \tparam Parameters parameter type
0160         \par Projection characteristics
0161          - Pseudocylindrical
0162          - Spheroid
0163         \par Example
0164         \image html ex_wag1.gif
0165     */
0166     template <typename T, typename Parameters>
0167     struct wag1_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters>
0168     {
0169         template <typename Params>
0170         inline wag1_spheroid(Params const& , Parameters & par)
0171         {
0172             detail::urmfps::setup_wag1(par, this->m_proj_parm);
0173         }
0174     };
0175 
0176     #ifndef DOXYGEN_NO_DETAIL
0177     namespace detail
0178     {
0179 
0180         // Static projection
0181         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_urmfps, urmfps_spheroid)
0182         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_wag1, wag1_spheroid)
0183 
0184         // Factory entry(s)
0185         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(urmfps_entry, urmfps_spheroid)
0186         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(wag1_entry, wag1_spheroid)
0187 
0188         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(urmfps_init)
0189         {
0190             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(urmfps, urmfps_entry)
0191             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wag1, wag1_entry)
0192         }
0193 
0194     } // namespace detail
0195     #endif // doxygen
0196 
0197 } // namespace projections
0198 
0199 }} // namespace boost::geometry
0200 
0201 #endif // BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
0202