GeographicLib  1.52
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-2020) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * https://geographiclib.sourceforge.io/
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  * This class also returns the meridian convergence \e gamma and scale \e k.
30  * The meridian convergence is the bearing of grid north (the \e y axis)
31  * measured clockwise from true north.
32  *
33  * Example of use:
34  * \include example-PolarStereographic.cpp
35  **********************************************************************/
37  private:
38  typedef Math::real real;
39  real _a, _f, _e2, _es, _e2m, _c;
40  real _k0;
41  public:
42 
43  /**
44  * Constructor for a ellipsoid with
45  *
46  * @param[in] a equatorial radius (meters).
47  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
48  * Negative \e f gives a prolate ellipsoid.
49  * @param[in] k0 central scale factor.
50  * @exception GeographicErr if \e a, (1 &minus; \e f) \e a, or \e k0 is
51  * not positive.
52  **********************************************************************/
53  PolarStereographic(real a, real f, real k0);
54 
55  /**
56  * Set the scale for the projection.
57  *
58  * @param[in] lat (degrees) assuming \e northp = true.
59  * @param[in] k scale at latitude \e lat (default 1).
60  * @exception GeographicErr \e k is not positive.
61  * @exception GeographicErr if \e lat is not in (&minus;90&deg;,
62  * 90&deg;].
63  **********************************************************************/
64  void SetScale(real lat, real k = real(1));
65 
66  /**
67  * Forward projection, from geographic to polar stereographic.
68  *
69  * @param[in] northp the pole which is the center of projection (true means
70  * north, false means south).
71  * @param[in] lat latitude of point (degrees).
72  * @param[in] lon longitude of point (degrees).
73  * @param[out] x easting of point (meters).
74  * @param[out] y northing of point (meters).
75  * @param[out] gamma meridian convergence at point (degrees).
76  * @param[out] k scale of projection at point.
77  *
78  * No false easting or northing is added. \e lat should be in the range
79  * (&minus;90&deg;, 90&deg;] for \e northp = true and in the range
80  * [&minus;90&deg;, 90&deg;) for \e northp = false.
81  **********************************************************************/
82  void Forward(bool northp, real lat, real lon,
83  real& x, real& y, real& gamma, real& k) const;
84 
85  /**
86  * Reverse projection, from polar stereographic to geographic.
87  *
88  * @param[in] northp the pole which is the center of projection (true means
89  * north, false means south).
90  * @param[in] x easting of point (meters).
91  * @param[in] y northing of point (meters).
92  * @param[out] lat latitude of point (degrees).
93  * @param[out] lon longitude of point (degrees).
94  * @param[out] gamma meridian convergence at point (degrees).
95  * @param[out] k scale of projection at point.
96  *
97  * No false easting or northing is added. The value of \e lon returned is
98  * in the range [&minus;180&deg;, 180&deg;].
99  **********************************************************************/
100  void Reverse(bool northp, real x, real y,
101  real& lat, real& lon, real& gamma, real& k) const;
102 
103  /**
104  * PolarStereographic::Forward without returning the convergence and scale.
105  **********************************************************************/
106  void Forward(bool northp, real lat, real lon,
107  real& x, real& y) const {
108  real gamma, k;
109  Forward(northp, lat, lon, x, y, gamma, k);
110  }
111 
112  /**
113  * PolarStereographic::Reverse without returning the convergence and scale.
114  **********************************************************************/
115  void Reverse(bool northp, real x, real y,
116  real& lat, real& lon) const {
117  real gamma, k;
118  Reverse(northp, x, y, lat, lon, gamma, k);
119  }
120 
121  /** \name Inspector functions
122  **********************************************************************/
123  ///@{
124  /**
125  * @return \e a the equatorial radius of the ellipsoid (meters). This is
126  * the value used in the constructor.
127  **********************************************************************/
128  Math::real EquatorialRadius() const { return _a; }
129 
130  /**
131  * @return \e f the flattening of the ellipsoid. This is the value used in
132  * the constructor.
133  **********************************************************************/
134  Math::real Flattening() const { return _f; }
135 
136  /**
137  * The central scale for the projection. This is the value of \e k0 used
138  * in the constructor and is the scale at the pole unless overridden by
139  * PolarStereographic::SetScale.
140  **********************************************************************/
141  Math::real CentralScale() const { return _k0; }
142 
143  /**
144  * \deprecated An old name for EquatorialRadius().
145  **********************************************************************/
146  GEOGRAPHICLIB_DEPRECATED("Use EquatorialRadius()")
147  Math::real MajorRadius() const { return EquatorialRadius(); }
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
Header for GeographicLib::Constants class.
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:66
#define GEOGRAPHICLIB_DEPRECATED(msg)
Definition: Constants.hpp:81
GeographicLib::Math::real real
Definition: GeodSolve.cpp:31
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:76
Polar stereographic projection.
void Forward(bool northp, real lat, real lon, real &x, real &y) const
void Reverse(bool northp, real x, real y, real &lat, real &lon) const
Namespace for GeographicLib.
Definition: Accumulator.cpp:12