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

« back to all changes in this revision

Viewing changes to include/ggl/extensions/gis/projections/impl/adjlon.hpp

Tags: upstream-0.15.3+svn20934
ImportĀ upstreamĀ versionĀ 0.15.3+svn20934

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Generic Geometry Library - projections (based on PROJ4)
2
 
// This file is manually converted from PROJ4
3
 
 
4
 
// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
5
 
// Copyright Bruno Lalande 2008, 2009
6
 
// Use, modification and distribution is subject to the Boost Software License,
7
 
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8
 
// http://www.boost.org/LICENSE_1_0.txt)
9
 
 
10
 
// This file is converted from PROJ4, http://trac.osgeo.org/proj
11
 
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
12
 
// PROJ4 is maintained by Frank Warmerdam
13
 
// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
14
 
 
15
 
// Original copyright notice:
16
 
 
17
 
// Permission is hereby granted, free of charge, to any person obtaining a
18
 
// copy of this software and associated documentation files (the "Software"),
19
 
// to deal in the Software without restriction, including without limitation
20
 
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
21
 
// and/or sell copies of the Software, and to permit persons to whom the
22
 
// Software is furnished to do so, subject to the following conditions:
23
 
 
24
 
// The above copyright notice and this permission notice shall be included
25
 
// in all copies or substantial portions of the Software.
26
 
 
27
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
28
 
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30
 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32
 
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33
 
// DEALINGS IN THE SOFTWARE.
34
 
 
35
 
#ifndef GGL_PROJECTIONS_IMPL_ADJLON_HPP
36
 
#define GGL_PROJECTIONS_IMPL_ADJLON_HPP
37
 
 
38
 
#include <cmath>
39
 
 
40
 
#include <ggl/extensions/gis/projections/impl/projects.hpp>
41
 
 
42
 
namespace ggl { namespace projection { namespace detail {
43
 
 
44
 
/* reduce argument to range +/- PI */
45
 
inline double adjlon (double lon)
46
 
{
47
 
    static const double SPI = 3.14159265359;
48
 
    static const double TWOPI = 6.2831853071795864769;
49
 
    static const double ONEPI = 3.14159265358979323846;
50
 
 
51
 
    if (std::fabs(lon) <= SPI)
52
 
    {
53
 
        return lon;
54
 
    }
55
 
 
56
 
    lon += ONEPI;  /* adjust to 0..2pi rad */
57
 
    lon -= TWOPI * std::floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
58
 
    lon -= ONEPI;  /* adjust back to -pi..pi rad */
59
 
 
60
 
    return lon;
61
 
}
62
 
 
63
 
}}} // namespace ggl::projection::impl
64
 
 
65
 
#endif // GGL_PROJECTIONS_IMPL_ADJLON_HPP