1 // Boost.Geometry - gis-projections (based on PROJ4)
3 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2017, 2018, 2019.
6 // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 // This file is converted from PROJ4, http://trac.osgeo.org/proj
14 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
15 // PROJ4 is maintained by Frank Warmerdam
16 // PROJ4 is converted to Boost.Geometry by Barend Gehrels
18 // Last updated version of proj: 5.0.0
20 // Original copyright notice:
22 // Permission is hereby granted, free of charge, to any person obtaining a
23 // copy of this software and associated documentation files (the "Software"),
24 // to deal in the Software without restriction, including without limitation
25 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
26 // and/or sell copies of the Software, and to permit persons to whom the
27 // Software is furnished to do so, subject to the following conditions:
29 // The above copyright notice and this permission notice shall be included
30 // in all copies or substantial portions of the Software.
32 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
33 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
35 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
38 // DEALINGS IN THE SOFTWARE.
40 #ifndef BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
43 #include <boost/geometry/srs/projections/impl/aasincos.hpp>
44 #include <boost/geometry/srs/projections/impl/base_static.hpp>
45 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
46 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
47 #include <boost/geometry/srs/projections/impl/pj_param.hpp>
48 #include <boost/geometry/srs/projections/impl/projects.hpp>
50 namespace boost { namespace geometry
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace urmfps
59 static const double C_x = 0.8773826753;
60 static const double Cy = 1.139753528477;
68 template <typename T, typename Parameters>
69 struct base_urmfps_spheroid
71 par_urmfps<T> m_proj_parm;
73 // FORWARD(s_forward) sphere
74 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
75 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
77 lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat));
78 xy_x = C_x * lp_lon * cos(lp_lat);
79 xy_y = this->m_proj_parm.C_y * lp_lat;
82 // INVERSE(s_inverse) sphere
83 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
84 inline void inv(Parameters const& , T const& xy_x, T xy_y, T& lp_lon, T& lp_lat) const
86 xy_y /= this->m_proj_parm.C_y;
87 lp_lat = aasin(sin(xy_y) / this->m_proj_parm.n);
88 lp_lon = xy_x / (C_x * cos(xy_y));
91 static inline std::string get_name()
93 return "urmfps_spheroid";
98 template <typename Parameters, typename T>
99 inline void setup(Parameters& par, par_urmfps<T>& proj_parm)
101 proj_parm.C_y = Cy / proj_parm.n;
106 // Urmaev Flat-Polar Sinusoidal
107 template <typename Params, typename Parameters, typename T>
108 inline void setup_urmfps(Params const& params, Parameters& par, par_urmfps<T>& proj_parm)
110 if (pj_param_f<srs::spar::n>(params, "n", srs::dpar::n, proj_parm.n)) {
111 if (proj_parm.n <= 0. || proj_parm.n > 1.)
112 BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
114 BOOST_THROW_EXCEPTION( projection_exception(error_n_out_of_range) );
116 setup(par, proj_parm);
119 // Wagner I (Kavraisky VI)
120 template <typename Parameters, typename T>
121 inline void setup_wag1(Parameters& par, par_urmfps<T>& proj_parm)
123 proj_parm.n = 0.8660254037844386467637231707;
124 setup(par, proj_parm);
127 }} // namespace detail::urmfps
131 \brief Urmaev Flat-Polar Sinusoidal projection
133 \tparam Geographic latlong point type
134 \tparam Cartesian xy point type
135 \tparam Parameters parameter type
136 \par Projection characteristics
139 \par Projection parameters
142 \image html ex_urmfps.gif
144 template <typename T, typename Parameters>
145 struct urmfps_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters>
147 template <typename Params>
148 inline urmfps_spheroid(Params const& params, Parameters & par)
150 detail::urmfps::setup_urmfps(params, par, this->m_proj_parm);
155 \brief Wagner I (Kavraisky VI) projection
157 \tparam Geographic latlong point type
158 \tparam Cartesian xy point type
159 \tparam Parameters parameter type
160 \par Projection characteristics
164 \image html ex_wag1.gif
166 template <typename T, typename Parameters>
167 struct wag1_spheroid : public detail::urmfps::base_urmfps_spheroid<T, Parameters>
169 template <typename Params>
170 inline wag1_spheroid(Params const& , Parameters & par)
172 detail::urmfps::setup_wag1(par, this->m_proj_parm);
176 #ifndef DOXYGEN_NO_DETAIL
181 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_urmfps, urmfps_spheroid)
182 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_wag1, wag1_spheroid)
185 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(urmfps_entry, urmfps_spheroid)
186 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(wag1_entry, wag1_spheroid)
188 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(urmfps_init)
190 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(urmfps, urmfps_entry)
191 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(wag1, wag1_entry)
194 } // namespace detail
197 } // namespace projections
199 }} // namespace boost::geometry
201 #endif // BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP