]>
Commit | Line | Data |
---|---|---|
92f5a8d4 | 1 | // Boost.Geometry - gis-projections (based on PROJ4) |
11fdf7f2 TL |
2 | |
3 | // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | ||
92f5a8d4 TL |
5 | // This file was modified by Oracle on 2017, 2018, 2019. |
6 | // Modifications copyright (c) 2017-2019, Oracle and/or its affiliates. | |
11fdf7f2 TL |
7 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle. |
8 | ||
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) | |
12 | ||
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 | |
17 | ||
92f5a8d4 | 18 | // Last updated version of proj: 5.0.0 |
11fdf7f2 TL |
19 | |
20 | // Original copyright notice: | |
21 | ||
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: | |
28 | ||
29 | // The above copyright notice and this permission notice shall be included | |
30 | // in all copies or substantial portions of the Software. | |
31 | ||
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. | |
39 | ||
92f5a8d4 TL |
40 | #ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP |
41 | #define BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP | |
42 | ||
11fdf7f2 TL |
43 | #include <boost/geometry/util/math.hpp> |
44 | ||
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> | |
49 | ||
50 | namespace boost { namespace geometry | |
51 | { | |
52 | ||
11fdf7f2 TL |
53 | namespace projections |
54 | { | |
55 | #ifndef DOXYGEN_NO_DETAIL | |
56 | namespace detail { namespace mbtfpp | |
57 | { | |
58 | ||
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; | |
92f5a8d4 | 64 | static const double one_plus_eps = 1.0000001; |
11fdf7f2 | 65 | |
92f5a8d4 TL |
66 | template <typename T, typename Parameters> |
67 | struct base_mbtfpp_spheroid | |
11fdf7f2 | 68 | { |
11fdf7f2 TL |
69 | // FORWARD(s_forward) spheroid |
70 | // Project coordinates from geographic (lon, lat) to cartesian (x, y) | |
92f5a8d4 | 71 | inline void fwd(Parameters const& , T const& lp_lon, T lp_lat, T& xy_x, T& xy_y) const |
11fdf7f2 | 72 | { |
92f5a8d4 TL |
73 | static const T C23 = detail::two_thirds<T>(); |
74 | static const T C13 = detail::third<T>(); | |
11fdf7f2 TL |
75 | |
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); | |
79 | } | |
80 | ||
81 | // INVERSE(s_inverse) spheroid | |
82 | // Project coordinates from cartesian (x, y) to geographic (lon, lat) | |
92f5a8d4 | 83 | inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const |
11fdf7f2 | 84 | { |
92f5a8d4 TL |
85 | static const T half_pi = detail::half_pi<T>(); |
86 | static const T C23 = detail::two_thirds<T>(); | |
11fdf7f2 TL |
87 | |
88 | lp_lat = xy_y / FYC; | |
89 | if (fabs(lp_lat) >= 1.) { | |
92f5a8d4 TL |
90 | if (fabs(lp_lat) > one_plus_eps) { |
91 | BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); | |
92 | } else { | |
93 | lp_lat = (lp_lat < 0.) ? -half_pi : half_pi; | |
94 | } | |
11fdf7f2 TL |
95 | } else |
96 | lp_lat = asin(lp_lat); | |
92f5a8d4 | 97 | |
11fdf7f2 TL |
98 | lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) ); |
99 | if (fabs(lp_lat = sin(lp_lat) / CS_) >= 1.) { | |
92f5a8d4 TL |
100 | if (fabs(lp_lat) > one_plus_eps) { |
101 | BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); | |
102 | } else { | |
103 | lp_lat = (lp_lat < 0.) ? -half_pi : half_pi; | |
104 | } | |
11fdf7f2 TL |
105 | } else |
106 | lp_lat = asin(lp_lat); | |
107 | } | |
108 | ||
109 | static inline std::string get_name() | |
110 | { | |
111 | return "mbtfpp_spheroid"; | |
112 | } | |
113 | ||
114 | }; | |
115 | ||
116 | // McBride-Thomas Flat-Polar Parabolic | |
117 | template <typename Parameters> | |
118 | inline void setup_mbtfpp(Parameters& par) | |
119 | { | |
120 | par.es = 0.; | |
121 | } | |
122 | ||
123 | }} // namespace detail::mbtfpp | |
124 | #endif // doxygen | |
125 | ||
126 | /*! | |
127 | \brief McBride-Thomas Flat-Polar Parabolic projection | |
128 | \ingroup projections | |
129 | \tparam Geographic latlong point type | |
130 | \tparam Cartesian xy point type | |
131 | \tparam Parameters parameter type | |
132 | \par Projection characteristics | |
133 | - Cylindrical | |
134 | - Spheroid | |
135 | \par Example | |
136 | \image html ex_mbtfpp.gif | |
137 | */ | |
92f5a8d4 TL |
138 | template <typename T, typename Parameters> |
139 | struct mbtfpp_spheroid : public detail::mbtfpp::base_mbtfpp_spheroid<T, Parameters> | |
11fdf7f2 | 140 | { |
92f5a8d4 TL |
141 | template <typename Params> |
142 | inline mbtfpp_spheroid(Params const& , Parameters & par) | |
11fdf7f2 | 143 | { |
92f5a8d4 | 144 | detail::mbtfpp::setup_mbtfpp(par); |
11fdf7f2 TL |
145 | } |
146 | }; | |
147 | ||
148 | #ifndef DOXYGEN_NO_DETAIL | |
149 | namespace detail | |
150 | { | |
151 | ||
152 | // Static projection | |
92f5a8d4 | 153 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(srs::spar::proj_mbtfpp, mbtfpp_spheroid) |
11fdf7f2 TL |
154 | |
155 | // Factory entry(s) | |
92f5a8d4 TL |
156 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(mbtfpp_entry, mbtfpp_spheroid) |
157 | ||
158 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(mbtfpp_init) | |
11fdf7f2 | 159 | { |
92f5a8d4 | 160 | BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(mbtfpp, mbtfpp_entry) |
11fdf7f2 TL |
161 | } |
162 | ||
163 | } // namespace detail | |
164 | #endif // doxygen | |
165 | ||
166 | } // namespace projections | |
167 | ||
168 | }} // namespace boost::geometry | |
169 | ||
170 | #endif // BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP | |
171 |