File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
LunarAzimuthalEqualArea.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "LunarAzimuthalEqualArea.h"
8 
9 #include <cmath>
10 #include <cfloat>
11 
12 #include "Constants.h"
13 #include "IException.h"
14 #include "TProjection.h"
15 #include "Pvl.h"
16 #include "PvlGroup.h"
17 
18 using namespace std;
19 namespace Isis {
30  LunarAzimuthalEqualArea::LunarAzimuthalEqualArea(
31  Pvl &label) : TProjection::TProjection(label) {
32  try {
33  // Try to read the mapping group
34  PvlGroup &mapGroup = label.findGroup("Mapping", Pvl::Traverse);
35 
36  // Get the max libration
37  m_maxLibration = mapGroup["MaximumLibration"];
38  m_maxLibration *= PI / 180.0;
39  }
40  catch(IException &e) {
41  QString message = "Invalid label group [Mapping]";
42  throw IException(IException::Unknown, message, _FILEINFO_);
43  }
44  }
45 
48  }
49 
59  if (!Projection::operator==(proj))
60  return false;
61  // dont use != (it is a recusive plunge)
62  // if (Projection::operator!=(proj)) return false;
63 
65  if (LKAEA->m_maxLibration != m_maxLibration)
66  return false;
67  return true;
68  }
69 
76  return "LunarAzimuthalEqualArea";
77  }
78 
86  return "0.1";
87  }
88 
101  bool LunarAzimuthalEqualArea::SetGround(const double lat,
102  const double lon) {
103  // Convert longitude to radians
104  m_longitude = lon;
105  double lonRadians = lon * Isis::PI / 180.0;
107  lonRadians *= -1.0;
108 
109  // Now convert latitude to radians... it must be planetographic
110  m_latitude = lat;
111  double latRadians = lat;
112  if (IsPlanetocentric())
113  latRadians = ToPlanetographic(latRadians);
114  latRadians *= Isis::PI / 180.0;
115 
116  double x, y;
117  if (lonRadians == 0.0 && latRadians == 0.0) {
118  x = 0.0;
119  y = 0.0;
120  SetComputedXY(x, y);
121  m_good = true;
122  return true;
123  }
124 
125  double E = acos(cos(latRadians) * cos(lonRadians));
126  double test = (sin(lonRadians) * cos(latRadians)) / sin(E);
127 
128  if (test > 1.0) test = 1.0;
129  else if (test < -1.0) test = -1.0;
130 
131  double D = HALFPI - asin(test);
132  if (latRadians < 0.0)
133  D = -D;
134 
135  double radius = m_equatorialRadius;
136  double PFAC = (HALFPI + m_maxLibration) / HALFPI;
137  double RP = radius * sin(E / PFAC);
138 
139  x = RP * cos(D);
140  y = RP * sin(D);
141 
142  SetComputedXY(x, y);
143  m_good = true;
144  return true;
145 
146  } // of SetGround
147 
148 
163  const double y) {
164  // Save the coordinate
165  SetXY(x, y);
166 
167  double RP = sqrt((x * x) + (y * y));
168 
169  double lat, lon;
170  if (y == 0.0 && x == 0.0) {
171  lat = 0.0;
172  lon = 0.0;
173  return true;
174  }
175 
176  double radius = m_equatorialRadius;
177 
178  double D = atan2(y, x);
179  double test = RP / radius;
180  if (abs(test) > 1.0) {
181  return false;
182  }
183 
184  double EPSILON = 0.0000000001;
185  double PFAC = (HALFPI + m_maxLibration) / HALFPI;
186  double E = PFAC * asin(RP / radius);
187 
188  lat = HALFPI - (acos(sin(D) * sin(E)));
189 
190  if (abs(HALFPI - abs(lat)) <= EPSILON) {
191  lon = 0.0;
192  }
193  else {
194  test = sin(E) * cos(D) / sin(HALFPI - lat);
195  if (test > 1.0) test = 1.0;
196  else if (test < -1.0) test = -1.0;
197 
198  lon = asin(test);
199  }
200 
201  if (E >= HALFPI) {
202  if (lon <= 0.0) lon = -PI - lon;
203  else lon = PI - lon;
204  }
205 
206  // Convert to degrees
207  m_latitude = lat * 180.0 / Isis::PI;
208  m_longitude = lon * 180.0 / Isis::PI;
209 
210  // Cleanup the latitude
211  if (IsPlanetocentric())
213 
214  m_good = true;
215  return m_good;
216  }
217 
218 
242  bool LunarAzimuthalEqualArea::XYRange(double &minX, double &maxX,
243  double &minY, double &maxY) {
244  // Check the corners of the lat/lon range
249 
250  // If the latitude range contains 0
251  if ((m_minimumLatitude < 0.0) && (m_maximumLatitude > 0.0)) {
254  }
255 
256  // If the longitude range contains 0
257  if ((m_minimumLongitude < 0.0) && (m_maximumLongitude > 0.0)) {
260  }
261 
262  // Make sure everything is ordered
263  if (m_minimumX >= m_maximumX) return false;
264  if (m_minimumY >= m_maximumY) return false;
265 
266  // Return X/Y min/maxs
267  minX = m_minimumX;
268  maxX = m_maximumX;
269  minY = m_minimumY;
270  maxY = m_maximumY;
271  return true;
272  }
273 
280  PvlGroup mapping = TProjection::Mapping();
281  mapping += m_mappingGrp["MaximumLibration"];
282  return mapping;
283  }
284 
285 } // end namespace isis
286 
299 extern "C" Isis::TProjection *LunarAzimuthalEqualAreaPlugin(Isis::Pvl &lab,
300  bool allowDefaults) {
301  return new Isis::LunarAzimuthalEqualArea(lab);
302 }
Isis::LunarAzimuthalEqualArea::Name
QString Name() const
Returns the name of the map projection, "LunarAzimuthalEqualArea".
Definition: LunarAzimuthalEqualArea.cpp:75
Isis::TProjection::m_maximumLatitude
double m_maximumLatitude
Contains the maximum latitude for the entire ground range.
Definition: TProjection.h:356
Isis::LunarAzimuthalEqualArea::SetGround
bool SetGround(const double lat, const double lon)
This method is used to set the latitude/longitude (assumed to be of the correct LatitudeType,...
Definition: LunarAzimuthalEqualArea.cpp:101
Isis::HALFPI
const double HALFPI
The mathematical constant PI/2.
Definition: Constants.h:41
Isis::TProjection::m_longitude
double m_longitude
This contains the currently set longitude value.
Definition: TProjection.h:318
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::TProjection::m_minimumLongitude
double m_minimumLongitude
Contains the minimum longitude for the entire ground range.
Definition: TProjection.h:358
Isis::TProjection::m_latitude
double m_latitude
This contains the currently set latitude value.
Definition: TProjection.h:316
Isis::PI
const double PI
The mathematical constant PI.
Definition: Constants.h:40
Isis::TProjection::m_longitudeDirection
LongitudeDirection m_longitudeDirection
An enumerated type indicating the LongitudeDirection read from the labels.
Definition: TProjection.h:324
Isis::TProjection::m_minimumLatitude
double m_minimumLatitude
Contains the minimum latitude for the entire ground range.
Definition: TProjection.h:354
Isis::TProjection::PositiveWest
@ PositiveWest
Longitude values increase in the westerly direction.
Definition: TProjection.h:225
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::Projection::m_minimumY
double m_minimumY
See minimumX description.
Definition: Projection.h:327
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::Projection::SetXY
void SetXY(double x, double y)
This protected method is a helper for derived classes.
Definition: Projection.cpp:804
Isis::TProjection::ToPlanetocentric
double ToPlanetocentric(const double lat) const
This method converts a planetographic latitude to a planetocentric latitude.
Definition: TProjection.cpp:418
Isis::LunarAzimuthalEqualArea::Mapping
PvlGroup Mapping()
This function returns the keywords that this projection uses.
Definition: LunarAzimuthalEqualArea.cpp:279
Isis::TProjection::XYRangeCheck
void XYRangeCheck(const double latitude, const double longitude)
This convience function is established to assist in the development of the XYRange virtual method.
Definition: TProjection.cpp:1062
Isis::LunarAzimuthalEqualArea
Modified Lambert Azimuthal Equal-Area Map Projection.
Definition: LunarAzimuthalEqualArea.h:45
Isis::LunarAzimuthalEqualArea::~LunarAzimuthalEqualArea
~LunarAzimuthalEqualArea()
Destroys the LunarAzimuthalEqualArea object.
Definition: LunarAzimuthalEqualArea.cpp:47
Isis::Projection::m_mappingGrp
PvlGroup m_mappingGrp
Mapping group that created this projection.
Definition: Projection.h:329
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Projection::m_minimumX
double m_minimumX
The data elements m_minimumX, m_minimumY, m_maximumX, and m_maximumY are convience data elements when...
Definition: Projection.h:317
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::LunarAzimuthalEqualArea::operator==
bool operator==(const TProjection &proj)
Compares two Projection objects to see if they are equal.
Definition: LunarAzimuthalEqualArea.cpp:58
Isis::Projection::m_good
bool m_good
Indicates if the contents of m_x, m_y, m_latitude, and m_longitude are valid.
Definition: Projection.h:300
Isis::TProjection
Base class for Map TProjections.
Definition: TProjection.h:166
Isis::LunarAzimuthalEqualArea::Version
QString Version() const
Returns the version of the map projection.
Definition: LunarAzimuthalEqualArea.cpp:85
Isis::LunarAzimuthalEqualArea::SetCoordinate
bool SetCoordinate(const double x, const double y)
This method is used to set the projection x/y.
Definition: LunarAzimuthalEqualArea.cpp:162
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::LunarAzimuthalEqualArea::m_maxLibration
double m_maxLibration
Value of the MaximumLibration keyword from the Mapping group of the labels.
Definition: LunarAzimuthalEqualArea.h:61
Isis::Projection::SetComputedXY
void SetComputedXY(double x, double y)
This protected method is a helper for derived classes.
Definition: Projection.cpp:780
std
Namespace for the standard library.
Isis::TProjection::m_maximumLongitude
double m_maximumLongitude
Contains the maximum longitude for the entire ground range.
Definition: TProjection.h:360
Isis::TProjection::ToPlanetographic
double ToPlanetographic(const double lat) const
This method converts a planetocentric latitude to a planetographic latitude.
Definition: TProjection.cpp:463
Isis::E
const double E
Sets some basic constants for use in ISIS programming.
Definition: Constants.h:39
Isis::TProjection::Mapping
virtual PvlGroup Mapping()
This function returns the keywords that this projection uses.
Definition: TProjection.cpp:1698
Isis::TProjection::m_equatorialRadius
double m_equatorialRadius
Polar radius of the target.
Definition: TProjection.h:335
Isis::TProjection::IsPlanetocentric
bool IsPlanetocentric() const
This indicates if the latitude type is planetocentric (as opposed to planetographic).
Definition: TProjection.cpp:392
Isis::Projection::m_maximumY
double m_maximumY
See minimumX description.
Definition: Projection.h:328
Isis::Projection::m_maximumX
double m_maximumX
See minimumX description.
Definition: Projection.h:326
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::LunarAzimuthalEqualArea::XYRange
bool XYRange(double &minX, double &maxX, double &minY, double &maxY)
This method is used to determine the x/y range which completely covers the area of interest specified...
Definition: LunarAzimuthalEqualArea.cpp:242

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:49