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

« back to all changes in this revision

Viewing changes to include/ggl/projections/proj/wag3.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_WAG3_HPP
 
2
#define GGL_PROJECTIONS_WAG3_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 wag3{ 
 
49
            static const double TWOTHIRD = 0.6666666666666666666667;
 
50
 
 
51
            struct par_wag3
 
52
            {
 
53
                double C_x;
 
54
            };
 
55
 
 
56
            // template class, using CRTP to implement forward/inverse
 
57
            template <typename Geographic, typename Cartesian, typename Parameters>
 
58
            struct base_wag3_spheroid : public base_t_fi<base_wag3_spheroid<Geographic, Cartesian, Parameters>,
 
59
                     Geographic, Cartesian, Parameters>
 
60
            {
 
61
 
 
62
                 typedef double geographic_type;
 
63
                 typedef double cartesian_type;
 
64
 
 
65
                par_wag3 m_proj_parm;
 
66
 
 
67
                inline base_wag3_spheroid(const Parameters& par)
 
68
                    : base_t_fi<base_wag3_spheroid<Geographic, Cartesian, Parameters>,
 
69
                     Geographic, Cartesian, Parameters>(*this, par) {}
 
70
 
 
71
                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 
72
                {
 
73
                        xy_x = this->m_proj_parm.C_x * lp_lon * cos(TWOTHIRD * lp_lat);
 
74
                        xy_y = lp_lat;
 
75
                }
 
76
 
 
77
                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
 
78
                {
 
79
                        lp_lat = xy_y;
 
80
                        lp_lon = xy_x / (this->m_proj_parm.C_x * cos(TWOTHIRD * lp_lat));
 
81
                }
 
82
            };
 
83
 
 
84
            // Wagner III
 
85
            template <typename Parameters>
 
86
            void setup_wag3(Parameters& par, par_wag3& proj_parm)
 
87
            {
 
88
                double ts;
 
89
                ts = pj_param(par.params, "rlat_ts").f;
 
90
                proj_parm.C_x = cos(ts) / cos(2.*ts/3.);
 
91
                par.es = 0.;
 
92
                // par.inv = s_inverse;
 
93
                // par.fwd = s_forward;
 
94
            }
 
95
 
 
96
        }} // namespace detail::wag3
 
97
    #endif // doxygen 
 
98
 
 
99
    /*!
 
100
        \brief Wagner III projection
 
101
        \ingroup projections
 
102
        \tparam Geographic latlong point type
 
103
        \tparam Cartesian xy point type
 
104
        \tparam Parameters parameter type
 
105
        \par Projection characteristics
 
106
         - Pseudocylindrical
 
107
         - Spheroid
 
108
         - lat_ts=
 
109
        \par Example
 
110
        \image html ex_wag3.gif
 
111
    */
 
112
    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
 
113
    struct wag3_spheroid : public detail::wag3::base_wag3_spheroid<Geographic, Cartesian, Parameters>
 
114
    {
 
115
        inline wag3_spheroid(const Parameters& par) : detail::wag3::base_wag3_spheroid<Geographic, Cartesian, Parameters>(par)
 
116
        {
 
117
            detail::wag3::setup_wag3(this->m_par, this->m_proj_parm);
 
118
        }
 
119
    };
 
120
 
 
121
    #ifndef DOXYGEN_NO_DETAIL
 
122
    namespace detail
 
123
    {
 
124
 
 
125
        // Factory entry(s)
 
126
        template <typename Geographic, typename Cartesian, typename Parameters>
 
127
        class wag3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
 
128
        {
 
129
            public :
 
130
                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
 
131
                {
 
132
                    return new base_v_fi<wag3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
 
133
                }
 
134
        };
 
135
 
 
136
        template <typename Geographic, typename Cartesian, typename Parameters>
 
137
        inline void wag3_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
 
138
        {
 
139
            factory.add_to_factory("wag3", new wag3_entry<Geographic, Cartesian, Parameters>);
 
140
        }
 
141
 
 
142
    } // namespace detail 
 
143
    #endif // doxygen
 
144
 
 
145
}} // namespace ggl::projection
 
146
 
 
147
#endif // GGL_PROJECTIONS_WAG3_HPP
 
148