Commit 9228f7cb authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Fixed an error were GroundGrid would thrown an exception when calculating...

Fixed an error were GroundGrid would thrown an exception when calculating longitude grid lines near 90 latitude. Fixes #4766.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7570 41f8697f-d340-4b68-9986-7bafba869bb8
parent e0afab2f
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -325,7 +325,11 @@ namespace Isis {
      progress->CheckStatus();
    }

    for (Latitude lat = startLat; lat <= endLat + latInc / 2; lat += latInc) {
    // Ensure that the Latitude being incremented does not throw an exception
    // if incremented past -90 or 90 degrees.
    Latitude latStep = startLat;
    latStep.setErrorChecking(Latitude::AllowPastPole);
    for (; latStep <= endLat + latInc / 2; latStep += latInc) {
      unsigned int previousX = 0;
      unsigned int previousY = 0;
      bool havePrevious = false;
@@ -333,7 +337,7 @@ namespace Isis {
      for (Longitude lon = *p_minLon; lon <= *p_maxLon; lon += latRes) {
        unsigned int x = 0;
        unsigned int y = 0;
        bool valid = GetXY(lat, lon, x, y);
        bool valid = GetXY(latStep, lon, x, y);

        if (valid && havePrevious) {
          if (previousX != x || previousY != y) {
@@ -356,11 +360,15 @@ namespace Isis {
      unsigned int previousY = 0;
      bool havePrevious = false;

      for (Latitude lat = *p_minLat; lat <= *p_maxLat; lat += lonRes) {
      // Ensure that the Latitude being incremented does not throw an exception
      // if incremented past -90 or 90 degrees.
      latStep = *p_minLat;
      latStep.setErrorChecking(Latitude::AllowPastPole);
      for (; latStep <= *p_maxLat; latStep += lonRes) {
        unsigned int x = 0;
        unsigned int y = 0;

        bool valid = GetXY(lat, lon, x, y);
        bool valid = GetXY(latStep, lon, x, y);

        if (valid && havePrevious) {
          if (previousX == x && previousY == y) {
@@ -423,7 +431,11 @@ namespace Isis {
    const Longitude &maxLon = *p_maxLon;

    // Walk the minLat/maxLat lines
    for (Latitude lat = minLat; lat <= maxLat; lat += (maxLat - minLat)) {
    // Ensure that the Latitude being incremented does not throw an exception
    // if incremented past -90 or 90 degrees.
    Latitude latStep = minLat;
    latStep.setErrorChecking(Latitude::AllowPastPole);
    for (; latStep <= maxLat; latStep += (maxLat - minLat)) {
      unsigned int previousX = 0;
      unsigned int previousY = 0;
      bool havePrevious = false;
@@ -431,7 +443,7 @@ namespace Isis {
      for (Longitude lon = minLon; lon <= maxLon; lon += latRes) {
        unsigned int x = 0;
        unsigned int y = 0;
        bool valid = GetXY(lat, lon, x, y);
        bool valid = GetXY(latStep, lon, x, y);

        if (valid && havePrevious) {
          if (previousX != x || previousY != y) {
@@ -451,10 +463,14 @@ namespace Isis {
      unsigned int previousY = 0;
      bool havePrevious = false;

      for (Latitude lat = minLat; lat <= maxLat; lat += lonRes) {
      // Ensure that the Latitude being incremented does not throw an exception
      // if incremented past -90 or 90 degrees.
      latStep = minLat;
      latStep.setErrorChecking(Latitude::AllowPastPole);
      for (; latStep <= maxLat; latStep += lonRes) {
        unsigned int x = 0;
        unsigned int y = 0;
        bool valid = GetXY(lat, lon, x, y);
        bool valid = GetXY(latStep, lon, x, y);

        if (valid && havePrevious) {
          if (previousX != x || previousY != y) {
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ namespace Isis {
   *                           method was fixed to match the signature of the parent method.
   *                           Moved implementation of GroundMap() and GetMappingGroup() to the
   *                           cpp file per ISIS coding standards.
   *   @history 2017-04-10 Jesse mapel - Modified to not throw an exception when calculating
   *                           longitude lines close to 90 or -90 latitude. Fixes #4766.
   */
  class GroundGrid {
    public:
+25 −0
Original line number Diff line number Diff line
@@ -407,6 +407,31 @@ namespace Isis {
  }


  /**
   * Get the error checking status. This indicates if the Latitude object will
   * throw an error when set to an angle less than -90 degrees or greater than
   * 90 degrees.
   * 
   * @return @b ErrorChecking The error checking status.
   */
  Latitude::ErrorChecking Latitude::errorChecking() const {
    return m_errors;
  }


  /**
   * Set the error checking status. If set to ThrowAllErrors, then an exception
   * will be thrown if the Latitude object is set to an angle less than -90
   * degrees or greater than 90 degrees. If set to AllowPastPole, then no
   * exception will be thrown.
   * 
   * @param error The new error checking status.
   */
  void Latitude::setErrorChecking(ErrorChecking errors) {
    m_errors = errors;
  }


  /**
   * Checks if this latitude value is within the given range.  Defines the
   * range as the change from the minimum latitude to the maximum latitude (an
+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ namespace Isis {
   *                           documentation for all exceptions thrown. Fixes #3907
   *   @history 2016-09-29 Jeannie Backer - Changed strings in error message to use Angle::toString
   *                           instead of the Isis::toString(double) method.
   *   @history 2017-04-10 Jesse Mapel - Added an accessor and mutator for ErrorChecking member.
   *                           Fixes #4766.
   */
  class Latitude : public Angle {
    public:
@@ -144,6 +146,9 @@ namespace Isis {
      void setPlanetographic(double latitude,
                           Angle::Units units = Angle::Radians);

      ErrorChecking errorChecking() const;
      void setErrorChecking(ErrorChecking errors);

      bool inRange(Latitude min, Latitude max) const;

      Latitude& operator=(const Latitude & latitudeToCopy);