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

« back to all changes in this revision

Viewing changes to include/ggl/projections/proj/sterea.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_STEREA_HPP
 
2
#define GGL_PROJECTIONS_STEREA_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
#include <ggl/projections/impl/pj_gauss.hpp>
 
45
 
 
46
#include <ggl/projections/epsg_traits.hpp>
 
47
 
 
48
namespace ggl { namespace projection
 
49
{
 
50
    #ifndef DOXYGEN_NO_DETAIL
 
51
    namespace detail { namespace sterea{
 
52
            static const double DEL_TOL = 1.e-14;
 
53
            static const int MAX_ITER = 10;
 
54
 
 
55
            struct par_sterea
 
56
            {
 
57
                double phic0;
 
58
                double cosc0, sinc0;
 
59
                double R2;
 
60
                gauss::GAUSS en;
 
61
            };
 
62
 
 
63
 
 
64
 
 
65
 
 
66
            // template class, using CRTP to implement forward/inverse
 
67
            template <typename Geographic, typename Cartesian, typename Parameters>
 
68
            struct base_sterea_ellipsoid : public base_t_fi<base_sterea_ellipsoid<Geographic, Cartesian, Parameters>,
 
69
                     Geographic, Cartesian, Parameters>
 
70
            {
 
71
 
 
72
                 typedef double geographic_type;
 
73
                 typedef double cartesian_type;
 
74
 
 
75
                par_sterea m_proj_parm;
 
76
 
 
77
                inline base_sterea_ellipsoid(const Parameters& par)
 
78
                    : base_t_fi<base_sterea_ellipsoid<Geographic, Cartesian, Parameters>,
 
79
                     Geographic, Cartesian, Parameters>(*this, par) {}
 
80
 
 
81
                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 
82
                {
 
83
                    double cosc, sinc, cosl, k;
 
84
 
 
85
                    detail::gauss::gauss(m_proj_parm.en, lp_lon, lp_lat);
 
86
                    sinc = sin(lp_lat);
 
87
                    cosc = cos(lp_lat);
 
88
                    cosl = cos(lp_lon);
 
89
                    k = this->m_par.k0 * this->m_proj_parm.R2 / (1. + this->m_proj_parm.sinc0 * sinc + this->m_proj_parm.cosc0 * cosc * cosl);
 
90
                    xy_x = k * cosc * sin(lp_lon);
 
91
                    xy_y = k * (this->m_proj_parm.cosc0 * sinc - this->m_proj_parm.sinc0 * cosc * cosl);
 
92
                }
 
93
 
 
94
                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
 
95
                {
 
96
                    double rho, c, sinc, cosc;
 
97
 
 
98
                    xy_x /= this->m_par.k0;
 
99
                    xy_y /= this->m_par.k0;
 
100
                    if((rho = boost::math::hypot(xy_x, xy_y))) {
 
101
                        c = 2. * atan2(rho, this->m_proj_parm.R2);
 
102
                        sinc = sin(c);
 
103
                        cosc = cos(c);
 
104
                        lp_lat = asin(cosc * this->m_proj_parm.sinc0 + xy_y * sinc * this->m_proj_parm.cosc0 / rho);
 
105
                        lp_lon = atan2(xy_x * sinc, rho * this->m_proj_parm.cosc0 * cosc -
 
106
                            xy_y * this->m_proj_parm.sinc0 * sinc);
 
107
                    } else {
 
108
                        lp_lat = this->m_proj_parm.phic0;
 
109
                        lp_lon = 0.;
 
110
                    }
 
111
                    detail::gauss::inv_gauss(m_proj_parm.en, lp_lon, lp_lat);
 
112
                }
 
113
            };
 
114
 
 
115
            // Oblique Stereographic Alternative
 
116
            template <typename Parameters>
 
117
            void setup_sterea(Parameters& par, par_sterea& proj_parm)
 
118
            {
 
119
                double R;
 
120
                proj_parm.en = detail::gauss::gauss_ini(par.e, par.phi0, proj_parm.phic0, R);
 
121
                proj_parm.sinc0 = sin(proj_parm.phic0);
 
122
                proj_parm.cosc0 = cos(proj_parm.phic0);
 
123
                proj_parm.R2 = 2. * R;
 
124
                // par.inv = e_inverse;
 
125
                // par.fwd = e_forward;
 
126
            }
 
127
 
 
128
        }} // namespace detail::sterea
 
129
    #endif // doxygen
 
130
 
 
131
    /*!
 
132
        \brief Oblique Stereographic Alternative projection
 
133
        \ingroup projections
 
134
        \tparam Geographic latlong point type
 
135
        \tparam Cartesian xy point type
 
136
        \tparam Parameters parameter type
 
137
        \par Projection characteristics
 
138
         - Azimuthal
 
139
         - Spheroid
 
140
         - Ellipsoid
 
141
        \par Example
 
142
        \image html ex_sterea.gif
 
143
    */
 
144
    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
 
145
    struct sterea_ellipsoid : public detail::sterea::base_sterea_ellipsoid<Geographic, Cartesian, Parameters>
 
146
    {
 
147
        inline sterea_ellipsoid(const Parameters& par) : detail::sterea::base_sterea_ellipsoid<Geographic, Cartesian, Parameters>(par)
 
148
        {
 
149
            detail::sterea::setup_sterea(this->m_par, this->m_proj_parm);
 
150
        }
 
151
    };
 
152
 
 
153
    #ifndef DOXYGEN_NO_DETAIL
 
154
    namespace detail
 
155
    {
 
156
 
 
157
        // Factory entry(s)
 
158
        template <typename Geographic, typename Cartesian, typename Parameters>
 
159
        class sterea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
 
160
        {
 
161
            public :
 
162
                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
 
163
                {
 
164
                    return new base_v_fi<sterea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
 
165
                }
 
166
        };
 
167
 
 
168
        template <typename Geographic, typename Cartesian, typename Parameters>
 
169
        inline void sterea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
 
170
        {
 
171
            factory.add_to_factory("sterea", new sterea_entry<Geographic, Cartesian, Parameters>);
 
172
        }
 
173
 
 
174
    } // namespace detail
 
175
    // Create EPSG specializations
 
176
    // (Proof of Concept, only for some)
 
177
 
 
178
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
179
    struct epsg_traits<2036, LatLongRadian, Cartesian, Parameters>
 
180
    {
 
181
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
182
        static inline std::string par()
 
183
        {
 
184
            return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=2500000 +y_0=7500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
 
185
        }
 
186
    };
 
187
 
 
188
 
 
189
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
190
    struct epsg_traits<2171, LatLongRadian, Cartesian, Parameters>
 
191
    {
 
192
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
193
        static inline std::string par()
 
194
        {
 
195
            return "+proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5647000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
 
196
        }
 
197
    };
 
198
 
 
199
 
 
200
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
201
    struct epsg_traits<2172, LatLongRadian, Cartesian, Parameters>
 
202
    {
 
203
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
204
        static inline std::string par()
 
205
        {
 
206
            return "+proj=sterea +lat_0=53.00194444444445 +lon_0=21.50277777777778 +k=0.9998 +x_0=4603000 +y_0=5806000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
 
207
        }
 
208
    };
 
209
 
 
210
 
 
211
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
212
    struct epsg_traits<2173, LatLongRadian, Cartesian, Parameters>
 
213
    {
 
214
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
215
        static inline std::string par()
 
216
        {
 
217
            return "+proj=sterea +lat_0=53.58333333333334 +lon_0=17.00833333333333 +k=0.9998 +x_0=3501000 +y_0=5999000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
 
218
        }
 
219
    };
 
220
 
 
221
 
 
222
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
223
    struct epsg_traits<2174, LatLongRadian, Cartesian, Parameters>
 
224
    {
 
225
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
226
        static inline std::string par()
 
227
        {
 
228
            return "+proj=sterea +lat_0=51.67083333333333 +lon_0=16.67222222222222 +k=0.9998 +x_0=3703000 +y_0=5627000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
 
229
        }
 
230
    };
 
231
 
 
232
 
 
233
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
234
    struct epsg_traits<2200, LatLongRadian, Cartesian, Parameters>
 
235
    {
 
236
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
237
        static inline std::string par()
 
238
        {
 
239
            return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=300000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m";
 
240
        }
 
241
    };
 
242
 
 
243
 
 
244
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
245
    struct epsg_traits<2290, LatLongRadian, Cartesian, Parameters>
 
246
    {
 
247
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
248
        static inline std::string par()
 
249
        {
 
250
            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=700000 +y_0=400000 +a=6378135 +b=6356750.304921594 +units=m";
 
251
        }
 
252
    };
 
253
 
 
254
 
 
255
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
256
    struct epsg_traits<2291, LatLongRadian, Cartesian, Parameters>
 
257
    {
 
258
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
259
        static inline std::string par()
 
260
        {
 
261
            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m";
 
262
        }
 
263
    };
 
264
 
 
265
 
 
266
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
267
    struct epsg_traits<2292, LatLongRadian, Cartesian, Parameters>
 
268
    {
 
269
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
270
        static inline std::string par()
 
271
        {
 
272
            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
 
273
        }
 
274
    };
 
275
 
 
276
 
 
277
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
278
    struct epsg_traits<2953, LatLongRadian, Cartesian, Parameters>
 
279
    {
 
280
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
281
        static inline std::string par()
 
282
        {
 
283
            return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=2500000 +y_0=7500000 +ellps=GRS80 +units=m";
 
284
        }
 
285
    };
 
286
 
 
287
 
 
288
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
289
    struct epsg_traits<2954, LatLongRadian, Cartesian, Parameters>
 
290
    {
 
291
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
292
        static inline std::string par()
 
293
        {
 
294
            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +units=m";
 
295
        }
 
296
    };
 
297
 
 
298
 
 
299
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
300
    struct epsg_traits<3120, LatLongRadian, Cartesian, Parameters>
 
301
    {
 
302
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
303
        static inline std::string par()
 
304
        {
 
305
            return "+proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5467000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
 
306
        }
 
307
    };
 
308
 
 
309
 
 
310
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
311
    struct epsg_traits<3328, LatLongRadian, Cartesian, Parameters>
 
312
    {
 
313
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
314
        static inline std::string par()
 
315
        {
 
316
            return "+proj=sterea +lat_0=52.16666666666666 +lon_0=19.16666666666667 +k=0.999714 +x_0=500000 +y_0=500000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
 
317
        }
 
318
    };
 
319
 
 
320
 
 
321
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
322
    struct epsg_traits<22780, LatLongRadian, Cartesian, Parameters>
 
323
    {
 
324
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
325
        static inline std::string par()
 
326
        {
 
327
            return "+proj=sterea +lat_0=34.2 +lon_0=39.15 +k=0.9995341 +x_0=0 +y_0=0 +a=6378249.2 +b=6356515 +units=m";
 
328
        }
 
329
    };
 
330
 
 
331
 
 
332
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
333
    struct epsg_traits<28991, LatLongRadian, Cartesian, Parameters>
 
334
    {
 
335
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
336
        static inline std::string par()
 
337
        {
 
338
            return "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=0 +y_0=0 +ellps=bessel +units=m";
 
339
        }
 
340
    };
 
341
 
 
342
 
 
343
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
344
    struct epsg_traits<28992, LatLongRadian, Cartesian, Parameters>
 
345
    {
 
346
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
347
        static inline std::string par()
 
348
        {
 
349
            return "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m";
 
350
        }
 
351
    };
 
352
 
 
353
 
 
354
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
355
    struct epsg_traits<31600, LatLongRadian, Cartesian, Parameters>
 
356
    {
 
357
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
358
        static inline std::string par()
 
359
        {
 
360
            return "+proj=sterea +lat_0=45.9 +lon_0=25.39246588888889 +k=0.9996667 +x_0=500000 +y_0=500000 +ellps=intl +units=m";
 
361
        }
 
362
    };
 
363
 
 
364
 
 
365
    template<typename LatLongRadian, typename Cartesian, typename Parameters>
 
366
    struct epsg_traits<31700, LatLongRadian, Cartesian, Parameters>
 
367
    {
 
368
        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
 
369
        static inline std::string par()
 
370
        {
 
371
            return "+proj=sterea +lat_0=46 +lon_0=25 +k=0.99975 +x_0=500000 +y_0=500000 +ellps=krass +units=m";
 
372
        }
 
373
    };
 
374
 
 
375
 
 
376
    #endif // doxygen
 
377
 
 
378
}} // namespace ggl::projection
 
379
 
 
380
#endif // GGL_PROJECTIONS_STEREA_HPP
 
381