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_URM5_HPP
0041 #define BOOST_GEOMETRY_PROJECTIONS_URM5_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 urm5
0057     {
0058             template <typename T>
0059             struct par_urm5
0060             {
0061                 T m, rmn, q3, n;
0062             };
0063 
0064             template <typename T, typename Parameters>
0065             struct base_urm5_spheroid
0066             {
0067                 par_urm5<T> m_proj_parm;
0068 
0069                 // FORWARD(s_forward)  spheroid
0070                 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
0071                 inline void fwd(Parameters const&, T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
0072                 {
0073                     T t;
0074 
0075                     t = lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat));
0076                     xy_x = this->m_proj_parm.m * lp_lon * cos(lp_lat);
0077                     t *= t;
0078                     xy_y = lp_lat * (1. + t * this->m_proj_parm.q3) * this->m_proj_parm.rmn;
0079                 }
0080 
0081                 static inline std::string get_name()
0082                 {
0083                     return "urm5_spheroid";
0084                 }
0085 
0086             };
0087 
0088             // Urmaev V
0089             template <typename Params, typename Parameters, typename T>
0090             inline void setup_urm5(Params const& params, Parameters& par, par_urm5<T>& proj_parm)
0091             {
0092                 T alpha, t;
0093 
0094                 if (pj_param_f<srs::spar::n>(params, "n", srs::dpar::n, proj_parm.n)) {
0095                     if (proj_parm.n <= 0. || proj_parm.n > 1.)
0096                         BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
0097                 } else {
0098                     BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
0099                 }
0100                 proj_parm.q3 = pj_get_param_f<T, srs::spar::q>(params, "q", srs::dpar::q) / 3.;
0101                 alpha = pj_get_param_r<T, srs::spar::alpha>(params, "alpha", srs::dpar::alpha);
0102                 t = proj_parm.n * sin(alpha);
0103                 proj_parm.m = cos(alpha) / sqrt(1. - t * t);
0104                 proj_parm.rmn = 1. / (proj_parm.m * proj_parm.n);
0105 
0106                 par.es = 0.;
0107             }
0108 
0109     }} // namespace detail::urm5
0110     #endif // doxygen
0111 
0112     /*!
0113         \brief Urmaev V 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          - Spheroid
0121          - no inverse
0122         \par Projection parameters
0123          - n (real)
0124          - q (real)
0125          - alpha: Alpha (degrees)
0126         \par Example
0127         \image html ex_urm5.gif
0128     */
0129     template <typename T, typename Parameters>
0130     struct urm5_spheroid : public detail::urm5::base_urm5_spheroid<T, Parameters>
0131     {
0132         template <typename Params>
0133         inline urm5_spheroid(Params const& params, Parameters & par)
0134         {
0135             detail::urm5::setup_urm5(params, par, this->m_proj_parm);
0136         }
0137     };
0138 
0139     #ifndef DOXYGEN_NO_DETAIL
0140     namespace detail
0141     {
0142 
0143         // Static projection
0144         BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(srs::spar::proj_urm5, urm5_spheroid)
0145 
0146         // Factory entry(s)
0147         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(urm5_entry, urm5_spheroid)
0148 
0149         BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(urm5_init)
0150         {
0151             BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(urm5, urm5_entry)
0152         }
0153 
0154     } // namespace detail
0155     #endif // doxygen
0156 
0157 } // namespace projections
0158 
0159 }} // namespace boost::geometry
0160 
0161 #endif // BOOST_GEOMETRY_PROJECTIONS_URM5_HPP
0162