1
#ifndef GGL_PROJECTIONS_MBTFPQ_HPP
2
#define GGL_PROJECTIONS_MBTFPQ_HPP
4
// Generic Geometry Library - projections (based on PROJ4)
5
// This file is automatically generated. DO NOT EDIT.
7
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
8
// Copyright Bruno Lalande (2008-2009)
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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
18
// Original copyright notice:
20
// Permission is hereby granted, free of charge, to any person obtaining a
21
// copy of this software and associated documentation files (the "Software"),
22
// to deal in the Software without restriction, including without limitation
23
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
24
// and/or sell copies of the Software, and to permit persons to whom the
25
// Software is furnished to do so, subject to the following conditions:
27
// The above copyright notice and this permission notice shall be included
28
// in all copies or substantial portions of the Software.
30
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
33
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
36
// DEALINGS IN THE SOFTWARE.
38
#include <boost/math/special_functions/hypot.hpp>
40
#include <ggl/projections/impl/base_static.hpp>
41
#include <ggl/projections/impl/base_dynamic.hpp>
42
#include <ggl/projections/impl/projects.hpp>
43
#include <ggl/projections/impl/factory_entry.hpp>
45
namespace ggl { namespace projection
47
#ifndef DOXYGEN_NO_DETAIL
48
namespace detail { namespace mbtfpq{
49
static const int NITER = 20;
50
static const double EPS = 1e-7;
51
static const double ONETOL = 1.000001;
52
static const double C = 1.70710678118654752440;
53
static const double RC = 0.58578643762690495119;
54
static const double FYC = 1.87475828462269495505;
55
static const double RYC = 0.53340209679417701685;
56
static const double FXC = 0.31245971410378249250;
57
static const double RXC = 3.20041258076506210122;
60
// template class, using CRTP to implement forward/inverse
61
template <typename Geographic, typename Cartesian, typename Parameters>
62
struct base_mbtfpq_spheroid : public base_t_fi<base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>,
63
Geographic, Cartesian, Parameters>
66
typedef double geographic_type;
67
typedef double cartesian_type;
70
inline base_mbtfpq_spheroid(const Parameters& par)
71
: base_t_fi<base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>,
72
Geographic, Cartesian, Parameters>(*this, par) {}
74
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
80
for (i = NITER; i; --i) {
81
lp_lat -= th1 = (sin(.5*lp_lat) + sin(lp_lat) - c) /
82
(.5*cos(.5*lp_lat) + cos(lp_lat));
83
if (fabs(th1) < EPS) break;
85
xy_x = FXC * lp_lon * (1.0 + 2. * cos(lp_lat)/cos(0.5 * lp_lat));
86
xy_y = FYC * sin(0.5 * lp_lat);
89
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
94
if (fabs(lp_lat) > 1.) {
95
if (fabs(lp_lat) > ONETOL) throw proj_exception();
96
else if (lp_lat < 0.) { t = -1.; lp_lat = -PI; }
97
else { t = 1.; lp_lat = PI; }
99
lp_lat = 2. * asin(t = lp_lat);
100
lp_lon = RXC * xy_x / (1. + 2. * cos(lp_lat)/cos(0.5 * lp_lat));
101
lp_lat = RC * (t + sin(lp_lat));
102
if (fabs(lp_lat) > 1.)
103
if (fabs(lp_lat) > ONETOL) throw proj_exception();
104
else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
106
lp_lat = asin(lp_lat);
110
// McBryde-Thomas Flat-Polar Quartic
111
template <typename Parameters>
112
void setup_mbtfpq(Parameters& par)
115
// par.inv = s_inverse;
116
// par.fwd = s_forward;
119
}} // namespace detail::mbtfpq
123
\brief McBryde-Thomas Flat-Polar Quartic projection
125
\tparam Geographic latlong point type
126
\tparam Cartesian xy point type
127
\tparam Parameters parameter type
128
\par Projection characteristics
132
\image html ex_mbtfpq.gif
134
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
135
struct mbtfpq_spheroid : public detail::mbtfpq::base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>
137
inline mbtfpq_spheroid(const Parameters& par) : detail::mbtfpq::base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>(par)
139
detail::mbtfpq::setup_mbtfpq(this->m_par);
143
#ifndef DOXYGEN_NO_DETAIL
148
template <typename Geographic, typename Cartesian, typename Parameters>
149
class mbtfpq_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
152
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
154
return new base_v_fi<mbtfpq_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
158
template <typename Geographic, typename Cartesian, typename Parameters>
159
inline void mbtfpq_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
161
factory.add_to_factory("mbtfpq", new mbtfpq_entry<Geographic, Cartesian, Parameters>);
164
} // namespace detail
167
}} // namespace ggl::projection
169
#endif // GGL_PROJECTIONS_MBTFPQ_HPP