GeographicLib  1.43
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PolarStereographic.hpp
Go to the documentation of this file.
1 /**
2  * \file PolarStereographic.hpp
3  * \brief Header for GeographicLib::PolarStereographic class
4  *
5  * Copyright (c) Charles Karney (2008-2015) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9 
10 #if !defined(GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP)
11 #define GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP 1
12 
14 
15 namespace GeographicLib {
16 
17  /**
18  * \brief Polar stereographic projection
19  *
20  * Implementation taken from the report,
21  * - J. P. Snyder,
22  * <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projections: A
23  * Working Manual</a>, USGS Professional Paper 1395 (1987),
24  * pp. 160--163.
25  *
26  * This is a straightforward implementation of the equations in Snyder except
27  * that Newton's method is used to invert the projection.
28  *
29  * Example of use:
30  * \include example-PolarStereographic.cpp
31  **********************************************************************/
33  private:
34  typedef Math::real real;
35  real _a, _f, _e2, _es, _e2m, _c;
36  real _k0;
37  public:
38 
39  /**
40  * Constructor for a ellipsoid with
41  *
42  * @param[in] a equatorial radius (meters).
43  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
44  * Negative \e f gives a prolate ellipsoid. If \e f &gt; 1, set
45  * flattening to 1/\e f.
46  * @param[in] k0 central scale factor.
47  * @exception GeographicErr if \e a, (1 &minus; \e f) \e a, or \e k0 is
48  * not positive.
49  **********************************************************************/
50  PolarStereographic(real a, real f, real k0);
51 
52  /**
53  * Set the scale for the projection.
54  *
55  * @param[in] lat (degrees) assuming \e northp = true.
56  * @param[in] k scale at latitude \e lat (default 1).
57  * @exception GeographicErr \e k is not positive.
58  * @exception GeographicErr if \e lat is not in (&minus;90&deg;,
59  * 90&deg;].
60  **********************************************************************/
61  void SetScale(real lat, real k = real(1));
62 
63  /**
64  * Forward projection, from geographic to polar stereographic.
65  *
66  * @param[in] northp the pole which is the center of projection (true means
67  * north, false means south).
68  * @param[in] lat latitude of point (degrees).
69  * @param[in] lon longitude of point (degrees).
70  * @param[out] x easting of point (meters).
71  * @param[out] y northing of point (meters).
72  * @param[out] gamma meridian convergence at point (degrees).
73  * @param[out] k scale of projection at point.
74  *
75  * No false easting or northing is added. \e lat should be in the range
76  * (&minus;90&deg;, 90&deg;] for \e northp = true and in the range
77  * [&minus;90&deg;, 90&deg;) for \e northp = false; \e lon should
78  * be in the range [&minus;540&deg;, 540&deg;).
79  **********************************************************************/
80  void Forward(bool northp, real lat, real lon,
81  real& x, real& y, real& gamma, real& k) const;
82 
83  /**
84  * Reverse projection, from polar stereographic to geographic.
85  *
86  * @param[in] northp the pole which is the center of projection (true means
87  * north, false means south).
88  * @param[in] x easting of point (meters).
89  * @param[in] y northing of point (meters).
90  * @param[out] lat latitude of point (degrees).
91  * @param[out] lon longitude of point (degrees).
92  * @param[out] gamma meridian convergence at point (degrees).
93  * @param[out] k scale of projection at point.
94  *
95  * No false easting or northing is added. The value of \e lon returned is
96  * in the range [&minus;180&deg;, 180&deg;).
97  **********************************************************************/
98  void Reverse(bool northp, real x, real y,
99  real& lat, real& lon, real& gamma, real& k) const;
100 
101  /**
102  * PolarStereographic::Forward without returning the convergence and scale.
103  **********************************************************************/
104  void Forward(bool northp, real lat, real lon,
105  real& x, real& y) const {
106  real gamma, k;
107  Forward(northp, lat, lon, x, y, gamma, k);
108  }
109 
110  /**
111  * PolarStereographic::Reverse without returning the convergence and scale.
112  **********************************************************************/
113  void Reverse(bool northp, real x, real y,
114  real& lat, real& lon) const {
115  real gamma, k;
116  Reverse(northp, x, y, lat, lon, gamma, k);
117  }
118 
119  /** \name Inspector functions
120  **********************************************************************/
121  ///@{
122  /**
123  * @return \e a the equatorial radius of the ellipsoid (meters). This is
124  * the value used in the constructor.
125  **********************************************************************/
126  Math::real MajorRadius() const { return _a; }
127 
128  /**
129  * @return \e f the flattening of the ellipsoid. This is the value used in
130  * the constructor.
131  **********************************************************************/
132  Math::real Flattening() const { return _f; }
133 
134  /// \cond SKIP
135  /**
136  * <b>DEPRECATED</b>
137  * @return \e r the inverse flattening of the ellipsoid.
138  **********************************************************************/
139  Math::real InverseFlattening() const { return 1/_f; }
140  /// \endcond
141 
142  /**
143  * The central scale for the projection. This is the value of \e k0 used
144  * in the constructor and is the scale at the pole unless overridden by
145  * PolarStereographic::SetScale.
146  **********************************************************************/
147  Math::real CentralScale() const { return _k0; }
148  ///@}
149 
150  /**
151  * A global instantiation of PolarStereographic with the WGS84 ellipsoid
152  * and the UPS scale factor. However, unlike UPS, no false easting or
153  * northing is added.
154  **********************************************************************/
155  static const PolarStereographic& UPS();
156  };
157 
158 } // namespace GeographicLib
159 
160 #endif // GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP
void Reverse(bool northp, real x, real y, real &lat, real &lon) const
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:90
GeographicLib::Math::real real
Definition: GeodSolve.cpp:32
void Forward(bool northp, real lat, real lon, real &x, real &y) const
Polar stereographic projection.
Header for GeographicLib::Constants class.