Commit 399c1f28 authored by Jesse Mapel's avatar Jesse Mapel Committed by jlaura
Browse files

Fixed canModelBeConstructedFromISD throwing an exception when the metadata...

Fixed canModelBeConstructedFromISD throwing an exception when the metadata file doesn't exist. (#134)

* fixed can be converted error

* Added not constructible test for frame plugin
parent 3f2515da
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
@@ -317,15 +317,15 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup
     return val*pow(10, typemap[from].get<int>() - typemap[to].get<int>());
  };

  csm::Isd imageSupportData = loadImageSupportData(imageSupportDataOriginal);

  // Check if the sensor model can be constructed from ISD given the model name
  if (!canModelBeConstructedFromISD(imageSupportData, modelName)) {
  if (!canModelBeConstructedFromISD(imageSupportDataOriginal, modelName)) {
    throw csm::Error(csm::Error::ISD_NOT_SUPPORTED,
                     "Sensor model support data provided is not supported by this plugin",
                     "UsgsAstroFramePlugin::constructModelFromISD");
  }

  csm::Isd imageSupportData = loadImageSupportData(imageSupportDataOriginal);

  // Create the empty sensorModel
  UsgsAstroFrameSensorModel *sensorModel = new UsgsAstroFrameSensorModel();

@@ -651,10 +651,13 @@ bool UsgsAstroFramePlugin::canISDBeConvertedToModelState(const csm::Isd &imageSu
      convertible = false;
  }

  csm::Isd localImageSupportData = imageSupportData; 
  if (imageSupportData.parameters().empty()) {
  csm::Isd localImageSupportData;
  try {
    localImageSupportData = loadImageSupportData(imageSupportData);
  }
  catch (...) {
     return false;
  }

  std::string value;
  for(auto &key : _ISD_KEYWORD){
+8 −0
Original line number Diff line number Diff line
@@ -70,6 +70,14 @@ TEST_F(SimpleFrameIsdTest, Constructible) {
               "USGS_ASTRO_FRAME_SENSOR_MODEL"));
}

TEST_F(SimpleFrameIsdTest, NotConstructible) {
   UsgsAstroFramePlugin testPlugin;
   isd.setFilename("Not a file");
   EXPECT_FALSE(testPlugin.canModelBeConstructedFromISD(
                isd,
                "USGS_ASTRO_FRAME_SENSOR_MODEL"));
}

TEST_F(SimpleFrameIsdTest, ConstructValidCamera) {
   UsgsAstroFramePlugin testPlugin;
   csm::Model *cameraModel = NULL;