~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to include/ggl/projections/proj/wink2.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef GGL_PROJECTIONS_WINK2_HPP
 
2
#define GGL_PROJECTIONS_WINK2_HPP
 
3
 
 
4
// Generic Geometry Library - projections (based on PROJ4)
 
5
// This file is automatically generated. DO NOT EDIT.
 
6
 
 
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)
 
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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
 
17
 
 
18
// Original copyright notice:
 
19
 
 
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:
 
26
 
 
27
// The above copyright notice and this permission notice shall be included
 
28
// in all copies or substantial portions of the Software.
 
29
 
 
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.
 
37
 
 
38
#include <boost/math/special_functions/hypot.hpp>
 
39
 
 
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>
 
44
 
 
45
namespace ggl { namespace projection
 
46
{
 
47
    #ifndef DOXYGEN_NO_DETAIL
 
48
    namespace detail { namespace wink2{ 
 
49
            static const int MAX_ITER = 10;
 
50
            static const double LOOP_TOL = 1e-7;
 
51
            static const double TWO_D_PI = 0.636619772367581343;
 
52
 
 
53
            struct par_wink2
 
54
            {
 
55
                double cosphi1;
 
56
            };
 
57
 
 
58
            // template class, using CRTP to implement forward/inverse
 
59
            template <typename Geographic, typename Cartesian, typename Parameters>
 
60
            struct base_wink2_spheroid : public base_t_f<base_wink2_spheroid<Geographic, Cartesian, Parameters>,
 
61
                     Geographic, Cartesian, Parameters>
 
62
            {
 
63
 
 
64
                 typedef double geographic_type;
 
65
                 typedef double cartesian_type;
 
66
 
 
67
                par_wink2 m_proj_parm;
 
68
 
 
69
                inline base_wink2_spheroid(const Parameters& par)
 
70
                    : base_t_f<base_wink2_spheroid<Geographic, Cartesian, Parameters>,
 
71
                     Geographic, Cartesian, Parameters>(*this, par) {}
 
72
 
 
73
                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 
74
                {
 
75
                        double k, V;
 
76
                        int i;
 
77
                
 
78
                        xy_y = lp_lat * TWO_D_PI;
 
79
                        k = PI * sin(lp_lat);
 
80
                        lp_lat *= 1.8;
 
81
                        for (i = MAX_ITER; i ; --i) {
 
82
                                lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
 
83
                                        (1. + cos(lp_lat));
 
84
                                if (fabs(V) < LOOP_TOL)
 
85
                                        break;
 
86
                        }
 
87
                        if (!i)
 
88
                                lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
 
89
                        else
 
90
                                lp_lat *= 0.5;
 
91
                        xy_x = 0.5 * lp_lon * (cos(lp_lat) + this->m_proj_parm.cosphi1);
 
92
                        xy_y = FORTPI * (sin(lp_lat) + xy_y);
 
93
                }
 
94
            };
 
95
 
 
96
            // Winkel II
 
97
            template <typename Parameters>
 
98
            void setup_wink2(Parameters& par, par_wink2& proj_parm)
 
99
            {
 
100
                proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_1").f);
 
101
                par.es = 0.;
 
102
                // par.inv = 0;
 
103
                // par.fwd = s_forward;
 
104
            }
 
105
 
 
106
        }} // namespace detail::wink2
 
107
    #endif // doxygen 
 
108
 
 
109
    /*!
 
110
        \brief Winkel II projection
 
111
        \ingroup projections
 
112
        \tparam Geographic latlong point type
 
113
        \tparam Cartesian xy point type
 
114
        \tparam Parameters parameter type
 
115
        \par Projection characteristics
 
116
         - Pseudocylindrical
 
117
         - Spheroid
 
118
         - no inverse
 
119
         - lat_1=
 
120
        \par Example
 
121
        \image html ex_wink2.gif
 
122
    */
 
123
    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
 
124
    struct wink2_spheroid : public detail::wink2::base_wink2_spheroid<Geographic, Cartesian, Parameters>
 
125
    {
 
126
        inline wink2_spheroid(const Parameters& par) : detail::wink2::base_wink2_spheroid<Geographic, Cartesian, Parameters>(par)
 
127
        {
 
128
            detail::wink2::setup_wink2(this->m_par, this->m_proj_parm);
 
129
        }
 
130
    };
 
131
 
 
132
    #ifndef DOXYGEN_NO_DETAIL
 
133
    namespace detail
 
134
    {
 
135
 
 
136
        // Factory entry(s)
 
137
        template <typename Geographic, typename Cartesian, typename Parameters>
 
138
        class wink2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
 
139
        {
 
140
            public :
 
141
                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
 
142
                {
 
143
                    return new base_v_f<wink2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
 
144
                }
 
145
        };
 
146
 
 
147
        template <typename Geographic, typename Cartesian, typename Parameters>
 
148
        inline void wink2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
 
149
        {
 
150
            factory.add_to_factory("wink2", new wink2_entry<Geographic, Cartesian, Parameters>);
 
151
        }
 
152
 
 
153
    } // namespace detail 
 
154
    #endif // doxygen
 
155
 
 
156
}} // namespace ggl::projection
 
157
 
 
158
#endif // GGL_PROJECTIONS_WINK2_HPP
 
159