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_MBTFPP_HPP
41 #define BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
43 #include <boost/geometry/util/math.hpp>
45 #include <boost/geometry/srs/projections/impl/base_static.hpp>
46 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
47 #include <boost/geometry/srs/projections/impl/projects.hpp>
48 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
50 namespace boost { namespace geometry
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace mbtfpp
59 static const double CS_ = .95257934441568037152;
60 static const double FXC = .92582009977255146156;
61 static const double FYC = 3.40168025708304504493;
62 //static const double C23 = .66666666666666666666;
63 //static const double C13 = .33333333333333333333;
64 static const double one_plus_eps = 1.0000001;
66 template <typename T, typename Parameters>
67 struct base_mbtfpp_spheroid
69 // FORWARD(s_forward) spheroid
70 // Project coordinates from geographic (lon, lat) to cartesian (x, y)
71 inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const
73 static const T C23 = detail::two_thirds<T>();
74 static const T C13 = detail::third<T>();
76 lp_lat = asin(CS_ * sin(lp_lat));
77 xy_x = FXC * lp_lon * (2. * cos(C23 * lp_lat) - 1.);
78 xy_y = FYC * sin(C13 * lp_lat);
81 // INVERSE(s_inverse) spheroid
82 // Project coordinates from cartesian (x, y) to geographic (lon, lat)
83 inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
85 static const T half_pi = detail::half_pi<T>();
86 static const T C23 = detail::two_thirds<T>();
89 if (fabs(lp_lat) >= 1.) {
90 if (fabs(lp_lat) > one_plus_eps) {
91 BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
93 lp_lat = (lp_lat < 0.) ? -half_pi : half_pi;
96 lp_lat = asin(lp_lat);
98 lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) );
99 if (fabs(lp_lat = sin(lp_lat) / CS_) >= 1.) {
100 if (fabs(lp_lat) > one_plus_eps) {
101 BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
103 lp_lat = (lp_lat < 0.) ? -half_pi : half_pi;
106 lp_lat = asin(lp_lat);
109 static inline std::string get_name()
111 return "mbtfpp_spheroid";
116 // McBride-Thomas Flat-Polar Parabolic
117 template <typename Parameters>
118 inline void setup_mbtfpp(Parameters& par)
123 }} // namespace detail::mbtfpp
127 \brief McBride-Thomas Flat-Polar Parabolic projection
129 \tparam Geographic latlong point type
130 \tparam Cartesian xy point type
131 \tparam Parameters parameter type
132 \par Projection characteristics
136 \image html ex_mbtfpp.gif
138 template <typename T, typename Parameters>
139 struct mbtfpp_spheroid : public detail::mbtfpp::base_mbtfpp_spheroid<T, Parameters>
141 template <typename Params>
142 inline mbtfpp_spheroid(Params const& , Parameters & par)
144 detail::mbtfpp::setup_mbtfpp(par);
148 #ifndef DOXYGEN_NO_DETAIL
153 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_mbtfpp, mbtfpp_spheroid)
156 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(mbtfpp_entry, mbtfpp_spheroid)
158 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(mbtfpp_init)
160 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(mbtfpp, mbtfpp_entry)
163 } // namespace detail
166 } // namespace projections
168 }} // namespace boost::geometry
170 #endif // BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP