Skip to content
Snippets Groups Projects
Commit 7079a414 authored by Jesse Mapel's avatar Jesse Mapel Committed by jlaura
Browse files

Fixed state being written out and read in differently (#183)

* Fixed state being written out and read in differently

* Fixed canModelBeConstructedFromState
parent 19c29897
Branches
Tags
No related merge requests found
...@@ -252,6 +252,7 @@ std::string UsgsAstroLsSensorModel::getModelNameFromModelState( ...@@ -252,6 +252,7 @@ std::string UsgsAstroLsSensorModel::getModelNameFromModelState(
std::string UsgsAstroLsSensorModel::getModelState() const { std::string UsgsAstroLsSensorModel::getModelState() const {
json state; json state;
state["m_modelName"] = _SENSOR_MODEL_NAME;
state["m_imageIdentifier"] = m_imageIdentifier; state["m_imageIdentifier"] = m_imageIdentifier;
state["m_sensorType"] = m_sensorType; state["m_sensorType"] = m_sensorType;
state["m_totalLines"] = m_totalLines; state["m_totalLines"] = m_totalLines;
...@@ -306,9 +307,9 @@ std::string UsgsAstroLsSensorModel::getModelState() const { ...@@ -306,9 +307,9 @@ std::string UsgsAstroLsSensorModel::getModelState() const {
state["m_imageFlipFlag"] = m_imageFlipFlag; state["m_imageFlipFlag"] = m_imageFlipFlag;
state["m_referencePointXyz"] = json(); state["m_referencePointXyz"] = json();
state["m_referencePointXyz"]["x"] = m_referencePointXyz.x; state["m_referencePointXyz"][0] = m_referencePointXyz.x;
state["m_referencePointXyz"]["y"] = m_referencePointXyz.y; state["m_referencePointXyz"][1] = m_referencePointXyz.y;
state["m_referencePointXyz"]["z"] = m_referencePointXyz.z; state["m_referencePointXyz"][2] = m_referencePointXyz.z;
return state.dump(); return state.dump();
} }
......
...@@ -201,7 +201,7 @@ bool UsgsAstroPlugin::canISDBeConvertedToModelState(const csm::Isd &imageSupport ...@@ -201,7 +201,7 @@ bool UsgsAstroPlugin::canISDBeConvertedToModelState(const csm::Isd &imageSupport
std::string UsgsAstroPlugin::getStateFromISD(csm::Isd imageSupportData) const { std::string UsgsAstroPlugin::getStateFromISD(csm::Isd imageSupportData) const {
std::string stringIsd = loadImageSupportData(imageSupportData); std::string stringIsd = loadImageSupportData(imageSupportData);
json jsonIsd = json::parse(stringIsd); json jsonIsd = json::parse(stringIsd);
return convertISDToModelState(imageSupportData, jsonIsd.at("modelName")); return convertISDToModelState(imageSupportData, jsonIsd.at("name_model"));
} }
...@@ -259,7 +259,7 @@ csm::Model *UsgsAstroPlugin::constructModelFromState(const std::string& modelSta ...@@ -259,7 +259,7 @@ csm::Model *UsgsAstroPlugin::constructModelFromState(const std::string& modelSta
csm::WarningList *warnings) const { csm::WarningList *warnings) const {
json state = json::parse(modelState); json state = json::parse(modelState);
std::string modelName = state["modelName"]; std::string modelName = state["m_modelName"];
if (modelName == UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME) { if (modelName == UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME) {
UsgsAstroFrameSensorModel* model = new UsgsAstroFrameSensorModel(); UsgsAstroFrameSensorModel* model = new UsgsAstroFrameSensorModel();
......
...@@ -15,14 +15,12 @@ using json = nlohmann::json; ...@@ -15,14 +15,12 @@ using json = nlohmann::json;
TEST_F(ConstVelocityLineScanSensorModel, State) { TEST_F(ConstVelocityLineScanSensorModel, State) {
std::string modelState = sensorModel->getModelState(); std::string modelState = sensorModel->getModelState();
// EXPECT_NO_THROW( sensorModel->replaceModelState(modelState);
// sensorModel->replaceModelState(modelState)
// );
// When this is different, the output is very hard to parse // When this is different, the output is very hard to parse
// TODO implement JSON diff for gtest // TODO implement JSON diff for gtest
// EXPECT_EQ(sensorModel->getModelState(), modelState); EXPECT_EQ(sensorModel->getModelState(), modelState);
} }
// Fly by tests // Fly by tests
......
...@@ -82,6 +82,14 @@ TEST_F(FrameIsdTest, Constructible) { ...@@ -82,6 +82,14 @@ TEST_F(FrameIsdTest, Constructible) {
"USGS_ASTRO_FRAME_SENSOR_MODEL")); "USGS_ASTRO_FRAME_SENSOR_MODEL"));
} }
TEST_F(FrameIsdTest, ConstructibleFromState) {
UsgsAstroPlugin testPlugin;
std::string modelState = testPlugin.getStateFromISD(isd);
EXPECT_TRUE(testPlugin.canModelBeConstructedFromState(
"USGS_ASTRO_FRAME_SENSOR_MODEL",
modelState));
}
TEST_F(FrameIsdTest, NotConstructible) { TEST_F(FrameIsdTest, NotConstructible) {
UsgsAstroPlugin testPlugin; UsgsAstroPlugin testPlugin;
isd.setFilename("data/constVelocityLineScan.img"); isd.setFilename("data/constVelocityLineScan.img");
...@@ -142,6 +150,14 @@ TEST_F(ConstVelLineScanIsdTest, Constructible) { ...@@ -142,6 +150,14 @@ TEST_F(ConstVelLineScanIsdTest, Constructible) {
"USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL")); "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL"));
} }
TEST_F(ConstVelLineScanIsdTest, ConstructibleFromState) {
UsgsAstroPlugin testPlugin;
std::string modelState = testPlugin.getStateFromISD(isd);
EXPECT_TRUE(testPlugin.canModelBeConstructedFromState(
"USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL",
modelState));
}
TEST_F(ConstVelLineScanIsdTest, NotConstructible) { TEST_F(ConstVelLineScanIsdTest, NotConstructible) {
UsgsAstroPlugin testPlugin; UsgsAstroPlugin testPlugin;
isd.setFilename("data/simpleFramerISD.img"); isd.setFilename("data/simpleFramerISD.img");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment