Commit 62464df2 authored by Marjorie Hahn's avatar Marjorie Hahn
Browse files

Updated Latitude class documentation and changed IStrings to QStrings. Fixes #3907

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6903 41f8697f-d340-4b68-9986-7bafba869bb8
parent d4a38ff3
Loading
Loading
Loading
Loading
+128 −75
Original line number Diff line number Diff line
@@ -28,12 +28,15 @@
#include "PvlGroup.h"
#include "SpecialPixel.h"
#include "Target.h"
#include "QString"

namespace Isis {
  
  /**
   * Create a blank Latitude object without Planetographic support.
   */
  Latitude::Latitude() : Angle() {
    
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -44,15 +47,17 @@ namespace Isis {
  /**
   * Create and initialize a Latitude value without planetographic support.
   *
   * @see ErrorChecking
   * @see CoordinateType
   * @param latitude The latitude value this instance will represent,
   *     in the planetocentric coordinate system
   * @param latitudeUnits The angular units of the latitude value (degs, rads)
   * @param errors Error checking conditions
   * 
   * @see ErrorChecking
   * @see CoordinateType
   */
  Latitude::Latitude(double latitude, Angle::Units latitudeUnits,
                     ErrorChecking errors) : Angle() {

    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -70,6 +75,7 @@ namespace Isis {
   * @param errors Error checking conditions
   */
  Latitude::Latitude(Angle latitude, ErrorChecking errors) : Angle() {
    
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -80,19 +86,23 @@ namespace Isis {


  /**
   * Create and initialize a Latitude value using the mapping group's latitude
   * Create and initialize a latitude value using the mapping group's latitude
   * units and radii.
   *
   * @see ErrorChecking
   * @see CoordinateType
   * @param latitude The latitude value this instance will represent,
   *     in the mapping group's units
   * @param mapping A mapping group
   * @param latitudeUnits The angular units of the latitude value (degs, rads)
   * @param errors Error checking conditions
   * 
   * @throws IException::Unknown "Unable to create Latitude object from given mapping group."
   * @throws IException::Programmer "Latitude type is not recognized"
   * 
   * @see ErrorChecking
   * @see CoordinateType
   */
  Latitude::Latitude(Angle latitude, PvlGroup mapping,
                     ErrorChecking errors) : Angle(latitude) {
    
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -133,21 +143,26 @@ namespace Isis {


  /**
   * Create and initialize a Latitude value using the mapping group's latitude
   * units and radii.
   * Create and initialize a latitude value using the latitude units and the
   * mapping group's radii.
   *
   * @see ErrorChecking
   * @see CoordinateType
   * @param latitude The latitude value this instance will represent,
   *     in the mapping group's units
   * @param mapping A mapping group
   * @param latitudeUnits The angular units of the latitude value (degs, rads)
   * @param errors Error checking conditions
   * 
   * @throws IException::Unknown "Unable to create Latitude object from given mapping group."
   * @throws IException::Programmer "Latitude type is not recognized"
   *
   * @see ErrorChecking
   * @see CoordinateType
   */
  Latitude::Latitude(double latitude,
                     PvlGroup mapping,
                     Angle::Units latitudeUnits,
                     ErrorChecking errors) : Angle(latitude, latitudeUnits) {

    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -180,7 +195,7 @@ namespace Isis {
      setPlanetocentric(latitude, latitudeUnits);
    }
    else {
      IString msg = "Latitude type [" + IString(mapping["LatitudeType"][0]) +
      QString msg = "Latitude type [" + mapping["LatitudeType"][0] +
        "] is not recognized";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
@@ -190,8 +205,6 @@ namespace Isis {
  /**
   * Create and initialize a Latitude value with planetographic support.
   *
   * @see ErrorChecking
   * @see CoordinateType
   * @param latitude The latitude value this instance will represent,
   *     in planetocentric
   * @param equatorialRadius Radius of the target (planet) at the equator
@@ -199,12 +212,18 @@ namespace Isis {
   * @param latType The coordinate system of the latitude parameter
   * @param latitudeUnits The angular units of the latitude value (degs, rads)
   * @param errors Error checking conditions
   * 
   * @throws IException::Programmer "Enumeration value [latType] is not a valid CoordinateType"
   *
   * @see ErrorChecking
   * @see CoordinateType
   */
  Latitude::Latitude(double latitude,
                     Distance equatorialRadius, Distance polarRadius,
                     CoordinateType latType,
                     Angle::Units latitudeUnits,
                     ErrorChecking errors) : Angle(latitude, latitudeUnits) {
    
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -220,8 +239,7 @@ namespace Isis {
      setPlanetographic(latitude, latitudeUnits);
    }
    else {
      IString msg = "Enumeration value [" + IString(latType) + "] is not a "
        "valid CoordinateType";
      QString msg = "Enumeration value [" + toString(latType) + "] is not a valid CoordinateType";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
  }
@@ -233,6 +251,7 @@ namespace Isis {
   * @param latitudeToCopy The latitude we're duplicating
   */
  Latitude::Latitude(const Latitude &latitudeToCopy) : Angle(latitudeToCopy) {
    
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

@@ -267,8 +286,10 @@ namespace Isis {
  /**
   * Get the latitude in the planetocentric (universal) coordinate system.
   * 
   * @see CoordinateType
   * @param units The angular units to get the latitude in
   *
   * @see CoordinateType
   * 
   * @return The Planetocentric latitude value
   */
  double Latitude::planetocentric(Angle::Units units) const {
@@ -288,31 +309,40 @@ namespace Isis {


  /**
   * Get the latitude in the planetographic coordinate system. If this instance
   *   was not constructed with the planetary radii, then an exception will be
   *   thrown.
   * Get the latitude in the planetographic coordinate system. If this instance was 
   *   not constructed with the planetary radii, then an exception will be thrown.
   *
   * @see CoordinateType
   * @param units The angular units to get the latitude in
   * 
   * @throws IException::Programmer "The latitude cannot be converted to Planetographic 
   *     without the planetary radii, please use the other Latitude constructor"
   * @throws IException::Programmer "Latitudes outside of the -90/90 range cannot be 
   *     converted between Planetographic and Planetocentric"
   * @throws IException::Programmer "Invalid planetographic latitudes are not currently 
   *     supported"
   * 
   * @see CoordinateType
   *
   * @return The Planetographic latitude value
   */
  double Latitude::planetographic(Angle::Units units) const {
    
    if (m_equatorialRadius == NULL || m_polarRadius == NULL) {
      IString msg = "Latitude [" + IString(degrees()) + " degrees] cannot "
      QString msg = "Latitude [" + toString(degrees()) + " degrees] cannot "
          "be converted to Planetographic without the planetary radii, please "
          "use the other Latitude constructor";
          "use the other Latitude constructor.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    if (*this > Angle(90.0, Angle::Degrees) ||
        *this < Angle(-90.0, Angle::Degrees)) {
      IString msg = "Latitudes outside of the -90/90 range cannot be converted "
      QString msg = "Latitudes outside of the -90/90 range cannot be converted "
          "between Planetographic and Planetocentric";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    if (!isValid()) {
      IString msg = "Invalid planetographic latitudes are not currently "
      QString msg = "Invalid planetographic latitudes are not currently "
          "supported";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
@@ -332,12 +362,20 @@ namespace Isis {
   *
   * @param latitude The planetographic latitude to set ourselves to
   * @param units The angular units latitude is in
   * 
   * @throws IException::Programmer "The latitude cannot be converted to Planetographic 
   *     without the planetary radii, please use the other Latitude constructor"
   * @throws IException::Programmer "Latitudes outside of the -90/90 range cannot be 
   *     converted between Planetographic and Planetocentric"
   * @throws IException::Programmer "Invalid planetographic latitudes are not currently 
   *     supported"
   */
  void Latitude::setPlanetographic(double latitude, Angle::Units units) {
    
    if (m_equatorialRadius == NULL || m_polarRadius == NULL) {
      IString msg = "Latitude [" + IString(latitude) + "] cannot be "
      QString msg = "Latitude [" + Isis::toString(latitude) + "] cannot be "
          "converted to Planetocentic without the planetary radii, please use "
          "the other Latitude constructor";
          "the other Latitude constructor.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

@@ -345,13 +383,13 @@ namespace Isis {

    if (inputAngle > Angle(90.0, Angle::Degrees) ||
        inputAngle < Angle(-90.0, Angle::Degrees)) {
      IString msg = "Latitudes outside of the -90/90 range cannot be converted "
      QString msg = "Latitudes outside of the -90/90 range cannot be converted "
          "between Planetographic and Planetocentric";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    if (IsSpecial(latitude)) {
      IString msg = "Invalid planetographic latitudes are not currently "
      QString msg = "Invalid planetographic latitudes are not currently "
          "supported";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
@@ -378,14 +416,18 @@ namespace Isis {
   * @param min The beginning of the valid latitude range
   * @param max The end of the valid latitude range
   * 
   * @throws IException::User "The minimum latitude degrees is greater 
   *     than the maximum latitude degrees"
   *
   * @return Whether the latitude is in the given range
   */
  bool Latitude::inRange(Latitude min, Latitude max) const {
    
    // Validity check on the range
    if (min > max) {
      IString msg = "Minimum latitude [" + IString(min.degrees()) +
      QString msg = "Minimum latitude [" + toString(min.degrees()) + 
                    "] degrees is greater than maximum latitude [" + 
        IString(max.degrees()) + "] degrees";
                    toString(max.degrees()) + "] degrees";
      throw IException(IException::User, msg, _FILEINFO_);
    }

@@ -404,9 +446,11 @@ namespace Isis {
   *   exact duplicate of the other.
   *
   * @param latitudeToCopy The latitude we are assigning from
    * @return The result, a reference to this
   * 
   * @return A reference to the dublicate latitude
   */
  Latitude& Latitude::operator=(const Latitude & latitudeToCopy) {
    
    if (this == &latitudeToCopy) return *this;

    m_equatorialRadius = NULL;
@@ -434,7 +478,12 @@ namespace Isis {
   *
   * @param angleToAdd the latitude being added to this one
   * @param mapping the mapping group from a projection
    * @return The result
   * 
   * @throws IException::Unknown "Unable to add angle to Latitude object 
   *     from given mapping group."
   * @throws IException::Programmer "Latitude type is not recognized"
   * 
   * @return The result of adding an angle to the latitude
   */
  Latitude Latitude::add(Angle angleToAdd, PvlGroup mapping) {

@@ -467,8 +516,7 @@ namespace Isis {
    else if (mapping["LatitudeType"][0] == "Planetographic")
      latType = Planetographic;
    else {
      IString msg = "Latitude type [" + IString(mapping["LatitudeType"][0]) +
        "] is not recognized";
      QString msg = "Latitude type [" + mapping["LatitudeType"][0] + "] is not recognized";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

@@ -480,10 +528,11 @@ namespace Isis {
   * Adds another latitude to this one. Handles planetographic latitudes.
   *
   * @param angleToAdd the latitude being added to this one
    * @param equatorialRadius
    * @param polarRadius
    * @param latType
    * @return The result
   * @param equatorialRadius Radius of the target (planet) at the equator
   * @param polarRadius Radius of the target (planet) at the poles
   * @param latType Planetocentric or Planetographic
   * 
   * @return The result of adding another latitude
   */
  Latitude Latitude::add(Angle angleToAdd, Distance equatorialRadius, Distance polarRadius,
                         CoordinateType latType) {
@@ -509,16 +558,20 @@ namespace Isis {
   * We're overriding this method in order to do -90/90 degree checking
   *
   * @param angle The numeric value of the angle
   * @param units The units angle is in (radians or degrees typically)
   * @param units The units the angle is in (radians or degrees typically)
   * 
   * @throws IException::Programmer "Latitudes past 90 degrees are not valid. 
   *     The latitude is not allowed"
   */
  void Latitude::setAngle(double angle, const Angle::Units &units) {
    
    // Check for passing 90 degrees if that error checking is on
    if (!IsSpecial(angle) && (m_errors & AllowPastPole) != AllowPastPole) {
      Angle tmpAngle(angle, units);
      if (tmpAngle > Angle(90, Angle::Degrees) ||
          tmpAngle < Angle(-90, Angle::Degrees)) {
        IString msg = "Latitudes past 90 degrees are not valid. The latitude "
            "[" + IString(tmpAngle.degrees()) + " degrees] is not allowed";
        QString msg = "Latitudes past 90 degrees are not valid. The latitude [" 
                      + toString(tmpAngle.degrees()) + " degrees] is not allowed";
        throw IException(IException::Programmer, msg, _FILEINFO_);
      }
    }
+5 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ namespace Isis {

  /**
   * This class is designed to encapsulate the concept of a Latitude. This is
   *   used primary for surface points but is also a general purpose class.
   *   used primarily for surface points but is also a general purpose class.
   *   This class has error checking for past the poles. This adds
   *   the concept of 90/-90 and planetographic to the Angle class.
   *
@@ -49,6 +49,10 @@ namespace Isis {
   *   @history 2016-04-22 Jeannie Backer - Added try/catch around calls to
   *                           Target::radiiGroup() in constructors and add(angle, mapGroup). 
   *                           Appended message to caught exceptions. References #3892,3896
   *   @history 2016-07-05 Marjorie Hahn - Fixed documentation for 
   *                           Latitude::Latitude(double latitude, PvlGroup mapping, 
   *                           Angle::Units latitudeUnits, ErrorChecking errors) and added in
   *                           documentation for all exceptions thrown. Fixes #3907
   */
  class Latitude : public Angle {
    public: