PolarStereographic.hpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. #if !defined(GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP)
  10. #define GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP 1
  11. #include <GeographicLib/Constants.hpp>
  12. namespace GeographicLib {
  13. /**
  14. * \brief Polar stereographic projection
  15. *
  16. * Implementation taken from the report,
  17. * - J. P. Snyder,
  18. * <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projections: A
  19. * Working Manual</a>, USGS Professional Paper 1395 (1987),
  20. * pp. 160--163.
  21. *
  22. * This is a straightforward implementation of the equations in Snyder except
  23. * that Newton's method is used to invert the projection.
  24. *
  25. * This class also returns the meridian convergence \e gamma and scale \e k.
  26. * The meridian convergence is the bearing of grid north (the \e y axis)
  27. * measured clockwise from true north.
  28. *
  29. * Example of use:
  30. * \include example-PolarStereographic.cpp
  31. **********************************************************************/
  32. class GEOGRAPHICLIB_EXPORT PolarStereographic {
  33. private:
  34. typedef Math::real real;
  35. real _a, _f, _e2, _es, _e2m, _c;
  36. real _k0;
  37. public:
  38. /**
  39. * Constructor for a ellipsoid with
  40. *
  41. * @param[in] a equatorial radius (meters).
  42. * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
  43. * Negative \e f gives a prolate ellipsoid.
  44. * @param[in] k0 central scale factor.
  45. * @exception GeographicErr if \e a, (1 &minus; \e f) \e a, or \e k0 is
  46. * not positive.
  47. **********************************************************************/
  48. PolarStereographic(real a, real f, real k0);
  49. /**
  50. * Set the scale for the projection.
  51. *
  52. * @param[in] lat (degrees) assuming \e northp = true.
  53. * @param[in] k scale at latitude \e lat (default 1).
  54. * @exception GeographicErr \e k is not positive.
  55. * @exception GeographicErr if \e lat is not in (&minus;90&deg;,
  56. * 90&deg;].
  57. **********************************************************************/
  58. void SetScale(real lat, real k = real(1));
  59. /**
  60. * Forward projection, from geographic to polar stereographic.
  61. *
  62. * @param[in] northp the pole which is the center of projection (true means
  63. * north, false means south).
  64. * @param[in] lat latitude of point (degrees).
  65. * @param[in] lon longitude of point (degrees).
  66. * @param[out] x easting of point (meters).
  67. * @param[out] y northing of point (meters).
  68. * @param[out] gamma meridian convergence at point (degrees).
  69. * @param[out] k scale of projection at point.
  70. *
  71. * No false easting or northing is added. \e lat should be in the range
  72. * (&minus;90&deg;, 90&deg;] for \e northp = true and in the range
  73. * [&minus;90&deg;, 90&deg;) for \e northp = false.
  74. **********************************************************************/
  75. void Forward(bool northp, real lat, real lon,
  76. real& x, real& y, real& gamma, real& k) const;
  77. /**
  78. * Reverse projection, from polar stereographic to geographic.
  79. *
  80. * @param[in] northp the pole which is the center of projection (true means
  81. * north, false means south).
  82. * @param[in] x easting of point (meters).
  83. * @param[in] y northing of point (meters).
  84. * @param[out] lat latitude of point (degrees).
  85. * @param[out] lon longitude of point (degrees).
  86. * @param[out] gamma meridian convergence at point (degrees).
  87. * @param[out] k scale of projection at point.
  88. *
  89. * No false easting or northing is added. The value of \e lon returned is
  90. * in the range [&minus;180&deg;, 180&deg;].
  91. **********************************************************************/
  92. void Reverse(bool northp, real x, real y,
  93. real& lat, real& lon, real& gamma, real& k) const;
  94. /**
  95. * PolarStereographic::Forward without returning the convergence and scale.
  96. **********************************************************************/
  97. void Forward(bool northp, real lat, real lon,
  98. real& x, real& y) const {
  99. real gamma, k;
  100. Forward(northp, lat, lon, x, y, gamma, k);
  101. }
  102. /**
  103. * PolarStereographic::Reverse without returning the convergence and scale.
  104. **********************************************************************/
  105. void Reverse(bool northp, real x, real y,
  106. real& lat, real& lon) const {
  107. real gamma, k;
  108. Reverse(northp, x, y, lat, lon, gamma, k);
  109. }
  110. /** \name Inspector functions
  111. **********************************************************************/
  112. ///@{
  113. /**
  114. * @return \e a the equatorial radius of the ellipsoid (meters). This is
  115. * the value used in the constructor.
  116. **********************************************************************/
  117. Math::real EquatorialRadius() const { return _a; }
  118. /**
  119. * @return \e f the flattening of the ellipsoid. This is the value used in
  120. * the constructor.
  121. **********************************************************************/
  122. Math::real Flattening() const { return _f; }
  123. /**
  124. * The central scale for the projection. This is the value of \e k0 used
  125. * in the constructor and is the scale at the pole unless overridden by
  126. * PolarStereographic::SetScale.
  127. **********************************************************************/
  128. Math::real CentralScale() const { return _k0; }
  129. /**
  130. * \deprecated An old name for EquatorialRadius().
  131. **********************************************************************/
  132. GEOGRAPHICLIB_DEPRECATED("Use EquatorialRadius()")
  133. Math::real MajorRadius() const { return EquatorialRadius(); }
  134. ///@}
  135. /**
  136. * A global instantiation of PolarStereographic with the WGS84 ellipsoid
  137. * and the UPS scale factor. However, unlike UPS, no false easting or
  138. * northing is added.
  139. **********************************************************************/
  140. static const PolarStereographic& UPS();
  141. };
  142. } // namespace GeographicLib
  143. #endif // GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP