Commit 7ddc1aee authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Improved error messages for Shape Model failures. Fixes #1957.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5681 41f8697f-d340-4b68-9986-7bafba869bb8
parent 6177177a
Loading
Loading
Loading
Loading
+18 −8
Changes for isis/src/base/objs/ShapeModelFactory/ShapeModelFactory.cpp: 18 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -93,24 +93,34 @@ namespace Isis {
          shapeModelCube.open(FileName(shapeModelFilenames).expanded(), "r" );
        }
        catch (IException &e) {
          IString msg = "Shape file " + shapeModelFilenames + " does not exist or is not an Isis cube";
          IString msg = "Shape file " + shapeModelFilenames 
                        + " does not exist or is not an Isis cube.";
          throw IException(e, IException::Unknown, msg, _FILEINFO_);
        }
        
        Projection *projection = NULL;
        try {
          // get projection of shape model cube
          Projection *projection = shapeModelCube.projection();
          projection = shapeModelCube.projection();
        }
        catch (IException &projectionException) {
          QString msg = "Shape model cube must be an Isis DEM file, meaning it must "
              "be map-projected. This cube is NOT map projected.";
          throw IException(projectionException, IException::User, msg, _FILEINFO_);
        }

        try {
          // Next, check if ISIS DEM cube is an equatorial cylindrical projection
          if (projection->IsEquatorialCylindrical())
          if (projection->IsEquatorialCylindrical()) {
            shapeModel = new EquatorialCylindricalShape(target, pvl);
          else 
          }
          else {
            shapeModel = new DemShape(target, pvl);
          }
        catch (IException &e) {
          QString msg = "Shape model cube must be an Isis DEM file, meaning it must " \
                        "be map-projected. This cube is NOT map projected.";
          throw IException(IException::User, msg, _FILEINFO_);
        }
        catch (IException &shapeModelException) {
          QString msg = "Unable to create shape model from the given Isis DEM file.";
          throw IException(shapeModelException, IException::User, msg, _FILEINFO_);
        }
      }
      catch (IException &e) {
+2 −0
Changes for isis/src/base/objs/ShapeModelFactory/ShapeModelFactory.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ namespace Isis {
   *
   * @internal
   *   @history 2012-10-31 - Ken Edmundson - Implemented plane shape
   *   @history 2014-01-14 - Jeannie Backer - Improved error message. Fixes
   *            #1957.
   */
  class ShapeModelFactory {
    public:
+7 −0
Changes for isis/src/base/objs/ShapeModelFactory/ShapeModelFactory.truth: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,10 +20,17 @@ Unit test for Isis::ShapeModel
  Testing Isis cube file for dem that is not map projected
**ERROR** Failed opening shape file /usgs/cpkgs/isis3/data/mgs/testData/ab102401.cub.
**USER ERROR** Shape model cube must be an Isis DEM file, meaning it must be map-projected. This cube is NOT map projected.
**ERROR** Unable to initialize cube projection from file [/usgs/cpkgs/isis3/data/mgs/testData/ab102401.cub].
**ERROR** Unable to find PVL group [Mapping] in file [/usgs/cpkgs/isis3/data/mgs/testData/ab102401.cub].

  Testing a dem that's not equatorial cylindrical
    Successfully created shape DemShape

  Testing Isis cube file for dem that is missing shape model statistics
**ERROR** Failed opening shape file unitTestDemNoShapeModelStats.pvl.
**USER ERROR** Unable to create shape model from the given Isis DEM file.
**USER ERROR** The input cube references a ShapeModel that has not been updated for the new ray tracing algorithm. All DEM files must now be padded at the poles and contain a ShapeModelStatistics table defining their minimum and maximum radii values. The demprep program should be used to prepare the DEM before you can run this program. There is more information available in the documentation of the demprep program.

  Testing dem shape...
    Successfully created shape EquatorialCylindricalShape

+17 −0
Changes for isis/src/base/objs/ShapeModelFactory/unitTest.cpp: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -153,6 +153,23 @@ int main() {
    e.print();
  }

  try {
    // Test ShapeModel without shape model statistics
    cout << endl << "  Testing Isis cube file for dem that is missing shape model statistics" << endl;
    PvlGroup kern5 = kern1;
    kern5 += PvlKeyword("ShapeModel", "unitTestDemNoShapeModelStats.pvl");
    Pvl lab5;
    lab5.addGroup(inst2);
    lab5.addGroup(kern5);
    Target targBadFile(NULL, lab5);
    ShapeModel *smBadFile = ShapeModelFactory::create(&targBadFile, lab4);
    cout << "    Successfully created shape " << smBadFile->name() << endl;
    delete smBadFile;
  }
  catch (Isis::IException &e) {
    e.print();
  }

  // Test demshape with ShapeModel keyword
  cout << endl << "  Testing dem shape..." << endl;
  QString inputFile = "$ISIS3DATA/mgs/testData/ab102401.cub";
+53 −0
Changes for isis/src/base/objs/ShapeModelFactory/unitTestDemNoShapeModelStats.pvl: 53 added lines, 0 removed lines.
Original line number Diff line number Diff line
Object = IsisCube
  Object = Core
    StartByte   = 65537
    Format      = Tile
    TileSamples = 128
    TileLines   = 128

    Group = Dimensions
      Samples = 46082
      Lines   = 23042
      Bands   = 1
    End_Group

    Group = Pixels
      Type       = SignedWord
      ByteOrder  = Lsb
      Base       = 3396000.0
      Multiplier = 1.0
    End_Group
  End_Object

  Group = Mapping
    ProjectionName     = SimpleCylindrical
    CenterLongitude    = 180.0000000
    TargetName         = Mars
    EquatorialRadius   = 3396190.0 <meters>
    PolarRadius        = 3376200.0 <meters>
    LatitudeType       = Planetocentric
    LongitudeDirection = PositiveEast
    LongitudeDomain    = 360
    UpperLeftCornerX   = -10669909.2276 <meters>
    UpperLeftCornerY   = 5335186.1556 <meters>
    PixelResolution    = 463.0836 <meters/pixel>
    Scale              = 127.99999292419 <pixels/degree>
  End_Group
End_Object

Object = Label
  Bytes = 65536
End_Object

Object = History
  Name      = IsisCube
  StartByte = 2141162145
  Bytes     = 5884
End_Object

Object = OriginalLabel
  Name      = IsisCube
  StartByte = 2141159441
  Bytes     = 2704
End_Object
End