13#include "IException.h"
17#include "SpecialPixel.h"
96 if (mapping.hasKeyword(
"EquatorialRadius") && mapping.hasKeyword(
"PolarRadius")) {
97 m_equatorialRadius = new Distance(toDouble(mapping[
"EquatorialRadius"][0]),
99 m_polarRadius = new Distance(toDouble(mapping[
"PolarRadius"][0]),
104 PvlGroup radiiGrp = Target::radiiGroup(mapping[
"TargetName"][0]);
105 m_equatorialRadius = new Distance(toDouble(radiiGrp[
"EquatorialRadius"][0]),
107 m_polarRadius = new Distance(toDouble(radiiGrp[
"PolarRadius"][0]),
110 catch (IException &e) {
111 QString msg =
"Unable to create Latitude object from given mapping group.";
112 throw IException(e, IException::Unknown, msg, _FILEINFO_);
118 if (mapping[
"LatitudeType"][0] ==
"Planetographic") {
119 setPlanetographic(latitude.radians(), Radians);
121 else if (mapping[
"LatitudeType"][0] ==
"Planetocentric") {
122 setPlanetocentric(latitude.radians(), Radians);
125 QString msg =
"Latitude type [" + mapping[
"LatitudeType"][0] +
126 "] is not recognized";
127 throw IException(IException::Programmer, msg, _FILEINFO_);
156 if (mapping.hasKeyword(
"EquatorialRadius") && mapping.hasKeyword(
"PolarRadius")) {
157 m_equatorialRadius = new Distance(toDouble(mapping[
"EquatorialRadius"][0]),
159 m_polarRadius = new Distance(toDouble(mapping[
"PolarRadius"][0]),
164 PvlGroup radiiGrp = Target::radiiGroup(mapping[
"TargetName"][0]);
165 m_equatorialRadius = new Distance(toDouble(radiiGrp[
"EquatorialRadius"][0]),
167 m_polarRadius = new Distance(toDouble(radiiGrp[
"PolarRadius"][0]),
170 catch (IException &e) {
171 QString msg =
"Unable to create Latitude object from given mapping group.";
172 throw IException(e, IException::Unknown, msg, _FILEINFO_);
178 if (mapping[
"LatitudeType"][0] ==
"Planetographic") {
179 setPlanetographic(latitude, latitudeUnits);
181 else if (mapping[
"LatitudeType"][0] ==
"Planetocentric") {
182 setPlanetocentric(latitude, latitudeUnits);
185 QString msg =
"Latitude type [" + mapping[
"LatitudeType"][0] +
186 "] is not recognized";
187 throw IException(IException::Programmer, msg, _FILEINFO_);
229 QString msg =
"Enumeration value [" +
toString(latType) +
"] is not a valid CoordinateType";
230 throw IException(IException::Programmer, msg, _FILEINFO_);
248 m_equatorialRadius = new Distance(*latitudeToCopy.m_equatorialRadius);
252 m_polarRadius = new Distance(*latitudeToCopy.m_polarRadius);
318 QString msg =
"Latitude [" +
toString(
true) +
"] cannot "
319 "be converted to Planetographic without the planetary radii, please "
320 "use the other Latitude constructor.";
321 throw IException(IException::Programmer, msg, _FILEINFO_);
326 QString msg =
"Latitudes outside of the -90/90 range cannot be converted "
327 "between Planetographic and Planetocentric";
328 throw IException(IException::Programmer, msg, _FILEINFO_);
332 QString msg =
"Invalid planetographic latitudes are not currently "
334 throw IException(IException::Programmer, msg, _FILEINFO_);
337 double ographicLatitude = atan(tan(
radians()) *
363 QString msg =
"Latitude [" +
Isis::toString(latitude) +
" degrees] cannot be "
364 "converted to Planetocentic without the planetary radii, please use "
365 "the other Latitude constructor.";
366 throw IException(IException::Programmer, msg, _FILEINFO_);
369 Angle inputAngle(latitude, units);
373 QString msg =
"Latitudes outside of the -90/90 range cannot be converted "
374 "between Planetographic and Planetocentric";
375 throw IException(IException::Programmer, msg, _FILEINFO_);
381 if (IsSpecial(latitude)) {
382 QString msg =
"Invalid planetographic latitudes are not currently "
384 throw IException(IException::Programmer, msg, _FILEINFO_);
387 double ocentricLatitude = atan(tan(inputAngle.
radians()) *
392 if ((ocentricLatitude > 0) != (inputAngle.
radians() > 0)) {
393 ocentricLatitude *= -1;
443 QString msg =
"Minimum latitude [" + min.
toString(
true) +
444 "] is greater than maximum latitude [" +
446 throw IException(IException::User, msg, _FILEINFO_);
451 Latitude adjustedMin = min - epsilon;
452 Latitude adjustedMax = max + epsilon;
455 return *
this >= adjustedMin && *
this <= adjustedMax;
469 if (
this == &latitudeToCopy)
return *
this;
509 if (mapping.hasKeyword(
"EquatorialRadius") && mapping.hasKeyword(
"PolarRadius")) {
510 equatorialRadius =
Distance(toDouble(mapping[
"EquatorialRadius"][0]),
512 polarRadius =
Distance(toDouble(mapping[
"PolarRadius"][0]),
518 equatorialRadius =
Distance(toDouble(radiiGrp[
"EquatorialRadius"][0]),
520 polarRadius =
Distance(toDouble(radiiGrp[
"PolarRadius"][0]),
523 catch (IException &e) {
524 QString msg =
"Unable to add angle to Latitude object from given mapping group.";
525 throw IException(e, IException::Unknown, msg, _FILEINFO_);
529 if (mapping[
"LatitudeType"][0] ==
"Planetocentric")
531 else if (mapping[
"LatitudeType"][0] ==
"Planetographic")
534 QString msg =
"Latitude type [" + mapping[
"LatitudeType"][0] +
"] is not recognized";
535 throw IException(IException::Programmer, msg, _FILEINFO_);
538 return add(angleToAdd, equatorialRadius, polarRadius, latType);
591 QString msg =
"Latitudes past 90 degrees are not valid. The latitude ["
593 throw IException(IException::Programmer, msg, _FILEINFO_);
bool isValid() const
This indicates whether we have a legitimate angle stored or are in an unset, or invalid,...
Angle()
Constructs a blank angle object which needs a value to be set in order to do any calculations.
virtual void setAngle(const double &angle, const Units &unit)
Set angle value in desired units.
double radians() const
Convert an angle to a double.
double degrees() const
Get the angle in units of Degrees.
virtual double angle(const Units &unit) const
Return angle value in desired units.
Units
The set of usable angle measurement units.
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
@ Radians
Radians are generally used in mathematical equations, 0-2*PI is one circle, however these are more di...
virtual QString toString(bool includeUnits=true) const
Get the angle in human-readable form.
Distance measurement, usually in meters.
@ Meters
The distance is being specified in meters.
void setPlanetographic(double latitude, Angle::Units units=Angle::Radians)
Set the latitude given a value in the Planetographic coordinate system.
Distance * m_equatorialRadius
Used for converting to Planetographic, this is the radius of the target on the equatorial plane.
Latitude & operator=(const Latitude &latitudeToCopy)
This assigns another latitude to this one - making this latitude an exact duplicate of the other.
~Latitude()
This cleans up the Latitude class.
Latitude add(Angle angleToAdd, PvlGroup mapping)
Adds an angle to this latitude.
ErrorChecking
Some user-configurable error checking parameters.
@ AllowPastPole
Don't throw an exception if a latitude beyond -90/90 is found.
CoordinateType
These are the latitude coordinate systems.
@ Planetocentric
This is the universal (and default) latitude coordinate system.
@ Planetographic
This is a secondary coordinate system for latitudes.
bool inRange(Latitude min, Latitude max) const
Checks if this latitude value is within the given range.
void setErrorChecking(ErrorChecking errors)
Set the error checking status.
Distance * m_polarRadius
Used for converting to Planetographic, this is the radius of the target perpendicular to the equatori...
double planetographic(Angle::Units units=Angle::Radians) const
Get the latitude in the planetographic coordinate system.
Latitude()
Create a blank Latitude object without Planetographic support.
double planetocentric(Angle::Units units=Angle::Radians) const
Get the latitude in the planetocentric (universal) coordinate system.
ErrorChecking m_errors
This contains which exceptions should not be thrown.
void setPlanetocentric(double latitude, Angle::Units units=Angle::Radians)
Set the latitude given a value in the Planetocentric coordinate system.
ErrorChecking errorChecking() const
Get the error checking status.
virtual void setAngle(const double &angle, const Angle::Units &units)
Same as planetocentric.
static PvlGroup radiiGroup(QString target)
Creates a Pvl Group with keywords TargetName, EquitorialRadius, and PolarRadius.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.